Java 类com.google.android.exoplayer.drm.DrmInitData 实例源码

项目:miku    文件:FragmentedMp4Extractor.java   
private void onMoovContainerAtomRead(ContainerAtom moov) {
  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(MimeTypes.VIDEO_MP4);
      }
      byte[] psshData = child.data.data;
      drmInitData.put(PsshAtomUtil.parseUuid(psshData), 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));
  Assertions.checkState(track != null);
  trackOutput.format(track.mediaFormat);
}
项目:miku    文件:DashChunkSource.java   
private static DrmInitData getDrmInitData(MediaPresentationDescription manifest,
    int adaptationSetIndex) {
  AdaptationSet adaptationSet = manifest.periods.get(0).adaptationSets.get(adaptationSetIndex);
  String drmInitMimeType = mimeTypeIsWebm(adaptationSet.representations.get(0).format.mimeType)
      ? MimeTypes.VIDEO_WEBM : MimeTypes.VIDEO_MP4;
  if (adaptationSet.contentProtections.isEmpty()) {
    return null;
  } else {
    DrmInitData.Mapped drmInitData = null;
    for (ContentProtection contentProtection : adaptationSet.contentProtections) {
      if (contentProtection.uuid != null && contentProtection.data != null) {
        if (drmInitData == null) {
          drmInitData = new DrmInitData.Mapped(drmInitMimeType);
        }
        drmInitData.put(contentProtection.uuid, contentProtection.data);
      }
    }
    return drmInitData;
  }
}
项目:ExoPlayer-Demo    文件:DashChunkSource.java   
private static DrmInitData getDrmInitData(AdaptationSet adaptationSet) {
  if (adaptationSet.contentProtections.isEmpty()) {
    return null;
  } else {
    DrmInitData.Mapped drmInitData = null;
    for (int i = 0; i < adaptationSet.contentProtections.size(); i++) {
      ContentProtection contentProtection = adaptationSet.contentProtections.get(i);
      if (contentProtection.uuid != null && contentProtection.data != null) {
        if (drmInitData == null) {
          drmInitData = new DrmInitData.Mapped();
        }
        drmInitData.put(contentProtection.uuid, contentProtection.data);
      }
    }
    return drmInitData;
  }
}
项目:ExoPlayer-Demo    文件:WebmExtractorTest.java   
public void testPrepareContentEncodingEncryption() throws IOException, InterruptedException {
  ContentEncodingSettings settings = new StreamBuilder.ContentEncodingSettings(0, 1, 5, 1);
  byte[] data = new StreamBuilder()
      .setHeader(WEBM_DOC_TYPE)
      .setInfo(DEFAULT_TIMECODE_SCALE, TEST_DURATION_TIMECODE)
      .addVp9Track(VIDEO_TRACK_NUMBER, TEST_WIDTH, TEST_HEIGHT, settings)
      .build(1);

  TestUtil.consumeTestData(extractor, data);

  assertTracksEnded();
  assertVp9VideoFormat(VIDEO_TRACK_NUMBER, DEFAULT_TIMECODE_SCALE);
  assertIndex(DEFAULT_TIMECODE_SCALE, 1);
  DrmInitData drmInitData = extractorOutput.drmInitData;
  assertNotNull(drmInitData);
  SchemeInitData widevineInitData = drmInitData.get(WIDEVINE_UUID);
  assertEquals(MimeTypes.VIDEO_WEBM, widevineInitData.mimeType);
  android.test.MoreAsserts.assertEquals(TEST_ENCRYPTION_KEY_ID, widevineInitData.data);
  SchemeInitData zeroInitData = drmInitData.get(ZERO_UUID);
  assertEquals(MimeTypes.VIDEO_WEBM, zeroInitData.mimeType);
  android.test.MoreAsserts.assertEquals(TEST_ENCRYPTION_KEY_ID, zeroInitData.data);
}
项目:ExoPlayer    文件:FragmentedMp4Extractor.java   
private void onMoovContainerAtomRead(ContainerAtom moov) {
  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(MimeTypes.VIDEO_MP4);
      }
      byte[] psshData = child.data.data;
      drmInitData.put(PsshAtomUtil.parseUuid(psshData), 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));
  Assertions.checkState(track != null);
  trackOutput.format(track.mediaFormat);
}
项目:ExoPlayer    文件:DashChunkSource.java   
private static DrmInitData getDrmInitData(MediaPresentationDescription manifest,
    int adaptationSetIndex) {
  AdaptationSet adaptationSet = manifest.periods.get(0).adaptationSets.get(adaptationSetIndex);
  String drmInitMimeType = mimeTypeIsWebm(adaptationSet.representations.get(0).format.mimeType)
      ? MimeTypes.VIDEO_WEBM : MimeTypes.VIDEO_MP4;
  if (adaptationSet.contentProtections.isEmpty()) {
    return null;
  } else {
    DrmInitData.Mapped drmInitData = null;
    for (ContentProtection contentProtection : adaptationSet.contentProtections) {
      if (contentProtection.uuid != null && contentProtection.data != null) {
        if (drmInitData == null) {
          drmInitData = new DrmInitData.Mapped(drmInitMimeType);
        }
        drmInitData.put(contentProtection.uuid, contentProtection.data);
      }
    }
    return drmInitData;
  }
}
项目:ExoPlayer    文件:WebmExtractorTest.java   
public void testPrepareContentEncodingEncryption() throws IOException, InterruptedException {
  ContentEncodingSettings settings = new StreamBuilder.ContentEncodingSettings(0, 1, 5, 1);
  byte[] data = new StreamBuilder()
      .setHeader(WEBM_DOC_TYPE)
      .setInfo(DEFAULT_TIMECODE_SCALE, TEST_DURATION_TIMECODE)
      .addVp9Track(TEST_WIDTH, TEST_HEIGHT, settings)
      .build(1);

  TestUtil.consumeTestData(extractor, data);

  assertTracksEnded();
  assertVp9VideoFormat(DEFAULT_TIMECODE_SCALE);
  assertIndex(DEFAULT_TIMECODE_SCALE, 1);
  DrmInitData drmInitData = extractorOutput.drmInitData;
  assertNotNull(drmInitData);
  android.test.MoreAsserts.assertEquals(TEST_ENCRYPTION_KEY_ID, drmInitData.get(WIDEVINE_UUID));
  android.test.MoreAsserts.assertEquals(TEST_ENCRYPTION_KEY_ID, drmInitData.get(ZERO_UUID));
}
项目:player-sdk-native-android    文件:SimpleDashParser.java   
private void loadDrmInitData(Representation representation) throws IOException {
    Uri initFile = representation.getInitializationUri().getUri();

    FileDataSource initChunkSource = new FileDataSource();
    DataSpec initDataSpec = new DataSpec(initFile);
    int trigger = 2;
    ChunkExtractorWrapper extractorWrapper = new ChunkExtractorWrapper(new FragmentedMp4Extractor());
    InitializationChunk chunk = new InitializationChunk(initChunkSource, initDataSpec, trigger, format, extractorWrapper);
    try {
        chunk.load();
    } catch (InterruptedException e) {
        Log.d(TAG, "Interrupted!", e);
    }
    if (!chunk.isLoadCanceled()) {
        drmInitData = chunk.getDrmInitData();
    }

    if (drmInitData != null) {
        DrmInitData.SchemeInitData schemeInitData = OfflineDrmManager.getWidevineInitData(drmInitData);
        if (schemeInitData != null) {
            widevineInitData = schemeInitData.data;
        }
    }
}
项目:player-sdk-native-android    文件:OfflineDrmManager.java   
@Nullable
static DrmInitData.SchemeInitData getWidevineInitData(@Nullable DrmInitData drmInitData) {

    if (drmInitData == null) {
        Log.e(TAG, "No PSSH in media");
        return null;
    }

    DrmInitData.SchemeInitData schemeInitData = drmInitData.get(WIDEVINE_UUID);
    if (schemeInitData == null) {
        Log.e(TAG, "No Widevine PSSH in media");
        return null;
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        // Prior to L the Widevine CDM required data to be extracted from the PSSH atom.
        byte[] psshData = PsshAtomUtil.parseSchemeSpecificData(schemeInitData.data, WIDEVINE_UUID);
        if (psshData == null) {
            // Extraction failed. schemeData isn't a Widevine PSSH atom, so leave it unchanged.
        } else {
            schemeInitData = new DrmInitData.SchemeInitData(schemeInitData.mimeType, psshData);
        }
    }
    return schemeInitData;
}
项目:miku    文件:FrameworkSampleSource.java   
@TargetApi(18)
private DrmInitData getDrmInitDataV18() {
  // MediaExtractor only supports psshInfo for MP4, so it's ok to hard code the mimeType here.
  Map<UUID, byte[]> psshInfo = extractor.getPsshInfo();
  if (psshInfo == null || psshInfo.isEmpty()) {
    return null;
  }
  DrmInitData.Mapped drmInitData = new DrmInitData.Mapped(MimeTypes.VIDEO_MP4);
  for (UUID uuid : psshInfo.keySet()) {
    byte[] psshAtom = PsshAtomUtil.buildPsshAtom(uuid, psshInfo.get(uuid));
    drmInitData.put(uuid, psshAtom);
  }
  return drmInitData;
}
项目:miku    文件:SmoothStreamingChunkSource.java   
private static MediaChunk newMediaChunk(Format formatInfo, Uri uri, String cacheKey,
    ChunkExtractorWrapper extractorWrapper, DrmInitData drmInitData, DataSource dataSource,
    int chunkIndex, boolean isLast, long chunkStartTimeUs, long chunkEndTimeUs,
    int trigger, MediaFormat mediaFormat) {
  long offset = 0;
  DataSpec dataSpec = new DataSpec(uri, offset, -1, cacheKey);
  // In SmoothStreaming each chunk contains sample timestamps relative to the start of the chunk.
  // To convert them the absolute timestamps, we need to set sampleOffsetUs to -chunkStartTimeUs.
  return new ContainerMediaChunk(dataSource, dataSpec, trigger, formatInfo, chunkStartTimeUs,
      chunkEndTimeUs, chunkIndex, isLast, chunkStartTimeUs, extractorWrapper, mediaFormat,
      drmInitData, true);
}
项目:ExoPlayer-Demo    文件:FrameworkSampleSource.java   
@TargetApi(18)
private DrmInitData getDrmInitDataV18() {
  // MediaExtractor only supports psshInfo for MP4, so it's ok to hard code the mimeType here.
  Map<UUID, byte[]> psshInfo = extractor.getPsshInfo();
  if (psshInfo == null || psshInfo.isEmpty()) {
    return null;
  }
  DrmInitData.Mapped drmInitData = new DrmInitData.Mapped();
  for (UUID uuid : psshInfo.keySet()) {
    byte[] psshAtom = PsshAtomUtil.buildPsshAtom(uuid, psshInfo.get(uuid));
    drmInitData.put(uuid, new SchemeInitData(MimeTypes.VIDEO_MP4, psshAtom));
  }
  return drmInitData;
}
项目:ExoPlayer-Demo    文件:SmoothStreamingChunkSource.java   
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();
    drmInitData.put(protectionElement.uuid,
        new SchemeInitData(MimeTypes.VIDEO_MP4, protectionElement.data));
  } else {
    trackEncryptionBoxes = null;
    drmInitData = null;
  }
}
项目:ExoPlayer-Demo    文件:SmoothStreamingChunkSource.java   
private static MediaChunk newMediaChunk(Format formatInfo, Uri uri, String cacheKey,
    ChunkExtractorWrapper extractorWrapper, DrmInitData drmInitData, DataSource dataSource,
    int chunkIndex, long chunkStartTimeUs, long chunkEndTimeUs, int trigger,
    MediaFormat mediaFormat, int adaptiveMaxWidth, int adaptiveMaxHeight) {
  long offset = 0;
  DataSpec dataSpec = new DataSpec(uri, offset, -1, cacheKey);
  // In SmoothStreaming each chunk contains sample timestamps relative to the start of the chunk.
  // To convert them the absolute timestamps, we need to set sampleOffsetUs to -chunkStartTimeUs.
  return new ContainerMediaChunk(dataSource, dataSpec, trigger, formatInfo, chunkStartTimeUs,
      chunkEndTimeUs, chunkIndex, chunkStartTimeUs, extractorWrapper, mediaFormat,
      adaptiveMaxWidth, adaptiveMaxHeight, drmInitData, true, Chunk.NO_PARENT_ID);
}
项目:ExoPlayer    文件:FrameworkSampleSource.java   
@TargetApi(18)
private DrmInitData getDrmInitDataV18() {
  // MediaExtractor only supports psshInfo for MP4, so it's ok to hard code the mimeType here.
  Map<UUID, byte[]> psshInfo = extractor.getPsshInfo();
  if (psshInfo == null || psshInfo.isEmpty()) {
    return null;
  }
  DrmInitData.Mapped drmInitData = new DrmInitData.Mapped(MimeTypes.VIDEO_MP4);
  for (UUID uuid : psshInfo.keySet()) {
    byte[] psshAtom = PsshAtomUtil.buildPsshAtom(uuid, psshInfo.get(uuid));
    drmInitData.put(uuid, psshAtom);
  }
  return drmInitData;
}
项目:ExoPlayer    文件:SmoothStreamingChunkSource.java   
private static MediaChunk newMediaChunk(Format formatInfo, Uri uri, String cacheKey,
    ChunkExtractorWrapper extractorWrapper, DrmInitData drmInitData, DataSource dataSource,
    int chunkIndex, boolean isLast, long chunkStartTimeUs, long chunkEndTimeUs,
    int trigger, MediaFormat mediaFormat) {
  long offset = 0;
  DataSpec dataSpec = new DataSpec(uri, offset, -1, cacheKey);
  // In SmoothStreaming each chunk contains sample timestamps relative to the start of the chunk.
  // To convert them the absolute timestamps, we need to set sampleOffsetUs to -chunkStartTimeUs.
  return new ContainerMediaChunk(dataSource, dataSpec, trigger, formatInfo, chunkStartTimeUs,
      chunkEndTimeUs, chunkIndex, isLast, chunkStartTimeUs, extractorWrapper, mediaFormat,
      drmInitData, true);
}
项目:miku    文件:HlsExtractorWrapper.java   
@Override
public void drmInitData(DrmInitData drmInit) {
  // Do nothing.
}
项目:miku    文件:SingleSampleMediaChunk.java   
@Override
public DrmInitData getDrmInitData() {
  return sampleDrmInitData;
}
项目:miku    文件:ContainerMediaChunk.java   
@Override
public final DrmInitData getDrmInitData() {
  return drmInitData;
}
项目:miku    文件:SmoothStreamingChunkSource.java   
private SmoothStreamingChunkSource(ManifestFetcher<SmoothStreamingManifest> manifestFetcher,
    SmoothStreamingManifest initialManifest, int streamElementIndex, int[] trackIndices,
    DataSource dataSource, FormatEvaluator formatEvaluator, long liveEdgeLatencyMs) {
  this.manifestFetcher = manifestFetcher;
  this.streamElementIndex = streamElementIndex;
  this.currentManifest = initialManifest;
  this.dataSource = dataSource;
  this.formatEvaluator = formatEvaluator;
  this.liveEdgeLatencyUs = liveEdgeLatencyMs * 1000;

  StreamElement streamElement = getElement(initialManifest);
  trackInfo = new TrackInfo(streamElement.tracks[0].format.mimeType, initialManifest.durationUs);
  evaluation = new Evaluation();

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

  int trackCount = trackIndices != null ? trackIndices.length : streamElement.tracks.length;
  formats = new Format[trackCount];
  extractorWrappers = new SparseArray<>();
  mediaFormats = new SparseArray<>();
  int maxWidth = 0;
  int maxHeight = 0;
  for (int i = 0; i < trackCount; i++) {
    int trackIndex = trackIndices != null ? trackIndices[i] : i;
    formats[i] = streamElement.tracks[trackIndex].format;
    maxWidth = Math.max(maxWidth, formats[i].width);
    maxHeight = Math.max(maxHeight, formats[i].height);

    MediaFormat mediaFormat = getMediaFormat(streamElement, trackIndex);
    int trackType = streamElement.type == StreamElement.TYPE_VIDEO ? Track.TYPE_VIDEO
        : Track.TYPE_AUDIO;
    FragmentedMp4Extractor extractor = new FragmentedMp4Extractor(
        FragmentedMp4Extractor.WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME);
    extractor.setTrack(new Track(trackIndex, trackType, streamElement.timescale,
        initialManifest.durationUs, mediaFormat, trackEncryptionBoxes,
        trackType == Track.TYPE_VIDEO ? 4 : -1));
    extractorWrappers.put(trackIndex, new ChunkExtractorWrapper(extractor));
    mediaFormats.put(trackIndex, mediaFormat);
  }
  this.maxWidth = maxWidth;
  this.maxHeight = maxHeight;
  Arrays.sort(formats, new DecreasingBandwidthComparator());
}
项目:ExoPlayer-Demo    文件:HlsExtractorWrapper.java   
@Override
public void drmInitData(DrmInitData drmInit) {
  // Do nothing.
}
项目:ExoPlayer-Demo    文件:WebmExtractor.java   
void endMasterElement(int id) throws ParserException {
  switch (id) {
    case ID_SEGMENT_INFO:
      if (timecodeScale == C.UNKNOWN_TIME_US) {
        // timecodeScale was omitted. Use the default value.
        timecodeScale = 1000000;
      }
      if (durationTimecode != C.UNKNOWN_TIME_US) {
        durationUs = scaleTimecodeToUs(durationTimecode);
      }
      return;
    case ID_SEEK:
      if (seekEntryId == UNKNOWN || seekEntryPosition == UNKNOWN) {
        throw new ParserException("Mandatory element SeekID or SeekPosition not found");
      }
      if (seekEntryId == ID_CUES) {
        cuesContentPosition = seekEntryPosition;
      }
      return;
    case ID_CUES:
      if (!sentSeekMap) {
        extractorOutput.seekMap(buildSeekMap());
        sentSeekMap = true;
      } else {
        // We have already built the cues. Ignore.
      }
      return;
    case ID_BLOCK_GROUP:
      if (blockState != BLOCK_STATE_DATA) {
        // We've skipped this block (due to incompatible track number).
        return;
      }
      // If the ReferenceBlock element was not found for this sample, then it is a keyframe.
      if (!sampleSeenReferenceBlock) {
        blockFlags |= C.SAMPLE_FLAG_SYNC;
      }
      commitSampleToOutput(tracks.get(blockTrackNumber), blockTimeUs);
      blockState = BLOCK_STATE_START;
      return;
    case ID_CONTENT_ENCODING:
      if (currentTrack.hasContentEncryption) {
        if (currentTrack.encryptionKeyId == null) {
          throw new ParserException("Encrypted Track found but ContentEncKeyID was not found");
        }
        if (!sentDrmInitData) {
          extractorOutput.drmInitData(new DrmInitData.Universal(
              new SchemeInitData(MimeTypes.VIDEO_WEBM, currentTrack.encryptionKeyId)));
          sentDrmInitData = true;
        }
      }
      return;
    case ID_CONTENT_ENCODINGS:
      if (currentTrack.hasContentEncryption && currentTrack.sampleStrippedBytes != null) {
        throw new ParserException("Combining encryption and compression is not supported");
      }
      return;
    case ID_TRACK_ENTRY:
      if (tracks.get(currentTrack.number) == null && isCodecSupported(currentTrack.codecId)) {
        currentTrack.initializeOutput(extractorOutput, currentTrack.number, durationUs);
        tracks.put(currentTrack.number, currentTrack);
      } else {
        // We've seen this track entry before, or the codec is unsupported. Do nothing.
      }
      currentTrack = null;
      return;
    case ID_TRACKS:
      if (tracks.size() == 0) {
        throw new ParserException("No valid tracks were found");
      }
      extractorOutput.endTracks();
      return;
    default:
      return;
  }
}
项目:ExoPlayer-Demo    文件:SingleSampleMediaChunk.java   
@Override
public DrmInitData getDrmInitData() {
  return sampleDrmInitData;
}
项目:ExoPlayer-Demo    文件:ContainerMediaChunk.java   
@Override
public final DrmInitData getDrmInitData() {
  return drmInitData;
}
项目:ExoPlayer-Demo    文件:DashChunkSource.java   
public DrmInitData getDrmInitData() {
  return drmInitData;
}
项目:ExoPlayer    文件:HlsExtractorWrapper.java   
@Override
public void drmInitData(DrmInitData drmInit) {
  // Do nothing.
}
项目:ExoPlayer    文件:SingleSampleMediaChunk.java   
@Override
public DrmInitData getDrmInitData() {
  return sampleDrmInitData;
}
项目:ExoPlayer    文件:ContainerMediaChunk.java   
@Override
public final DrmInitData getDrmInitData() {
  return drmInitData;
}
项目:ExoPlayer    文件:SmoothStreamingChunkSource.java   
private SmoothStreamingChunkSource(ManifestFetcher<SmoothStreamingManifest> manifestFetcher,
    SmoothStreamingManifest initialManifest, int streamElementIndex, int[] trackIndices,
    DataSource dataSource, FormatEvaluator formatEvaluator, long liveEdgeLatencyMs) {
  this.manifestFetcher = manifestFetcher;
  this.streamElementIndex = streamElementIndex;
  this.currentManifest = initialManifest;
  this.dataSource = dataSource;
  this.formatEvaluator = formatEvaluator;
  this.liveEdgeLatencyUs = liveEdgeLatencyMs * 1000;

  StreamElement streamElement = getElement(initialManifest);
  trackInfo = new TrackInfo(streamElement.tracks[0].format.mimeType, initialManifest.durationUs);
  evaluation = new Evaluation();

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

  int trackCount = trackIndices != null ? trackIndices.length : streamElement.tracks.length;
  formats = new Format[trackCount];
  extractorWrappers = new SparseArray<>();
  mediaFormats = new SparseArray<>();
  int maxWidth = 0;
  int maxHeight = 0;
  for (int i = 0; i < trackCount; i++) {
    int trackIndex = trackIndices != null ? trackIndices[i] : i;
    formats[i] = streamElement.tracks[trackIndex].format;
    maxWidth = Math.max(maxWidth, formats[i].width);
    maxHeight = Math.max(maxHeight, formats[i].height);

    MediaFormat mediaFormat = getMediaFormat(streamElement, trackIndex);
    int trackType = streamElement.type == StreamElement.TYPE_VIDEO ? Track.TYPE_VIDEO
        : Track.TYPE_AUDIO;
    FragmentedMp4Extractor extractor = new FragmentedMp4Extractor(
        FragmentedMp4Extractor.WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME);
    extractor.setTrack(new Track(trackIndex, trackType, streamElement.timescale,
        initialManifest.durationUs, mediaFormat, trackEncryptionBoxes,
        trackType == Track.TYPE_VIDEO ? 4 : -1));
    extractorWrappers.put(trackIndex, new ChunkExtractorWrapper(extractor));
    mediaFormats.put(trackIndex, mediaFormat);
  }
  this.maxWidth = maxWidth;
  this.maxHeight = maxHeight;
  Arrays.sort(formats, new DecreasingBandwidthComparator());
}
项目:miku    文件:SingleSampleMediaChunk.java   
/**
 * @param dataSource A {@link DataSource} for loading the data.
 * @param dataSpec Defines the data to be loaded.
 * @param trigger The reason for this chunk being selected.
 * @param format The format of the stream to which this chunk belongs.
 * @param startTimeUs The start time of the media contained by the chunk, in microseconds.
 * @param endTimeUs The end time of the media contained by the chunk, in microseconds.
 * @param chunkIndex The index of the chunk.
 * @param isLastChunk True if this is the last chunk in the media. False otherwise.
 * @param sampleFormat The format of the sample.
 * @param sampleDrmInitData The {@link DrmInitData} for the sample. Null if the sample is not drm
 *     protected.
 * @param headerData Custom header data for the sample. May be null. If set, the header data is
 *     prepended to the sample data. It is not reflected in the values returned by
 *     {@link #bytesLoaded()}.
 */
