Class: shaka.abr.SimpleAbrManager

This defines the default ABR manager for the Player. An instance of this class is used when no ABR manager is given.

The behavior of this class is to take throughput samples using segmentDownloaded to estimate the current network bandwidth. Then it will use that to choose the streams that best fit the current bandwidth. It will always pick the highest bandwidth variant it thinks can be played.

After initial choices are made, this class will call switchCallback() when there is a better choice. switchCallback() will not be called more than once per (shaka.abr.SimpleAbrManager.SWITCH_INTERVAL_MS).

Constructor

new SimpleAbrManager()

This defines the default ABR manager for the Player. An instance of this class is used when no ABR manager is given.

The behavior of this class is to take throughput samples using segmentDownloaded to estimate the current network bandwidth. Then it will use that to choose the streams that best fit the current bandwidth. It will always pick the highest bandwidth variant it thinks can be played.

After initial choices are made, this class will call switchCallback() when there is a better choice. switchCallback() will not be called more than once per (shaka.abr.SimpleAbrManager.SWITCH_INTERVAL_MS).

Implements:
Source:

Members

RESIZE_OBSERVER_BATCH_TIME :number

The amount of time, in seconds, we wait to batch up rapid resize changes. This allows us to avoid multiple resize events in most cases.
Type:
  • number
Source:

enabled_ :boolean

Type:
  • boolean
Source:

lastTimeChosenMs_ :number

The last wall-clock time, in milliseconds, when streams were chosen.
Type:
  • number
Source:

playbackRate_ :number

Type:
  • number
Source:

resizeObserver_ :ResizeObserver

Type:
  • ResizeObserver
Source:

startupComplete_ :boolean

Type:
  • boolean
Source:

variants_ :Array.<!shaka.extern.Variant>

A filtered list of Variants to choose from.
Type:
Source:

Methods

chooseVariant(preferFastSwitchingopt) → {shaka.extern.Variant}

Chooses one variant to switch to. Called by the Player.
Parameters:
Name Type Attributes Default Description
preferFastSwitching boolean <optional>
false
Implements:
Source:
Returns:
Type
shaka.extern.Variant

configure(config)

Sets the ABR configuration. It is the responsibility of the AbrManager implementation to implement the restrictions behavior described in shaka.extern.AbrConfiguration.
Parameters:
Name Type Description
config shaka.extern.AbrConfiguration
Implements:
Source:

disable()

Disables automatic Stream suggestions. After this, the AbrManager may not call switchCallback().
Implements:
Source:

enable()

Enables automatic Variant choices from the last ones passed to setVariants. After this, the AbrManager may call switchCallback() at any time.
Implements:
Source:

filterAndSortVariants_(restrictionsnullable, variantsnon-null, maxHeightnon-null, maxWidthnon-null) → {Array.<shaka.extern.Variant>}

Parameters:
Name Type Attributes Description
restrictions shaka.extern.Restrictions <nullable>
variants Array.<shaka.extern.Variant>
maxHeight number
maxWidth number
Source:
Returns:
variants filtered according to |restrictions| and sorted in ascending order of bandwidth.
Type
Array.<shaka.extern.Variant>

getBandwidthEstimate() → {number}

Gets an estimate of the current bandwidth in bit/sec. This is used by the Player to generate stats.
Implements:
Source:
Returns:
Type
number

getDefaultBandwidth_()

Source:

getResolutionList_(variantsnon-null) → {Array.<{height: number, width: number}>}

Parameters:
Name Type Description
variants Array.<shaka.extern.Variant>
Source:
Returns:
Type
Array.<{height: number, width: number}>

init(switchCallback)

Initializes the AbrManager.
Parameters:
Name Type Description
switchCallback shaka.extern.AbrManager.SwitchCallback
Implements:
Source:

isSameBandwidthAndHigherResolution_(chosenVariant, newVariant) → {boolean}

Parameters:
Name Type Description
chosenVariant shaka.extern.Variant
newVariant shaka.extern.Variant
Source:
Returns:
Type
boolean

playbackRateChanged(rate)

Updates manager playback rate.
Parameters:
Name Type Description
rate number
Implements:
Source:

release()

Request that this object release all internal references.
Implements:
Source:

segmentDownloaded(deltaTimeMs, numBytes, allowSwitch, requestopt)

Notifies the AbrManager that a segment has been downloaded (includes MP4 SIDX data, WebM Cues data, initialization segments, and media segments).
Parameters:
Name Type Attributes Description
deltaTimeMs number The duration, in milliseconds, that the request took to complete.
numBytes number The total number of bytes transferred.
allowSwitch boolean Indicate if the segment is allowed to switch to another stream.
request shaka.extern.Request <optional>
A reference to the request
Implements:
Source:

setCmsdManager(cmsdManager)

Set CMSD manager.
Parameters:
Name Type Description
cmsdManager shaka.util.CmsdManager
Implements:
Source:

setMediaElement(mediaElement)

Set media element.
Parameters:
Name Type Description
mediaElement HTMLMediaElement
Implements:
Source:

setVariants(variantsnon-null)

Updates manager's variants collection.
Parameters:
Name Type Description
variants Array.<!shaka.extern.Variant>
Implements:
Source:

stop()

Stops any background timers and frees any objects held by this instance. This will only be called after a call to init.
Implements:
Source:

suggestStreams_()

Calls switch_() with the variant chosen by chooseVariant().
Source:

trySuggestStreams()

Notifies the ABR that it is a time to suggest new streams. This is used by the Player when it finishes adding the last partial segment of a fast switching stream.
Implements:
Source: