Skip to content

Commit

Permalink
Fix BOLA rule on track switch (#3884)
Browse files Browse the repository at this point in the history
* BOLA rule: reset placeholderbuffer on empty buffer only for concerned media type

* BOLA rule: if audio buffer runs empty (due to track switch for example) then reset placeholder buffer only for audio (to avoid decrease video BOLA quality)
  • Loading branch information
bbert authored Mar 23, 2022
1 parent 0cc7834 commit b9be635
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/streaming/rules/abr/BolaRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import EventBus from '../../../core/EventBus';
import Events from '../../../core/events/Events';
import Debug from '../../../core/Debug';
import MediaPlayerEvents from '../../MediaPlayerEvents';
import Constants from '../../constants/Constants';

// BOLA_STATE_ONE_BITRATE : If there is only one bitrate (or initialization failed), always return NO_CHANGE.
// BOLA_STATE_STARTUP : Set placeholder buffer such that we download fragments at most recently measured throughput.
Expand Down Expand Up @@ -258,9 +259,12 @@ function BolaRule(config) {
checkBolaStateStableBufferTime(bolaState, mediaType);
}

function onBufferEmpty() {
function onBufferEmpty(e) {
// if we rebuffer, we don't want the placeholder buffer to artificially raise BOLA quality
for (const mediaType in bolaStateDict) {
const mediaType = e.mediaType;
// if audio buffer runs empty (due to track switch for example) then reset placeholder buffer only for audio (to avoid decrease video BOLA quality)
const stateDict = mediaType === Constants.AUDIO ? [Constants.AUDIO] : bolaStateDict;
for (const mediaType in stateDict) {
if (bolaStateDict.hasOwnProperty(mediaType) && bolaStateDict[mediaType].state === BOLA_STATE_STEADY) {
bolaStateDict[mediaType].placeholderBuffer = 0;
}
Expand Down

0 comments on commit b9be635

Please sign in to comment.