Class: shaka.util.EWMABandwidthEstimator

Constructor

new EWMABandwidthEstimator()

Tracks bandwidth samples and estimates available bandwidth. Based on the minimum of two exponentially-weighted moving averages with different half-lives.
Implements:
Extends:
Source:

Members

(private, constant) defaultEstimate_ :number

Initial estimate used when there is not enough data.
Type:
  • number
Source:

(private, non-null) fast_ :shaka.util.EWMA

A fast-moving average. Half of the estimate is based on the last 3 seconds of sample history.
Type:
Source:

(private) lastSampleTime_ :number

The last time a sample was recorded, in milliseconds.
Type:
  • number
Source:

(private, non-null) listeners_ :shaka.util.MultiMap.<shaka.util.FakeEventTarget.ListenerType>

Type:
Inherited From:
Source:

(private, constant) minBytes_ :number

Minimum number of bytes, under which samples are discarded.
Type:
  • number
Source:

(private, constant) minDelayMs_ :number

Prevents ultra-fast internal connections from causing crazy results.
Type:
  • number
Source:

(private, constant) minWeight_ :number

Minimum weight required to trust the estimate.
Type:
  • number
Source:

(protected) parent :shaka.util.FakeEventTarget

Type:
Inherited From:
Source:

(private, non-null) slow_ :shaka.util.EWMA

A slow-moving average. Half of the estimate is based on the last 10 seconds of sample history.
Type:
Source:

Methods

addEventListener(type, listener, opt_capturingopt)

Add an event listener to this object.
Parameters:
Name Type Attributes Description
type string The event type to listen for.
listener shaka.util.FakeEventTarget.ListenerType The callback or listener object to invoke.
opt_capturing boolean <optional>
True to listen during the capturing phase, false to listen during the bubbling phase. Note that FakeEventTarget does not support the capturing phase from the standard event model.
Inherited From:
Source:

dispatchEvent(eventnon-null) → {boolean}

Dispatch an event from this object.
Parameters:
Name Type Description
event Event The event to be dispatched from this object.
Inherited From:
Source:
Returns:
True if the default action was prevented.
Type
boolean

getBandwidth() → {number}

Get estimated bandwidth in bits per second.
Implements:
Source:
Returns:
Type
number

getDataAge() → {number}

Get the age of the data in seconds. This is the time since the last sample was collected.
Implements:
Source:
Returns:
Type
number

(private) recursiveDispatch_(eventnon-null) → {boolean}

Dispatches an event recursively without changing its original target.
Parameters:
Name Type Description
event Event
Inherited From:
Source:
Returns:
True if the default action was prevented.
Type
boolean

removeEventListener(type, listener, opt_capturingopt)

Remove an event listener from this object.
Parameters:
Name Type Attributes Description
type string The event type for which you wish to remove a listener.
listener shaka.util.FakeEventTarget.ListenerType The callback or listener object to remove.
opt_capturing boolean <optional>
True to remove a listener for the capturing phase, false to remove a listener for the bubbling phase. Note that FakeEventTarget does not support the capturing phase from the standard event model.
Inherited From:
Source:

sample(delayMs, bytes)

Takes a bandwidth sample and dispatches a 'bandwidth' event.
Parameters:
Name Type Description
delayMs number The time it took to collect the sample, in ms.
bytes number The number of bytes downloaded.
Implements:
Source:
Fires:

supportsCaching() → {boolean}

Indicates that this BandwidthEstimator can correctly handle bandwidth samples from cached responses. Cached responses make bandwidth estimation difficult, which then makes sensible adaptation decisions difficult or impossible. So, it's recommended that implementations return false, unless they were explicitly designed to take into account cached responses. If this returns false then all AJAX requests using this BandwidthEstimator will force the end-point to forego caching.
Implements:
Source:
Returns:
Type
boolean