com.google.android.exoplayer.util.ManifestFetcher Java Examples

The following examples show how to use com.google.android.exoplayer.util.ManifestFetcher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HlsRendererBuilder.java    From exoplayer-textureview with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(HlsRendererBuilder rendererBuilder,
        RendererBuilderCallback callback) {
    this.rendererBuilder = rendererBuilder;
    this.callback = callback;
    HlsPlaylistParser parser = new HlsPlaylistParser();
    playlistFetcher = new ManifestFetcher<>(rendererBuilder.uri.toString(),
            new DefaultUriDataSource(rendererBuilder.context,
                    rendererBuilder.userAgent), parser);
}
 
Example #2
Source File: HlsRendererBuilder.java    From google-media-framework-android with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url, ExoplayerWrapper player) {
  this.context = context;
  this.userAgent = userAgent;
  this.url = url;
  this.player = player;
  HlsPlaylistParser parser = new HlsPlaylistParser();
  playlistFetcher = new ManifestFetcher<>(url, new DefaultUriDataSource(context, userAgent),
          parser);
}
 
Example #3
Source File: DashRendererBuilder.java    From google-media-framework-android with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
                            MediaDrmCallback drmCallback, ExoplayerWrapper player) {
  this.context = context;
  this.userAgent = userAgent;
  this.drmCallback = drmCallback;
  this.player = player;
  MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser();
  manifestDataSource = new DefaultUriDataSource(context, userAgent);
  manifestFetcher = new ManifestFetcher<>(url, manifestDataSource, parser);
}
 
Example #4
Source File: SmoothStreamingRendererBuilder.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
        MediaDrmCallback drmCallback, DemoPlayer player) {
    this.context = context;
    this.userAgent = userAgent;
    this.drmCallback = drmCallback;
    this.player = player;
    SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser();
    manifestFetcher = new ManifestFetcher<>(url, new DefaultHttpDataSource(userAgent, null),
            parser);
}
 
Example #5
Source File: HlsRendererBuilder.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
        DemoPlayer player) {
    this.context = context;
    this.userAgent = userAgent;
    this.player = player;
    HlsPlaylistParser parser = new HlsPlaylistParser();
    playlistFetcher = new ManifestFetcher<>(url,
            new DefaultUriDataSource(context, userAgent), parser);
}
 
Example #6
Source File: DashRendererBuilder.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
                            MediaDrmCallback drmCallback, DemoPlayer player) {
    this.context = context;
    this.userAgent = userAgent;
    this.drmCallback = drmCallback;
    this.player = player;
    MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser();
    manifestDataSource = new DefaultUriDataSource(context, userAgent);
    manifestFetcher = new ManifestFetcher<>(url, manifestDataSource, parser);
}
 
Example #7
Source File: DashRendererBuilder.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
    this.player = player;
  MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser();
  manifestDataSource = new DefaultUriDataSource(context, userAgent);
  manifestFetcher = new ManifestFetcher<>(url, manifestDataSource, parser);
}
 
Example #8
Source File: DashChunkSource.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
private DashChunkSource(ManifestFetcher<MediaPresentationDescription> manifestFetcher,
    MediaPresentationDescription initialManifest, int adaptationSetIndex,
    int[] representationIndices, DataSource dataSource, FormatEvaluator formatEvaluator,
    long liveEdgeLatencyUs) {
  this.manifestFetcher = manifestFetcher;
  this.currentManifest = initialManifest;
  this.adaptationSetIndex = adaptationSetIndex;
  this.representationIndices = representationIndices;
  this.dataSource = dataSource;
  this.evaluator = formatEvaluator;
  this.liveEdgeLatencyUs = liveEdgeLatencyUs;
  this.evaluation = new Evaluation();
  this.headerBuilder = new StringBuilder();

  psshInfo = getPsshInfo(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<String, RepresentationHolder>();
  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], extractor));
  }
  this.maxWidth = maxWidth;
  this.maxHeight = maxHeight;
  Arrays.sort(formats, new DecreasingBandwidthComparator());
}
 
Example #9
Source File: SmoothStreamingRendererBuilder.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
@Override
public void buildRenderers(DemoPlayer player, RendererBuilderCallback callback) {
  this.player = player;
  this.callback = callback;
  SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser();
  manifestFetcher = new ManifestFetcher<SmoothStreamingManifest>(parser, contentId,
      url + "/Manifest", userAgent);
  manifestFetcher.singleLoad(player.getMainHandler().getLooper(), this);
}
 
