TrackSelectionAdaptiveTrackSelection, BaseTrackSelection, FakeTrackSelection, FixedTrackSelection, RandomTrackSelectionpublic interface ExoTrackSelection extends TrackSelection
TrackSelection that can change the individually selected track as a result of calling
updateSelectedTrack(long, long, long, List, MediaChunkIterator[]) or evaluateQueueSize(long, List). This only happens between calls to enable() and disable().| Modifier and Type | Interface | Description |
|---|---|---|
static class |
ExoTrackSelection.Definition |
Contains of a subset of selected tracks belonging to a
TrackGroup. |
static interface |
ExoTrackSelection.Factory |
Factory for
ExoTrackSelection instances. |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
blacklist(int index,
long exclusionDurationMs) |
Attempts to exclude the track at the specified index in the selection, making it ineligible for
selection by calls to
updateSelectedTrack(long, long, long, List,
MediaChunkIterator[]) for the specified period of time. |
void |
disable() |
Disables this track selection.
|
void |
enable() |
Enables the track selection.
|
int |
evaluateQueueSize(long playbackPositionUs,
List<? extends MediaChunk> queue) |
Returns the number of chunks that should be retained in the queue.
|
Format |
getSelectedFormat() |
Returns the
Format of the individual selected track. |
int |
getSelectedIndex() |
Returns the index of the selected track.
|
int |
getSelectedIndexInTrackGroup() |
Returns the index in the track group of the individual selected track.
|
Object |
getSelectionData() |
Returns optional data associated with the current track selection.
|
int |
getSelectionReason() |
Returns the reason for the current track selection.
|
default void |
onDiscontinuity() |
Called to notify the selection of a position discontinuity.
|
void |
onPlaybackSpeed(float speed) |
Called to notify the selection of the current playback speed.
|
default void |
onPlayWhenReadyChanged(boolean playWhenReady) |
Called to notify when the playback is paused or resumed.
|
default void |
onRebuffer() |
Called to notify when a rebuffer occurred.
|
default boolean |
shouldCancelChunkLoad(long playbackPositionUs,
Chunk loadingChunk,
List<? extends MediaChunk> queue) |
Returns whether an ongoing load of a chunk should be canceled.
|
void |
updateSelectedTrack(long playbackPositionUs,
long bufferedDurationUs,
long availableDurationUs,
List<? extends MediaChunk> queue,
MediaChunkIterator[] mediaChunkIterators) |
Updates the selected track for sources that load media in discrete
MediaChunks. |
getFormat, getIndexInTrackGroup, getTrackGroup, indexOf, indexOf, lengthvoid enable()
updateSelectedTrack(long, long, long,
List, MediaChunkIterator[]), evaluateQueueSize(long, List) or shouldCancelChunkLoad(long, Chunk, List) will only happen after this call.
This method may not be called when the track selection is already enabled.
void disable()
updateSelectedTrack(long,
long, long, List, MediaChunkIterator[]), evaluateQueueSize(long, List) or shouldCancelChunkLoad(long, Chunk, List) will happen after this call.
This method may only be called when the track selection is already enabled.
int getSelectedIndexInTrackGroup()
int getSelectedIndex()
int getSelectionReason()
@Nullable Object getSelectionData()
void onPlaybackSpeed(float speed)
speed - The factor by which playback is sped up.default void onDiscontinuity()
This happens when the playback position jumps, e.g., as a result of a seek being performed.
default void onRebuffer()
A rebuffer is defined to be caused by buffer depletion rather than a user action. Hence this method is not called during initial buffering or when buffering as a result of a seek operation.
default void onPlayWhenReadyChanged(boolean playWhenReady)
playWhenReady - Whether playback will proceed when ready.void updateSelectedTrack(long playbackPositionUs,
long bufferedDurationUs,
long availableDurationUs,
List<? extends MediaChunk> queue,
MediaChunkIterator[] mediaChunkIterators)
MediaChunks.
This method will only be called when the selection is enabled.
playbackPositionUs - The current playback position in microseconds. If playback of the
period to which this track selection belongs has not yet started, the value will be the
starting position in the period minus the duration of any media in previous periods still
to be played.bufferedDurationUs - The duration of media currently buffered from the current playback
position, in microseconds. Note that the next load position can be calculated as
(playbackPositionUs + bufferedDurationUs).availableDurationUs - The duration of media available for buffering from the current
playback position, in microseconds, or C.TIME_UNSET if media can be buffered to the
end of the current period. Note that if not set to C.TIME_UNSET, the position up to
which media is available for buffering can be calculated as (playbackPositionUs +
availableDurationUs).queue - The queue of already buffered MediaChunks. Must not be modified.mediaChunkIterators - An array of MediaChunkIterators providing information about
the sequence of upcoming media chunks for each track in the selection. All iterators start
from the media chunk which will be loaded next if the respective track is selected. Note
that this information may not be available for all tracks, and so some iterators may be
empty.int evaluateQueueSize(long playbackPositionUs,
List<? extends MediaChunk> queue)
May be called by sources that load media in discrete MediaChunks and
support discarding of buffered chunks.
To avoid excessive re-buffering, implementations should normally return the size of the queue. An example of a case where a smaller value may be returned is if network conditions have improved dramatically, allowing chunks to be discarded and re-buffered in a track of significantly higher quality. Discarding chunks may allow faster switching to a higher quality track in this case.
Note that even if the source supports discarding of buffered chunks, the actual number of
discarded chunks is not guaranteed. The source will call updateSelectedTrack(long,
long, long, List, MediaChunkIterator[]) with the updated queue of chunks before loading a new
chunk to allow switching to another quality.
This method will only be called when the selection is enabled and none of the MediaChunks in the queue are currently loading.
playbackPositionUs - The current playback position in microseconds. If playback of the
period to which this track selection belongs has not yet started, the value will be the
starting position in the period minus the duration of any media in previous periods still
to be played.queue - The queue of buffered MediaChunks. Must not be modified.default boolean shouldCancelChunkLoad(long playbackPositionUs,
Chunk loadingChunk,
List<? extends MediaChunk> queue)
May be called by sources that load media in discrete MediaChunks and
support canceling the ongoing chunk load. The ongoing chunk load is either the last MediaChunk in the queue or another type of Chunk, for example, if the source loads
initialization or encryption data.
To avoid excessive re-buffering, implementations should normally return false. An
example where true might be returned is if a load of a high quality chunk gets stuck
and canceling this load in favor of a lower quality alternative may avoid a rebuffer.
The source will call evaluateQueueSize(long, List) after the cancelation finishes
to allow discarding of chunks, and updateSelectedTrack(long, long, long, List,
MediaChunkIterator[]) before loading a new chunk to allow switching to another quality.
This method will only be called when the selection is enabled.
playbackPositionUs - The current playback position in microseconds. If playback of the
period to which this track selection belongs has not yet started, the value will be the
starting position in the period minus the duration of any media in previous periods still
to be played.loadingChunk - The currently loading Chunk that will be canceled if this method
returns true.queue - The queue of buffered MediaChunks, including the
loadingChunk if it's a MediaChunk. Must not be modified.loadingChunk should be canceled.boolean blacklist(int index,
long exclusionDurationMs)
updateSelectedTrack(long, long, long, List,
MediaChunkIterator[]) for the specified period of time.
Exclusion will fail if all other tracks are currently excluded. If excluding the currently
selected track, note that it will remain selected until the next call to updateSelectedTrack(long, long, long, List, MediaChunkIterator[]).
This method will only be called when the selection is enabled.
index - The index of the track in the selection.exclusionDurationMs - The duration of time for which the track should be excluded, in
milliseconds.