Skip to content

Commit

Permalink
abr-controller: move magic numbers to hls config params
Browse files Browse the repository at this point in the history
  • Loading branch information
mangui committed Jun 9, 2016
1 parent ffa0bb0 commit 7bb1f2a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
16 changes: 14 additions & 2 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,15 +483,27 @@ this helps playback continue in certain cases that might otherwise get stuck.
parameter should be a boolean
#### ```abrControllerBandwidthWeight```
#### ```abrBandwidthWeight```
(default : 1.0)
The weight to apply to the current bandwidth measurement when calculating the Exponentially-Weighted Moving Average (EWMA) of the bandwidth in the ABR controller.
If ```α := abrControllerBandwidthWeight```, then ```bandwidth average :=* latest bandwidth measurement) + ((1 - α) * previous bandwidth average)```.
If ```α := abrBandwidthWeight```, then ```bandwidth average :=* latest bandwidth measurement) + ((1 - α) * previous bandwidth average)```.
parameter should be a float in the range (0.0, 1.0]
#### ```abrBandWidthFactor```
(default : 0.8)
scale factor to be applied against measured bandwidth average, to determine whether we can stay on current or lower quality level
If ``` abrBandWidthFactor * bandwidth average < level.bitrate ``` then ABR can switch to that level providing that it is equal or less than current level
#### ```abrBandWidthUpFactor```
(default : 0.7)
scale factor to be applied against measured bandwidth average, to determine whether we can switch up to a higher quality level
If ``` abrBandWidthUpFactor * bandwidth average < level.bitrate ``` then ABR can switch up to that quality level
## Video Binding/Unbinding API
#### ```hls.attachMedia(videoElement)```
Expand Down
8 changes: 4 additions & 4 deletions src/controller/abr-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AbrController extends EventHandler {
this.lastfetchduration = (performance.now() - stats.trequest) / 1000;
let thisbw = (stats.loaded * 8) / this.lastfetchduration;
if (this.lastbw) {
let w = this.hls.config.abrControllerBandwidthWeight;
let w = this.hls.config.abrBandwidthWeight;
this.lastbw = (w * thisbw) + (1.0 - w) * this.lastbw;
} else {
this.lastbw = thisbw;
Expand Down Expand Up @@ -182,11 +182,11 @@ class AbrController extends EventHandler {
// be even more conservative (70%) to avoid overestimating and immediately
// switching back.
if (i <= this.lastLoadedFragLevel) {
adjustedbw = 0.8 * lastbw;
adjustedbw = config.abrBandWidthFactor * lastbw;
} else {
adjustedbw = 0.7 * lastbw;
adjustedbw = config.abrBandWidthUpFactor * lastbw;
}
if (adjustedbw < hls.levels[i].bitrate) {
if (adjustedbw < levels[i].bitrate) {
return Math.max(0, i - 1);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/hls.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class Hls {
enableCEA708Captions: true,
enableMP2TPassThrough : false,
stretchShortVideoTrack: false,
abrControllerBandwidthWeight: 1.0
abrBandwidthWeight: 1.0,
abrBandWidthFactor : 0.8,
abrBandWidthUpFactor : 0.7
};
}
return Hls.defaultConfig;
Expand Down

0 comments on commit 7bb1f2a

Please sign in to comment.