Skip to content

Commit

Permalink
feat: Dash-Industry-Forum#3610 minBufferToKeep
Browse files Browse the repository at this point in the history
  • Loading branch information
orange4glace committed Apr 16, 2021
1 parent 9e1abfc commit 7d5ea48
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.d.ts
Expand Up @@ -117,6 +117,7 @@ declare namespace dashjs {
calcSegmentAvailabilityRangeFromTimeline?: boolean,
bufferPruningInterval?: number;
bufferToKeep?: number;
minBufferToKeep?: number;
jumpGaps?: boolean;
jumpLargeGaps?: boolean;
smallGapLimit?: number;
Expand Down
1 change: 1 addition & 0 deletions samples/dash-if-reference-player/dashjs_config.json
Expand Up @@ -12,6 +12,7 @@
"flushBufferAtTrackSwitch": false,
"bufferPruningInterval": 10,
"bufferToKeep": 20,
"minBufferToKeep": 0,
"jumpGaps": true,
"smallGapLimit": 1.5,
"stableBufferTime": -1,
Expand Down
1 change: 1 addition & 0 deletions samples/offline/dashjs_config.json
Expand Up @@ -11,6 +11,7 @@
"fastSwitchEnabled": false,
"bufferPruningInterval": 10,
"bufferToKeep": 20,
"minBufferToKeep": 0,
"jumpGaps": false,
"smallGapLimit": 0.8,
"stableBufferTime": -1,
Expand Down
4 changes: 4 additions & 0 deletions src/core/Settings.js
Expand Up @@ -66,6 +66,7 @@ import {HTTPRequest} from '../streaming/vo/metrics/HTTPRequest';
* reuseExistingSourceBuffers: true,
* bufferPruningInterval: 10,
* bufferToKeep: 20,
* minBufferToKeep: 0,
* jumpGaps: true,
* jumpLargeGaps: true,
* smallGapLimit: 1.5,
Expand Down Expand Up @@ -322,6 +323,8 @@ import {HTTPRequest} from '../streaming/vo/metrics/HTTPRequest';
*
* Allows you to modify the buffer that is kept in source buffer in seconds.
* 0|-----------bufferToPrune-----------|-----bufferToKeep-----|currentTime|
* @property {boolean} [minBufferToKeep=true]
* bufferToKeep can be changed by internally. Minimum value of bufferToKeep.
* @property {boolean} [jumpGaps=true]
* Sets whether player should jump small gaps (discontinuities) in the buffer.
* @property {boolean} [jumpLargeGaps=true]
Expand Down Expand Up @@ -611,6 +614,7 @@ function Settings() {
reuseExistingSourceBuffers: true,
bufferPruningInterval: 10,
bufferToKeep: 20,
minBufferToKeep: 0,
jumpGaps: true,
jumpLargeGaps: true,
smallGapLimit: 1.5,
Expand Down
2 changes: 1 addition & 1 deletion src/streaming/controllers/BufferController.js
Expand Up @@ -630,7 +630,7 @@ function BufferController(config) {
}

const currentTime = playbackController.getTime();
let startRangeToKeep = Math.max(0, currentTime - settings.get().streaming.bufferToKeep);
let startRangeToKeep = Math.max(0, currentTime - Math.max(settings.get().streaming.minBufferToKeep, settings.get().streaming.bufferToKeep));

const currentTimeRequest = fragmentModel.getRequests({
state: FragmentModel.FRAGMENT_MODEL_EXECUTED,
Expand Down
10 changes: 10 additions & 0 deletions test/unit/streaming.MediaPlayer.js
Expand Up @@ -721,6 +721,16 @@ describe('MediaPlayer', function () {
expect(BufferToKeep).to.equal(50);
});

it('should configure MinBufferToKeep', function () {
let MinBufferToKeep = player.getSettings().streaming.minBufferToKeep;
expect(MinBufferToKeep).to.equal(20);

player.updateSettings({'streaming': {'minBufferToKeep': 50}});

MinBufferToKeep = player.getSettings().streaming.minBufferToKeep;
expect(MinBufferToKeep).to.equal(50);
});

it('should configure BufferPruningInterval', function () {
let BufferPruningInterval = player.getSettings().streaming.bufferPruningInterval;
expect(BufferPruningInterval).to.equal(10);
Expand Down

0 comments on commit 7d5ea48

Please sign in to comment.