public SingleSampleMediaChunk(DataSource dataSource, DataSpec dataSpec, int trigger,
    Format format, long startTimeUs, long endTimeUs, int chunkIndex, boolean isLastChunk,
    MediaFormat sampleFormat, DrmInitData sampleDrmInitData, byte[] headerData) {
  super(dataSource, dataSpec, trigger, format, startTimeUs, endTimeUs, chunkIndex, isLastChunk,
      true);
  this.sampleFormat = sampleFormat;
  this.sampleDrmInitData = sampleDrmInitData;
  this.headerData = headerData;
}
项目:miku    文件:ContainerMediaChunk.java   
/**
 * @param dataSource A {@link DataSource} for loading the data.
 * @param dataSpec Defines the data to be loaded.
 * @param trigger The reason for this chunk being selected.
 * @param format The format of the stream to which this chunk belongs.
 * @param startTimeUs The start time of the media contained by the chunk, in microseconds.
 * @param endTimeUs The end time of the media contained by the chunk, in microseconds.
 * @param chunkIndex The index of the chunk.
 * @param isLastChunk True if this is the last chunk in the media. False otherwise.
 * @param sampleOffsetUs An offset to add to the sample timestamps parsed by the extractor.
 * @param extractorWrapper A wrapped extractor to use for parsing the data.
 * @param mediaFormat The {@link MediaFormat} of the chunk, if known. May be null if the data is
 *     known to define its own format.
 * @param drmInitData The {@link DrmInitData} for the chunk. Null if the media is not drm
 *     protected. May also be null if the data is known to define its own initialization data.
 * @param isMediaFormatFinal True if {@code mediaFormat} and {@code drmInitData} are known to be
 *     correct and final. False if the data may define its own format or initialization data.
 */
