From b9be63508b26fdb1cefe48ae242b43c2f134e270 Mon Sep 17 00:00:00 2001 From: Bertrand Berthelot Date: Wed, 23 Mar 2022 10:58:08 +0100 Subject: [PATCH] Fix BOLA rule on track switch (#3884) * 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) --- src/streaming/rules/abr/BolaRule.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/streaming/rules/abr/BolaRule.js b/src/streaming/rules/abr/BolaRule.js index 21fc7ddf9d..cbc80d7b09 100644 --- a/src/streaming/rules/abr/BolaRule.js +++ b/src/streaming/rules/abr/BolaRule.js @@ -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. @@ -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; }