Constructor
new EwmaBandwidthEstimator()
This class tracks bandwidth samples and estimates available bandwidth. Based on the minimum of two exponentially-weighted moving averages with different half-lives.
Members
bytesSampled_ :number
Number of bytes sampled.
Type:
- number
fast_ :shaka.abr.Ewma
A fast-moving average.
Half of the estimate is based on the last 2 seconds of sample history.
Type:
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
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
slow_ :shaka.abr.Ewma
A slow-moving average.
Half of the estimate is based on the last 5 seconds of sample history.
Type:
Methods
configure(config)
Called by the Player to provide an updated configuration any time it
changes.
Must be called at least once before init().
Parameters:
Name | Type | Description |
---|---|---|
config |
shaka.extern.AdvancedAbrConfiguration |
getBandwidthEstimate(defaultEstimate) → {number}
Gets the current bandwidth estimate.
Parameters:
Name | Type | Description |
---|---|---|
defaultEstimate |
number |
Returns:
The bandwidth estimate in bits per second.
- Type
- number
hasGoodEstimate() → {boolean}
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. |