当前位置: 首页>>代码示例>>Java>>正文


Java C.SAMPLE_FLAG_DECODE_ONLY属性代码示例

本文整理汇总了Java中com.google.android.exoplayer.C.SAMPLE_FLAG_DECODE_ONLY属性的典型用法代码示例。如果您正苦于以下问题:Java C.SAMPLE_FLAG_DECODE_ONLY属性的具体用法?Java C.SAMPLE_FLAG_DECODE_ONLY怎么用?Java C.SAMPLE_FLAG_DECODE_ONLY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.android.exoplayer.C的用法示例。


在下文中一共展示了C.SAMPLE_FLAG_DECODE_ONLY属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readData

@Override
public int readData(int track, long playbackPositionUs, MediaFormatHolder formatHolder,
    SampleHolder sampleHolder, boolean onlyReadDiscontinuity) {
  downstreamPositionUs = playbackPositionUs;

  if (pendingDiscontinuities[track]) {
    pendingDiscontinuities[track] = false;
    return DISCONTINUITY_READ;
  }

  if (onlyReadDiscontinuity || isPendingReset()) {
    return NOTHING_READ;
  }

  InternalTrackOutput sampleQueue = sampleQueues.valueAt(track);
  if (pendingMediaFormat[track]) {
    formatHolder.format = sampleQueue.getFormat();
    formatHolder.drmInitData = drmInitData;
    pendingMediaFormat[track] = false;
    return FORMAT_READ;
  }

  if (sampleQueue.getSample(sampleHolder)) {
    boolean decodeOnly = sampleHolder.timeUs < lastSeekPositionUs;
    sampleHolder.flags |= decodeOnly ? C.SAMPLE_FLAG_DECODE_ONLY : 0;
    if (havePendingNextSampleUs) {
      // Set the offset to make the timestamp of this sample equal to pendingNextSampleUs.
      sampleTimeOffsetUs = pendingNextSampleUs - sampleHolder.timeUs;
      havePendingNextSampleUs = false;
    }
    sampleHolder.timeUs += sampleTimeOffsetUs;
    return SAMPLE_READ;
  }

  if (loadingFinished) {
    return END_OF_STREAM;
  }

  return NOTHING_READ;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:40,代码来源:ExtractorSampleSource.java

示例2: readData

@Override
public int readData(int track, long playbackPositionUs, MediaFormatHolder formatHolder,
    SampleHolder sampleHolder) {
  downstreamPositionUs = playbackPositionUs;

  if (pendingDiscontinuities[track] || isPendingReset()) {
    return NOTHING_READ;
  }

  InternalTrackOutput sampleQueue = sampleQueues.valueAt(track);
  if (pendingMediaFormat[track]) {
    formatHolder.format = sampleQueue.getFormat();
    formatHolder.drmInitData = drmInitData;
    pendingMediaFormat[track] = false;
    return FORMAT_READ;
  }

  if (sampleQueue.getSample(sampleHolder)) {
    boolean decodeOnly = sampleHolder.timeUs < lastSeekPositionUs;
    sampleHolder.flags |= decodeOnly ? C.SAMPLE_FLAG_DECODE_ONLY : 0;
    if (havePendingNextSampleUs) {
      // Set the offset to make the timestamp of this sample equal to pendingNextSampleUs.
      sampleTimeOffsetUs = pendingNextSampleUs - sampleHolder.timeUs;
      havePendingNextSampleUs = false;
    }
    sampleHolder.timeUs += sampleTimeOffsetUs;
    return SAMPLE_READ;
  }

  if (loadingFinished) {
    return END_OF_STREAM;
  }

  return NOTHING_READ;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:35,代码来源:ExtractorSampleSource.java

示例3: assertSample

private void assertSample(int index, byte[] expectedMedia, long timeUs, boolean keyframe,
    boolean invisible, byte[] encryptionKey, FakeTrackOutput output) {
  if (encryptionKey != null) {
    expectedMedia = TestUtil.joinByteArrays(
        new byte[] {(byte) StreamBuilder.TEST_INITIALIZATION_VECTOR.length},
        StreamBuilder.TEST_INITIALIZATION_VECTOR, expectedMedia);
  }
  int flags = 0;
  flags |= keyframe ? C.SAMPLE_FLAG_SYNC : 0;
  flags |= invisible ? C.SAMPLE_FLAG_DECODE_ONLY : 0;
  flags |= encryptionKey != null ? C.SAMPLE_FLAG_ENCRYPTED : 0;
  output.assertSample(index, expectedMedia, timeUs, flags, encryptionKey);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:13,代码来源:WebmExtractorTest.java

示例4: readData

@Override
public int readData(int track, long playbackPositionUs, MediaFormatHolder formatHolder,
    SampleHolder sampleHolder, boolean onlyReadDiscontinuity) {
  Assertions.checkState(prepared);
  downstreamPositionUs = playbackPositionUs;

  if (pendingDiscontinuities[track]) {
    pendingDiscontinuities[track] = false;
    return DISCONTINUITY_READ;
  }

  if (onlyReadDiscontinuity) {
    return NOTHING_READ;
  }

  if (isPendingReset()) {
    return NOTHING_READ;
  }

  HlsExtractorWrapper extractor = getCurrentExtractor();
  if (!extractor.isPrepared()) {
    return NOTHING_READ;
  }

  if (downstreamFormat == null || !downstreamFormat.equals(extractor.format)) {
    // Notify a change in the downstream format.
    notifyDownstreamFormatChanged(extractor.format, extractor.trigger, extractor.startTimeUs);
    downstreamFormat = extractor.format;
  }

  if (extractors.size() > 1) {
    // If there's more than one extractor, attempt to configure a seamless splice from the
    // current one to the next one.
    extractor.configureSpliceTo(extractors.get(1));
  }

  int extractorIndex = 0;
  while (extractors.size() > extractorIndex + 1 && !extractor.hasSamples(track)) {
    // We're finished reading from the extractor for this particular track, so advance to the
    // next one for the current read.
    extractor = extractors.get(++extractorIndex);
    if (!extractor.isPrepared()) {
      return NOTHING_READ;
    }
  }

  MediaFormat mediaFormat = extractor.getMediaFormat(track);
  if (mediaFormat != null && !mediaFormat.equals(downstreamMediaFormats[track], true)) {
    chunkSource.getMaxVideoDimensions(mediaFormat);
    formatHolder.format = mediaFormat;
    downstreamMediaFormats[track] = mediaFormat;
    return FORMAT_READ;
  }

  if (extractor.getSample(track, sampleHolder)) {
    boolean decodeOnly = sampleHolder.timeUs < lastSeekPositionUs;
    sampleHolder.flags |= decodeOnly ? C.SAMPLE_FLAG_DECODE_ONLY : 0;
    return SAMPLE_READ;
  }

  if (loadingFinished) {
    return END_OF_STREAM;
  }

  return NOTHING_READ;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:66,代码来源:HlsSampleSource.java

示例5: readData

@Override
public int readData(int track, long positionUs, MediaFormatHolder formatHolder,
    SampleHolder sampleHolder, boolean onlyReadDiscontinuity) {
  Assertions.checkState(state == STATE_ENABLED);
  Assertions.checkState(track == 0);
  downstreamPositionUs = positionUs;

  if (pendingDiscontinuity) {
    pendingDiscontinuity = false;
    return DISCONTINUITY_READ;
  }

  if (onlyReadDiscontinuity) {
    return NOTHING_READ;
  }

  if (isPendingReset()) {
    return NOTHING_READ;
  }

  boolean haveSamples = !sampleQueue.isEmpty();
  BaseMediaChunk currentChunk = mediaChunks.getFirst();
  while (haveSamples && mediaChunks.size() > 1
      && mediaChunks.get(1).getFirstSampleIndex() == sampleQueue.getReadIndex()) {
    mediaChunks.removeFirst();
    currentChunk = mediaChunks.getFirst();
  }

  if (downstreamFormat == null || !downstreamFormat.equals(currentChunk.format)) {
    notifyDownstreamFormatChanged(currentChunk.format, currentChunk.trigger,
        currentChunk.startTimeUs);
    downstreamFormat = currentChunk.format;
  }

  if (haveSamples || currentChunk.isMediaFormatFinal) {
    MediaFormat mediaFormat = currentChunk.getMediaFormat();
    if (!mediaFormat.equals(downstreamMediaFormat, true)) {
      chunkSource.getMaxVideoDimensions(mediaFormat);
      formatHolder.format = mediaFormat;
      formatHolder.drmInitData = currentChunk.getDrmInitData();
      downstreamMediaFormat = mediaFormat;
      return FORMAT_READ;
    }
  }

  if (!haveSamples) {
    if (loadingFinished) {
      return END_OF_STREAM;
    }
    return NOTHING_READ;
  }

  if (sampleQueue.getSample(sampleHolder)) {
    boolean decodeOnly = sampleHolder.timeUs < lastSeekPositionUs;
    sampleHolder.flags |= decodeOnly ? C.SAMPLE_FLAG_DECODE_ONLY : 0;
    onSampleRead(currentChunk, sampleHolder);
    return SAMPLE_READ;
  }

  return NOTHING_READ;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:61,代码来源:ChunkSampleSource.java

示例6: readData

@Override
public int readData(int track, long playbackPositionUs, MediaFormatHolder formatHolder,
    SampleHolder sampleHolder) {
  Assertions.checkState(prepared);
  downstreamPositionUs = playbackPositionUs;

  if (pendingDiscontinuities[track] || isPendingReset()) {
    return NOTHING_READ;
  }

  HlsExtractorWrapper extractor = getCurrentExtractor();
  if (!extractor.isPrepared()) {
    return NOTHING_READ;
  }

  Format format = extractor.format;
  if (!format.equals(downstreamFormat)) {
    notifyDownstreamFormatChanged(format, extractor.trigger, extractor.startTimeUs);
  }
  downstreamFormat = format;

  if (extractors.size() > 1) {
    // If there's more than one extractor, attempt to configure a seamless splice from the
    // current one to the next one.
    extractor.configureSpliceTo(extractors.get(1));
  }

  int extractorTrack = extractorTrackIndices[track];
  int extractorIndex = 0;
  while (extractors.size() > extractorIndex + 1 && !extractor.hasSamples(extractorTrack)) {
    // We're finished reading from the extractor for this particular track, so advance to the
    // next one for the current read.
    extractor = extractors.get(++extractorIndex);
    if (!extractor.isPrepared()) {
      return NOTHING_READ;
    }
  }

  MediaFormat mediaFormat = extractor.getMediaFormat(extractorTrack);
  if (mediaFormat != null) {
    if (!mediaFormat.equals(downstreamMediaFormats[track])) {
      formatHolder.format = mediaFormat;
      downstreamMediaFormats[track] = mediaFormat;
      return FORMAT_READ;
    }
    // If mediaFormat and downstreamMediaFormat[track] are equal but different objects then the
    // equality check above will have been expensive, comparing the fields in each format. We
    // update downstreamMediaFormat here so that referential equality can be cheaply established
    // during subsequent calls.
    downstreamMediaFormats[track] = mediaFormat;
  }

  if (extractor.getSample(extractorTrack, sampleHolder)) {
    boolean decodeOnly = sampleHolder.timeUs < lastSeekPositionUs;
    sampleHolder.flags |= decodeOnly ? C.SAMPLE_FLAG_DECODE_ONLY : 0;
    return SAMPLE_READ;
  }

  if (loadingFinished) {
    return END_OF_STREAM;
  }

  return NOTHING_READ;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:64,代码来源:HlsSampleSource.java

示例7: readData

@Override
public int readData(int track, long positionUs, MediaFormatHolder formatHolder,
    SampleHolder sampleHolder) {
  Assertions.checkState(state == STATE_ENABLED);
  downstreamPositionUs = positionUs;

  if (pendingDiscontinuity || isPendingReset()) {
    return NOTHING_READ;
  }

  boolean haveSamples = !sampleQueue.isEmpty();
  BaseMediaChunk currentChunk = mediaChunks.getFirst();
  while (haveSamples && mediaChunks.size() > 1
      && mediaChunks.get(1).getFirstSampleIndex() <= sampleQueue.getReadIndex()) {
    mediaChunks.removeFirst();
    currentChunk = mediaChunks.getFirst();
  }

  Format format = currentChunk.format;
  if (!format.equals(downstreamFormat)) {
    notifyDownstreamFormatChanged(format, currentChunk.trigger, currentChunk.startTimeUs);
  }
  downstreamFormat = format;

  if (haveSamples || currentChunk.isMediaFormatFinal) {
    MediaFormat mediaFormat = currentChunk.getMediaFormat();
    if (!mediaFormat.equals(downstreamMediaFormat)) {
      formatHolder.format = mediaFormat;
      formatHolder.drmInitData = currentChunk.getDrmInitData();
      downstreamMediaFormat = mediaFormat;
      return FORMAT_READ;
    }
    // If mediaFormat and downstreamMediaFormat are equal but different objects then the equality
    // check above will have been expensive, comparing the fields in each format. We update
    // downstreamMediaFormat here so that referential equality can be cheaply established during
    // subsequent calls.
    downstreamMediaFormat = mediaFormat;
  }

  if (!haveSamples) {
    if (loadingFinished) {
      return END_OF_STREAM;
    }
    return NOTHING_READ;
  }

  if (sampleQueue.getSample(sampleHolder)) {
    boolean decodeOnly = sampleHolder.timeUs < lastSeekPositionUs;
    sampleHolder.flags |= decodeOnly ? C.SAMPLE_FLAG_DECODE_ONLY : 0;
    onSampleRead(currentChunk, sampleHolder);
    return SAMPLE_READ;
  }

  return NOTHING_READ;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:55,代码来源:ChunkSampleSource.java


注:本文中的com.google.android.exoplayer.C.SAMPLE_FLAG_DECODE_ONLY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。