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

项目:ExoPlayer-Demo    文件:DashChunkSource.java   
protected Chunk newMediaChunk(
    PeriodHolder periodHolder, RepresentationHolder representationHolder, DataSource dataSource,
    MediaFormat mediaFormat, ExposedTrack enabledTrack, int segmentNum, int trigger) {
  Representation representation = representationHolder.representation;
  Format format = representation.format;
  long startTimeUs = representationHolder.getSegmentStartTimeUs(segmentNum);
  long endTimeUs = representationHolder.getSegmentEndTimeUs(segmentNum);
  RangedUri segmentUri = representationHolder.getSegmentUrl(segmentNum);
  DataSpec dataSpec = new DataSpec(segmentUri.getUri(), segmentUri.start, segmentUri.length,
      representation.getCacheKey());

  long sampleOffsetUs = periodHolder.startTimeUs - representation.presentationTimeOffsetUs;
  if (mimeTypeIsRawText(format.mimeType)) {
    return new SingleSampleMediaChunk(dataSource, dataSpec, Chunk.TRIGGER_INITIAL, format,
        startTimeUs, endTimeUs, segmentNum, enabledTrack.trackFormat, null,
        periodHolder.localIndex);
  } else {
    boolean isMediaFormatFinal = (mediaFormat != null);
    return new ContainerMediaChunk(dataSource, dataSpec, trigger, format, startTimeUs, endTimeUs,
        segmentNum, sampleOffsetUs, representationHolder.extractorWrapper, mediaFormat,
        enabledTrack.adaptiveMaxWidth, enabledTrack.adaptiveMaxHeight, periodHolder.drmInitData,
        isMediaFormatFinal, periodHolder.localIndex);
  }
}
项目:miku    文件:DashChunkSource.java   
private Chunk newMediaChunk(RepresentationHolder representationHolder, DataSource dataSource,
    int segmentNum, int trigger) {
  Representation representation = representationHolder.representation;
  DashSegmentIndex segmentIndex = representationHolder.segmentIndex;

  long startTimeUs = segmentIndex.getTimeUs(segmentNum);
  long endTimeUs = startTimeUs + segmentIndex.getDurationUs(segmentNum);

  int absoluteSegmentNum = segmentNum + representationHolder.segmentNumShift;
  boolean isLastSegment = !currentManifest.dynamic
      && segmentNum == segmentIndex.getLastSegmentNum();

  RangedUri segmentUri = segmentIndex.getSegmentUrl(segmentNum);
  DataSpec dataSpec = new DataSpec(segmentUri.getUri(), segmentUri.start, segmentUri.length,
      representation.getCacheKey());

  long sampleOffsetUs = representation.periodStartMs * 1000
      - representation.presentationTimeOffsetUs;
  if (representation.format.mimeType.equals(MimeTypes.TEXT_VTT)) {
    if (representationHolder.vttHeaderOffsetUs != sampleOffsetUs) {
      // Update the VTT header.
      headerBuilder.setLength(0);
      headerBuilder.append(C.WEBVTT_EXO_HEADER).append("=")
          .append(C.WEBVTT_EXO_HEADER_OFFSET).append(sampleOffsetUs)
          .append("\n");
      representationHolder.vttHeader = headerBuilder.toString().getBytes();
      representationHolder.vttHeaderOffsetUs = sampleOffsetUs;
    }
    return new SingleSampleMediaChunk(dataSource, dataSpec, Chunk.TRIGGER_INITIAL,
        representation.format, startTimeUs, endTimeUs, absoluteSegmentNum, isLastSegment,
        MediaFormat.createTextFormat(MimeTypes.TEXT_VTT), null, representationHolder.vttHeader);
  } else {
    return new ContainerMediaChunk(dataSource, dataSpec, trigger, representation.format,
        startTimeUs, endTimeUs, absoluteSegmentNum, isLastSegment, sampleOffsetUs,
        representationHolder.extractorWrapper, representationHolder.format, drmInitData, true);
  }
}
项目: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    文件: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_VLC    文件:DashChunkSource.java   
private Chunk newMediaChunk(RepresentationHolder representationHolder, DataSource dataSource,
    int segmentNum, int trigger) {
  Representation representation = representationHolder.representation;
  DashSegmentIndex segmentIndex = representationHolder.segmentIndex;

  long startTimeUs = segmentIndex.getTimeUs(segmentNum);
  long endTimeUs = startTimeUs + segmentIndex.getDurationUs(segmentNum);

  boolean isLastSegment = !currentManifest.dynamic
      && segmentNum == segmentIndex.getLastSegmentNum();
  int nextAbsoluteSegmentNum = isLastSegment ? -1
      : (representationHolder.segmentNumShift + segmentNum + 1);

  RangedUri segmentUri = segmentIndex.getSegmentUrl(segmentNum);
  DataSpec dataSpec = new DataSpec(segmentUri.getUri(), segmentUri.start, segmentUri.length,
      representation.getCacheKey());

  long presentationTimeOffsetUs = representation.presentationTimeOffsetUs;
  if (representation.format.mimeType.equals(MimeTypes.TEXT_VTT)) {
    if (representationHolder.vttHeaderOffsetUs != presentationTimeOffsetUs) {
      // Update the VTT header.
      headerBuilder.setLength(0);
      headerBuilder.append(WebvttParser.EXO_HEADER).append("=")
          .append(WebvttParser.OFFSET).append(presentationTimeOffsetUs).append("\n");
      representationHolder.vttHeader = headerBuilder.toString().getBytes();
      representationHolder.vttHeaderOffsetUs = presentationTimeOffsetUs;
    }
    return new SingleSampleMediaChunk(dataSource, dataSpec, representation.format, 0,
        startTimeUs, endTimeUs, nextAbsoluteSegmentNum, null, representationHolder.vttHeader);
  } else {
    return new ContainerMediaChunk(dataSource, dataSpec, representation.format, trigger,
        startTimeUs, endTimeUs, nextAbsoluteSegmentNum, representationHolder.extractor, psshInfo,
        false, presentationTimeOffsetUs);
  }
}
项目:Exoplayer_VLC    文件:SmoothStreamingChunkSource.java   
private static MediaChunk newMediaChunk(Format formatInfo, Uri uri, String cacheKey,
    Extractor extractor, Map<UUID, byte[]> psshInfo, DataSource dataSource, int chunkIndex,
    boolean isLast, long chunkStartTimeUs, long nextChunkStartTimeUs, int trigger) {
  int nextChunkIndex = isLast ? -1 : chunkIndex + 1;
  long nextStartTimeUs = isLast ? -1 : nextChunkStartTimeUs;
  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, formatInfo, trigger, chunkStartTimeUs,
      nextStartTimeUs, nextChunkIndex, extractor, psshInfo, false, -chunkStartTimeUs);
}
项目:ExoPlayer    文件:DashChunkSource.java   
private Chunk newMediaChunk(RepresentationHolder representationHolder, DataSource dataSource,
    int segmentNum, int trigger) {
  Representation representation = representationHolder.representation;
  DashSegmentIndex segmentIndex = representationHolder.segmentIndex;

  long startTimeUs = segmentIndex.getTimeUs(segmentNum);
  long endTimeUs = startTimeUs + segmentIndex.getDurationUs(segmentNum);

  int absoluteSegmentNum = segmentNum + representationHolder.segmentNumShift;
  boolean isLastSegment = !currentManifest.dynamic
      && segmentNum == segmentIndex.getLastSegmentNum();

  RangedUri segmentUri = segmentIndex.getSegmentUrl(segmentNum);
  DataSpec dataSpec = new DataSpec(segmentUri.getUri(), segmentUri.start, segmentUri.length,
      representation.getCacheKey());

  long sampleOffsetUs = representation.periodStartMs * 1000
      - representation.presentationTimeOffsetUs;
  if (representation.format.mimeType.equals(MimeTypes.TEXT_VTT)) {
    if (representationHolder.vttHeaderOffsetUs != sampleOffsetUs) {
      // Update the VTT header.
      headerBuilder.setLength(0);
      headerBuilder.append(C.WEBVTT_EXO_HEADER).append("=")
          .append(C.WEBVTT_EXO_HEADER_OFFSET).append(sampleOffsetUs)
          .append("\n");
      representationHolder.vttHeader = headerBuilder.toString().getBytes();
      representationHolder.vttHeaderOffsetUs = sampleOffsetUs;
    }
    return new SingleSampleMediaChunk(dataSource, dataSpec, Chunk.TRIGGER_INITIAL,
        representation.format, startTimeUs, endTimeUs, absoluteSegmentNum, isLastSegment,
        MediaFormat.createTextFormat(MimeTypes.TEXT_VTT), null, representationHolder.vttHeader);
  } else {
    return new ContainerMediaChunk(dataSource, dataSpec, trigger, representation.format,
        startTimeUs, endTimeUs, absoluteSegmentNum, isLastSegment, sampleOffsetUs,
        representationHolder.extractorWrapper, representationHolder.format, drmInitData, true);
  }
}
项目: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);
}