Class BufferConfiguration
- All Implemented Interfaces:
Parcelable
The primary parameter of the configuration is the buffer size in bytes
(see bufferSizeBytes
.
Beside the size, you can use this class to configure the parameters that are used to control the buffer state and when downloading data is permitted. The buffer internally maintains two states: "fill" and "drain". If the buffer is in "fill" state, it will permit downloading and adding data to the buffer until both "memory" and "time" are above their upper bounds. Once that happens, the buffer will switch to "drain" mode and no more downloads are permitted until either "time" or "memory" goes below their low values. Once "time" or "memory" are below their lower bounds, the buffer will switch to "fill" mode again.
The reason why the buffer is not constantly allowing downloads is that during the "drain" phase,
the operating system can decide to deactivate the devices network interfaces periodically and
safe battery.
You can use PlayerController.setBufferConfiguration(BufferConfiguration)
if you manually
start the playback (note this has to be called before you call
PlayerController.open(PlayerConfig)
. Alternatively you can use the Bundle key
SdkConsts.INTENT_BUFFER_CONFIGURATION
and pass a configuration
to PlayerController.open(Bundle)
.
- Since:
- 3.3.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
-
Field Summary
Modifier and TypeFieldDescriptionboolean
The behaviour for audio renderer when feeding decoder.long
Maximum duration of the back buffer.int
The internal buffer is divided into segment and this specifies the size of a single buffer segment.int
The buffer size in bytesstatic final Parcelable.Creator
<BufferConfiguration> static final boolean
The default behaviour for audio renderer when feeding decoder.static final long
The default minimum back buffer length.static final int
The default buffer segment size.static final int
The default buffer size in bytes.static final boolean
The default behaviour when charging.static final long
The default value forhighMediaTimeMs
.static final long
The default value forlowMediaTimeMs
.static final int
The default minimum playback start buffer.static final int
The default minimum rebuffer start buffer.static final boolean
The default value indicating whether the buffered duration is evaluated based on playlist (manifest) tags like duration or based on audio and video data segments durationsstatic final boolean
The default value indicating whether the buffer time constraints are prioritized over buffer size constraintsstatic final boolean
The default behaviour for video renderer when feeding decoder.boolean
Flag indicating whether the buffer should be drained (untilminPlaybackStartMs
is reached) or not.long
Time in milliseconds that will be used by the buffer controls to determine if the buffer can be drained.long
Time in milliseconds that will be used by the buffer controls to determine if the buffer needs to be filled.long
The minimum duration of data that must be buffered for playback to start or resume following a user action such as a seek.long
The minimum duration of data that must be buffered for playback to resume after a player invoked rebuffer (i.e.boolean
Flag indicating whether the buffered duration is evaluated based on playlist (manifest) tags like duration or based on audio/video data segments durations.boolean
Flag indicating whether the buffer time constraints are prioritized over buffer size constraintslowMediaTimeMs
andhighMediaTimeMs
.boolean
The behaviour for video renderer when feeding decoder.Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
Constructor Summary
ConstructorDescriptionCreate a new buffer configuration using the default valuesBufferConfiguration
(int bufferSizeBytes, long lowMediaTimeMs, long highMediaTimeMs) Create a new buffer configuration -
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(BufferConfiguration source) Copies the values from the given buffer configuration to this configurationint
boolean
int
hashCode()
toString()
void
writeToParcel
(Parcel dest, int flags)
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEThe default buffer size in bytes. The default is 16 MB.- See Also:
-
DEFAULT_LOW_MEDIA_TIME
public static final long DEFAULT_LOW_MEDIA_TIMEThe default value forlowMediaTimeMs
. The default is 15 seconds.- See Also:
-
DEFAULT_HIGH_MEDIA_TIME
public static final long DEFAULT_HIGH_MEDIA_TIMEThe default value forhighMediaTimeMs
. The default is 60 seconds.- See Also:
-
DEFAULT_BUFFER_SEGMENT_SIZE
public static final int DEFAULT_BUFFER_SEGMENT_SIZEThe default buffer segment size. The default is 64 KB- See Also:
-
DEFAULT_MIN_PLAYBACK_START_MS
public static final int DEFAULT_MIN_PLAYBACK_START_MSThe default minimum playback start buffer. Default is 2.5 seconds.- See Also:
-
DEFAULT_MIN_REBUFFER_START_MS
public static final int DEFAULT_MIN_REBUFFER_START_MSThe default minimum rebuffer start buffer. Default is 5 seconds.- See Also:
-
DEFAULT_DRAIN_WHILE_CHARGING
public static final boolean DEFAULT_DRAIN_WHILE_CHARGINGThe default behaviour when charging. Default is false.- See Also:
-
DEFAULT_BACK_BUFFER_LENGTH_MS
public static final long DEFAULT_BACK_BUFFER_LENGTH_MSThe default minimum back buffer length. Default is 0 seconds.- See Also:
-
DEFAULT_AUDIO_FEED_YIELD
public static final boolean DEFAULT_AUDIO_FEED_YIELDThe default behaviour for audio renderer when feeding decoder. Default istrue
meaning audio renderer will not block other renderers (video) when feeding decoder.- See Also:
-
DEFAULT_VIDEO_FEED_YIELD
public static final boolean DEFAULT_VIDEO_FEED_YIELDThe default behaviour for video renderer when feeding decoder. Default istrue
meaning video renderer will not block other renderers (audio) when feeding decoder.- See Also:
-
DEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDS
public static final boolean DEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDSThe default value indicating whether the buffer time constraints are prioritized over buffer size constraints- See Also:
-
DEFAULT_PRIORITIZE_INSTREAM_OVER_MANIFEST_DURATION
public static final boolean DEFAULT_PRIORITIZE_INSTREAM_OVER_MANIFEST_DURATIONThe default value indicating whether the buffered duration is evaluated based on playlist (manifest) tags like duration or based on audio and video data segments durations- See Also:
-
CREATOR
-
bufferSizeBytes
public int bufferSizeBytesThe buffer size in bytes -
lowMediaTimeMs
public long lowMediaTimeMsTime in milliseconds that will be used by the buffer controls to determine if the buffer needs to be filled. If the buffer contains data that accumulate to less than this time, the buffer can be put in "fill" state. -
highMediaTimeMs
public long highMediaTimeMsTime in milliseconds that will be used by the buffer controls to determine if the buffer can be drained. If the buffer contains data that accumulate to more than this time, the buffer can be put in "drain" state. -
bufferSegmentSize
public int bufferSegmentSizeThe internal buffer is divided into segment and this specifies the size of a single buffer segment. -
minPlaybackStartMs
public long minPlaybackStartMsThe minimum duration of data that must be buffered for playback to start or resume following a user action such as a seek. -
minRebufferStartMs
public long minRebufferStartMsThe minimum duration of data that must be buffered for playback to resume after a player invoked rebuffer (i.e. a rebuffer that occurs due to buffer depletion, and not due to a user action such as starting playback or seeking). -
prioritizeTimeOverSizeThresholds
public boolean prioritizeTimeOverSizeThresholdsFlag indicating whether the buffer time constraints are prioritized over buffer size constraintslowMediaTimeMs
andhighMediaTimeMs
. Usefalse
to reduce the buffer size up to the value ofbufferSizeBytes
and do not use the mentioned above time constraints. Note, however, when set tofalse
the buffer size may still go temporarily above thebufferSizeBytes
in order to put the complete chunk into the buffer. Also, the buffer size will increase always in order to fill#minPlaybackStartMs
and to allow playback uninterruptedly continue. -
prioritizeInstreamOverManifestDuration
public boolean prioritizeInstreamOverManifestDurationFlag indicating whether the buffered duration is evaluated based on playlist (manifest) tags like duration or based on audio/video data segments durations. The playlist and audio/video durations could become significantly different (seconds) after continuous playback (hours) and when the durations from manifest are not matching the audio/video segment durations. It is recommended to use true which is the default, in order for the player not to get into the stalled state after continuous playback. -
drainWhileCharging
public boolean drainWhileChargingFlag indicating whether the buffer should be drained (untilminPlaybackStartMs
is reached) or not.If
false
the buffer will "bounce" around the max state and never reach its min state. This can potentially reduce the chances of hitting a buffer underrun if the battery is charging.- Since:
- 4.1.11
-
backBufferDurationMs
public long backBufferDurationMsMaximum duration of the back buffer. In other words, how much time are already played segments to remain in the buffer.Note that this value is independent and does not take into account other "forward" buffer parameters such as
bufferSizeBytes
. If this value is too high, it can lead to memory exhaustion.- Since:
- 4.2.0
-
audioFeedYieldEnabled
public boolean audioFeedYieldEnabledThe behaviour for audio renderer when feeding decoder. Set totrue
in order audio renderer not to block other renderers (video) when feeding decoder. -
videoFeedYieldEnabled
public boolean videoFeedYieldEnabledThe behaviour for video renderer when feeding decoder. Set totrue
in order video renderer not to block other renderers (audio) when feeding decoder.
-
-
Constructor Details
-
BufferConfiguration
public BufferConfiguration()Create a new buffer configuration using the default values -
BufferConfiguration
public BufferConfiguration(int bufferSizeBytes, long lowMediaTimeMs, long highMediaTimeMs) Create a new buffer configuration- Parameters:
bufferSizeBytes
- The buffer size in byteslowMediaTimeMs
- The media time that is considered "low"highMediaTimeMs
- The media time that is considered "high"
-
-
Method Details
-
describeContents
public int describeContents()- Specified by:
describeContents
in interfaceParcelable
-
writeToParcel
- Specified by:
writeToParcel
in interfaceParcelable
-
apply
Copies the values from the given buffer configuration to this configuration- Parameters:
source
- the source
-
toString
-
hashCode
public int hashCode() -
equals
-