public ContainerMediaChunk(DataSource dataSource, DataSpec dataSpec, int trigger, Format format,
    long startTimeUs, long endTimeUs, int chunkIndex, boolean isLastChunk, long sampleOffsetUs,
    ChunkExtractorWrapper extractorWrapper, MediaFormat mediaFormat, DrmInitData drmInitData,
    boolean isMediaFormatFinal) {
  super(dataSource, dataSpec, trigger, format, startTimeUs, endTimeUs, chunkIndex, isLastChunk,
      isMediaFormatFinal);
  this.extractorWrapper = extractorWrapper;
  this.sampleOffsetUs = sampleOffsetUs;
  this.mediaFormat = mediaFormat;
  this.drmInitData = drmInitData;
}
项目:ExoPlayer-Demo    文件:SingleSampleMediaChunk.java   
/**
 * @param dataSource A {@link DataSource} for loading the data.
 * @param dataSpec Defines the data to be loaded.
 * @param trigger The reason for this chunk being selected.
 * @param format The format of the stream to which this chunk belongs.
 * @param startTimeUs The start time of the media contained by the chunk, in microseconds.
 * @param endTimeUs The end time of the media contained by the chunk, in microseconds.
 * @param chunkIndex The index of the chunk.
 * @param sampleFormat The format of the sample.
 * @param sampleDrmInitData The {@link DrmInitData} for the sample. Null if the sample is not drm
 *     protected.
 * @param parentId Identifier for a parent from which this chunk originates.
 */
