Skip to content

Commit

Permalink
Merge pull request #3587 from video-dev/bugfix/bandwidth-estimate-cus…
Browse files Browse the repository at this point in the history
…tom-estimator

Fix `hls.bandwidthEstimate()` with custom `abrController`
  • Loading branch information
robwalch committed Mar 8, 2021
2 parents 8ef5ffe + 5a8f495 commit 9e13e30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,8 @@ Parameter should be a class providing 2 getters, 2 setters and a `destroy()` met
- get/set `autoLevelCapping`: capping/max level value that could be used by ABR Controller
- `destroy()`: should clean-up all used resources

For `hls.bandwidthEstimate()` to return an estimate from your custom controller, it will also need to satisfy `abrController.bwEstimator.getEstimate()`.

### `bufferController`

(default: internal buffer controller)
Expand Down
6 changes: 5 additions & 1 deletion src/hls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,11 @@ export default class Hls implements HlsEventEmitter {
* @type {number}
*/
get bandwidthEstimate(): number {
return this.abrController.bwEstimator.getEstimate();
const { bwEstimator } = this.abrController;
if (!bwEstimator) {
return NaN;
}
return bwEstimator.getEstimate();
}

/**
Expand Down

0 comments on commit 9e13e30

Please sign in to comment.