public final class SsMediaSource extends Object implements MediaSource, Loader.Callback<ParsingLoadable<SsManifest>>
MediaSource
.MediaSource.Listener
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_LIVE_PRESENTATION_DELAY_MS
The default presentation delay for live streams.
|
static int |
DEFAULT_MIN_LOADABLE_RETRY_COUNT
The default minimum number of times to retry loading data prior to failing.
|
Constructor and Description |
---|
SsMediaSource(Uri manifestUri,
DataSource.Factory manifestDataSourceFactory,
SsChunkSource.Factory chunkSourceFactory,
Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener) |
SsMediaSource(Uri manifestUri,
DataSource.Factory dataSourceFactory,
SsChunkSource.Factory chunkSourceFactory,
int minLoadableRetryCount,
long livePresentationDelayMs,
Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener) |
Modifier and Type | Method and Description |
---|---|
MediaPeriod |
createPeriod(int index,
Allocator allocator,
long positionUs)
Returns a
MediaPeriod corresponding to the period at the specified index. |
void |
maybeThrowSourceInfoRefreshError()
Throws any pending error encountered while loading or refreshing source information.
|
void |
onLoadCanceled(ParsingLoadable<SsManifest> loadable,
long elapsedRealtimeMs,
long loadDurationMs,
boolean released)
Called when a load has been canceled.
|
void |
onLoadCompleted(ParsingLoadable<SsManifest> loadable,
long elapsedRealtimeMs,
long loadDurationMs)
Called when a load has completed.
|
int |
onLoadError(ParsingLoadable<SsManifest> loadable,
long elapsedRealtimeMs,
long loadDurationMs,
IOException error)
Called when a load encounters an error.
|
void |
prepareSource(MediaSource.Listener listener)
Starts preparation of the source.
|
void |
releasePeriod(MediaPeriod period)
Releases the period.
|
void |
releaseSource()
Releases the source.
|
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT
public static final long DEFAULT_LIVE_PRESENTATION_DELAY_MS
public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory, SsChunkSource.Factory chunkSourceFactory, Handler eventHandler, AdaptiveMediaSourceEventListener eventListener)
public SsMediaSource(Uri manifestUri, DataSource.Factory dataSourceFactory, SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, long livePresentationDelayMs, Handler eventHandler, AdaptiveMediaSourceEventListener eventListener)
public void prepareSource(MediaSource.Listener listener)
MediaSource
prepareSource
in interface MediaSource
listener
- The listener for source events.public void maybeThrowSourceInfoRefreshError() throws IOException
MediaSource
maybeThrowSourceInfoRefreshError
in interface MediaSource
IOException
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs)
MediaSource
MediaPeriod
corresponding to the period at the specified index.createPeriod
in interface MediaSource
index
- The index of the period.allocator
- An Allocator
from which to obtain media buffer allocations.positionUs
- The player's current playback position.MediaPeriod
.public void releasePeriod(MediaPeriod period)
MediaSource
releasePeriod
in interface MediaSource
period
- The period to release.public void releaseSource()
MediaSource
This method should be called when the source is no longer required. It may be called in any state.
releaseSource
in interface MediaSource
public void onLoadCompleted(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs)
Loader.Callback
Note: There is guaranteed to be a memory barrier between Loader.Loadable.load()
exiting and
this callback being called.
onLoadCompleted
in interface Loader.Callback<ParsingLoadable<SsManifest>>
loadable
- The loadable whose load has completed.elapsedRealtimeMs
- SystemClock.elapsedRealtime()
when the load ended.loadDurationMs
- The duration of the load.public void onLoadCanceled(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, boolean released)
Loader.Callback
Note: If the Loader
has not been released then there is guaranteed to be a memory
barrier between Loader.Loadable.load()
exiting and this callback being called. If the
Loader
has been released then this callback may be called before
Loader.Loadable.load()
exits.
onLoadCanceled
in interface Loader.Callback<ParsingLoadable<SsManifest>>
loadable
- The loadable whose load has been canceled.elapsedRealtimeMs
- SystemClock.elapsedRealtime()
when the load was canceled.loadDurationMs
- The duration of the load up to the point at which it was canceled.released
- True if the load was canceled because the Loader
was released. False
otherwise.public int onLoadError(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error)
Loader.Callback
Note: There is guaranteed to be a memory barrier between Loader.Loadable.load()
exiting and
this callback being called.
onLoadError
in interface Loader.Callback<ParsingLoadable<SsManifest>>
loadable
- The loadable whose load has encountered an error.elapsedRealtimeMs
- SystemClock.elapsedRealtime()
when the error occurred.loadDurationMs
- The duration of the load up to the point at which the error occurred.error
- The load error.Loader.RETRY
,
Loader.RETRY_RESET_ERROR_COUNT
, Loader.DONT_RETRY
and
Loader.DONT_RETRY_FATAL
.