@Override public void continueBuffering(long playbackPositionUs) { if (manifestFetcher == null || !currentManifest.dynamic || fatalError != null) { return; } MediaPresentationDescription newManifest = manifestFetcher.getManifest(); if (newManifest != null && newManifest != processedManifest) { processManifest(newManifest); // Manifests may be rejected, so the new manifest may not become the next currentManifest. // Track a manifest has been processed to avoid processing twice when it was discarded. processedManifest = newManifest; } // TODO: This is a temporary hack to avoid constantly refreshing the MPD in cases where // minUpdatePeriod is set to 0. In such cases we shouldn't refresh unless there is explicit // signaling in the stream, according to: // http://azure.microsoft.com/blog/2014/09/13/dash-live-streaming-with-azure-media-service/ long minUpdatePeriod = currentManifest.minUpdatePeriod; if (minUpdatePeriod == 0) { minUpdatePeriod = 5000; } if (android.os.SystemClock.elapsedRealtime() > manifestFetcher.getManifestLoadStartTimestamp() + minUpdatePeriod) { manifestFetcher.requestRefresh(); } }
public DefaultBandwidthMeter(Handler eventHandler, EventListener eventListener) { this(eventHandler, eventListener, new SystemClock()); }
public DefaultBandwidthMeter(Handler eventHandler, EventListener eventListener, int maxWeight) { this(eventHandler, eventListener, new SystemClock(), maxWeight); }
public LimitedBandwidthMeter(Handler eventHandler, EventListener eventListener, int maxWeight) { this(eventHandler, eventListener, new SystemClock(), maxWeight); }
/** * 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. * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between * server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified * as the server's unix time minus the local elapsed time. It unknown, set to 0. * @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 DashChunkSource(ManifestFetcher<MediaPresentationDescription> manifestFetcher, int adaptationSetIndex, int[] representationIndices, DataSource dataSource, FormatEvaluator formatEvaluator, long liveEdgeLatencyMs, long elapsedRealtimeOffsetMs, Handler eventHandler, EventListener eventListener) { this(manifestFetcher, manifestFetcher.getManifest(), adaptationSetIndex, representationIndices, dataSource, formatEvaluator, new SystemClock(), liveEdgeLatencyMs * 1000, elapsedRealtimeOffsetMs * 1000, true, eventHandler, eventListener); }
/** * Constructor to use for live DVR streaming. * * @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. * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between * server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified * as the server's unix time minus the local elapsed time. It unknown, set to 0. * @param startAtLiveEdge True if the stream should start at the live edge; false if it should * at the beginning of the live window. * @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 DashChunkSource(ManifestFetcher<MediaPresentationDescription> manifestFetcher, int adaptationSetIndex, int[] representationIndices, DataSource dataSource, FormatEvaluator formatEvaluator, long liveEdgeLatencyMs, long elapsedRealtimeOffsetMs, boolean startAtLiveEdge, Handler eventHandler, EventListener eventListener) { this(manifestFetcher, manifestFetcher.getManifest(), adaptationSetIndex, representationIndices, dataSource, formatEvaluator, new SystemClock(), liveEdgeLatencyMs * 1000, elapsedRealtimeOffsetMs * 1000, startAtLiveEdge, eventHandler, eventListener); }
/** * 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 trackSelector Selects tracks from manifest periods to be exposed by this source. * @param dataSource A {@link DataSource} suitable for loading the media data. * @param adaptiveFormatEvaluator For adaptive tracks, 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. * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between * server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified * as the server's unix time minus the local elapsed time. It unknown, set to 0. * @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. * @param eventSourceId An identifier that gets passed to {@code eventListener} methods. */ public DashChunkSource(ManifestFetcher<MediaPresentationDescription> manifestFetcher, DashTrackSelector trackSelector, DataSource dataSource, FormatEvaluator adaptiveFormatEvaluator, long liveEdgeLatencyMs, long elapsedRealtimeOffsetMs, Handler eventHandler, EventListener eventListener, int eventSourceId) { this(manifestFetcher, manifestFetcher.getManifest(), trackSelector, dataSource, adaptiveFormatEvaluator, new SystemClock(), liveEdgeLatencyMs * 1000, elapsedRealtimeOffsetMs * 1000, true, eventHandler, eventListener, eventSourceId); }
/** * Constructor to use for live DVR streaming. * * @param manifestFetcher A fetcher for the manifest, which must have already successfully * completed an initial load. * @param trackSelector Selects tracks from manifest periods to be exposed by this source. * @param dataSource A {@link DataSource} suitable for loading the media data. * @param adaptiveFormatEvaluator For adaptive tracks, 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. * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between * server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified * as the server's unix time minus the local elapsed time. It unknown, set to 0. * @param startAtLiveEdge True if the stream should start at the live edge; false if it should * at the beginning of the live window. * @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. * @param eventSourceId An identifier that gets passed to {@code eventListener} methods. */ public DashChunkSource(ManifestFetcher<MediaPresentationDescription> manifestFetcher, DashTrackSelector trackSelector, DataSource dataSource, FormatEvaluator adaptiveFormatEvaluator, long liveEdgeLatencyMs, long elapsedRealtimeOffsetMs, boolean startAtLiveEdge, Handler eventHandler, EventListener eventListener, int eventSourceId) { this(manifestFetcher, manifestFetcher.getManifest(), trackSelector, dataSource, adaptiveFormatEvaluator, new SystemClock(), liveEdgeLatencyMs * 1000, elapsedRealtimeOffsetMs * 1000, startAtLiveEdge, eventHandler, eventListener, eventSourceId); }
/** * Constructor to use for fixed duration content. * * @param manifest The manifest. * @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. */ public DashChunkSource(MediaPresentationDescription manifest, int adaptationSetIndex, int[] representationIndices, DataSource dataSource, FormatEvaluator formatEvaluator) { this(null, manifest, adaptationSetIndex, representationIndices, dataSource, formatEvaluator, new SystemClock(), 0, 0, false, null, null); }
/** * Constructor to use for fixed duration content. * * @param manifest The manifest. * @param trackSelector Selects tracks from manifest periods to be exposed by this source. * @param dataSource A {@link DataSource} suitable for loading the media data. * @param adaptiveFormatEvaluator For adaptive tracks, selects from the available formats. */ public DashChunkSource(MediaPresentationDescription manifest, DashTrackSelector trackSelector, DataSource dataSource, FormatEvaluator adaptiveFormatEvaluator) { this(null, manifest, trackSelector, dataSource, adaptiveFormatEvaluator, new SystemClock(), 0, 0, false, null, null, 0); }