Example #10
Source File: HlsRendererBuilder.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
@Override
public void buildRenderers(DemoPlayer player, RendererBuilderCallback callback) {
  this.player = player;
  this.callback = callback;
  HlsPlaylistParser parser = new HlsPlaylistParser();
  ManifestFetcher<HlsPlaylist> playlistFetcher =
      new ManifestFetcher<HlsPlaylist>(parser, contentId, url, userAgent);
  playlistFetcher.singleLoad(player.getMainHandler().getLooper(), this);
}
 
Example #11
Source File: DashRendererBuilder.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
@Override
public void buildRenderers(DemoPlayer player, RendererBuilderCallback callback) {
  this.player = player;
  this.callback = callback;
  MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser();
  manifestFetcher = new ManifestFetcher<MediaPresentationDescription>(parser, contentId, url,
      userAgent);
  manifestFetcher.singleLoad(player.getMainHandler().getLooper(), this);
}
 
Example #12
Source File: HlsRendererBuilder.java    From iview-android-tv with MIT License 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
                            AudioCapabilities audioCapabilities, VideoPlayer player) {
    this.context = context;
    this.userAgent = userAgent;
    this.url = url;
    this.audioCapabilities = audioCapabilities;
    this.player = player;
    HlsPlaylistParser parser = new HlsPlaylistParser();
    playlistFetcher = new ManifestFetcher<>(url, new DefaultUriDataSource(context, userAgent),
            parser);
}
 
Example #13
Source File: DashRendererBuilder.java    From AndroidTvDemo with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
    MediaDrmCallback drmCallback, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.drmCallback = drmCallback;
  this.player = player;
  MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser();
  manifestDataSource = new DefaultUriDataSource(context, userAgent);
  manifestFetcher = new ManifestFetcher<>(url, manifestDataSource, parser);
}
 
Example #14
Source File: HlsRendererBuilder.java    From Android-Example-HLS-ExoPlayer with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.url = url;
  this.player = player;
  HlsPlaylistParser parser = new HlsPlaylistParser();
  playlistFetcher = new ManifestFetcher<>(url, new DefaultUriDataSource(context, userAgent),
      parser);
}
 
Example #15
Source File: SmoothStreamingRendererBuilder.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
    MediaDrmCallback drmCallback, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.drmCallback = drmCallback;
  this.player = player;
  SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser();
  manifestFetcher = new ManifestFetcher<>(url, new DefaultHttpDataSource(userAgent, null),
      parser);
}
 
Example #16
Source File: HlsRendererBuilder.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.url = url;
  this.player = player;
  HlsPlaylistParser parser = new HlsPlaylistParser();
  playlistFetcher = new ManifestFetcher<>(url, new DefaultUriDataSource(context, userAgent),
      parser);
}
 
Example #17
Source File: DashRendererBuilder.java    From WliveTV with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
    MediaDrmCallback drmCallback, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.drmCallback = drmCallback;
  this.player = player;
  MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser();
  manifestDataSource = new DefaultUriDataSource(context, userAgent);
  manifestFetcher = new ManifestFetcher<>(url, manifestDataSource, parser);
}
 
Example #18
Source File: DashRendererBuilder.java    From droidkaigi2016 with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
    this.player = player;
  MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser();
  manifestDataSource = new DefaultUriDataSource(context, userAgent);
  manifestFetcher = new ManifestFetcher<>(url, manifestDataSource, parser);
}
 
Example #19
Source File: SmoothStreamingRendererBuilder.java    From talk-android with MIT License 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
    MediaDrmCallback drmCallback, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.drmCallback = drmCallback;
  this.player = player;
  SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser();
  manifestFetcher = new ManifestFetcher<>(url, new DefaultHttpDataSource(userAgent, null),
      parser);
}
 
Example #20
Source File: HlsRendererBuilder.java    From talk-android with MIT License 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.url = url;
  this.player = player;
  HlsPlaylistParser parser = new HlsPlaylistParser();
  playlistFetcher = new ManifestFetcher<>(url, new DefaultUriDataSource(context, userAgent),
      parser);
}
 
