Java 类com.google.android.exoplayer.upstream.UriDataSource 实例源码

项目:Exoplayer_VLC    文件:HlsRendererBuilder.java   
@Override
public void onManifest(String contentId, HlsPlaylist manifest) {
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  DataSource dataSource = new UriDataSource(userAgent, bandwidthMeter);
  HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter, null,
      HlsChunkSource.ADAPTIVE_MODE_SPLICE);
  HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, true, 3);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
      MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, player.getMainHandler(), player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);

  MetadataTrackRenderer<Map<String, Object>> id3Renderer =
      new MetadataTrackRenderer<Map<String, Object>>(sampleSource, new Id3Parser(),
          player.getId3MetadataRenderer(), player.getMainHandler().getLooper());

  Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
      player.getMainHandler().getLooper());

  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TIMED_METADATA] = id3Renderer;
  renderers[DemoPlayer.TYPE_TEXT] = closedCaptionRenderer;
  callback.onRenderers(null, null, renderers);
}
项目:miku    文件:ManifestFetcher.java   
/**
 * @param manifestUri The manifest location.
 * @param uriDataSource The {@link UriDataSource} to use when loading the manifest.
 * @param parser A parser to parse the loaded manifest data.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public ManifestFetcher(String manifestUri, UriDataSource uriDataSource,
    UriLoadable.Parser<T> parser, Handler eventHandler, EventListener eventListener) {
  this.parser = parser;
  this.manifestUri = manifestUri;
  this.uriDataSource = uriDataSource;
  this.eventHandler = eventHandler;
  this.eventListener = eventListener;
}
项目:miku    文件:UtcTimingElementResolver.java   
private UtcTimingElementResolver(UriDataSource uriDataSource, UtcTimingElement timingElement,
    long timingElementElapsedRealtime, UtcTimingCallback callback) {
  this.uriDataSource = uriDataSource;
  this.timingElement = Assertions.checkNotNull(timingElement);
  this.timingElementElapsedRealtime = timingElementElapsedRealtime;
  this.callback = Assertions.checkNotNull(callback);
}
项目:ExoPlayer-Demo    文件:ManifestFetcher.java   
/**
 * @param manifestUri The manifest location.
 * @param uriDataSource The {@link UriDataSource} to use when loading the manifest.
 * @param parser A parser to parse the loaded manifest data.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public ManifestFetcher(String manifestUri, UriDataSource uriDataSource,
    UriLoadable.Parser<T> parser, Handler eventHandler, EventListener eventListener) {
  this.parser = parser;
  this.manifestUri = manifestUri;
  this.uriDataSource = uriDataSource;
  this.eventHandler = eventHandler;
  this.eventListener = eventListener;
}
项目:ExoPlayer-Demo    文件:UtcTimingElementResolver.java   
private UtcTimingElementResolver(UriDataSource uriDataSource, UtcTimingElement timingElement,
    long timingElementElapsedRealtime, UtcTimingCallback callback) {
  this.uriDataSource = uriDataSource;
  this.timingElement = Assertions.checkNotNull(timingElement);
  this.timingElementElapsedRealtime = timingElementElapsedRealtime;
  this.callback = Assertions.checkNotNull(callback);
}
项目:danish-media-license    文件:HlsRendererBuilder.java   
private static UriDataSource createDataSource(Context context, String userAgent,
                                              TransferListener transferListener) {
  return new DefaultUriDataSource(
      context,
      transferListener,
      new OkHttpDataSource(userAgent, null, transferListener)
  );
}
项目:ExoPlayer    文件:ManifestFetcher.java   
/**
 * @param manifestUri The manifest location.
 * @param uriDataSource The {@link UriDataSource} to use when loading the manifest.
 * @param parser A parser to parse the loaded manifest data.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public ManifestFetcher(String manifestUri, UriDataSource uriDataSource,
    UriLoadable.Parser<T> parser, Handler eventHandler, EventListener eventListener) {
  this.parser = parser;
  this.manifestUri = manifestUri;
  this.uriDataSource = uriDataSource;
  this.eventHandler = eventHandler;
  this.eventListener = eventListener;
}
项目:ExoPlayer    文件:UtcTimingElementResolver.java   
private UtcTimingElementResolver(UriDataSource uriDataSource, UtcTimingElement timingElement,
    long timingElementElapsedRealtime, UtcTimingCallback callback) {
  this.uriDataSource = uriDataSource;
  this.timingElement = Assertions.checkNotNull(timingElement);
  this.timingElementElapsedRealtime = timingElementElapsedRealtime;
  this.callback = Assertions.checkNotNull(callback);
}
项目:danish-media-license    文件:HlsRendererBuilder.java   
private static UriDataSource createDataSource(Context context, String userAgent) {
  return createDataSource(context, userAgent, null);
}
项目:luxunPro    文件:DashRenderBuilder.java   
protected UriDataSource createManifestDataSource(Context context, String userAgent) {
    return new DefaultUriDataSource(context, userAgent);
}
项目:luxunPro    文件:HlsRenderBuilder.java   
protected UriDataSource createManifestDataSource(Context context, String userAgent) {
    return new DefaultUriDataSource(context, userAgent);
}
项目:luxunPro    文件:SmoothStreamRenderBuilder.java   
@SuppressWarnings("UnusedParameters") // Context kept for consistency with the HLS and Dash builders
protected UriDataSource createManifestDataSource(Context context, String userAgent) {
    return new DefaultHttpDataSource(userAgent, null);
}
项目:android-exoplayer    文件:SmoothStreamingRendererBuilder.java   
@Override
public void onManifest(String contentId, SmoothStreamingManifest manifest) {
  Handler mainHandler = playerActivity.getMainHandler();
  LoadControl loadControl = new DefaultLoadControl(new BufferPool(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  // Obtain stream elements for playback.
  int maxDecodableFrameSize = MediaCodecUtil.maxH264DecodableFrameSize();
  int audioStreamElementIndex = -1;
  int videoStreamElementIndex = -1;
  ArrayList<Integer> videoTrackIndexList = new ArrayList<Integer>();
  for (int i = 0; i < manifest.streamElements.length; i++) {
    if (audioStreamElementIndex == -1
        && manifest.streamElements[i].type == StreamElement.TYPE_AUDIO) {
      audioStreamElementIndex = i;
    } else if (videoStreamElementIndex == -1
        && manifest.streamElements[i].type == StreamElement.TYPE_VIDEO) {
      videoStreamElementIndex = i;
      StreamElement streamElement = manifest.streamElements[i];
      for (int j = 0; j < streamElement.tracks.length; j++) {
        TrackElement trackElement = streamElement.tracks[j];
        if (trackElement.maxWidth * trackElement.maxHeight <= maxDecodableFrameSize) {
          videoTrackIndexList.add(j);
        } else {
          // The device isn't capable of playing this stream.
        }
      }
    }
  }
  int[] videoTrackIndices = Util.toArray(videoTrackIndexList);

  // Build the video renderer.
  DataSource videoDataSource = new UriDataSource(userAgent, bandwidthMeter);
  ChunkSource videoChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
      videoStreamElementIndex, videoTrackIndices, videoDataSource,
      new AdaptiveEvaluator(bandwidthMeter), LIVE_EDGE_LATENCY_MS);
  ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl,
      VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(videoSampleSource,
      MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 0, mainHandler, playerActivity, 50);

  // Build the audio renderer.
  DataSource audioDataSource = new UriDataSource(userAgent, bandwidthMeter);
  ChunkSource audioChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
      audioStreamElementIndex, new int[] {0}, audioDataSource,
      new FormatEvaluator.FixedEvaluator(), LIVE_EDGE_LATENCY_MS);
  SampleSource audioSampleSource = new ChunkSampleSource(audioChunkSource, loadControl,
      AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(
      audioSampleSource);
  callback.onRenderers(videoRenderer, audioRenderer);
}
项目:miku    文件:UtcTimingElementResolver.java   
/**
 * Resolves a {@link UtcTimingElement}.
 *
 * @param uriDataSource A source to use should loading from a URI be necessary.
 * @param timingElement The element to resolve.
 * @param timingElementElapsedRealtime The {@link SystemClock#elapsedRealtime()} timestamp at
 *     which the element was obtained. Used if the element contains a timestamp directly.
 * @param callback The callback to invoke on resolution or failure.
 */
