use of org.codice.alliance.libs.klv.Stanag4609ParseException in project alliance by codice.
the class MpegTsInputTransformer method extractStanag4609Metadata.
private void extractStanag4609Metadata(MetacardImpl metacard, TemporaryFileBackedOutputStream fbos) throws IOException, CatalogTransformerException {
Stanag4609Parser stanag4609Parser = stanagParserFactory.createParser(fbos.asByteSource());
Map<Integer, List<DecodedKLVMetadataPacket>> decodedMetadata;
try {
decodedMetadata = stanag4609Parser.parse();
} catch (Stanag4609ParseException e) {
throw new CatalogTransformerException("failed to extract STANAG 4609 metadata", e);
}
Map<String, KlvHandler> handlers = klvHandlerFactory.createStanag4609Handlers();
stanag4609Processor.handle(handlers, defaultKlvHandler, decodedMetadata);
KlvProcessor.Configuration klvProcessConfiguration = new KlvProcessor.Configuration();
klvProcessConfiguration.set(KlvProcessor.Configuration.SUBSAMPLE_COUNT, subsampleCount);
klvProcessConfiguration.getGeometryOperatorContext().setDistanceTolerance(distanceTolerance);
klvProcessor.process(handlers, metacard, klvProcessConfiguration);
}
use of org.codice.alliance.libs.klv.Stanag4609ParseException in project alliance by codice.
the class MpegTsInputTransformerTest method setup.
@Before
public void setup() throws IOException, CatalogTransformerException {
metacardTypes = Collections.singletonList(mock(MetacardType.class));
stanag4609Processor = mock(Stanag4609Processor.class);
klvHandlerFactory = mock(KlvHandlerFactory.class);
defaultKlvHandler = mock(KlvHandler.class);
streamParser = mock(Stanag4609TransportStreamParser.class);
metacard = new MetacardImpl();
inputTransformer = mock(InputTransformer.class);
stanagParserFactory = mock(StanagParserFactory.class);
klvProcessor = mock(KlvProcessor.class);
when(inputTransformer.transform(any(), any())).thenReturn(metacard);
when(stanagParserFactory.createParser(any())).thenReturn(() -> {
try {
return streamParser.parse();
} catch (Exception e) {
throw new Stanag4609ParseException(e);
}
});
}
Aggregations