public SingleSampleMediaChunk(DataSource dataSource, DataSpec dataSpec, int trigger,
    Format format, long startTimeUs, long endTimeUs, int chunkIndex, MediaFormat sampleFormat,
    DrmInitData sampleDrmInitData, int parentId) {
  super(dataSource, dataSpec, trigger, format, startTimeUs, endTimeUs, chunkIndex, true,
      parentId);
  this.sampleFormat = sampleFormat;
  this.sampleDrmInitData = sampleDrmInitData;
}
项目:ExoPlayer-Demo    文件:ContainerMediaChunk.java   
/**
 * @param dataSource A {@link DataSource} for loading the data.
 * @param dataSpec Defines the data to be loaded.
 * @param trigger The reason for this chunk being selected.
 * @param format The format of the stream to which this chunk belongs.
 * @param startTimeUs The start time of the media contained by the chunk, in microseconds.
 * @param endTimeUs The end time of the media contained by the chunk, in microseconds.
 * @param chunkIndex The index of the chunk.
 * @param sampleOffsetUs An offset to add to the sample timestamps parsed by the extractor.
 * @param extractorWrapper A wrapped extractor to use for parsing the data.
 * @param mediaFormat The {@link MediaFormat} of the chunk, if known. May be null if the data is
 *     known to define its own format.
 * @param adaptiveMaxWidth If this chunk contains video and is part of an adaptive playback, this
 *     is the maximum width of the video in pixels that will be encountered during the playback.
 *     {@link MediaFormat#NO_VALUE} otherwise.
 * @param adaptiveMaxHeight If this chunk contains video and is part of an adaptive playback, this
 *     is the maximum height of the video in pixels that will be encountered during the playback.
 *     {@link MediaFormat#NO_VALUE} otherwise.
 * @param drmInitData The {@link DrmInitData} for the chunk. Null if the media is not drm
 *     protected. May also be null if the data is known to define its own initialization data.
 * @param isMediaFormatFinal True if {@code mediaFormat} and {@code drmInitData} are known to be
 *     correct and final. False if the data may define its own format or initialization data.
 * @param parentId Identifier for a parent from which this chunk originates.
 */
