Class: shaka.abr.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.
Source:

Members

(static, constant) DEFAULT_ESTIMATE :number

Contains the default estimate to use when there is not enough data. This is a relatively safe default, since 3G cell connections are faster than this. For slower connections, such as 2G, the default estimate may be too high. This default can be changed at runtime using shaka.Player#configure and shakaExtern.AbrConfiguration.
Type:
  • number
Source:

(private) bytesSampled_ :number

Number of bytes sampled.
Type:
  • number
Source:

(private) defaultEstimate_ :number

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

(private, non-null) fast_ :shaka.abr.Ewma

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

(private, constant) minBytes_ :number

Minimum number of bytes, under which samples are discarded. Our models do not include latency information, so connection startup time (time to first byte) is considered part of the download time. Because of this, we should ignore very small downloads which would cause our estimate to be too low. This specific value is based on experimentation.
Type:
  • number
Source:

(private, constant) minTotalBytes_ :number

Minimum number of bytes sampled before we trust the estimate. If we have not sampled much data, our estimate may not be accurate enough to trust. If bytesSampled_ is less than minTotalBytes_, we use defaultEstimate_. This specific value is based on experimentation.
Type:
  • number
Source:

(private, non-null) slow_ :shaka.abr.Ewma

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

Methods

getBandwidthEstimate() → {number}

Gets the current bandwidth estimate.
Source:
Returns:
The bandwidth estimate in bits per second.
Type
number

hasGoodEstimate() → {boolean}

Source:
Returns:
True if there is enough data to produce a meaningful estimate.
Type
boolean

sample(durationMs, numBytes)

Takes a bandwidth sample.
Parameters:
Name Type Description
durationMs number The amount of time, in milliseconds, for a particular request.
numBytes number The total number of bytes transferred in that request.
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.
Source: