T - The type of the id used to identify prepared child sources.MediaSourceAdsMediaSource, ClippingMediaSource, ConcatenatingMediaSource, ExtractorMediaSource, LoopingMediaSource, MaskingMediaSource, MergingMediaSourcepublic abstract class CompositeMediaSource<T> extends BaseMediaSource
MediaSource consisting of multiple child sources.MediaSource.MediaPeriodId, MediaSource.MediaSourceCaller| Modifier | Constructor | Description |
|---|---|---|
protected |
CompositeMediaSource() |
Creates composite media source without child sources.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
disableChildSource(T id) |
Disables a child source.
|
protected void |
disableInternal() |
Disables the source, see
BaseMediaSource.disable(MediaSourceCaller). |
protected void |
enableChildSource(T id) |
Enables a child source.
|
protected void |
enableInternal() |
Enables the source, see
BaseMediaSource.enable(MediaSourceCaller). |
protected MediaSource.MediaPeriodId |
getMediaPeriodIdForChildMediaPeriodId(T id,
MediaSource.MediaPeriodId mediaPeriodId) |
Returns the
MediaSource.MediaPeriodId in the composite source corresponding to the specified MediaSource.MediaPeriodId in a child source. |
protected long |
getMediaTimeForChildMediaTime(T id,
long mediaTimeMs) |
Returns the media time in the composite source corresponding to the specified media time in a
child source.
|
protected int |
getWindowIndexForChildWindowIndex(T id,
int windowIndex) |
Returns the window index in the composite source corresponding to the specified window index in
a child source.
|
void |
maybeThrowSourceInfoRefreshError() |
Throws any pending error encountered while loading or refreshing source information.
|
protected abstract void |
onChildSourceInfoRefreshed(T id,
MediaSource mediaSource,
Timeline timeline) |
Called when the source info of a child source has been refreshed.
|
protected void |
prepareChildSource(T id,
MediaSource mediaSource) |
Prepares a child source.
|
protected void |
prepareSourceInternal(TransferListener mediaTransferListener) |
Starts source preparation and enables the source, see
BaseMediaSource.prepareSource(MediaSourceCaller,
TransferListener). |
protected void |
releaseChildSource(T id) |
Releases a child source.
|
protected void |
releaseSourceInternal() |
Releases the source, see
BaseMediaSource.releaseSource(MediaSourceCaller). |
addDrmEventListener, addEventListener, createDrmEventDispatcher, createDrmEventDispatcher, createEventDispatcher, createEventDispatcher, createEventDispatcher, disable, enable, isEnabled, prepareSource, refreshSourceInfo, releaseSource, removeDrmEventListener, removeEventListenercreatePeriod, getInitialTimeline, getMediaItem, getTag, isSingleWindow, releasePeriodprotected CompositeMediaSource()
@CallSuper
protected void prepareSourceInternal(@Nullable
TransferListener mediaTransferListener)
BaseMediaSourceBaseMediaSource.prepareSource(MediaSourceCaller,
TransferListener). This method is called at most once until the next call to BaseMediaSource.releaseSourceInternal().prepareSourceInternal in class BaseMediaSourcemediaTransferListener - 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.@CallSuper
public void maybeThrowSourceInfoRefreshError()
throws IOException
MediaSourceShould not be called directly from application code.
Must only be called after MediaSource.prepareSource(MediaSourceCaller, TransferListener).
IOException@CallSuper protected void enableInternal()
BaseMediaSourceBaseMediaSource.enable(MediaSourceCaller).enableInternal in class BaseMediaSource@CallSuper protected void disableInternal()
BaseMediaSourceBaseMediaSource.disable(MediaSourceCaller).disableInternal in class BaseMediaSource@CallSuper protected void releaseSourceInternal()
BaseMediaSourceBaseMediaSource.releaseSource(MediaSourceCaller). This method is called
exactly once after each call to BaseMediaSource.prepareSourceInternal(TransferListener).releaseSourceInternal in class BaseMediaSourceprotected abstract void onChildSourceInfoRefreshed(T id, MediaSource mediaSource, Timeline timeline)
id - The unique id used to prepare the child source.mediaSource - The child source whose source info has been refreshed.timeline - The timeline of the child source.protected final void prepareChildSource(T id, MediaSource mediaSource)
onChildSourceInfoRefreshed(Object, MediaSource, Timeline) will be called when the
child source updates its timeline with the same id passed to this method.
Any child sources that aren't explicitly released with releaseChildSource(Object)
will be released in releaseSourceInternal().
id - A unique id to identify the child source preparation. Null is allowed as an id.mediaSource - The child MediaSource.protected final void enableChildSource(T id)
id - The unique id used to prepare the child source.protected final void disableChildSource(T id)
id - The unique id used to prepare the child source.protected final void releaseChildSource(T id)
id - The unique id used to prepare the child source.protected int getWindowIndexForChildWindowIndex(T id, int windowIndex)
id - The unique id used to prepare the child source.windowIndex - A window index of the child source.@Nullable protected MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(T id, MediaSource.MediaPeriodId mediaPeriodId)
MediaSource.MediaPeriodId in the composite source corresponding to the specified MediaSource.MediaPeriodId in a child source. The default implementation does not change the media period
id.id - The unique id used to prepare the child source.mediaPeriodId - A MediaSource.MediaPeriodId of the child source.MediaSource.MediaPeriodId in the composite source. Null if no
corresponding media period id can be determined.protected long getMediaTimeForChildMediaTime(T id, long mediaTimeMs)
id - The unique id used to prepare the child source.mediaTimeMs - A media time of the child source, in milliseconds.