public final class SsMediaSource extends Object implements MediaSource, Loader.Callback<ParsingLoadable<SsManifest>>
MediaSource
.MediaSource.Listener, MediaSource.MediaPeriodId
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(SsManifest manifest,
SsChunkSource.Factory chunkSourceFactory,
Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener)
Constructs an instance to play a given
SsManifest , which must not be live. |
SsMediaSource(SsManifest manifest,
SsChunkSource.Factory chunkSourceFactory,
int minLoadableRetryCount,
Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener)
Constructs an instance to play a given
SsManifest , which must not be live. |
SsMediaSource(Uri manifestUri,
DataSource.Factory manifestDataSourceFactory,
ParsingLoadable.Parser<? extends SsManifest> manifestParser,
SsChunkSource.Factory chunkSourceFactory,
int minLoadableRetryCount,
long livePresentationDelayMs,
Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener)
Constructs an instance to play the manifest at a given
Uri , which may be live or
on-demand. |
SsMediaSource(Uri manifestUri,
DataSource.Factory manifestDataSourceFactory,
SsChunkSource.Factory chunkSourceFactory,
Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener)
Constructs an instance to play the manifest at a given
Uri , which may be live or
on-demand. |
SsMediaSource(Uri manifestUri,
DataSource.Factory manifestDataSourceFactory,
SsChunkSource.Factory chunkSourceFactory,
int minLoadableRetryCount,
long livePresentationDelayMs,
Handler eventHandler,
AdaptiveMediaSourceEventListener eventListener)
Constructs an instance to play the manifest at a given
Uri , which may be live or
on-demand. |
Modifier and Type | Method and Description |
---|---|
MediaPeriod |
createPeriod(MediaSource.MediaPeriodId id,
Allocator allocator)
Returns a new
MediaPeriod identified by periodId . |
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(ExoPlayer player,
boolean isTopLevelSource,
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(SsManifest manifest, SsChunkSource.Factory chunkSourceFactory, Handler eventHandler, AdaptiveMediaSourceEventListener eventListener)
SsManifest
, which must not be live.manifest
- The manifest. SsManifest.isLive
must be false.chunkSourceFactory
- A factory for SsChunkSource
instances.eventHandler
- A handler for events. May be null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.public SsMediaSource(SsManifest manifest, SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, Handler eventHandler, AdaptiveMediaSourceEventListener eventListener)
SsManifest
, which must not be live.manifest
- The manifest. SsManifest.isLive
must be false.chunkSourceFactory
- A factory for SsChunkSource
instances.minLoadableRetryCount
- The minimum number of times to retry if a loading error occurs.eventHandler
- A handler for events. May be null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory, SsChunkSource.Factory chunkSourceFactory, Handler eventHandler, AdaptiveMediaSourceEventListener eventListener)
Uri
, which may be live or
on-demand.manifestUri
- The manifest Uri
.manifestDataSourceFactory
- A factory for DataSource
instances that will be used
to load (and refresh) the manifest.chunkSourceFactory
- A factory for SsChunkSource
instances.eventHandler
- A handler for events. May be null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory, SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, long livePresentationDelayMs, Handler eventHandler, AdaptiveMediaSourceEventListener eventListener)
Uri
, which may be live or
on-demand.manifestUri
- The manifest Uri
.manifestDataSourceFactory
- A factory for DataSource
instances that will be used
to load (and refresh) the manifest.chunkSourceFactory
- A factory for SsChunkSource
instances.minLoadableRetryCount
- The minimum number of times to retry if a loading error occurs.livePresentationDelayMs
- For live playbacks, the duration in milliseconds by which the
default start position should precede the end of the live window.eventHandler
- A handler for events. May be null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory, ParsingLoadable.Parser<? extends SsManifest> manifestParser, SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, long livePresentationDelayMs, Handler eventHandler, AdaptiveMediaSourceEventListener eventListener)
Uri
, which may be live or
on-demand.manifestUri
- The manifest Uri
.manifestDataSourceFactory
- A factory for DataSource
instances that will be used
to load (and refresh) the manifest.manifestParser
- A parser for loaded manifest data.chunkSourceFactory
- A factory for SsChunkSource
instances.minLoadableRetryCount
- The minimum number of times to retry if a loading error occurs.livePresentationDelayMs
- For live playbacks, the duration in milliseconds by which the
default start position should precede the end of the live window.eventHandler
- A handler for events. May be null if delivery of events is not required.eventListener
- A listener of events. May be null if delivery of events is not required.public void prepareSource(ExoPlayer player, boolean isTopLevelSource, MediaSource.Listener listener)
MediaSource
prepareSource
in interface MediaSource
player
- The player for which this source is being prepared.isTopLevelSource
- Whether this source has been passed directly to
ExoPlayer.prepare(MediaSource)
or
ExoPlayer.prepare(MediaSource, boolean, boolean)
. If false
, this source is
being prepared by another source (e.g. ConcatenatingMediaSource
) for composition.listener
- The listener for source events.public void maybeThrowSourceInfoRefreshError() throws IOException
MediaSource
maybeThrowSourceInfoRefreshError
in interface MediaSource
IOException
public MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator)
MediaSource
MediaPeriod
identified by periodId
. This method may be called
multiple times with the same period identifier without an intervening call to
MediaSource.releasePeriod(MediaPeriod)
.createPeriod
in interface MediaSource
id
- The identifier of the period.allocator
- An Allocator
from which to obtain media buffer allocations.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
.