public static void resolveTimingElement(UriDataSource uriDataSource,
    UtcTimingElement timingElement, long timingElementElapsedRealtime,
    UtcTimingCallback callback) {
  UtcTimingElementResolver resolver = new UtcTimingElementResolver(uriDataSource, timingElement,
      timingElementElapsedRealtime, callback);
  resolver.resolve();
}
项目:ExoPlayer-Demo    文件:UtcTimingElementResolver.java   
/**
 * Resolves a {@link UtcTimingElement}.
 *
 * @param uriDataSource A source to use should loading from a URI be necessary.
 * @param timingElement The element to resolve.
 * @param timingElementElapsedRealtime The {@link SystemClock#elapsedRealtime()} timestamp at
 *     which the element was obtained. Used if the element contains a timestamp directly.
 * @param callback The callback to invoke on resolution or failure.
 */
public static void resolveTimingElement(UriDataSource uriDataSource,
    UtcTimingElement timingElement, long timingElementElapsedRealtime,
    UtcTimingCallback callback) {
  UtcTimingElementResolver resolver = new UtcTimingElementResolver(uriDataSource, timingElement,
      timingElementElapsedRealtime, callback);
  resolver.resolve();
}
项目:ExoPlayer    文件:UtcTimingElementResolver.java   
/**
 * Resolves a {@link UtcTimingElement}.
 *
 * @param uriDataSource A source to use should loading from a URI be necessary.
 * @param timingElement The element to resolve.
 * @param timingElementElapsedRealtime The {@link SystemClock#elapsedRealtime()} timestamp at
 *     which the element was obtained. Used if the element contains a timestamp directly.
 * @param callback The callback to invoke on resolution or failure.
 */
