Ejemplo n.º 1
0
  private void onMoovContainerAtomRead(ContainerAtom moov) throws ParserException {
    List<Atom.LeafAtom> moovChildren = moov.leafChildren;
    int moovChildrenSize = moovChildren.size();

    DrmInitData.Mapped drmInitData = null;
    for (int i = 0; i < moovChildrenSize; i++) {
      LeafAtom child = moovChildren.get(i);
      if (child.type == Atom.TYPE_pssh) {
        if (drmInitData == null) {
          drmInitData = new DrmInitData.Mapped();
        }
        byte[] psshData = child.data.data;
        drmInitData.put(
            PsshAtomUtil.parseUuid(psshData), new SchemeInitData(MimeTypes.VIDEO_MP4, psshData));
      }
    }
    if (drmInitData != null) {
      extractorOutput.drmInitData(drmInitData);
    }

    ContainerAtom mvex = moov.getContainerAtomOfType(Atom.TYPE_mvex);
    extendsDefaults = parseTrex(mvex.getLeafAtomOfType(Atom.TYPE_trex).data);
    track =
        AtomParsers.parseTrak(
            moov.getContainerAtomOfType(Atom.TYPE_trak),
            moov.getLeafAtomOfType(Atom.TYPE_mvhd),
            false);
    checkState(track != null);
    trackOutput.format(track.mediaFormat);
  }
  private SmoothStreamingChunkSource(
      ManifestFetcher<SmoothStreamingManifest> manifestFetcher,
      SmoothStreamingManifest initialManifest,
      SmoothStreamingTrackSelector trackSelector,
      DataSource dataSource,
      FormatEvaluator adaptiveFormatEvaluator,
      long liveEdgeLatencyMs) {
    this.manifestFetcher = manifestFetcher;
    this.currentManifest = initialManifest;
    this.trackSelector = trackSelector;
    this.dataSource = dataSource;
    this.adaptiveFormatEvaluator = adaptiveFormatEvaluator;
    this.liveEdgeLatencyUs = liveEdgeLatencyMs * 1000;
    evaluation = new Evaluation();
    tracks = new ArrayList<>();
    extractorWrappers = new SparseArray<>();
    mediaFormats = new SparseArray<>();
    live = initialManifest.isLive;

    ProtectionElement protectionElement = initialManifest.protectionElement;
    if (protectionElement != null) {
      byte[] keyId = getProtectionElementKeyId(protectionElement.data);
      trackEncryptionBoxes = new TrackEncryptionBox[1];
      trackEncryptionBoxes[0] = new TrackEncryptionBox(true, INITIALIZATION_VECTOR_SIZE, keyId);
      drmInitData = new DrmInitData.Mapped(MimeTypes.VIDEO_MP4);
      drmInitData.put(protectionElement.uuid, protectionElement.data);
    } else {
      trackEncryptionBoxes = null;
      drmInitData = null;
    }
  }