Search in sources :

Example 1 with Stanag4609ParseException

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);
}
Also used : KlvHandler(org.codice.alliance.libs.klv.KlvHandler) Stanag4609Parser(org.codice.alliance.libs.klv.Stanag4609Parser) Stanag4609ParseException(org.codice.alliance.libs.klv.Stanag4609ParseException) List(java.util.List) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) KlvProcessor(org.codice.alliance.libs.klv.KlvProcessor) SecurityClassificationKlvProcessor(org.codice.alliance.libs.klv.SecurityClassificationKlvProcessor)

Example 2 with Stanag4609ParseException

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);
        }
    });
}
Also used : Stanag4609TransportStreamParser(org.codice.alliance.libs.stanag4609.Stanag4609TransportStreamParser) KlvHandlerFactory(org.codice.alliance.libs.klv.KlvHandlerFactory) KlvHandler(org.codice.alliance.libs.klv.KlvHandler) StanagParserFactory(org.codice.alliance.libs.klv.StanagParserFactory) Stanag4609Processor(org.codice.alliance.libs.klv.Stanag4609Processor) Stanag4609ParseException(org.codice.alliance.libs.klv.Stanag4609ParseException) InputTransformer(ddf.catalog.transform.InputTransformer) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Stanag4609ParseException(org.codice.alliance.libs.klv.Stanag4609ParseException) IOException(java.io.IOException) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) KlvProcessor(org.codice.alliance.libs.klv.KlvProcessor) SecurityClassificationKlvProcessor(org.codice.alliance.libs.klv.SecurityClassificationKlvProcessor) Before(org.junit.Before)

Aggregations

CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)2 KlvHandler (org.codice.alliance.libs.klv.KlvHandler)2 KlvProcessor (org.codice.alliance.libs.klv.KlvProcessor)2 SecurityClassificationKlvProcessor (org.codice.alliance.libs.klv.SecurityClassificationKlvProcessor)2 Stanag4609ParseException (org.codice.alliance.libs.klv.Stanag4609ParseException)2 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 InputTransformer (ddf.catalog.transform.InputTransformer)1 IOException (java.io.IOException)1 List (java.util.List)1 KlvHandlerFactory (org.codice.alliance.libs.klv.KlvHandlerFactory)1 Stanag4609Parser (org.codice.alliance.libs.klv.Stanag4609Parser)1 Stanag4609Processor (org.codice.alliance.libs.klv.Stanag4609Processor)1 StanagParserFactory (org.codice.alliance.libs.klv.StanagParserFactory)1 Stanag4609TransportStreamParser (org.codice.alliance.libs.stanag4609.Stanag4609TransportStreamParser)1 Before (org.junit.Before)1