public static void resolveTimingElement(UriDataSource uriDataSource,
    UtcTimingElement timingElement, long timingElementElapsedRealtime,
    UtcTimingCallback callback) {
  UtcTimingElementResolver resolver = new UtcTimingElementResolver(uriDataSource, timingElement,
      timingElementElapsedRealtime, callback);
  resolver.resolve();
}
项目:miku    文件:ManifestFetcher.java   
/**
 * @param manifestUri The manifest location.
 * @param uriDataSource The {@link UriDataSource} to use when loading the manifest.
 * @param parser A parser to parse the loaded manifest data.
 */
public ManifestFetcher(String manifestUri, UriDataSource uriDataSource,
    UriLoadable.Parser<T> parser) {
  this(manifestUri, uriDataSource, parser, null, null);
}
项目:ExoPlayer-Demo    文件:ManifestFetcher.java   
/**
 * @param manifestUri The manifest location.
 * @param uriDataSource The {@link UriDataSource} to use when loading the manifest.
 * @param parser A parser to parse the loaded manifest data.
 */
public ManifestFetcher(String manifestUri, UriDataSource uriDataSource,
    UriLoadable.Parser<T> parser) {
  this(manifestUri, uriDataSource, parser, null, null);
}
项目:ExoPlayer    文件:ManifestFetcher.java   
/**
 * @param manifestUri The manifest location.
 * @param uriDataSource The {@link UriDataSource} to use when loading the manifest.
 * @param parser A parser to parse the loaded manifest data.
 */
public ManifestFetcher(String manifestUri, UriDataSource uriDataSource,
    UriLoadable.Parser<T> parser) {
  this(manifestUri, uriDataSource, parser, null, null);
}