public ContainerMediaChunk(DataSource dataSource, DataSpec dataSpec, int trigger, Format format,
    long startTimeUs, long endTimeUs, int chunkIndex, long sampleOffsetUs,
    ChunkExtractorWrapper extractorWrapper, MediaFormat mediaFormat, int adaptiveMaxWidth,
    int adaptiveMaxHeight, DrmInitData drmInitData, boolean isMediaFormatFinal, int parentId) {
  super(dataSource, dataSpec, trigger, format, startTimeUs, endTimeUs, chunkIndex,
      isMediaFormatFinal, parentId);
  this.extractorWrapper = extractorWrapper;
  this.sampleOffsetUs = sampleOffsetUs;
  this.adaptiveMaxWidth = adaptiveMaxWidth;
  this.adaptiveMaxHeight = adaptiveMaxHeight;
  this.mediaFormat = getAdjustedMediaFormat(mediaFormat, sampleOffsetUs, adaptiveMaxWidth,
      adaptiveMaxHeight);
  this.drmInitData = drmInitData;
}
项目:ExoPlayer    文件:SingleSampleMediaChunk.java   
/**
 * @param dataSource A {@link DataSource} for loading the data.
 * @param dataSpec Defines the data to be loaded.
 * @param trigger The reason for this chunk being selected.
 * @param format The format of the stream to which this chunk belongs.
 * @param startTimeUs The start time of the media contained by the chunk, in microseconds.
 * @param endTimeUs The end time of the media contained by the chunk, in microseconds.
 * @param chunkIndex The index of the chunk.
 * @param isLastChunk True if this is the last chunk in the media. False otherwise.
 * @param sampleFormat The format of the sample.
 * @param sampleDrmInitData The {@link DrmInitData} for the sample. Null if the sample is not drm
 *     protected.
 * @param headerData Custom header data for the sample. May be null. If set, the header data is
 *     prepended to the sample data. It is not reflected in the values returned by
 *     {@link #bytesLoaded()}.
 */
