public abstract class BaseTrackSelection extends java.lang.Object implements TrackSelection
TrackSelection
implementations.TrackSelection.Factory
Modifier and Type | Field and Description |
---|---|
protected TrackGroup |
group
The selected
TrackGroup . |
protected int |
length
The number of selected tracks within the
TrackGroup . |
protected int[] |
tracks
The indices of the selected tracks in
group , in order of decreasing bandwidth. |
Constructor and Description |
---|
BaseTrackSelection(TrackGroup group,
int... tracks) |
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
TrackSelection.updateSelectedTrack(long) for the specified period of time. |
boolean |
equals(java.lang.Object obj) |
int |
evaluateQueueSize(long playbackPositionUs,
java.util.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 |
getSelectedIndexInTrackGroup()
Returns the index in the track group of the individual selected track.
|
TrackGroup |
getTrackGroup()
Returns the
TrackGroup to which the selected tracks belong. |
int |
hashCode() |
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.
|
protected boolean |
isBlacklisted(int index,
long nowMs)
Returns whether the track at the specified index in the selection is blaclisted.
|
int |
length()
Returns the number of tracks in the selection.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getSelectedIndex, getSelectionData, getSelectionReason, updateSelectedTrack
protected final TrackGroup group
TrackGroup
.protected final int length
TrackGroup
. Always greater than zero.protected final int[] tracks
group
, in order of decreasing bandwidth.public BaseTrackSelection(TrackGroup group, int... tracks)
group
- The TrackGroup
. Must not be null.tracks
- The indices of the selected tracks within the TrackGroup
. Must not be
null or empty. May be in any order.public final TrackGroup getTrackGroup()
TrackSelection
TrackGroup
to which the selected tracks belong.getTrackGroup
in interface TrackSelection
public final int length()
TrackSelection
length
in interface TrackSelection
public final Format getFormat(int index)
TrackSelection
getFormat
in interface TrackSelection
index
- The index in the selection.public final int getIndexInTrackGroup(int index)
TrackSelection
getIndexInTrackGroup
in interface TrackSelection
index
- The index in the selection.public final int indexOf(Format format)
TrackSelection
indexOf
in interface TrackSelection
format
- The format.C.INDEX_UNSET
if the track with the specified
format is not part of the selection.public final int indexOf(int indexInTrackGroup)
TrackSelection
indexOf
in interface TrackSelection
indexInTrackGroup
- The index in the track group.C.INDEX_UNSET
if the track with the specified
index is not part of the selection.public final Format getSelectedFormat()
TrackSelection
Format
of the individual selected track.getSelectedFormat
in interface TrackSelection
public final int getSelectedIndexInTrackGroup()
TrackSelection
getSelectedIndexInTrackGroup
in interface TrackSelection
public int evaluateQueueSize(long playbackPositionUs, java.util.List<? extends MediaChunk> queue)
TrackSelection
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.
evaluateQueueSize
in interface TrackSelection
playbackPositionUs
- The current playback position in microseconds.queue
- The queue of buffered MediaChunk
s. Must not be modified.public final boolean blacklist(int index, long blacklistDurationMs)
TrackSelection
TrackSelection.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
TrackSelection.updateSelectedTrack(long)
.blacklist
in interface TrackSelection
index
- The index of the track in the selection.blacklistDurationMs
- The duration of time for which the track should be blacklisted, in
milliseconds.protected final boolean isBlacklisted(int index, long nowMs)
index
- The index of the track in the selection.nowMs
- The current time in the timebase of SystemClock.elapsedRealtime()
.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object