/** * A stateless method to retrieve all the VirtualTracks that are a part of a Composition * * @param cpl - a payload corresponding to the Composition Playlist * @return list of VirtualTracks * @throws IOException - any I/O related error is exposed through an IOException */ public static List<? extends VirtualTrack> getVirtualTracks(PayloadRecord cpl) throws IOException { IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl(); List<ErrorLogger.ErrorObject> errorList = validateCPL(cpl); imfErrorLogger.addAllErrors(errorList); if (imfErrorLogger.hasFatalErrors()) { throw new IMFException("Virtual track failed validation", imfErrorLogger); } Composition composition = new Composition(new ByteArrayByteRangeProvider(cpl.getPayload())); return composition.getVirtualTracks(); }
/** * A stateless method that can be used to determine if a Composition is conformant. Conformance * checks perform deeper inspection of the Composition and the EssenceDescriptors corresponding to * all the Virtual Tracks that are a part of the Composition * * @param cplPayloadRecord a payload record corresponding to the Composition payload * @param essencesHeaderPartitionPayloads list of payload records containing the raw bytes of the * HeaderPartitions of the IMF Track files that are a part of the Virtual Track/s in the * Composition * @return list of error messages encountered while performing conformance validation of the * Composition document * @throws IOException - any I/O related error is exposed through an IOException */ public static List<ErrorLogger.ErrorObject> areAllVirtualTracksInCPLConformed( PayloadRecord cplPayloadRecord, List<PayloadRecord> essencesHeaderPartitionPayloads) throws IOException { IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl(); Composition composition = new Composition(new ByteArrayByteRangeProvider(cplPayloadRecord.getPayload())); imfErrorLogger.addAllErrors(composition.getErrors()); List<VirtualTrack> virtualTracks = new ArrayList<>(composition.getVirtualTracks()); imfErrorLogger.addAllErrors( checkVirtualTrackAndEssencesHeaderPartitionPayloadRecords( virtualTracks, essencesHeaderPartitionPayloads)); if (imfErrorLogger.hasFatalErrors()) { return imfErrorLogger.getErrors(); } imfErrorLogger.addAllErrors( conformVirtualTracksInCPL(cplPayloadRecord, essencesHeaderPartitionPayloads, true)); return imfErrorLogger.getErrors(); }