Interface: shakaExtern.AbrManager

An object which selects Streams from a set of possible choices. This also watches for system changes to automatically adapt for the current streaming requirements. For example, when the network slows down, this class is in charge of telling the Player which streams to switch to in order to reduce the required bandwidth. This class is given a set of streams to choose from when the Player starts up. This class should store these and use them to make future decisions about ABR. It is up to this class how those decisions are made. All the Player will do is tell this class what streams to choose from.
Implementations:
Source:

Methods

chooseStreams(mediaTypesToUpdatenon-null) → (non-null) {Object.<string, shakaExtern.Stream>}

Chooses one Stream from each media type in mediaTypesToUpdate to switch to. All Variants and Streams must be from the same Period.
Parameters:
Name Type Description
mediaTypesToUpdate Array.<!string>
Implementations:
Source:
Returns:
Type
Object.<string, shakaExtern.Stream>

disable()

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

enable()

Enables automatic Stream choices from the last StreamSets passed to chooseStreams(). After this, the AbrManager may call switchCallback() at any time.
Implementations:
Source:

getBandwidthEstimate() → {number}

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

init(switchCallback)

Initializes the AbrManager.
Parameters:
Name Type Description
switchCallback shakaExtern.AbrManager.SwitchCallback
Implementations:
Source:

segmentDownloaded(deltaTimeMs, numBytes)

Notifies the AbrManager that a segment has been downloaded (includes MP4 SIDX data, WebM Cues data, initialization segments, and media segments).
Parameters:
Name Type Description
deltaTimeMs number The duration, in milliseconds, that the request took to complete.
numBytes number The total number of bytes transferred.
Implementations:
Source:

setDefaultEstimate(estimate)

Sets the default bandwidth estimate to use if there is not enough data.
Parameters:
Name Type Description
estimate number The default bandwidth estimate, in bit/sec.
Implementations:
Source:

setRestrictions(restrictions)

Sets the restrictions that AbrManager will use when choosing streams.
Parameters:
Name Type Description
restrictions shakaExtern.Restrictions
Implementations:
Source:

setTextStreams(streamsnon-null)

Updates manager's text streams collection.
Parameters:
Name Type Description
streams Array.<!shakaExtern.Stream>
Implementations:
Source:

setVariants(variantsnon-null)

Updates manager's variants collection.
Parameters:
Name Type Description
variants Array.<!shakaExtern.Variant>
Implementations:
Source:

stop()

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

Type Definitions

SwitchCallback

A callback from the Player that should be called when the AbrManager decides it's time to change to a different set of streams. The first argument is a map of content types to chosen streams. The second argument is an optional boolean. If true, all data will be from the buffer, which will result in a buffering event.
Type:
Source: