Skip to content

Commit

Permalink
feat: add an option specifying when source buffer removals happen (#6242
Browse files Browse the repository at this point in the history
)

Increases the default required removal duration from `0.01` => `1.0`.

Closes #6240.
  • Loading branch information
JulianDomingo committed Feb 12, 2024
1 parent 83c02b8 commit 93d616e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ shakaDemo.Config = class {
/* canBeDecimal= */ true)
.addNumberInput_('Buffer Behind', 'streaming.bufferBehind',
/* canBeDecimal= */ true)
.addNumberInput_('Eviction Goal', 'streaming.evictionGoal',
/* canBeDecimal= */ true)
.addNumberInput_('Safe Seek Offset', 'streaming.safeSeekOffset',
/* canBeDecimal= */ true)
.addNumberInput_('Stall Threshold', 'streaming.stallThreshold',
Expand Down
5 changes: 5 additions & 0 deletions externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ shaka.extern.ManifestConfiguration;
* rebufferingGoal: number,
* bufferingGoal: number,
* bufferBehind: number,
* evictionGoal: number,
* ignoreTextStreamFailures: boolean,
* alwaysStreamText: boolean,
* startAtSegmentBoundary: boolean,
Expand Down Expand Up @@ -1198,6 +1199,10 @@ shaka.extern.ManifestConfiguration;
* The maximum number of seconds of content that the StreamingEngine will keep
* in buffer behind the playhead when it appends a new media segment.
* The StreamingEngine will evict content to meet this limit.
* @property {number} evictionGoal
* The minimum duration in seconds of buffer overflow the StreamingEngine
* requires to start removing content from the buffer.
* Values less than <code>1.0</code> are not recommended.
* @property {boolean} ignoreTextStreamFailures
* If <code>true</code>, the player will ignore text stream failures and
* continue playing other streams.
Expand Down
6 changes: 4 additions & 2 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2346,13 +2346,14 @@ shaka.media.StreamingEngine = class {
const bufferedBehind = presentationTime - startTime;

const overflow = bufferedBehind - bufferBehind;
// See: https://github.com/shaka-project/shaka-player/issues/2982
if (overflow <= 0.01) {
// See: https://github.com/shaka-project/shaka-player/issues/6240
if (overflow <= this.config_.evictionGoal) {
shaka.log.v2(logPrefix,
'buffer behind okay:',
'presentationTime=' + presentationTime,
'bufferedBehind=' + bufferedBehind,
'bufferBehind=' + bufferBehind,
'evictionGoal=' + this.config_.evictionGoal,
'underflow=' + Math.abs(overflow));
return;
}
Expand All @@ -2362,6 +2363,7 @@ shaka.media.StreamingEngine = class {
'presentationTime=' + presentationTime,
'bufferedBehind=' + bufferedBehind,
'bufferBehind=' + bufferBehind,
'evictionGoal=' + this.config_.evictionGoal,
'overflow=' + overflow);

await this.playerInterface_.mediaSourceEngine.remove(mediaState.type,
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ shaka.util.PlayerConfiguration = class {
rebufferingGoal: 2,
bufferingGoal: 10,
bufferBehind: 30,
evictionGoal: 1,
ignoreTextStreamFailures: false,
alwaysStreamText: false,
startAtSegmentBoundary: false,
Expand Down

0 comments on commit 93d616e

Please sign in to comment.