Class BufferConfiguration
- java.lang.Object
-
- com.castlabs.android.player.BufferConfiguration
-
- All Implemented Interfaces:
Parcelable
public class BufferConfiguration extends Object implements Parcelable
Container object that stores the buffer configuration.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 callPlayerController.open(PlayerConfig). Alternatively you can use the Bundle keySdkConsts.INTENT_BUFFER_CONFIGURATIONand pass a configuration toPlayerController.open(Bundle).- Since:
- 3.3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBufferConfiguration.Builder-
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T extends Object>, Parcelable.Creator<T extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description booleanaudioFeedYieldEnabledThe behaviour for audio renderer when feeding decoder.longbackBufferDurationMsMaximum duration of the back buffer.intbufferSegmentSizeThe internal buffer is divided into segment and this specifies the size of a single buffer segment.intbufferSizeBytesThe buffer size in bytesstatic Parcelable.Creator<BufferConfiguration>CREATORstatic booleanDEFAULT_AUDIO_FEED_YIELDThe default behaviour for audio renderer when feeding decoder.static longDEFAULT_BACK_BUFFER_LENGTH_MSThe default minimum back buffer length.static intDEFAULT_BUFFER_SEGMENT_SIZEThe default buffer segment size.static intDEFAULT_BUFFER_SIZEThe default buffer size in bytes.static booleanDEFAULT_DRAIN_WHILE_CHARGINGThe default behaviour when charging.static longDEFAULT_HIGH_MEDIA_TIMEThe default value forhighMediaTimeMs.static longDEFAULT_LOW_MEDIA_TIMEThe default value forlowMediaTimeMs.static intDEFAULT_MIN_PLAYBACK_START_MSThe default minimum playback start buffer.static intDEFAULT_MIN_REBUFFER_START_MSThe default minimum rebuffer start buffer.static booleanDEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDSThe default value indicating whether the buffer time constraints are prioritized over buffer size constraintsstatic booleanDEFAULT_VIDEO_FEED_YIELDThe default behaviour for video renderer when feeding decoder.booleandrainWhileChargingFlag indicating whether the buffer should be drained (untilminPlaybackStartMsis reached) or not.longhighMediaTimeMsTime in milliseconds that will be used by the buffer controls to determine if the buffer can be drained.longlowMediaTimeMsTime in milliseconds that will be used by the buffer controls to determine if the buffer needs to be filled.longminPlaybackStartMsThe minimum duration of data that must be buffered for playback to start or resume following a user action such as a seek.longminRebufferStartMsThe minimum duration of data that must be buffered for playback to resume after a player invoked rebuffer (i.e.booleanprioritizeTimeOverSizeThresholdsFlag indicating whether the buffer time constraints are prioritized over buffer size constraintslowMediaTimeMsandhighMediaTimeMs.booleanvideoFeedYieldEnabledThe behaviour for video renderer when feeding decoder.-
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
-
Constructor Summary
Constructors Constructor Description BufferConfiguration()Create a new buffer configuration using the default valuesBufferConfiguration(int bufferSizeBytes, long lowMediaTimeMs, long highMediaTimeMs)Create a new buffer configuration
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapply(BufferConfiguration source)Copies the values from the given buffer configuration to this configurationintdescribeContents()booleanequals(Object obj)inthashCode()StringtoString()voidwriteToParcel(Parcel dest, int flags)
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
The default buffer size in bytes. The default is 16 MB.- See Also:
- Constant Field Values
-
DEFAULT_LOW_MEDIA_TIME
public static final long DEFAULT_LOW_MEDIA_TIME
The default value forlowMediaTimeMs. The default is 15 seconds.- See Also:
- Constant Field Values
-
DEFAULT_HIGH_MEDIA_TIME
public static final long DEFAULT_HIGH_MEDIA_TIME
The default value forhighMediaTimeMs. The default is 60 seconds.- See Also:
- Constant Field Values
-
DEFAULT_BUFFER_SEGMENT_SIZE
public static final int DEFAULT_BUFFER_SEGMENT_SIZE
The default buffer segment size. The default is 64 KB- See Also:
- Constant Field Values
-
DEFAULT_MIN_PLAYBACK_START_MS
public static final int DEFAULT_MIN_PLAYBACK_START_MS
The default minimum playback start buffer. Default is 2.5 seconds.- See Also:
- Constant Field Values
-
DEFAULT_MIN_REBUFFER_START_MS
public static final int DEFAULT_MIN_REBUFFER_START_MS
The default minimum rebuffer start buffer. Default is 5 seconds.- See Also:
- Constant Field Values
-
DEFAULT_DRAIN_WHILE_CHARGING
public static final boolean DEFAULT_DRAIN_WHILE_CHARGING
The default behaviour when charging. Default is false.- See Also:
- Constant Field Values
-
DEFAULT_BACK_BUFFER_LENGTH_MS
public static final long DEFAULT_BACK_BUFFER_LENGTH_MS
The default minimum back buffer length. Default is 0 seconds.- See Also:
- Constant Field Values
-
DEFAULT_AUDIO_FEED_YIELD
public static final boolean DEFAULT_AUDIO_FEED_YIELD
The default behaviour for audio renderer when feeding decoder. Default istruemeaning audio renderer will not block other renderers (video) when feeding decoder.- See Also:
- Constant Field Values
-
DEFAULT_VIDEO_FEED_YIELD
public static final boolean DEFAULT_VIDEO_FEED_YIELD
The default behaviour for video renderer when feeding decoder. Default istruemeaning video renderer will not block other renderers (audio) when feeding decoder.- See Also:
- Constant Field Values
-
DEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDS
public static final boolean DEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDS
The default value indicating whether the buffer time constraints are prioritized over buffer size constraints- See Also:
- Constant Field Values
-
CREATOR
public static final Parcelable.Creator<BufferConfiguration> CREATOR
-
bufferSizeBytes
public int bufferSizeBytes
The buffer size in bytes
-
lowMediaTimeMs
public long lowMediaTimeMs
Time 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 highMediaTimeMs
Time 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 bufferSegmentSize
The internal buffer is divided into segment and this specifies the size of a single buffer segment.
-
minPlaybackStartMs
public long minPlaybackStartMs
The 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 minRebufferStartMs
The 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 prioritizeTimeOverSizeThresholds
Flag indicating whether the buffer time constraints are prioritized over buffer size constraintslowMediaTimeMsandhighMediaTimeMs. Usefalseto reduce the buffer size up to the value ofbufferSizeBytesand do not use the mentioned above time constraints. Note, however, when set tofalsethe buffer size may still go temporarily above thebufferSizeBytesin order to put the complete chunk into the buffer. Also, the buffer size will increase always in order to fill#minPlaybackStartMsand to allow playback uninterruptedly continue.
-
drainWhileCharging
public boolean drainWhileCharging
Flag indicating whether the buffer should be drained (untilminPlaybackStartMsis reached) or not.If
falsethe 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 backBufferDurationMs
Maximum 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 audioFeedYieldEnabled
The behaviour for audio renderer when feeding decoder. Set totruein order audio renderer not to block other renderers (video) when feeding decoder.
-
videoFeedYieldEnabled
public boolean videoFeedYieldEnabled
The behaviour for video renderer when feeding decoder. Set totruein order video renderer not to block other renderers (audio) when feeding decoder.
-
-
Constructor Detail
-
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 Detail
-
describeContents
public int describeContents()
- Specified by:
describeContentsin interfaceParcelable
-
writeToParcel
public void writeToParcel(Parcel dest, int flags)
- Specified by:
writeToParcelin interfaceParcelable
-
apply
public void apply(BufferConfiguration source)
Copies the values from the given buffer configuration to this configuration- Parameters:
source- the source
-
-