Java 类com.google.android.exoplayer.SampleSource.SampleSourceReader 实例源码

项目:ExoPlayer-Demo    文件:SampleSourceTrackRenderer.java   
/**
 * @param sources One or more upstream sources from which the renderer can obtain samples.
 */
public SampleSourceTrackRenderer(SampleSource... sources) {
  this.sources = new SampleSourceReader[sources.length];
  for (int i = 0; i < sources.length; i++) {
    this.sources[i] = sources[i].register();
  }
}
项目:ExoPlayer-Demo    文件:SampleSourceTrackRenderer.java   
private void maybeThrowError(SampleSourceReader source) throws ExoPlaybackException {
  try {
    source.maybeThrowError();
  } catch (IOException e) {
    throw new ExoPlaybackException(e);
  }
}
项目:android_packages_apps_tv    文件:MpegTsSampleSource.java   
@Override
public SampleSourceReader register() {
    mRemainingReleaseCount++;
    return this;
}
项目:miku    文件:FrameworkSampleSource.java   
@Override
public SampleSourceReader register() {
  remainingReleaseCount++;
  return this;
}
项目:miku    文件:HlsSampleSource.java   
@Override
public SampleSourceReader register() {
  remainingReleaseCount++;
  return this;
}
项目:miku    文件:ExtractorSampleSource.java   
@Override
public SampleSourceReader register() {
  remainingReleaseCount++;
  return this;
}
项目:miku    文件:SingleSampleSource.java   
@Override
public SampleSourceReader register() {
  return this;
}
项目:miku    文件:ChunkSampleSource.java   
@Override
public SampleSourceReader register() {
  Assertions.checkState(state == STATE_IDLE);
  state = STATE_INITIALIZED;
  return this;
}
项目:ExoPlayer-Demo    文件:FrameworkSampleSource.java   
@Override
public SampleSourceReader register() {
  remainingReleaseCount++;
  return this;
}
项目:ExoPlayer-Demo    文件:HlsSampleSource.java   
@Override
public SampleSourceReader register() {
  remainingReleaseCount++;
  return this;
}
项目:ExoPlayer-Demo    文件:ExtractorSampleSource.java   
@Override
public SampleSourceReader register() {
  remainingReleaseCount++;
  return this;
}
项目:ExoPlayer-Demo    文件:SingleSampleSource.java   
@Override
public SampleSourceReader register() {
  return this;
}
项目:ExoPlayer-Demo    文件:ChunkSampleSource.java   
@Override
public SampleSourceReader register() {
  Assertions.checkState(state == STATE_IDLE);
  state = STATE_INITIALIZED;
  return this;
}
项目:ExoPlayer-Demo    文件:SampleSourceTrackRenderer.java   
@Override
protected final boolean doPrepare(long positionUs) throws ExoPlaybackException {
  boolean allSourcesPrepared = true;
  for (int i = 0; i < sources.length; i++) {
    allSourcesPrepared &= sources[i].prepare(positionUs);
  }
  if (!allSourcesPrepared) {
    return false;
  }
  // The sources are all prepared.
  int totalSourceTrackCount = 0;
  for (int i = 0; i < sources.length; i++) {
    totalSourceTrackCount += sources[i].getTrackCount();
  }
  long durationUs = 0;
  int handledTrackCount = 0;
  int[] handledSourceIndices = new int[totalSourceTrackCount];
  int[] handledTrackIndices = new int[totalSourceTrackCount];
  int sourceCount = sources.length;
  for (int sourceIndex = 0; sourceIndex < sourceCount; sourceIndex++) {
    SampleSourceReader source = sources[sourceIndex];
    int sourceTrackCount = source.getTrackCount();
    for (int trackIndex = 0; trackIndex < sourceTrackCount; trackIndex++) {
      MediaFormat format = source.getFormat(trackIndex);
      boolean handlesTrack;
      try {
        handlesTrack = handlesTrack(format);
      } catch (DecoderQueryException e) {
        throw new ExoPlaybackException(e);
      }
      if (handlesTrack) {
        handledSourceIndices[handledTrackCount] = sourceIndex;
        handledTrackIndices[handledTrackCount] = trackIndex;
        handledTrackCount++;
        if (durationUs == TrackRenderer.UNKNOWN_TIME_US) {
          // We've already encountered a track for which the duration is unknown, so the media
          // duration is unknown regardless of the duration of this track.
        } else {
          long trackDurationUs = format.durationUs;
          if (trackDurationUs == TrackRenderer.UNKNOWN_TIME_US) {
            durationUs = TrackRenderer.UNKNOWN_TIME_US;
          } else if (trackDurationUs == TrackRenderer.MATCH_LONGEST_US) {
            // Do nothing.
          } else {
            durationUs = Math.max(durationUs, trackDurationUs);
          }
        }
      }
    }
  }
  this.durationUs = durationUs;
  this.handledSourceIndices = Arrays.copyOf(handledSourceIndices, handledTrackCount);
  this.handledSourceTrackIndices = Arrays.copyOf(handledTrackIndices, handledTrackCount);
  return true;
}
项目:ExoPlayer-Demo    文件:SampleSourceTrackRenderer.java   
@Override
protected final MediaFormat getFormat(int track) {
  SampleSourceReader source = sources[handledSourceIndices[track]];
  return source.getFormat(handledSourceTrackIndices[track]);
}
项目:ExoPlayer    文件:FrameworkSampleSource.java   
@Override
public SampleSourceReader register() {
  remainingReleaseCount++;
  return this;
}
项目:ExoPlayer    文件:HlsSampleSource.java   
@Override
public SampleSourceReader register() {
  remainingReleaseCount++;
  return this;
}
项目:ExoPlayer    文件:ExtractorSampleSource.java   
@Override
public SampleSourceReader register() {
  remainingReleaseCount++;
  return this;
}
项目:ExoPlayer    文件:SingleSampleSource.java   
@Override
public SampleSourceReader register() {
  return this;
}
项目:ExoPlayer    文件:ChunkSampleSource.java   
@Override
public SampleSourceReader register() {
  Assertions.checkState(state == STATE_IDLE);
  state = STATE_INITIALIZED;
  return this;
}