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 the initial choice (in chooseStreams), 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).
This does not adapt for text streams, it will always select the first one.
- Implements:
- Source:
Members
-
(private, static, constant) BANDWIDTH_DOWNGRADE_TARGET_ :number
-
The largest fraction of the estimated bandwidth we should use. We should downgrade to avoid this.
Type:
- number
- Source:
-
(private, static, constant) BANDWIDTH_UPGRADE_TARGET_ :number
-
The fraction of the estimated bandwidth which we should try to use when upgrading.
Type:
- number
- Source:
-
(static, constant) SWITCH_INTERVAL_MS :number
-
The minimum amount of time that must pass between switches, in milliseconds. This keeps us from changing too often and annoying the user.
Type:
- number
- Source:
-
(private) bandwidthEstimator_ :shaka.abr.EwmaBandwidthEstimator
-
Type:
- Source:
-
(private) enabled_ :boolean
-
Type:
- boolean
- Source:
-
(private, nullable) lastTimeChosenMs_ :number
-
The last wall-clock time, in milliseconds, when Streams were chosen via chooseStreams() or switch_().
Type:
- number
- Source:
-
(private) restrictions_ :shakaExtern.Restrictions
-
Type:
- Source:
-
(private) startupComplete_ :boolean
-
Type:
- boolean
- Source:
-
(private, nullable) switch_ :shakaExtern.AbrManager.SwitchCallback
-
Type:
- Source:
-
(private, non-null) textStreams_ :Array.<!shakaExtern.Stream>
-
A filtered list of text streams to choose from.
Type:
- Array.<!shakaExtern.Stream>
- Source:
-
(private, non-null) variants_ :Array.<!shakaExtern.Variant>
-
A filtered list of Variants to choose from.
Type:
- Array.<!shakaExtern.Variant>
- Source:
Methods
-
(private, static) filterAndSortVariants_(restrictions, variantsnon-null) → (non-null) {Array.<shakaExtern.Variant>}
-
Parameters:
Name Type Description restrictions
shakaExtern.Restrictions variants
Array.<shakaExtern.Variant> - Source:
Returns:
variants filtered according to |restrictions| and sorted in ascending order of bandwidth.- Type
- Array.<shakaExtern.Variant>
-
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> - Implements:
- Source:
Returns:
- Type
- Object.<string, shakaExtern.Stream>
-
(private) chooseVariant_(variantsnon-null) → {shakaExtern.Variant}
-
Chooses a Variant with an optimal bandwidth.
Parameters:
Name Type Description variants
Array.<shakaExtern.Variant> - Source:
Returns:
- Type
- shakaExtern.Variant
-
disable()
-
Disables automatic Stream suggestions. After this, the AbrManager may not call switchCallback().
- Implements:
- Source:
-
enable()
-
Enables automatic Stream choices from the last StreamSets passed to chooseStreams(). After this, the AbrManager may call switchCallback() at any time.
- Implements:
- Source:
-
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
-
init(switchCallback)
-
Initializes the AbrManager.
Parameters:
Name Type Description switchCallback
shakaExtern.AbrManager.SwitchCallback - Implements:
- 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. - Implements:
- 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. - Implements:
- Source:
-
setRestrictions(restrictions)
-
Sets the restrictions that AbrManager will use when choosing streams.
Parameters:
Name Type Description restrictions
shakaExtern.Restrictions - Implements:
- Source:
-
setTextStreams(streamsnon-null)
-
Updates manager's text streams collection.
Parameters:
Name Type Description streams
Array.<!shakaExtern.Stream> - Implements:
- Source:
-
setVariants(variantsnon-null)
-
Updates manager's variants collection.
Parameters:
Name Type Description variants
Array.<!shakaExtern.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:
-
(private) suggestStreams_()
-
Calls switch_() with which Streams to switch to.
- Source: