Skip to content

Commit b9eabe5

Browse files
authored
fix(DASH): Change fallback presentation delay (#7918)
Previously, if the presentation delay was not specified either by the manifest or by configuration, we defaulted to 1.5 * minBufferTime. That approach worked for most content, but in some cases it could cause live streams to start out with a seekRangeEnd that was before the live edge. This would lead to a brief pause in the beginning of the presentation, while the live edge caught up. This changes the DASH parser to use the segmentAvailabilityDuration if it is lower than 1.5 * minBufferTime, which fixes that issue. It also changes how that part of the code to be formatted, in order to hopefully make the increasingly-complex logic for determining the presentation delay more clear.
1 parent 19bd472 commit b9eabe5

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

externs/shaka/player.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,8 @@ shaka.extern.MssManifestConfiguration;
14101410
* @property {number} defaultPresentationDelay
14111411
* For DASH, it's a default <code>presentationDelay</code> value if
14121412
* <code>suggestedPresentationDelay</code> is missing in the MPEG DASH
1413-
* manifest. The default value is <code>1.5 * minBufferTime</code> if not
1413+
* manifest. The default value is the lower of <code>1.5 *
1414+
* minBufferTime</code> and <code>segmentAvailabilityDuration</code> if not
14141415
* configured or set as 0.
14151416
* For HLS, the default value is 3 segments duration if not configured or
14161417
* set as 0.

lib/dash/dash_parser.js

+21-11
Original file line numberDiff line numberDiff line change
@@ -707,18 +707,28 @@ shaka.dash.DashParser = class {
707707
// feasible choices for the value. Nothing older than
708708
// timeShiftBufferDepth is still available, and anything less than
709709
// minBufferTime will cause buffering issues.
710-
//
711-
// We have decided that our default will be the configured value, or
712-
// 1.5 * minBufferTime if not configured. This is fairly conservative.
713-
// Content providers should provide a suggestedPresentationDelay whenever
714-
// possible to optimize the live streaming experience.
715-
const defaultPresentationDelay =
716-
this.config_.defaultPresentationDelay || minBufferTime * 1.5;
717-
const presentationDelay = suggestedPresentationDelay != null ?
718-
suggestedPresentationDelay : defaultPresentationDelay;
710+
let delay = 0;
711+
if (suggestedPresentationDelay != null) {
712+
// 1. If a suggestedPresentationDelay is provided by the manifest, that
713+
// will be used preferentially.
714+
// This is given a minimum bound of segmentAvailabilityDuration.
715+
// Content providers should provide a suggestedPresentationDelay
716+
// whenever possible to optimize the live streaming experience.
717+
delay = Math.min(
718+
suggestedPresentationDelay,
719+
segmentAvailabilityDuration || Infinity);
720+
} else if (this.config_.defaultPresentationDelay > 0) {
721+
// 2. If the developer provides a value for
722+
// "manifest.defaultPresentationDelay", that is used as a fallback.
723+
delay = this.config_.defaultPresentationDelay;
724+
} else {
725+
// 3. Otherwise, we default to the lower of segmentAvailabilityDuration
726+
// and 1.5 * minBufferTime. This is fairly conservative.
727+
delay = Math.min(
728+
minBufferTime * 1.5, segmentAvailabilityDuration || Infinity);
729+
}
719730
presentationTimeline = new shaka.media.PresentationTimeline(
720-
presentationStartTime, presentationDelay,
721-
this.config_.dash.autoCorrectDrift);
731+
presentationStartTime, delay, this.config_.dash.autoCorrectDrift);
722732
}
723733

724734
presentationTimeline.setStatic(mpdType == 'static');

0 commit comments

Comments
 (0)