Example #21
Source File: DashRendererBuilder.java    From talk-android with MIT License 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
    MediaDrmCallback drmCallback, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.drmCallback = drmCallback;
  this.player = player;
  MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser();
  manifestDataSource = new DefaultUriDataSource(context, userAgent);
  manifestFetcher = new ManifestFetcher<>(url, manifestDataSource, parser);
}
 
Example #22
Source File: HlsRendererBuilder.java    From ExVidPlayer with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url, ExVidPlayerImp player) {
  this.context = context;
  this.userAgent = userAgent;
  this.url = url;
  this.player = player;
  HlsPlaylistParser parser = new HlsPlaylistParser();
  playlistFetcher = new ManifestFetcher<>(url, new DefaultUriDataSource(context, userAgent),
      parser);
}
 
Example #23
Source File: SmoothStreamingRendererBuilder.java    From ShareBox with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
    MediaDrmCallback drmCallback, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.drmCallback = drmCallback;
  this.player = player;
  SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser();
  manifestFetcher = new ManifestFetcher<>(url, new DefaultHttpDataSource(userAgent, null),
      parser);
}
 
Example #24
Source File: HlsRendererBuilder.java    From ShareBox with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.player = player;
  HlsPlaylistParser parser = new HlsPlaylistParser();
  playlistFetcher = new ManifestFetcher<>(url, new DefaultUriDataSource(context, userAgent),
      parser);
}
 
Example #25
Source File: DashRendererBuilder.java    From ShareBox with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
    MediaDrmCallback drmCallback, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.drmCallback = drmCallback;
  this.player = player;
  MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser();
  manifestDataSource = new DefaultUriDataSource(context, userAgent);
  manifestFetcher = new ManifestFetcher<>(url, manifestDataSource, parser);
}
 
Example #26
Source File: SmoothStreamingRendererBuilder.java    From AndroidTvDemo with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url,
    MediaDrmCallback drmCallback, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.drmCallback = drmCallback;
  this.player = player;
  SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser();
  manifestFetcher = new ManifestFetcher<>(url, new DefaultHttpDataSource(userAgent, null),
      parser);
}
 
Example #27
Source File: HlsRendererBuilder.java    From AndroidTvDemo with Apache License 2.0 5 votes vote down vote up
public AsyncRendererBuilder(Context context, String userAgent, String url, DemoPlayer player) {
  this.context = context;
  this.userAgent = userAgent;
  this.url = url;
  this.player = player;
  HlsPlaylistParser parser = new HlsPlaylistParser();
  playlistFetcher = new ManifestFetcher<>(url, new DefaultUriDataSource(context, userAgent),
      parser);
}
 
Example #28
Source File: SmoothStreamingChunkSource.java    From Exoplayer_VLC with Apache License 2.0 4 votes vote down vote up
private SmoothStreamingChunkSource(ManifestFetcher<SmoothStreamingManifest> manifestFetcher,
    SmoothStreamingManifest initialManifest, int streamElementIndex, int[] trackIndices,
    DataSource dataSource, FormatEvaluator formatEvaluator, long liveEdgeLatencyMs) {
  this.manifestFetcher = manifestFetcher;
  this.streamElementIndex = streamElementIndex;
  this.currentManifest = initialManifest;
  this.dataSource = dataSource;
  this.formatEvaluator = formatEvaluator;
  this.liveEdgeLatencyUs = liveEdgeLatencyMs * 1000;

  StreamElement streamElement = getElement(initialManifest);
  trackInfo = new TrackInfo(streamElement.tracks[0].mimeType, initialManifest.durationUs);
  evaluation = new Evaluation();

  TrackEncryptionBox[] trackEncryptionBoxes = null;
  ProtectionElement protectionElement = initialManifest.protectionElement;
  if (protectionElement != null) {
    byte[] keyId = getKeyId(protectionElement.data);
    trackEncryptionBoxes = new TrackEncryptionBox[1];
    trackEncryptionBoxes[0] = new TrackEncryptionBox(true, INITIALIZATION_VECTOR_SIZE, keyId);
    psshInfo = Collections.singletonMap(protectionElement.uuid, protectionElement.data);
  } else {
    psshInfo = null;
  }

  int trackCount = trackIndices != null ? trackIndices.length : streamElement.tracks.length;
  formats = new SmoothStreamingFormat[trackCount];
  extractors = new SparseArray<FragmentedMp4Extractor>();
  int maxWidth = 0;
  int maxHeight = 0;
  for (int i = 0; i < trackCount; i++) {
    int trackIndex = trackIndices != null ? trackIndices[i] : i;
    TrackElement trackElement = streamElement.tracks[trackIndex];
    formats[i] = new SmoothStreamingFormat(String.valueOf(trackIndex), trackElement.mimeType,
        trackElement.maxWidth, trackElement.maxHeight, trackElement.numChannels,
        trackElement.sampleRate, trackElement.bitrate, trackIndex);
    maxWidth = Math.max(maxWidth, trackElement.maxWidth);
    maxHeight = Math.max(maxHeight, trackElement.maxHeight);

    MediaFormat mediaFormat = getMediaFormat(streamElement, trackIndex);
    int trackType = streamElement.type == StreamElement.TYPE_VIDEO ? Track.TYPE_VIDEO
        : Track.TYPE_AUDIO;
    FragmentedMp4Extractor extractor = new FragmentedMp4Extractor(
        FragmentedMp4Extractor.WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME);
    extractor.setTrack(new Track(trackIndex, trackType, streamElement.timescale,
        initialManifest.durationUs, mediaFormat, trackEncryptionBoxes));
    extractors.put(trackIndex, extractor);
  }
  this.maxHeight = maxHeight;
  this.maxWidth = maxWidth;
  Arrays.sort(formats, new DecreasingBandwidthComparator());
}
 
