private void processSingleRecord()

in src/main/java/com/amazonaws/kinesisvideo/parser/kinesis/KinesisRecordProcessor.java [146:213]


    private void processSingleRecord(final Record record) {

        String data = null;
        final ObjectMapper mapper = new ObjectMapper();
        try {
            // For this app, we interpret the payload as UTF-8 chars.
            final ByteBuffer buffer = record.getData();
            data = new String(buffer.array(), "UTF-8");
            stringBuilder = stringBuilder.append(data).append(DELIMITER);

            final RekognitionOutput output = mapper.readValue(data, RekognitionOutput.class);

            // Get the fragment number from Rekognition Output
            final String fragmentNumber = output
                    .getInputInformation()
                    .getKinesisVideo()
                    .getFragmentNumber();
            final Double frameOffsetInSeconds = output
                    .getInputInformation()
                    .getKinesisVideo()
                    .getFrameOffsetInSeconds();
            final Double serverTimestamp = output
                    .getInputInformation()
                    .getKinesisVideo()
                    .getServerTimestamp();
            final Double producerTimestamp = output
                    .getInputInformation()
                    .getKinesisVideo()
                    .getProducerTimestamp();
            final double detectedTime = output.getInputInformation().getKinesisVideo().getServerTimestamp()
                    + output.getInputInformation().getKinesisVideo().getFrameOffsetInSeconds() * 1000L;
            final RekognizedOutput rekognizedOutput = RekognizedOutput.builder()
                    .fragmentNumber(fragmentNumber)
                    .serverTimestamp(serverTimestamp)
                    .producerTimestamp(producerTimestamp)
                    .frameOffsetInSeconds(frameOffsetInSeconds)
                    .detectedTime(detectedTime)
                    .build();

            // Add face search response
            final List<FaceSearchResponse> responses = output.getFaceSearchResponse();

            for (final FaceSearchResponse response : responses) {
                final DetectedFace detectedFace = response.getDetectedFace();
                final List<MatchedFace> matchedFaces = response.getMatchedFaces();
                final RekognizedOutput.FaceSearchOutput faceSearchOutput = RekognizedOutput.FaceSearchOutput.builder()
                        .detectedFace(detectedFace)
                        .matchedFaceList(matchedFaces)
                        .build();
                rekognizedOutput.addFaceSearchOutput(faceSearchOutput);
            }

            // Add it to the index
            rekognizedFragmentsIndex.add(fragmentNumber, producerTimestamp.longValue(),
                    serverTimestamp.longValue(), rekognizedOutput);

        } catch (final NumberFormatException e) {
            LOG.info("Record does not match sample record format. Ignoring record with data; " + data);
        } catch (final UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (final JsonParseException e) {
            e.printStackTrace();
        } catch (final JsonMappingException e) {
            e.printStackTrace();
        } catch (final IOException e) {
            e.printStackTrace();
        }
    }