Stanag4609TransportStreamParser { public void parse(final BiConsumer<Integer, DecodedKLVMetadataPacket> callback) throws Exception { extractor.getMetadata( (klvStreamPid, pesPacketBytes) -> { try { final DecodedKLVMetadataPacket decodedKLVMetadataPacket = handlePESPacketBytes(pesPacketBytes); if (decodedKLVMetadataPacket != null) { callback.accept(klvStreamPid, decodedKLVMetadataPacket); } } catch (KlvDecodingException e) { LOGGER.debug("The KLV could not be decoded.", e); } catch (RuntimeException e) { LOGGER.debug("An error occurred while handling the metadata packet bytes.", e); } }); } Stanag4609TransportStreamParser(final ByteSource byteSource); void parse(final BiConsumer<Integer, DecodedKLVMetadataPacket> callback); Map<Integer, List<DecodedKLVMetadataPacket>> parse(); static final KlvContext UAS_DATALINK_LOCAL_SET_CONTEXT; static final String UAS_DATALINK_LOCAL_SET; static final String CHECKSUM; static final String TIMESTAMP; static final String MISSION_ID; static final String PLATFORM_TAIL_NUMBER; static final String PLATFORM_DESIGNATION; static final String IMAGE_SOURCE_SENSOR; static final String IMAGE_COORDINATE_SYSTEM; static final String SENSOR_LATITUDE; static final String SENSOR_LONGITUDE; static final String SENSOR_TRUE_ALTITUDE; static final String SLANT_RANGE; static final String TARGET_WIDTH; static final String FRAME_CENTER_LATITUDE; static final String FRAME_CENTER_LONGITUDE; static final String FRAME_CENTER_ELEVATION; static final String OFFSET_CORNER_LATITUDE_1; static final String OFFSET_CORNER_LONGITUDE_1; static final String OFFSET_CORNER_LATITUDE_2; static final String OFFSET_CORNER_LONGITUDE_2; static final String OFFSET_CORNER_LATITUDE_3; static final String OFFSET_CORNER_LONGITUDE_3; static final String OFFSET_CORNER_LATITUDE_4; static final String OFFSET_CORNER_LONGITUDE_4; static final String TARGET_LOCATION_LATITUDE; static final String TARGET_LOCATION_LONGITUDE; static final String TARGET_LOCATION_ELEVATION; static final String GROUND_RANGE; static final String PLATFORM_CALL_SIGN; static final String EVENT_START_TIME; static final String OPERATIONAL_MODE; static final String CORNER_LATITUDE_1; static final String CORNER_LONGITUDE_1; static final String CORNER_LATITUDE_2; static final String CORNER_LONGITUDE_2; static final String CORNER_LATITUDE_3; static final String CORNER_LONGITUDE_3; static final String CORNER_LATITUDE_4; static final String CORNER_LONGITUDE_4; static final String SECURITY_LOCAL_METADATA_SET; static final String SECURITY_CLASSIFICATION; static final String CLASSIFYING_COUNTRY_CODING_METHOD; static final String CLASSIFYING_COUNTRY; static final String OBJECT_COUNTRY_CODING_METHOD; static final String OBJECT_COUNTRY_CODES; static final String SECURITY_SCI_SHI_INFORMATION; static final String CAVEATS; static final String RELEASING_INSTRUCTIONS; }
@Test public void testParseTransportStreamWithKLVCallback() throws Exception { final Stanag4609TransportStreamParser parser = getParser(); final BiConsumer<Integer, DecodedKLVMetadataPacket> callback = new BiConsumer<Integer, DecodedKLVMetadataPacket>() { @Override public void accept(Integer integer, DecodedKLVMetadataPacket decodedKLVMetadataPacket) {} }; final BiConsumer<Integer, DecodedKLVMetadataPacket> callbackSpy = spy(callback); parser.parse(callbackSpy); final ArgumentCaptor<DecodedKLVMetadataPacket> decodedPacketCaptor = ArgumentCaptor.forClass(DecodedKLVMetadataPacket.class); verify(callbackSpy, times(1)).accept(eq(497), decodedPacketCaptor.capture()); verifyDecodedMetadataPacket(decodedPacketCaptor.getValue()); }
@Test public void testParseTransportStreamWithKLVAll() throws Exception { final Stanag4609TransportStreamParser parser = getParser(); final Map<Integer, List<DecodedKLVMetadataPacket>> decodedStreams = parser.parse(); assertThat(decodedStreams.size(), is(1)); assertThat(decodedStreams, hasKey(497)); final List<DecodedKLVMetadataPacket> decodedPackets = decodedStreams.get(497); assertThat(decodedPackets.size(), is(1)); verifyDecodedMetadataPacket(decodedPackets.get(0)); }