Java 类com.google.android.exoplayer.chunk.InitializationChunk 实例源码

项目:miku    文件:DashChunkSource.java   
@Override
public void onChunkLoadCompleted(Chunk chunk) {
  if (chunk instanceof InitializationChunk) {
    InitializationChunk initializationChunk = (InitializationChunk) chunk;
    String formatId = initializationChunk.format.id;
    RepresentationHolder representationHolder = representationHolders.get(formatId);
    if (initializationChunk.hasFormat()) {
      representationHolder.format = initializationChunk.getFormat();
    }
    if (initializationChunk.hasSeekMap()) {
      representationHolder.segmentIndex = new DashWrappingSegmentIndex(
          (ChunkIndex) initializationChunk.getSeekMap(),
          initializationChunk.dataSpec.uri.toString(),
          representationHolder.representation.periodStartMs * 1000);
    }
    // The null check avoids overwriting drmInitData obtained from the manifest with drmInitData
    // obtained from the stream, as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
    if (drmInitData == null && initializationChunk.hasDrmInitData()) {
      drmInitData = initializationChunk.getDrmInitData();
    }
  }
}
项目:miku    文件:DashChunkSource.java   
private Chunk newInitializationChunk(RangedUri initializationUri, RangedUri indexUri,
    Representation representation, ChunkExtractorWrapper extractor, DataSource dataSource,
    int trigger) {
  RangedUri requestUri;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri);
    if (requestUri == null) {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
  }
  DataSpec dataSpec = new DataSpec(requestUri.getUri(), requestUri.start, requestUri.length,
      representation.getCacheKey());
  return new InitializationChunk(dataSource, dataSpec, trigger, representation.format, extractor);
}
项目:ExoPlayer-Demo    文件:DashChunkSource.java   
private Chunk newInitializationChunk(RangedUri initializationUri, RangedUri indexUri,
    Representation representation, ChunkExtractorWrapper extractor, DataSource dataSource,
    int manifestIndex, int trigger) {
  RangedUri requestUri;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri);
    if (requestUri == null) {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
  }
  DataSpec dataSpec = new DataSpec(requestUri.getUri(), requestUri.start, requestUri.length,
      representation.getCacheKey());
  return new InitializationChunk(dataSource, dataSpec, trigger, representation.format,
      extractor, manifestIndex);
}
项目:ExoPlayer-Demo    文件:DashChunkSourceTest.java   
public void testSegmentIndexInitializationOnVod() {
  DashChunkSource chunkSource = new DashChunkSource(buildVodMpd(),
      DefaultDashTrackSelector.newVideoInstance(null, false, false), mock(DataSource.class),
      null);
  chunkSource.prepare();
  chunkSource.enable(0);

  List<MediaChunk> queue = new ArrayList<>();
  ChunkOperationHolder out = new ChunkOperationHolder();

  // request first chunk; should get back initialization chunk
  chunkSource.getChunkOperation(queue,  0, out);

  assertNotNull(out.chunk);
  assertNotNull(((InitializationChunk) out.chunk).dataSpec);
}
项目:ExoPlayer    文件:DashChunkSource.java   
@Override
public void onChunkLoadCompleted(Chunk chunk) {
  if (chunk instanceof InitializationChunk) {
    InitializationChunk initializationChunk = (InitializationChunk) chunk;
    String formatId = initializationChunk.format.id;
    RepresentationHolder representationHolder = representationHolders.get(formatId);
    if (initializationChunk.hasFormat()) {
      representationHolder.format = initializationChunk.getFormat();
    }
    if (initializationChunk.hasSeekMap()) {
      representationHolder.segmentIndex = new DashWrappingSegmentIndex(
          (ChunkIndex) initializationChunk.getSeekMap(),
          initializationChunk.dataSpec.uri.toString(),
          representationHolder.representation.periodStartMs * 1000);
    }
    // The null check avoids overwriting drmInitData obtained from the manifest with drmInitData
    // obtained from the stream, as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
    if (drmInitData == null && initializationChunk.hasDrmInitData()) {
      drmInitData = initializationChunk.getDrmInitData();
    }
  }
}
项目:ExoPlayer    文件:DashChunkSource.java   
private Chunk newInitializationChunk(RangedUri initializationUri, RangedUri indexUri,
    Representation representation, ChunkExtractorWrapper extractor, DataSource dataSource,
    int trigger) {
  RangedUri requestUri;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    requestUri = initializationUri.attemptMerge(indexUri);
    if (requestUri == null) {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
  }
  DataSpec dataSpec = new DataSpec(requestUri.getUri(), requestUri.start, requestUri.length,
      representation.getCacheKey());
  return new InitializationChunk(dataSource, dataSpec, trigger, representation.format, extractor);
}
项目: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;
        }
    }
}
项目:ExoPlayer-Demo    文件:DashChunkSource.java   
@Override
public void onChunkLoadCompleted(Chunk chunk) {
  if (chunk instanceof InitializationChunk) {
    InitializationChunk initializationChunk = (InitializationChunk) chunk;
    String formatId = initializationChunk.format.id;
    PeriodHolder periodHolder = periodHolders.get(initializationChunk.parentId);
    if (periodHolder == null) {
      // period for this initialization chunk may no longer be on the manifest
      return;
    }

    RepresentationHolder representationHolder = periodHolder.representationHolders.get(formatId);
    if (initializationChunk.hasFormat()) {
      representationHolder.mediaFormat = initializationChunk.getFormat();
    }
    // The null check avoids overwriting an index obtained from the manifest with one obtained
    // from the stream. If the manifest defines an index then the stream shouldn't, but in cases
    // where it does we should ignore it.
    if (representationHolder.segmentIndex == null && initializationChunk.hasSeekMap()) {
      representationHolder.segmentIndex = new DashWrappingSegmentIndex(
          (ChunkIndex) initializationChunk.getSeekMap(),
          initializationChunk.dataSpec.uri.toString());
    }
    // The null check avoids overwriting drmInitData obtained from the manifest with drmInitData
    // obtained from the stream, as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
    if (periodHolder.drmInitData == null && initializationChunk.hasDrmInitData()) {
      periodHolder.drmInitData = initializationChunk.getDrmInitData();
    }
  }
}