public SingleSampleMediaChunk(DataSource dataSource, DataSpec dataSpec, int trigger,
    Format format, long startTimeUs, long endTimeUs, int chunkIndex, boolean isLastChunk,
    MediaFormat sampleFormat, DrmInitData sampleDrmInitData, byte[] headerData) {
  super(dataSource, dataSpec, trigger, format, startTimeUs, endTimeUs, chunkIndex, isLastChunk,
      true);
  this.sampleFormat = sampleFormat;
  this.sampleDrmInitData = sampleDrmInitData;
  this.headerData = headerData;
}
项目:ExoPlayer    文件:ContainerMediaChunk.java   
/**
 * @param dataSource A {@link DataSource} for loading the data.
 * @param dataSpec Defines the data to be loaded.
 * @param trigger The reason for this chunk being selected.
 * @param format The format of the stream to which this chunk belongs.
 * @param startTimeUs The start time of the media contained by the chunk, in microseconds.
 * @param endTimeUs The end time of the media contained by the chunk, in microseconds.
 * @param chunkIndex The index of the chunk.
 * @param isLastChunk True if this is the last chunk in the media. False otherwise.
 * @param sampleOffsetUs An offset to add to the sample timestamps parsed by the extractor.
 * @param extractorWrapper A wrapped extractor to use for parsing the data.
 * @param mediaFormat The {@link MediaFormat} of the chunk, if known. May be null if the data is
 *     known to define its own format.
 * @param drmInitData The {@link DrmInitData} for the chunk. Null if the media is not drm
 *     protected. May also be null if the data is known to define its own initialization data.
 * @param isMediaFormatFinal True if {@code mediaFormat} and {@code drmInitData} are known to be
 *     correct and final. False if the data may define its own format or initialization data.
 */
