public class AdaptiveVideoTrackSelection extends BaseTrackSelection
TrackSelection
for video, whose selected track is updated to
be the one of highest quality given the current network conditions and the state of the buffer.Modifier and Type | Class and Description |
---|---|
static class |
AdaptiveVideoTrackSelection.Factory
Factory for
AdaptiveVideoTrackSelection instances. |
Modifier and Type | Field and Description |
---|---|
static float |
DEFAULT_BANDWIDTH_FRACTION |
static int |
DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS |
static int |
DEFAULT_MAX_INITIAL_BITRATE |
static int |
DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS |
static int |
DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MS |
group, length, tracks
Constructor and Description |
---|
AdaptiveVideoTrackSelection(TrackGroup group,
int[] tracks,
BandwidthMeter bandwidthMeter) |
AdaptiveVideoTrackSelection(TrackGroup group,
int[] tracks,
BandwidthMeter bandwidthMeter,
int maxInitialBitrate,
long minDurationForQualityIncreaseMs,
long maxDurationForQualityDecreaseMs,
long minDurationToRetainAfterDiscardMs,
float bandwidthFraction) |
Modifier and Type | Method and Description |
---|---|
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. |
int |
getSelectedIndex()
Returns the index of the selected track.
|
Object |
getSelectionData()
Returns optional data associated with the current track selection.
|
int |
getSelectionReason()
Returns the reason for the current track selection.
|
void |
updateSelectedTrack(long bufferedDurationUs)
Updates the selected track.
|
blacklist, equals, getFormat, getIndexInTrackGroup, getSelectedFormat, getSelectedIndexInTrackGroup, getTrackGroup, hashCode, indexOf, indexOf, isBlacklisted, length
public static final int DEFAULT_MAX_INITIAL_BITRATE
public static final int DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS
public static final int DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS
public static final int DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MS
public static final float DEFAULT_BANDWIDTH_FRACTION
public AdaptiveVideoTrackSelection(TrackGroup group, int[] tracks, BandwidthMeter bandwidthMeter)
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.bandwidthMeter
- Provides an estimate of the currently available bandwidth.public AdaptiveVideoTrackSelection(TrackGroup group, int[] tracks, BandwidthMeter bandwidthMeter, int maxInitialBitrate, long minDurationForQualityIncreaseMs, long maxDurationForQualityDecreaseMs, long minDurationToRetainAfterDiscardMs, float bandwidthFraction)
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.bandwidthMeter
- Provides an estimate of the currently available bandwidth.maxInitialBitrate
- The maximum bitrate in bits per second that should be assumed when a
bandwidth estimate is unavailable.minDurationForQualityIncreaseMs
- The minimum duration of buffered data required for the
selected track to switch to one of higher quality.maxDurationForQualityDecreaseMs
- The maximum duration of buffered data required for the
selected track to switch to one of lower quality.minDurationToRetainAfterDiscardMs
- When switching to a track of significantly higher
quality, the selection may indicate that media already buffered at the lower quality can
be discarded to speed up the switch. This is the minimum duration of media that must be
retained at the lower quality.bandwidthFraction
- The fraction of the available bandwidth that the selection should
consider available for use. Setting to a value less than 1 is recommended to account
for inaccuracies in the bandwidth estimator.public void updateSelectedTrack(long bufferedDurationUs)
TrackSelection
bufferedDurationUs
- The duration of media currently buffered in microseconds.public int getSelectedIndex()
TrackSelection
public int getSelectionReason()
TrackSelection
public Object getSelectionData()
TrackSelection
public int evaluateQueueSize(long playbackPositionUs, 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
evaluateQueueSize
in class BaseTrackSelection
playbackPositionUs
- The current playback position in microseconds.queue
- The queue of buffered MediaChunk
s. Must not be modified.