public interface TrackSelection
TrackGroup
, and a possibly varying individual selected track from the subset.
Tracks belonging to the subset are exposed in decreasing bandwidth order. The individual selected
track may change as a result of calling updateSelectedTrack(long)
.
Modifier and Type | Interface and Description |
---|---|
static interface |
TrackSelection.Factory
Factory for
TrackSelection instances. |
Modifier and Type | Method and Description |
---|---|
boolean |
blacklist(int index,
long blacklistDurationMs)
Attempts to blacklist the track at the specified index in the selection, making it ineligible
for selection by calls to
updateSelectedTrack(long) for the specified period of time. |
int |
evaluateQueueSize(long playbackPositionUs,
List<? extends MediaChunk> queue)
May be called periodically by sources that load media in discrete
MediaChunk s and
support discarding of buffered chunks in order to re-buffer using a different selected track. |
Format |
getFormat(int index)
Returns the format of the track at a given index in the selection.
|
int |
getIndexInTrackGroup(int index)
Returns the index in the track group of the track at a given index in the selection.
|
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.
|
TrackGroup |
getTrackGroup()
Returns the
TrackGroup to which the selected tracks belong. |
int |
indexOf(Format format)
Returns the index in the selection of the track with the specified format.
|
int |
indexOf(int indexInTrackGroup)
Returns the index in the selection of the track with the specified index in the track group.
|
int |
length()
Returns the number of tracks in the selection.
|
void |
updateSelectedTrack(long bufferedDurationUs)
Updates the selected track.
|
TrackGroup getTrackGroup()
TrackGroup
to which the selected tracks belong.int length()
Format getFormat(int index)
index
- The index in the selection.int getIndexInTrackGroup(int index)
index
- The index in the selection.int indexOf(Format format)
format
- The format.C.INDEX_UNSET
if the track with the specified
format is not part of the selection.int indexOf(int indexInTrackGroup)
indexInTrackGroup
- The index in the track group.C.INDEX_UNSET
if the track with the specified
index is not part of the selection.int getSelectedIndexInTrackGroup()
int getSelectedIndex()
int getSelectionReason()
Object getSelectionData()
void updateSelectedTrack(long bufferedDurationUs)
bufferedDurationUs
- The duration of media currently buffered in microseconds.int evaluateQueueSize(long playbackPositionUs, List<? extends MediaChunk> queue)
MediaChunk
s and
support discarding of buffered chunks in order to re-buffer using a different selected track.
Returns the number of chunks that should be retained in the queue.
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.
playbackPositionUs
- The current playback position in microseconds.queue
- The queue of buffered MediaChunk
s. Must not be modified.boolean blacklist(int index, long blacklistDurationMs)
updateSelectedTrack(long)
for the specified period of time.
Blacklisting will fail if all other tracks are currently blacklisted. If blacklisting the
currently selected track, note that it will remain selected until the next call to
updateSelectedTrack(long)
.index
- The index of the track in the selection.blacklistDurationMs
- The duration of time for which the track should be blacklisted, in
milliseconds.