MediaSource
, Loader.Callback<ParsingLoadable<SsManifest>>
public final class SsMediaSource extends BaseMediaSource implements Loader.Callback<ParsingLoadable<SsManifest>>
MediaSource
.Modifier and Type | Class | Description |
---|---|---|
static class |
SsMediaSource.Factory |
Factory for
SsMediaSource . |
MediaSource.MediaPeriodId, MediaSource.MediaSourceCaller
Modifier and Type | Field | Description |
---|---|---|
static long |
DEFAULT_LIVE_PRESENTATION_DELAY_MS |
The default presentation delay for live streams.
|
Constructor | Description |
---|---|
SsMediaSource(Uri manifestUri,
DataSource.Factory manifestDataSourceFactory,
SsChunkSource.Factory chunkSourceFactory,
int minLoadableRetryCount,
long livePresentationDelayMs,
Handler eventHandler,
MediaSourceEventListener eventListener) |
Deprecated.
Use
SsMediaSource.Factory instead. |
SsMediaSource(Uri manifestUri,
DataSource.Factory manifestDataSourceFactory,
SsChunkSource.Factory chunkSourceFactory,
Handler eventHandler,
MediaSourceEventListener eventListener) |
Deprecated.
Use
SsMediaSource.Factory instead. |
SsMediaSource(Uri manifestUri,
DataSource.Factory manifestDataSourceFactory,
ParsingLoadable.Parser<? extends SsManifest> manifestParser,
SsChunkSource.Factory chunkSourceFactory,
int minLoadableRetryCount,
long livePresentationDelayMs,
Handler eventHandler,
MediaSourceEventListener eventListener) |
Deprecated.
Use
SsMediaSource.Factory instead. |
SsMediaSource(SsManifest manifest,
SsChunkSource.Factory chunkSourceFactory,
int minLoadableRetryCount,
Handler eventHandler,
MediaSourceEventListener eventListener) |
Deprecated.
Use
SsMediaSource.Factory instead. |
SsMediaSource(SsManifest manifest,
SsChunkSource.Factory chunkSourceFactory,
Handler eventHandler,
MediaSourceEventListener eventListener) |
Deprecated.
Use
SsMediaSource.Factory instead. |
Modifier and Type | Method | Description |
---|---|---|
MediaPeriod |
createPeriod(MediaSource.MediaPeriodId id,
Allocator allocator,
long startPositionUs) |
Returns a new
MediaPeriod identified by periodId . |
MediaItem |
getMediaItem() |
Returns the
MediaItem whose media is provided by the source. |
Object |
getTag() |
Deprecated.
Use
getMediaItem() and MediaItem.PlaybackProperties.tag instead. |
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.
|
Loader.LoadErrorAction |
onLoadError(ParsingLoadable<SsManifest> loadable,
long elapsedRealtimeMs,
long loadDurationMs,
IOException error,
int errorCount) |
Called when a load encounters an error.
|
protected void |
prepareSourceInternal(TransferListener mediaTransferListener) |
Starts source preparation and enables the source, see
BaseMediaSource.prepareSource(MediaSourceCaller,
TransferListener) . |
void |
releasePeriod(MediaPeriod period) |
Releases the period.
|
protected void |
releaseSourceInternal() |
Releases the source, see
BaseMediaSource.releaseSource(MediaSourceCaller) . |
addDrmEventListener, addEventListener, createDrmEventDispatcher, createDrmEventDispatcher, createEventDispatcher, createEventDispatcher, createEventDispatcher, disable, disableInternal, enable, enableInternal, isEnabled, prepareSource, refreshSourceInfo, releaseSource, removeDrmEventListener, removeEventListener
getInitialTimeline, isSingleWindow
public static final long DEFAULT_LIVE_PRESENTATION_DELAY_MS
@Deprecated public SsMediaSource(SsManifest manifest, SsChunkSource.Factory chunkSourceFactory, @Nullable Handler eventHandler, @Nullable MediaSourceEventListener eventListener)
SsMediaSource.Factory
instead.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.@Deprecated public SsMediaSource(SsManifest manifest, SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, @Nullable Handler eventHandler, @Nullable MediaSourceEventListener eventListener)
SsMediaSource.Factory
instead.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.@Deprecated public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory, SsChunkSource.Factory chunkSourceFactory, @Nullable Handler eventHandler, @Nullable MediaSourceEventListener eventListener)
SsMediaSource.Factory
instead.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.@Deprecated public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory, SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, long livePresentationDelayMs, @Nullable Handler eventHandler, @Nullable MediaSourceEventListener eventListener)
SsMediaSource.Factory
instead.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.@Deprecated public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory, ParsingLoadable.Parser<? extends SsManifest> manifestParser, SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, long livePresentationDelayMs, @Nullable Handler eventHandler, @Nullable MediaSourceEventListener eventListener)
SsMediaSource.Factory
instead.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.@Deprecated @Nullable public Object getTag()
getMediaItem()
and MediaItem.PlaybackProperties.tag
instead.getTag
in interface MediaSource
public MediaItem getMediaItem()
MediaSource
MediaItem
whose media is provided by the source.getMediaItem
in interface MediaSource
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener)
BaseMediaSource
BaseMediaSource.prepareSource(MediaSourceCaller,
TransferListener)
. This method is called at most once until the next call to BaseMediaSource.releaseSourceInternal()
.prepareSourceInternal
in class BaseMediaSource
mediaTransferListener
- The transfer listener which should be informed of any media data
transfers. May be null if no listener is available. Note that this listener should usually
be only informed of transfers related to the media loads and not of auxiliary loads for
manifests and other data.public void maybeThrowSourceInfoRefreshError() throws IOException
MediaSource
Should not be called directly from application code.
Must only be called after MediaSource.prepareSource(MediaSourceCaller, TransferListener)
.
maybeThrowSourceInfoRefreshError
in interface MediaSource
IOException
public MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator, long startPositionUs)
MediaSource
MediaPeriod
identified by periodId
.
Should not be called directly from application code.
Must only be called if the source is enabled.
createPeriod
in interface MediaSource
id
- The identifier of the period.allocator
- An Allocator
from which to obtain media buffer allocations.startPositionUs
- The expected start position, in microseconds.MediaPeriod
.public void releasePeriod(MediaPeriod period)
MediaSource
Should not be called directly from application code.
releasePeriod
in interface MediaSource
period
- The period to release.protected void releaseSourceInternal()
BaseMediaSource
BaseMediaSource.releaseSource(MediaSourceCaller)
. This method is called
exactly once after each call to BaseMediaSource.prepareSourceInternal(TransferListener)
.releaseSourceInternal
in class BaseMediaSource
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 in milliseconds of the load since Loader.startLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int)
was called.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 in milliseconds of the load since Loader.startLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int)
was called up to the point at which it was canceled.released
- True if the load was canceled because the Loader
was released. False
otherwise.public Loader.LoadErrorAction onLoadError(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount)
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 in milliseconds of the load since Loader.startLoading(T, com.google.android.exoplayer2.upstream.Loader.Callback<T>, int)
was called up to the point at which the error occurred.error
- The load error.errorCount
- The number of errors this load has encountered, including this one.Loader.RETRY
, Loader.RETRY_RESET_ERROR_COUNT
, Loader.DONT_RETRY
, Loader.DONT_RETRY_FATAL
or a retry action created by Loader.createRetryAction(boolean, long)
.