Example #29
Source File: DashChunkSource.java    From Exoplayer_VLC with Apache License 2.0 3 votes vote down vote up
/**
 * Constructor to use for live streaming.
 * <p>
 * May also be used for fixed duration content, in which case the call is equivalent to calling
 * the other constructor, passing {@code manifestFetcher.getManifest()} is the first argument.
 *
 * @param manifestFetcher A fetcher for the manifest, which must have already successfully
 *     completed an initial load.
 * @param adaptationSetIndex The index of the adaptation set that should be used.
 * @param representationIndices The indices of the representations within the adaptations set
 *     that should be used. May be null if all representations within the adaptation set should
 *     be considered.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param formatEvaluator Selects from the available formats.
 * @param liveEdgeLatencyMs For live streams, the number of milliseconds that the playback should
 *     lag behind the "live edge" (i.e. the end of the most recently defined media in the
 *     manifest). Choosing a small value will minimize latency introduced by the player, however
 *     note that the value sets an upper bound on the length of media that the player can buffer.
 *     Hence a small value may increase the probability of rebuffering and playback failures.
 */
public DashChunkSource(ManifestFetcher<MediaPresentationDescription> manifestFetcher,
    int adaptationSetIndex, int[] representationIndices, DataSource dataSource,
    FormatEvaluator formatEvaluator, long liveEdgeLatencyMs) {
  this(manifestFetcher, manifestFetcher.getManifest(), adaptationSetIndex, representationIndices,
      dataSource, formatEvaluator, liveEdgeLatencyMs * 1000);
}
 
Example #30
Source File: SmoothStreamingChunkSource.java    From Exoplayer_VLC with Apache License 2.0 3 votes vote down vote up
/**
 * Constructor to use for live streaming.
 * <p>
 * May also be used for fixed duration content, in which case the call is equivalent to calling
 * the other constructor, passing {@code manifestFetcher.getManifest()} is the first argument.
 *
 * @param manifestFetcher A fetcher for the manifest, which must have already successfully
 *     completed an initial load.
 * @param streamElementIndex The index of the stream element in the manifest to be provided by
 *     the source.
 * @param trackIndices The indices of the tracks within the stream element to be considered by
 *     the source. May be null if all tracks within the element should be considered.
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param formatEvaluator Selects from the available formats.
 * @param liveEdgeLatencyMs For live streams, the number of milliseconds that the playback should
 *     lag behind the "live edge" (i.e. the end of the most recently defined media in the
 *     manifest). Choosing a small value will minimize latency introduced by the player, however
 *     note that the value sets an upper bound on the length of media that the player can buffer.
 *     Hence a small value may increase the probability of rebuffering and playback failures.
 */
public SmoothStreamingChunkSource(ManifestFetcher<SmoothStreamingManifest> manifestFetcher,
    int streamElementIndex, int[] trackIndices, DataSource dataSource,
    FormatEvaluator formatEvaluator, long liveEdgeLatencyMs) {
  this(manifestFetcher, manifestFetcher.getManifest(), streamElementIndex, trackIndices,
      dataSource, formatEvaluator, liveEdgeLatencyMs);
}