public static final class FormatEvaluator.AdaptiveEvaluator extends Object implements FormatEvaluator
This implementation should be used for video only, and should not be used for audio. It is a reference implementation only. It is recommended that application developers implement their own adaptive evaluator to more precisely suit their use case.
FormatEvaluator.AdaptiveEvaluator, FormatEvaluator.Evaluation, FormatEvaluator.FixedEvaluator, FormatEvaluator.RandomEvaluator
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 |
Constructor and Description |
---|
AdaptiveEvaluator(BandwidthMeter bandwidthMeter) |
AdaptiveEvaluator(BandwidthMeter bandwidthMeter,
int maxInitialBitrate,
int minDurationForQualityIncreaseMs,
int maxDurationForQualityDecreaseMs,
int minDurationToRetainAfterDiscardMs,
float bandwidthFraction) |
Modifier and Type | Method and Description |
---|---|
void |
disable()
Disables the evaluator.
|
void |
enable()
Enables the evaluator.
|
void |
evaluate(List<? extends MediaChunk> queue,
long playbackPositionUs,
Format[] formats,
FormatEvaluator.Evaluation evaluation)
Update the supplied evaluation.
|
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 AdaptiveEvaluator(BandwidthMeter bandwidthMeter)
bandwidthMeter
- Provides an estimate of the currently available bandwidth.public AdaptiveEvaluator(BandwidthMeter bandwidthMeter, int maxInitialBitrate, int minDurationForQualityIncreaseMs, int maxDurationForQualityDecreaseMs, int minDurationToRetainAfterDiscardMs, float bandwidthFraction)
bandwidthMeter
- Provides an estimate of the currently available bandwidth.maxInitialBitrate
- The maximum bitrate in bits per second that should be assumed
when bandwidthMeter cannot provide an estimate due to playback having only just started.minDurationForQualityIncreaseMs
- The minimum duration of buffered data required for
the evaluator to consider switching to a higher quality format.maxDurationForQualityDecreaseMs
- The maximum duration of buffered data required for
the evaluator to consider switching to a lower quality format.minDurationToRetainAfterDiscardMs
- When switching to a significantly higher quality
format, the evaluator may discard some of the media that it has already buffered at the
lower quality, so as to switch up to the higher quality faster. This is the minimum
duration of media that must be retained at the lower quality.bandwidthFraction
- The fraction of the available bandwidth that the evaluator should
consider available for use. Setting to a value less than 1 is recommended to account
for inaccuracies in the bandwidth estimator.public void enable()
FormatEvaluator
enable
in interface FormatEvaluator
public void disable()
FormatEvaluator
disable
in interface FormatEvaluator
public void evaluate(List<? extends MediaChunk> queue, long playbackPositionUs, Format[] formats, FormatEvaluator.Evaluation evaluation)
FormatEvaluator
When the method is invoked, evaluation
will contain the currently selected
format (null for the first evaluation), the most recent trigger (TRIGGER_INITIAL for the
first evaluation) and the current queue size. The implementation should update these
fields as necessary.
The trigger should be considered "sticky" for as long as a given representation is selected, and so should only be changed if the representation is also changed.
evaluate
in interface FormatEvaluator
queue
- A read only representation of the currently buffered MediaChunk
s.playbackPositionUs
- The current playback position.formats
- The formats from which to select, ordered by decreasing bandwidth.evaluation
- The evaluation.