Class AdaptiveTrackSelection
- java.lang.Object
-
- com.google.android.exoplayer2.trackselection.BaseTrackSelection
-
- com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection
-
- All Implemented Interfaces:
ExoTrackSelection,TrackSelection
@Deprecated public class AdaptiveTrackSelection extends BaseTrackSelection
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.A bandwidth based adaptiveExoTrackSelection, whose selected track is updated to be the one of highest quality given the current network conditions and the state of the buffer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAdaptiveTrackSelection.AdaptationCheckpointDeprecated.Checkpoint to determine allocated bandwidth.static classAdaptiveTrackSelection.FactoryDeprecated.Factory forAdaptiveTrackSelectioninstances.-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.trackselection.ExoTrackSelection
ExoTrackSelection.Definition
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.trackselection.TrackSelection
TrackSelection.Type
-
-
Field Summary
Fields Modifier and Type Field Description static floatDEFAULT_BANDWIDTH_FRACTIONDeprecated.static floatDEFAULT_BUFFERED_FRACTION_TO_LIVE_EDGE_FOR_QUALITY_INCREASEDeprecated.static intDEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MSDeprecated.static intDEFAULT_MAX_HEIGHT_TO_DISCARDDeprecated.static intDEFAULT_MAX_WIDTH_TO_DISCARDDeprecated.static intDEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MSDeprecated.static intDEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MSDeprecated.-
Fields inherited from class com.google.android.exoplayer2.trackselection.BaseTrackSelection
group, length, tracks
-
Fields inherited from interface com.google.android.exoplayer2.trackselection.TrackSelection
TYPE_CUSTOM_BASE, TYPE_UNSET
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAdaptiveTrackSelection(TrackGroup group, int[] tracks, @com.google.android.exoplayer2.trackselection.TrackSelection.Type int type, BandwidthMeter bandwidthMeter, long minDurationForQualityIncreaseMs, long maxDurationForQualityDecreaseMs, long minDurationToRetainAfterDiscardMs, int maxWidthToDiscard, int maxHeightToDiscard, float bandwidthFraction, float bufferedFractionToLiveEdgeForQualityIncrease, List<AdaptiveTrackSelection.AdaptationCheckpoint> adaptationCheckpoints, Clock clock)Deprecated.AdaptiveTrackSelection(TrackGroup group, int[] tracks, BandwidthMeter bandwidthMeter)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected booleancanSelectFormat(Format format, int trackBitrate, long effectiveBitrate)Deprecated.Called when updating the selected track to determine whether a candidate track can be selected.voiddisable()Deprecated.Disables this track selection.voidenable()Deprecated.Enables the track selection.intevaluateQueueSize(long playbackPositionUs, List<? extends MediaChunk> queue)Deprecated.Returns the number of chunks that should be retained in the queue.longgetLatestBitrateEstimate()Deprecated.Returns the most recent bitrate estimate utilised for track selection.protected longgetMinDurationToRetainAfterDiscardUs()Deprecated.Called fromevaluateQueueSize(long, List)to determine the minimum duration of buffer to retain after discarding chunks.intgetSelectedIndex()Deprecated.Returns the index of the selected track.ObjectgetSelectionData()Deprecated.Returns optional data associated with the current track selection.@com.google.android.exoplayer2.C.SelectionReason intgetSelectionReason()Deprecated.Returns the reason for the current track selection.voidonPlaybackSpeed(float playbackSpeed)Deprecated.Called to notify the selection of the current playback speed.protected booleanshouldEvaluateQueueSize(long nowMs, List<? extends MediaChunk> queue)Deprecated.Called fromevaluateQueueSize(long, List)to determine whether an evaluation should be performed.voidupdateSelectedTrack(long playbackPositionUs, long bufferedDurationUs, long availableDurationUs, List<? extends MediaChunk> queue, MediaChunkIterator[] mediaChunkIterators)Deprecated.Updates the selected track for sources that load media in discreteMediaChunks.-
Methods inherited from class com.google.android.exoplayer2.trackselection.BaseTrackSelection
equals, excludeTrack, getFormat, getIndexInTrackGroup, getSelectedFormat, getSelectedIndexInTrackGroup, getTrackGroup, getType, hashCode, indexOf, indexOf, isTrackExcluded, length
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.android.exoplayer2.trackselection.ExoTrackSelection
onDiscontinuity, onPlayWhenReadyChanged, onRebuffer, shouldCancelChunkLoad
-
-
-
-
Field Detail
-
DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS
public static final int DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS
public static final int DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MS
public static final int DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MS
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_MAX_WIDTH_TO_DISCARD
public static final int DEFAULT_MAX_WIDTH_TO_DISCARD
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_MAX_HEIGHT_TO_DISCARD
public static final int DEFAULT_MAX_HEIGHT_TO_DISCARD
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_BANDWIDTH_FRACTION
public static final float DEFAULT_BANDWIDTH_FRACTION
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_BUFFERED_FRACTION_TO_LIVE_EDGE_FOR_QUALITY_INCREASE
public static final float DEFAULT_BUFFERED_FRACTION_TO_LIVE_EDGE_FOR_QUALITY_INCREASE
Deprecated.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AdaptiveTrackSelection
public AdaptiveTrackSelection(TrackGroup group, int[] tracks, BandwidthMeter bandwidthMeter)
Deprecated.- Parameters:
group- TheTrackGroup.tracks- The indices of the selected tracks within theTrackGroup. Must not be empty. May be in any order.bandwidthMeter- Provides an estimate of the currently available bandwidth.
-
AdaptiveTrackSelection
protected AdaptiveTrackSelection(TrackGroup group, int[] tracks, @com.google.android.exoplayer2.trackselection.TrackSelection.Type int type, BandwidthMeter bandwidthMeter, long minDurationForQualityIncreaseMs, long maxDurationForQualityDecreaseMs, long minDurationToRetainAfterDiscardMs, int maxWidthToDiscard, int maxHeightToDiscard, float bandwidthFraction, float bufferedFractionToLiveEdgeForQualityIncrease, List<AdaptiveTrackSelection.AdaptationCheckpoint> adaptationCheckpoints, Clock clock)
Deprecated.- Parameters:
group- TheTrackGroup.tracks- The indices of the selected tracks within theTrackGroup. Must not be empty. May be in any order.type- The type that will be returned fromTrackSelection.getType().bandwidthMeter- Provides an estimate of the currently available bandwidth.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 video track of 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. It must be at leastminDurationForQualityIncreaseMs.maxWidthToDiscard- The maximum video width that the selector may discard from the buffer to speed up switching to a higher quality.maxHeightToDiscard- The maximum video height that the selector may discard from the buffer to speed up switching to a higher 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.bufferedFractionToLiveEdgeForQualityIncrease- For live streaming, the fraction of the duration from current playback position to the live edge that has to be buffered before the selected track can be switched to one of higher quality. This parameter is only applied when the playback position is closer to the live edge thanminDurationForQualityIncreaseMs, which would otherwise prevent switching to a higher quality from happening.adaptationCheckpoints- Thecheckpointsthat can be used to calculate available bandwidth for this selection.clock- TheClock.
-
-
Method Detail
-
enable
@CallSuper public void enable()
Deprecated.Description copied from interface:ExoTrackSelectionEnables the track selection. Dynamic changes viaExoTrackSelection.updateSelectedTrack(long, long, long, List, MediaChunkIterator[]),ExoTrackSelection.evaluateQueueSize(long, List)orExoTrackSelection.shouldCancelChunkLoad(long, Chunk, List)will only happen after this call.This method may not be called when the track selection is already enabled.
- Specified by:
enablein interfaceExoTrackSelection- Overrides:
enablein classBaseTrackSelection
-
disable
@CallSuper public void disable()
Deprecated.Description copied from interface:ExoTrackSelectionDisables this track selection. No further dynamic changes viaExoTrackSelection.updateSelectedTrack(long, long, long, List, MediaChunkIterator[]),ExoTrackSelection.evaluateQueueSize(long, List)orExoTrackSelection.shouldCancelChunkLoad(long, Chunk, List)will happen after this call.This method may only be called when the track selection is already enabled.
- Specified by:
disablein interfaceExoTrackSelection- Overrides:
disablein classBaseTrackSelection
-
onPlaybackSpeed
public void onPlaybackSpeed(float playbackSpeed)
Deprecated.Description copied from interface:ExoTrackSelectionCalled to notify the selection of the current playback speed. The playback speed may affect adaptive track selection.- Specified by:
onPlaybackSpeedin interfaceExoTrackSelection- Overrides:
onPlaybackSpeedin classBaseTrackSelection- Parameters:
playbackSpeed- The factor by which playback is sped up.
-
updateSelectedTrack
public void updateSelectedTrack(long playbackPositionUs, long bufferedDurationUs, long availableDurationUs, List<? extends MediaChunk> queue, MediaChunkIterator[] mediaChunkIterators)Deprecated.Description copied from interface:ExoTrackSelectionUpdates the selected track for sources that load media in discreteMediaChunks.This method will only be called when the selection is enabled.
- Parameters:
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, orC.TIME_UNSETif media can be buffered to the end of the current period. Note that if not set toC.TIME_UNSET, the position up to which media is available for buffering can be calculated as(playbackPositionUs + availableDurationUs).queue- The queue of already bufferedMediaChunks. Must not be modified.mediaChunkIterators- An array ofMediaChunkIterators 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.
-
getSelectedIndex
public int getSelectedIndex()
Deprecated.Description copied from interface:ExoTrackSelectionReturns the index of the selected track.
-
getSelectionReason
public @com.google.android.exoplayer2.C.SelectionReason int getSelectionReason()
Deprecated.Description copied from interface:ExoTrackSelectionReturns the reason for the current track selection.
-
getSelectionData
@Nullable public Object getSelectionData()
Deprecated.Description copied from interface:ExoTrackSelectionReturns optional data associated with the current track selection.
-
evaluateQueueSize
public int evaluateQueueSize(long playbackPositionUs, List<? extends MediaChunk> queue)Deprecated.Description copied from interface:ExoTrackSelectionReturns the number of chunks that should be retained in the queue.May be called by sources that load media in discrete
MediaChunksand 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
ExoTrackSelection.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
MediaChunksin the queue are currently loading.- Specified by:
evaluateQueueSizein interfaceExoTrackSelection- Overrides:
evaluateQueueSizein classBaseTrackSelection- Parameters:
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 bufferedMediaChunks. Must not be modified.- Returns:
- The number of chunks to retain in the queue.
-
getLatestBitrateEstimate
public long getLatestBitrateEstimate()
Deprecated.Description copied from interface:ExoTrackSelectionReturns the most recent bitrate estimate utilised for track selection.The default behavior is to return
Long.MIN_VALUE, indicating that the bitrate estimate was not computed for the track selection decision.
-
canSelectFormat
protected boolean canSelectFormat(Format format, int trackBitrate, long effectiveBitrate)
Deprecated.Called when updating the selected track to determine whether a candidate track can be selected.- Parameters:
format- TheFormatof the candidate track.trackBitrate- The estimated bitrate of the track. May differ fromFormat.bitrateif a more accurate estimate of the current track bitrate is available.effectiveBitrate- The bitrate available to this selection.- Returns:
- Whether this
Formatcan be selected.
-
shouldEvaluateQueueSize
protected boolean shouldEvaluateQueueSize(long nowMs, List<? extends MediaChunk> queue)Deprecated.Called fromevaluateQueueSize(long, List)to determine whether an evaluation should be performed.- Parameters:
nowMs- The current value ofClock.elapsedRealtime().queue- The queue of bufferedMediaChunks. Must not be modified.- Returns:
- Whether an evaluation should be performed.
-
getMinDurationToRetainAfterDiscardUs
protected long getMinDurationToRetainAfterDiscardUs()
Deprecated.Called fromevaluateQueueSize(long, List)to determine the minimum duration of buffer to retain after discarding chunks.- Returns:
- The minimum duration of buffer to retain after discarding chunks, in microseconds.
-
-