public ContainerMediaChunk(DataSource dataSource, DataSpec dataSpec, int trigger, Format format,
    long startTimeUs, long endTimeUs, int chunkIndex, boolean isLastChunk, long sampleOffsetUs,
    ChunkExtractorWrapper extractorWrapper, MediaFormat mediaFormat, DrmInitData drmInitData,
    boolean isMediaFormatFinal) {
  super(dataSource, dataSpec, trigger, format, startTimeUs, endTimeUs, chunkIndex, isLastChunk,
      isMediaFormatFinal);
  this.extractorWrapper = extractorWrapper;
  this.sampleOffsetUs = sampleOffsetUs;
  this.mediaFormat = mediaFormat;
  this.drmInitData = drmInitData;
}
项目:miku    文件:InitializationChunk.java   
/**
 * Returns a {@link DrmInitData} parsed from the chunk, or null.
 * <p>
 * Should be called after loading has completed.
 */
public DrmInitData getDrmInitData() {
  return drmInitData;
}
项目:miku    文件:BaseMediaChunk.java   
/**
 * Gets the {@link DrmInitData} corresponding to the chunk.
 * <p>
 * See {@link #isMediaFormatFinal} for information about when this method is guaranteed to return
 * correct data.
 *
 * @return The {@link DrmInitData} corresponding to this chunk.
 */
public abstract DrmInitData getDrmInitData();
项目:ExoPlayer-Demo    文件:InitializationChunk.java   
/**
 * Returns a {@link DrmInitData} parsed from the chunk, or null.
 * <p>
 * Should be called after loading has completed.
 */
public DrmInitData getDrmInitData() {
  return drmInitData;
}
项目:ExoPlayer-Demo    文件:BaseMediaChunk.java   
/**
 * Gets the {@link DrmInitData} corresponding to the chunk.
 * <p>
 * See {@link #isMediaFormatFinal} for information about when this method is guaranteed to return
 * correct data.
 *
 * @return The {@link DrmInitData} corresponding to this chunk.
 */
public abstract DrmInitData getDrmInitData();
项目:ExoPlayer    文件:InitializationChunk.java   
/**
 * Returns a {@link DrmInitData} parsed from the chunk, or null.
 * <p>
 * Should be called after loading has completed.
 */
public DrmInitData getDrmInitData() {
  return drmInitData;
}