Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Set segmentPrefetchLimit to 2 by default for low latency streaming #5275

Merged
merged 2 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions docs/tutorials/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,20 @@ buffering settings) while some will not have any effect until the next call to
#### Low latency streaming

With `.streaming.lowLatencyMode` set to true,
`.streaming.inaccurateManifestTolerance` is set to 0 by default, and
`.streaming.rebufferingGoal` is set to 0.01 by default.
`.streaming.inaccurateManifestTolerance` is set to 0 by default,
`.streaming.rebufferingGoal` is set to 0.01 by default, and
`.streaming.segmentPrefetchLimit` is set to 2 by default.

To customize the values of inaccurateManifestTolerance and rebufferingGoal
with low latency mode, you can set the fields in the same or subsequent
call to configure().
To customize the values of inaccurateManifestTolerance, rebufferingGoal and
segmentPrefetchLimit with low latency mode, you can set the fields in the same
or subsequent call to configure().
```js
player.configure({
streaming: {
lowLatencyMode: true,
inaccurateManifestTolerance: 0,
rebufferingGoal: 0.01,
segmentPrefetchLimit: 2,
}
});

Expand Down
8 changes: 6 additions & 2 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -3205,15 +3205,19 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
}

// If lowLatencyMode is enabled, and inaccurateManifestTolerance and
// rebufferingGoal are not specified, set inaccurateManifestTolerance to 0
// and rebufferingGoal to 0.01 by default for low latency streaming.
// rebufferingGoal and segmentPrefetchLimit are not specified, set
// inaccurateManifestTolerance to 0 and rebufferingGoal to 0.01 and
// segmentPrefetchLimit to 2 by default for low latency streaming.
if (config['streaming'] && config['streaming']['lowLatencyMode']) {
if (config['streaming']['inaccurateManifestTolerance'] == undefined) {
config['streaming']['inaccurateManifestTolerance'] = 0;
}
if (config['streaming']['rebufferingGoal'] == undefined) {
config['streaming']['rebufferingGoal'] = 0.01;
}
if (config['streaming']['segmentPrefetchLimit'] == undefined) {
config['streaming']['segmentPrefetchLimit'] = 2;
}
}
const ret = shaka.util.PlayerConfiguration.mergeConfigObjects(
this.config_, config, this.defaultConfig_());
Expand Down
2 changes: 2 additions & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ shaka.util.PlayerConfiguration = class {
observeQualityChanges: false,
maxDisabledTime: 30,
parsePrftBox: false,
// When low latency streaming is enabled, segmentPrefetchLimit will
// default to 2 if not specified.
segmentPrefetchLimit: 0,
};

Expand Down
8 changes: 6 additions & 2 deletions test/player_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1291,19 +1291,23 @@ describe('Player', () => {
lowLatencyMode: true,
rebufferingGoal: 1,
inaccurateManifestTolerance: 1,
segmentPrefetchLimit: 1,
},
});
expect(player.getConfiguration().streaming.rebufferingGoal).toBe(1);
expect(player.getConfiguration().streaming.inaccurateManifestTolerance)
.toBe(1);
expect(player.getConfiguration().streaming.segmentPrefetchLimit).toBe(1);

// When low latency streaming gets enabled, rebufferingGoal will default
// to 0.01 if unless specified, and inaccurateManifestTolerance will
// default to 0 unless specified.
// to 0.01 if unless specified, inaccurateManifestTolerance will
// default to 0 unless specified, and segmentPrefetchLimit will
// default to 2 unless specified.
player.configure('streaming.lowLatencyMode', true);
expect(player.getConfiguration().streaming.rebufferingGoal).toBe(0.01);
expect(player.getConfiguration().streaming.inaccurateManifestTolerance)
.toBe(0);
expect(player.getConfiguration().streaming.segmentPrefetchLimit).toBe(2);
});
});

Expand Down