Package com.castlabs.android.player

# Class AbrConfiguration

java.lang.Object
com.castlabs.android.player.AbrConfiguration

All Implemented Interfaces:
  `Parcelable`

public class AbrConfiguration extends Object implements Parcelable
The ABR configuration. Use the `AbrConfiguration.Builder` to create new instances of this class.

Since:
  4.1.0

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static @interface`
  `AbrConfiguration.AbrMethod`
  The method used for ABR.
  `static class`
  `AbrConfiguration.Builder`
  A builder for ABR configuration instances

  ## Nested classes/interfaces inherited from interface android.os.Parcelable

  `Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final float`
  `bandwidthFraction`
  The fraction of the bandwidth estimation that we consider to calculate the effective bandwidth.
  `final int`
  `bytesThreshold`
  The min number of bytes before transferred bytes and times are used for ABR calculations, applicable to `METHOD_COMMON_NBA`
  `static final Parcelable.Creator<AbrConfiguration>`
  `CREATOR`
  `Parcelable.Creator` for the `AbrConfiguration` class.
  `static final float`
  `DEFAULT_BANDWIDTH_FRACTION`
  The default bandwidth fraction
  `static final float`
  `DEFAULT_DEGRADATION_PENALTY`
  The default degradation penalty
  `static final float`
  `DEFAULT_DEGRADATION_RECOVERY`
  The default degradation recovery
  `static final int`
  `DEFAULT_DEGRADATION_SAMPLES`
  The default min degradation samples
  `static final float`
  `DEFAULT_DOWNLOAD_TIME_FACTOR`
  The default download time factor
  `static final int`
  `DEFAULT_INITIAL_TRACK_SELECTION`
  The default initial track selection.
  `static final boolean`
  `DEFAULT_KEEP_INITIAL_TRACK_SELECTION`
  The default value for `keepInitialSelection`.
  `static final com.google.android.exoplayer2.Format`
  `DEFAULT_MANUAL_SELECTION`
  The default manual selection
  `static final long`
  `DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_US`
  The default max duration for quality decrease
  `static final long`
  `DEFAULT_MAX_INITIAL_BITRATE`
  The default max initial bitrate
  `static final int`
  `DEFAULT_METHOD`
  The default method
  `static final long`
  `DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_US`
  The default min duration for quality increase
  `static final long`
  `DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_US`
  The default min duration to retain after discard
  `static final long`
  `DEFAULT_MIN_SAMPLED_BYTES`
  The default min sampled bytes
  `static final float`
  `DEFAULT_PERCENTILE`
  The default percentile
  `static final int`
  `DEFAULT_PERCENTILE_WEIGHT`
  The default percentile weight
  `static final long`
  `DEFAULT_SAFE_BUFFER_SIZE_US`
  The default safe buffer size in microseconds
  `static final int`
  `DEFAULT_THRESHOLD_BYTES`
  The default bytes threshold
  `static final int`
  `DEFAULT_THRESHOLD_TIME_MS`
  The default time threshold in milliseconds
  `static final boolean`
  `DEFAULT_USE_CMSD`
  The default usage of CMSD
  `final float`
  `degradationPenalty`
  A value between 0 and 1 that is used as a penalty when a buffer degradation or a download time issue us detected.
  `final float`
  `degradationRecovery`
  The recovery that is applied on each selection after a `degradationPenalty` was applied.
  `final float`
  `downloadTimeFactor`
  Safety factor that is applied to download time calculations
  `static boolean`
  `ENABLED`
  The common algorithms may be disabled.
  `final int`
  `initialTrackSelection`
  The initial track selection can be used to manually select a track by index initially, in combination with `keepInitialSelection`.
  `final boolean`
  `keepInitialSelection`
  True if the first selection should be kept.
  `final long`
  `maxDurationForQualityDecreaseUs`
  The maximum amount of data that is expected to be buffered before a quality decrease is permitted.
  `final long`
  `maxInitialBitrate`
  The bandwidth estimation in bits per second that is used when the bandwidth estimator reports that it can not estimate due to lack of information.
  `final int`
  `method`
  The ABR method
  `static final int`
  `METHOD_COMMON_NBA`
  Common across platforms implementation of network based adaptation
  `static final int`
  `METHOD_EXO`
  Exo implementation of network based adaptation
  `static final int`
  `METHOD_FLIP`
  Flip between lowest and highest quality (FOR DEBUGGING)
  `static final int`
  `METHOD_ITERATE`
  Iterate through renditions (FOR DEBUGGING)
  `final int`
  `minDegradationSamples`
  The minium number of segments observed before buffer degradation detection is permitted.
  `final long`
  `minDurationForQualityIncreaseUs`
  The minimum amount of that data is expected to be buffered before a quality increase is permitted.
  `final long`
  `minDurationToRetainAfterDiscardUs`
  Duration of the buffer to retain after discarding chunks e.g.
  `final long`
  `minSampledBytes`
  The min number of totally transferred bytes before the ABR calculations are considered reliable, applicable to `METHOD_COMMON_NBA`
  `final float`
  `percentile`
  The percentile, applicable to `METHOD_COMMON_NBA`
  `final int`
  `percentileWeight`
  The weight used for the sliding percentile bandwidth estimator
  `final long`
  `safeBufferSizeUs`
  Minimum target buffer considered safe.
  `final int`
  `timeThresholdMs`
  The min time in milliseconds before transferred bytes and times are used for ABR calculations, applicable to `METHOD_COMMON_NBA`
  `final boolean`
  `useCMSD`
  When enabled, the Player will try to parse the CMSD-Dynamic header to extract the backend-informed estimated bandwidth (the etp field) and use it as the estimation for quality selection.

  ### Fields inherited from interface android.os.Parcelable

  `CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `describeContents()`
  `boolean`
  `equals(Object obj)`
  `int`
  `hashCode()`
  `String`
  `toString()`
  `AbrConfiguration.Builder`
  `update()`
  Returns a new builder instance that can be used to create a new configuration that is based on this instance.
  `void`
  `writeToParcel(Parcel parcel, int i)`

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### ENABLED

    public static boolean ENABLED
    The common algorithms may be disabled. This is useful for unit tests where the native libraries can not be loaded. The `METHOD_EXO` is used then.

  - ### METHOD_EXO

    public static final int METHOD_EXO
    Exo implementation of network based adaptation
    See Also:
      - Constant Field Values

  - ### METHOD_ITERATE

    public static final int METHOD_ITERATE
    Iterate through renditions (FOR DEBUGGING)
    See Also:
      - Constant Field Values

  - ### METHOD_FLIP

    public static final int METHOD_FLIP
    Flip between lowest and highest quality (FOR DEBUGGING)
    See Also:
      - Constant Field Values

  - ### METHOD_COMMON_NBA

    public static final int METHOD_COMMON_NBA
    Common across platforms implementation of network based adaptation
    See Also:
      - Constant Field Values

  - ### CREATOR

    public static final Parcelable.Creator<AbrConfiguration> CREATOR
    `Parcelable.Creator` for the `AbrConfiguration` class.

  - ### DEFAULT_MANUAL_SELECTION

    public static final com.google.android.exoplayer2.Format DEFAULT_MANUAL_SELECTION
    The default manual selection

  - ### DEFAULT_MAX_INITIAL_BITRATE

    public static final long DEFAULT_MAX_INITIAL_BITRATE
    The default max initial bitrate
    See Also:
      - Constant Field Values

  - ### DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_US

    public static final long DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_US
    The default min duration for quality increase
    See Also:
      - Constant Field Values

  - ### DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_US

    public static final long DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_US
    The default max duration for quality decrease
    See Also:
      - Constant Field Values

  - ### DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_US

    public static final long DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_US
    The default min duration to retain after discard
    See Also:
      - Constant Field Values

  - ### DEFAULT_SAFE_BUFFER_SIZE_US

    public static final long DEFAULT_SAFE_BUFFER_SIZE_US
    The default safe buffer size in microseconds
    See Also:
      - Constant Field Values

  - ### DEFAULT_DOWNLOAD_TIME_FACTOR

    public static final float DEFAULT_DOWNLOAD_TIME_FACTOR
    The default download time factor
    See Also:
      - Constant Field Values

  - ### DEFAULT_BANDWIDTH_FRACTION

    public static final float DEFAULT_BANDWIDTH_FRACTION
    The default bandwidth fraction
    See Also:
      - Constant Field Values

  - ### DEFAULT_METHOD

    public static final int DEFAULT_METHOD
    The default method
    See Also:
      - Constant Field Values

  - ### DEFAULT_PERCENTILE_WEIGHT

    public static final int DEFAULT_PERCENTILE_WEIGHT
    The default percentile weight
    See Also:
      - Constant Field Values

  - ### DEFAULT_PERCENTILE

    public static final float DEFAULT_PERCENTILE
    The default percentile
    See Also:
      - Constant Field Values

  - ### DEFAULT_THRESHOLD_BYTES

    public static final int DEFAULT_THRESHOLD_BYTES
    The default bytes threshold
    See Also:
      - Constant Field Values

  - ### DEFAULT_THRESHOLD_TIME_MS

    public static final int DEFAULT_THRESHOLD_TIME_MS
    The default time threshold in milliseconds
    See Also:
      - Constant Field Values

  - ### DEFAULT_MIN_SAMPLED_BYTES

    public static final long DEFAULT_MIN_SAMPLED_BYTES
    The default min sampled bytes
    See Also:
      - Constant Field Values

  - ### DEFAULT_DEGRADATION_PENALTY

    public static final float DEFAULT_DEGRADATION_PENALTY
    The default degradation penalty
    See Also:
      - Constant Field Values

  - ### DEFAULT_DEGRADATION_RECOVERY

    public static final float DEFAULT_DEGRADATION_RECOVERY
    The default degradation recovery
    See Also:
      - Constant Field Values

  - ### DEFAULT_DEGRADATION_SAMPLES

    public static final int DEFAULT_DEGRADATION_SAMPLES
    The default min degradation samples
    See Also:
      - Constant Field Values

  - ### DEFAULT_USE_CMSD

    public static final boolean DEFAULT_USE_CMSD
    The default usage of CMSD
    See Also:
      - Constant Field Values

  - ### DEFAULT_INITIAL_TRACK_SELECTION

    public static final int DEFAULT_INITIAL_TRACK_SELECTION
    The default initial track selection.
    See Also:
      - Constant Field Values

  - ### DEFAULT_KEEP_INITIAL_TRACK_SELECTION

    public static final boolean DEFAULT_KEEP_INITIAL_TRACK_SELECTION
    The default value for `keepInitialSelection`.
    See Also:
      - Constant Field Values

  - ### maxInitialBitrate

    public final long maxInitialBitrate
    The bandwidth estimation in bits per second that is used when the bandwidth estimator reports that it can not estimate due to lack of information. This is usually used for the initial quality selection when no network estimation was collected yet.

  - ### minDurationForQualityIncreaseUs

    public final long minDurationForQualityIncreaseUs
    The minimum amount of that data is expected to be buffered before a quality increase is permitted.

    By default, we we expect to have at least 10 seconds of buffered data before we can switch up the quality. That gives some safe guards around building up a stable buffer when the bandwidth estimation is not very accurate.

  - ### maxDurationForQualityDecreaseUs

    public final long maxDurationForQualityDecreaseUs
    The maximum amount of data that is expected to be buffered before a quality decrease is permitted.

    Similar to the min duration for quality increase. By default we will not switch down the quality if we have more than 25 seconds of buffer. That avoids that the player will react to short fluctuations in the network capacity. Decreasing this value will prevent down switches longer, but increase the chance for a buffer under run.

  - ### bandwidthFraction

    public final float bandwidthFraction
    The fraction of the bandwidth estimation that we consider to calculate the effective bandwidth. Defaults to 0.75.

  - ### initialTrackSelection

    public final int initialTrackSelection
    The initial track selection can be used to manually select a track by index initially, in combination with `keepInitialSelection`. You can also use `SdkConsts.VIDEO_QUALITY_HIGHEST` or `SdkConsts.VIDEO_QUALITY_LOWEST`. The default value is `SdkConsts.VIDEO_QUALITY_ADAPTIVE`.

    Please note that `maxInitialBitrate` is a better option if you want to influence the initial track selection because you will no need to know the actual indices.

  - ### keepInitialSelection

    public final boolean keepInitialSelection
    True if the first selection should be kept. This will effectively switch the ABR into manual mode after the initial selection.

  - ### method

    public final int method
    The ABR method

  - ### minDurationToRetainAfterDiscardUs

    public final long minDurationToRetainAfterDiscardUs
    Duration of the buffer to retain after discarding chunks e.g. discarding SD chunks to replace with better HD quality

  - ### safeBufferSizeUs

    public final long safeBufferSizeUs
    Minimum target buffer considered safe. Buffer below or equals this threshold results in emergency handling.

  - ### downloadTimeFactor

    public final float downloadTimeFactor
    Safety factor that is applied to download time calculations

  - ### percentileWeight

    public final int percentileWeight
    The weight used for the sliding percentile bandwidth estimator

  - ### percentile

    public final float percentile
    The percentile, applicable to `METHOD_COMMON_NBA`

  - ### bytesThreshold

    public final int bytesThreshold
    The min number of bytes before transferred bytes and times are used for ABR calculations, applicable to `METHOD_COMMON_NBA`

  - ### timeThresholdMs

    public final int timeThresholdMs
    The min time in milliseconds before transferred bytes and times are used for ABR calculations, applicable to `METHOD_COMMON_NBA`

  - ### minSampledBytes

    public final long minSampledBytes
    The min number of totally transferred bytes before the ABR calculations are considered reliable, applicable to `METHOD_COMMON_NBA`

  - ### degradationPenalty

    public final float degradationPenalty
    A value between 0 and 1 that is used as a penalty when a buffer degradation or a download time issue us detected. In that case the assumption is that the current bandwidth estimate is not enough, since the buffer is getting smaller or became already too small to provide enough time to download the next segment of a selected rendition. In that case the penalty is used to artificially reduce the bandwidth estimation and hence permit the player to re-build some of its buffer.

  - ### degradationRecovery

    public final float degradationRecovery
    The recovery that is applied on each selection after a `degradationPenalty` was applied. This removes the penalty over time.

  - ### minDegradationSamples

    public final int minDegradationSamples
    The minium number of segments observed before buffer degradation detection is permitted.

  - ### useCMSD

    public final boolean useCMSD
    When enabled, the Player will try to parse the CMSD-Dynamic header to extract the backend-informed estimated bandwidth (the etp field) and use it as the estimation for quality selection.

    In case the header is not found or cannot be properly parsed, the Player will fall back to using whatever `method` has been selected.

- ## Method Details

  - ### update

    public AbrConfiguration.Builder update()
    Returns a new builder instance that can be used to create a new configuration that is based on this instance.
    Returns:
      The builder

  - ### describeContents

    public int describeContents()
    Specified by:
      `describeContents` in interface `Parcelable`

  - ### writeToParcel

    public void writeToParcel(Parcel parcel, int i)
    Specified by:
      `writeToParcel` in interface `Parcelable`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`