Skip to content

Commit 63719e6

Browse files
tykus160avelad
authored andcommitted
fix(DASH): Always fit segments to period boundaries on VOD (#8825)
Fixes #8774
1 parent 9c93bf2 commit 63719e6

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/dash/segment_template.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ shaka.dash.SegmentTemplate = class {
173173

174174
shaka.log.debug(`Creating TSI with end ${periodEnd}`);
175175
segmentIndex = new TimelineSegmentIndex(
176+
context.dynamic,
176177
info,
177178
context.representation.originalId,
178179
context.bandwidth,
@@ -188,7 +189,8 @@ shaka.dash.SegmentTemplate = class {
188189
} else {
189190
const tsi = /** @type {!TimelineSegmentIndex} */(segmentIndex);
190191
tsi.appendTemplateInfo(
191-
info, periodStart, periodEnd, initSegmentReference);
192+
info, periodStart, periodEnd, initSegmentReference,
193+
context.dynamic);
192194

193195
const availabilityStart =
194196
context.presentationTimeline.getSegmentAvailabilityStart();
@@ -232,7 +234,7 @@ shaka.dash.SegmentTemplate = class {
232234
if (segmentIndex instanceof shaka.dash.TimelineSegmentIndex &&
233235
segmentIndex.isEmpty()) {
234236
segmentIndex.appendTemplateInfo(info, periodStart,
235-
periodEnd, initSegmentReference);
237+
periodEnd, initSegmentReference, context.dynamic);
236238
}
237239
return Promise.resolve(segmentIndex);
238240
},
@@ -778,7 +780,7 @@ shaka.dash.SegmentTemplate = class {
778780
*/
779781
shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
780782
/**
781-
*
783+
* @param {boolean} dynamic
782784
* @param {!shaka.dash.SegmentTemplate.SegmentTemplateInfo} templateInfo
783785
* @param {?string} representationId
784786
* @param {number} bandwidth
@@ -791,11 +793,14 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
791793
* @param {number} segmentSequenceCadence
792794
* @param {number} timeline
793795
*/
794-
constructor(templateInfo, representationId, bandwidth, getBaseUris,
796+
constructor(dynamic, templateInfo, representationId, bandwidth, getBaseUris,
795797
urlParams, periodStart, periodEnd, initSegmentReference,
796798
aesKey, segmentSequenceCadence, timeline) {
797799
super([]);
798800

801+
/** @private {boolean} */
802+
this.dynamic_ = dynamic;
803+
799804
/** @private {?shaka.dash.SegmentTemplate.SegmentTemplateInfo} */
800805
this.templateInfo_ = templateInfo;
801806

@@ -897,9 +902,12 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
897902
* @param {number} periodStart
898903
* @param {number} periodEnd
899904
* @param {shaka.media.InitSegmentReference} initSegmentReference
905+
* @param {boolean} dynamic
900906
*/
901-
appendTemplateInfo(info, periodStart, periodEnd, initSegmentReference) {
907+
appendTemplateInfo(info, periodStart, periodEnd, initSegmentReference,
908+
dynamic) {
902909
this.updateInitSegmentReference(initSegmentReference);
910+
this.dynamic_ = dynamic;
903911
if (!this.templateInfo_) {
904912
this.templateInfo_ = info;
905913
this.periodStart_ = periodStart;
@@ -1091,7 +1099,7 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
10911099
if (correctedPosition === this.getNumReferences() - 1 &&
10921100
this.periodEnd_ !== Infinity) {
10931101
// See https://github.com/shaka-project/shaka-player/issues/8672
1094-
if (Math.abs(segmentEnd - this.periodEnd_) > 0.1) {
1102+
if (this.dynamic_ && Math.abs(segmentEnd - this.periodEnd_) > 0.1) {
10951103
segmentEnd = Math.min(segmentEnd, this.periodEnd_);
10961104
} else {
10971105
segmentEnd = this.periodEnd_;

0 commit comments

Comments
 (0)