Constructor
new EwmaBandwidthEstimator()
Tracks bandwidth samples and estimates available bandwidth.
Based on the minimum of two exponentially-weighted moving averages with
different half-lives.
Members
(private) bytesSampled_ :number
Number of bytes sampled.
Type:
- number
(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:
(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
(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
(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:
Methods
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. |