Beispiel #1
0
  public static List<ErrorLogger.ErrorObject> conformVirtualTracksInCPL(
      PayloadRecord cplPayloadRecord,
      List<PayloadRecord> essencesHeaderPartitionPayloads,
      boolean conformAllVirtualTracks)
      throws IOException {

    IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl();
    List<PayloadRecord> essencesHeaderPartition =
        Collections.unmodifiableList(essencesHeaderPartitionPayloads);

    try {
      imfErrorLogger.addAllErrors(validateCPL(cplPayloadRecord));
      if (imfErrorLogger.hasFatalErrors())
        return Collections.unmodifiableList(imfErrorLogger.getErrors());

      Composition composition =
          new Composition(new ByteArrayByteRangeProvider(cplPayloadRecord.getPayload()));

      imfErrorLogger.addAllErrors(validateIMFTrackFileHeaderMetadata(essencesHeaderPartition));

      List<HeaderPartitionTuple> headerPartitionTuples = new ArrayList<>();
      for (PayloadRecord payloadRecord : essencesHeaderPartition) {
        if (payloadRecord.getPayloadAssetType()
            != PayloadRecord.PayloadAssetType.EssencePartition) {
          imfErrorLogger.addError(
              IMFErrorLogger.IMFErrors.ErrorCodes.IMF_MASTER_PACKAGE_ERROR,
              IMFErrorLogger.IMFErrors.ErrorLevels.FATAL,
              String.format(
                  "Payload asset type is %s, expected asset type %s",
                  payloadRecord.getPayloadAssetType(),
                  PayloadRecord.PayloadAssetType.EssencePartition.toString()));
          continue;
        }
        headerPartitionTuples.add(
            new HeaderPartitionTuple(
                new HeaderPartition(
                    new ByteArrayDataProvider(payloadRecord.getPayload()),
                    0L,
                    (long) payloadRecord.getPayload().length,
                    imfErrorLogger),
                new ByteArrayByteRangeProvider(payloadRecord.getPayload())));
      }

      if (imfErrorLogger.hasFatalErrors()) {
        return imfErrorLogger.getErrors();
      }

      imfErrorLogger.addAllErrors(
          composition.conformVirtualTracksInComposition(
              Collections.unmodifiableList(headerPartitionTuples), conformAllVirtualTracks));

      imfErrorLogger.addAllErrors(composition.getErrors());
    } catch (IMFException e) {
      imfErrorLogger.addAllErrors(e.getErrors());
    }

    return imfErrorLogger.getErrors();
  }
Beispiel #2
0
  /**
   * A stateless method that will validate an IMF Composition document
   *
   * @param cpl - a payload record for a Composition document
   * @return list of error messages encountered while validating an AssetMap document
   * @throws IOException - any I/O related error is exposed through an IOException
   */
  public static List<ErrorLogger.ErrorObject> validateCPL(PayloadRecord cpl) throws IOException {
    IMFErrorLogger imfErrorLogger = new IMFErrorLoggerImpl();
    if (cpl.getPayloadAssetType() != PayloadRecord.PayloadAssetType.CompositionPlaylist) {
      throw new IMFException(
          String.format(
              "Payload asset type is %s, expected asset type %s",
              cpl.getPayloadAssetType(),
              PayloadRecord.PayloadAssetType.CompositionPlaylist.toString()));
    }

    try {
      Composition composition = new Composition(new ByteArrayByteRangeProvider(cpl.getPayload()));
      imfErrorLogger.addAllErrors(composition.getErrors());
    } catch (IMFException e) {
      imfErrorLogger.addAllErrors(e.getErrors());
    }
    return imfErrorLogger.getErrors();
  }
Beispiel #3
0
  /**
   * 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();
  }