Java 类com.google.android.exoplayer.extractor.webm.WebmExtractor 实例源码

项目:mimi-reader    文件:WebmRendererBuilder.java   
@Override
public void buildRenderers(ExoPlayerHelper player) {
    Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);

    // Build the video and audio renderers.
    Extractor webmExtractor = new WebmExtractor();
    Extractor mp4Extractor = new Mp4Extractor();
    DataSource dataSource = new FileDataSource();
    ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
            BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, webmExtractor, mp4Extractor);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
            sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, player.getMainHandler(),
            player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource, MediaCodecSelector.DEFAULT,
            null, true, player.getMainHandler(), player);
    TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
            player.getMainHandler().getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[ExoPlayerHelper.RENDERER_COUNT];
    renderers[ExoPlayerHelper.TYPE_VIDEO] = videoRenderer;
    renderers[ExoPlayerHelper.TYPE_AUDIO] = audioRenderer;
    renderers[ExoPlayerHelper.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, null);
}
项目:ExoPlayer-Demo    文件:VpxPlaybackTest.java   
@Override
public void run() {
  Looper.prepare();
  player = ExoPlayer.Factory.newInstance(1);
  player.addListener(this);
  ExtractorSampleSource  sampleSource = new ExtractorSampleSource(
      uri, new DefaultUriDataSource(context, Util.getUserAgent(context, "ExoPlayerExtVP9Test")),
      new DefaultAllocator(BUFFER_SEGMENT_SIZE), BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT,
      new WebmExtractor());
  LibvpxVideoTrackRenderer videoRenderer = new LibvpxVideoTrackRenderer(sampleSource, true);
  player.sendMessage(videoRenderer, LibvpxVideoTrackRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
      new VpxVideoSurfaceView(context));
  player.prepare(videoRenderer);
  player.setPlayWhenReady(true);
  Looper.loop();
}
项目:ExoPlayer-Demo    文件:PlayerActivity.java   
private void startBasicPlayback() {
  player = ExoPlayer.Factory.newInstance(4);
  player.addListener(this);
  mediaController.setMediaPlayer(new PlayerControl(player));
  mediaController.setEnabled(true);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(
      contentUri,
      new DefaultUriDataSource(this, Util.getUserAgent(this, "ExoPlayerExtWebMDemo")),
      new DefaultAllocator(BUFFER_SEGMENT_SIZE), BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT,
      new WebmExtractor(), new FlacExtractor(), new OggExtractor());
  TrackRenderer videoRenderer =
      new LibvpxVideoTrackRenderer(sampleSource, true, handler, this, 50);
  if (useOpenGL) {
    player.sendMessage(videoRenderer, LibvpxVideoTrackRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
        vpxVideoSurfaceView);
    surfaceView.setVisibility(View.GONE);
  } else {
    player.sendMessage(
        videoRenderer, LibvpxVideoTrackRenderer.MSG_SET_SURFACE,
        surfaceView.getHolder().getSurface());
    vpxVideoSurfaceView.setVisibility(View.GONE);
  }
  TrackRenderer opusAudioTrackRenderer = new LibopusAudioTrackRenderer(sampleSource);
  TrackRenderer flacAudioTrackRenderer = new LibflacAudioTrackRenderer(sampleSource);
  TrackRenderer mediaCodecAudioTrackRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      MediaCodecSelector.DEFAULT);

  player.prepare(videoRenderer, opusAudioTrackRenderer, flacAudioTrackRenderer,
      mediaCodecAudioTrackRenderer);
  player.setPlayWhenReady(true);
}
项目:ExoPlayer-Demo    文件:OpusPlaybackTest.java   
@Override
public void run() {
  Looper.prepare();
  player = ExoPlayer.Factory.newInstance(1);
  player.addListener(this);
  ExtractorSampleSource  sampleSource = new ExtractorSampleSource(
      uri,
      new DefaultUriDataSource(context, Util.getUserAgent(context, "ExoPlayerExtOpusTest")),
      new DefaultAllocator(BUFFER_SEGMENT_SIZE), BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT,
      new WebmExtractor());
  LibopusAudioTrackRenderer audioRenderer = new LibopusAudioTrackRenderer(sampleSource);
  player.prepare(audioRenderer);
  player.setPlayWhenReady(true);
  Looper.loop();
}
项目:ExoPlayer-Demo    文件:FlacPlaybackTest.java   
@Override
public void run() {
  Looper.prepare();
  player = ExoPlayer.Factory.newInstance(1);
  player.addListener(this);
  ExtractorSampleSource  sampleSource = new ExtractorSampleSource(
      uri,
      new DefaultUriDataSource(context, Util.getUserAgent(context, "ExoPlayerExtFlacTest")),
      new DefaultAllocator(BUFFER_SEGMENT_SIZE), BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT,
      new WebmExtractor());
  LibflacAudioTrackRenderer audioRenderer = new LibflacAudioTrackRenderer(sampleSource);
  player.prepare(audioRenderer);
  player.setPlayWhenReady(true);
  Looper.loop();
}
项目:ExoPlayer-Demo    文件:DashChunkSource.java   
public RepresentationHolder(long periodStartTimeUs, long periodDurationUs,
    Representation representation) {
  this.periodStartTimeUs = periodStartTimeUs;
  this.periodDurationUs = periodDurationUs;
  this.representation = representation;
  String mimeType = representation.format.mimeType;
  mimeTypeIsRawText = mimeTypeIsRawText(mimeType);
  extractorWrapper = mimeTypeIsRawText ? null : new ChunkExtractorWrapper(
      mimeTypeIsWebm(mimeType) ? new WebmExtractor() : new FragmentedMp4Extractor());
  segmentIndex = representation.getIndex();
}
项目:ExoPlayer    文件:VideoPlayer.java   
private void startBasicPlayback() {
  if (filename == null) {
    Toast.makeText(this, "Choose a file!", Toast.LENGTH_SHORT).show();
    return;
  }
  findViewById(R.id.buttons).setVisibility(View.GONE);
  player = ExoPlayer.Factory.newInstance(2);
  player.addListener(this);
  mediaController.setMediaPlayer(new PlayerControl(player));
  mediaController.setEnabled(true);
  ExtractorSampleSource sampleSource = new ExtractorSampleSource(
      Uri.fromFile(new File(filename)),
      new DefaultUriDataSource(this, Util.getUserAgent(this, "ExoPlayerExtWebMDemo")),
      new DefaultAllocator(BUFFER_SEGMENT_SIZE), BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT,
      new WebmExtractor());
  TrackRenderer videoRenderer =
      new LibvpxVideoTrackRenderer(sampleSource, true, handler, this, 50);
  if (useOpenGL) {
    player.sendMessage(videoRenderer, LibvpxVideoTrackRenderer.MSG_SET_VPX_SURFACE_VIEW,
        vpxVideoSurfaceView);
    surfaceView.setVisibility(View.GONE);
  } else {
    player.sendMessage(
        videoRenderer, LibvpxVideoTrackRenderer.MSG_SET_SURFACE,
        surfaceView.getHolder().getSurface());
    vpxVideoSurfaceView.setVisibility(View.GONE);
  }
  TrackRenderer audioRenderer = new LibopusAudioTrackRenderer(sampleSource);
  player.prepare(videoRenderer, audioRenderer);
  player.setPlayWhenReady(true);
}
项目:miku    文件:DashChunkSource.java   
DashChunkSource(ManifestFetcher<MediaPresentationDescription> manifestFetcher,
    MediaPresentationDescription initialManifest, int adaptationSetIndex,
    int[] representationIndices, DataSource dataSource, FormatEvaluator formatEvaluator,
    Clock systemClock, long liveEdgeLatencyUs, long elapsedRealtimeOffsetUs,
    boolean startAtLiveEdge, Handler eventHandler, EventListener eventListener) {
  this.manifestFetcher = manifestFetcher;
  this.currentManifest = initialManifest;
  this.adaptationSetIndex = adaptationSetIndex;
  this.representationIndices = representationIndices;
  this.dataSource = dataSource;
  this.formatEvaluator = formatEvaluator;
  this.systemClock = systemClock;
  this.liveEdgeLatencyUs = liveEdgeLatencyUs;
  this.elapsedRealtimeOffsetUs = elapsedRealtimeOffsetUs;
  this.startAtLiveEdge = startAtLiveEdge;
  this.eventHandler = eventHandler;
  this.eventListener = eventListener;
  this.evaluation = new Evaluation();
  this.headerBuilder = new StringBuilder();
  this.seekRangeValues = new long[2];

  drmInitData = getDrmInitData(currentManifest, adaptationSetIndex);
  Representation[] representations = getFilteredRepresentations(currentManifest,
      adaptationSetIndex, representationIndices);
  long periodDurationUs = (representations[0].periodDurationMs == TrackRenderer.UNKNOWN_TIME_US)
      ? TrackRenderer.UNKNOWN_TIME_US : representations[0].periodDurationMs * 1000;
  this.trackInfo = new TrackInfo(representations[0].format.mimeType, periodDurationUs);

  this.formats = new Format[representations.length];
  this.representationHolders = new HashMap<>();
  int maxWidth = 0;
  int maxHeight = 0;
  for (int i = 0; i < representations.length; i++) {
    formats[i] = representations[i].format;
    maxWidth = Math.max(formats[i].width, maxWidth);
    maxHeight = Math.max(formats[i].height, maxHeight);
    Extractor extractor = mimeTypeIsWebm(formats[i].mimeType) ? new WebmExtractor()
        : new FragmentedMp4Extractor();
    representationHolders.put(formats[i].id,
        new RepresentationHolder(representations[i], new ChunkExtractorWrapper(extractor)));
  }
  this.maxWidth = maxWidth;
  this.maxHeight = maxHeight;
  Arrays.sort(formats, new DecreasingBandwidthComparator());
}
项目:ExoPlayer    文件:DashChunkSource.java   
DashChunkSource(ManifestFetcher<MediaPresentationDescription> manifestFetcher,
    MediaPresentationDescription initialManifest, int adaptationSetIndex,
    int[] representationIndices, DataSource dataSource, FormatEvaluator formatEvaluator,
    Clock systemClock, long liveEdgeLatencyUs, long elapsedRealtimeOffsetUs,
    boolean startAtLiveEdge, Handler eventHandler, EventListener eventListener) {
  this.manifestFetcher = manifestFetcher;
  this.currentManifest = initialManifest;
  this.adaptationSetIndex = adaptationSetIndex;
  this.representationIndices = representationIndices;
  this.dataSource = dataSource;
  this.formatEvaluator = formatEvaluator;
  this.systemClock = systemClock;
  this.liveEdgeLatencyUs = liveEdgeLatencyUs;
  this.elapsedRealtimeOffsetUs = elapsedRealtimeOffsetUs;
  this.startAtLiveEdge = startAtLiveEdge;
  this.eventHandler = eventHandler;
  this.eventListener = eventListener;
  this.evaluation = new Evaluation();
  this.headerBuilder = new StringBuilder();
  this.seekRangeValues = new long[2];

  drmInitData = getDrmInitData(currentManifest, adaptationSetIndex);
  Representation[] representations = getFilteredRepresentations(currentManifest,
      adaptationSetIndex, representationIndices);
  long periodDurationUs = (representations[0].periodDurationMs == TrackRenderer.UNKNOWN_TIME_US)
      ? TrackRenderer.UNKNOWN_TIME_US : representations[0].periodDurationMs * 1000;
  this.trackInfo = new TrackInfo(representations[0].format.mimeType, periodDurationUs);

  this.formats = new Format[representations.length];
  this.representationHolders = new HashMap<>();
  int maxWidth = 0;
  int maxHeight = 0;
  for (int i = 0; i < representations.length; i++) {
    formats[i] = representations[i].format;
    maxWidth = Math.max(formats[i].width, maxWidth);
    maxHeight = Math.max(formats[i].height, maxHeight);
    Extractor extractor = mimeTypeIsWebm(formats[i].mimeType) ? new WebmExtractor()
        : new FragmentedMp4Extractor();
    representationHolders.put(formats[i].id,
        new RepresentationHolder(representations[i], new ChunkExtractorWrapper(extractor)));
  }
  this.maxWidth = maxWidth;
  this.maxHeight = maxHeight;
  Arrays.sort(formats, new DecreasingBandwidthComparator());
}