Skip to content

Commit ed222f5

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

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
@@ -134,6 +134,7 @@ shaka.dash.SegmentTemplate = class {
134134
if (!segmentIndex) {
135135
shaka.log.debug(`Creating TSI with end ${periodEnd}`);
136136
segmentIndex = new TimelineSegmentIndex(
137+
context.dynamic,
137138
info,
138139
context.representation.originalId,
139140
context.bandwidth,
@@ -148,7 +149,8 @@ shaka.dash.SegmentTemplate = class {
148149
} else {
149150
const tsi = /** @type {!TimelineSegmentIndex} */(segmentIndex);
150151
tsi.appendTemplateInfo(
151-
info, periodStart, periodEnd, initSegmentReference);
152+
info, periodStart, periodEnd, initSegmentReference,
153+
context.dynamic);
152154

153155
const availabilityStart =
154156
context.presentationTimeline.getSegmentAvailabilityStart();
@@ -178,7 +180,7 @@ shaka.dash.SegmentTemplate = class {
178180
if (segmentIndex instanceof shaka.dash.TimelineSegmentIndex &&
179181
segmentIndex.isEmpty()) {
180182
segmentIndex.appendTemplateInfo(info, periodStart,
181-
periodEnd, initSegmentReference);
183+
periodEnd, initSegmentReference, context.dynamic);
182184
}
183185
return Promise.resolve(segmentIndex);
184186
},
@@ -723,7 +725,7 @@ shaka.dash.SegmentTemplate = class {
723725
*/
724726
shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
725727
/**
726-
*
728+
* @param {boolean} dynamic
727729
* @param {!shaka.dash.SegmentTemplate.SegmentTemplateInfo} templateInfo
728730
* @param {?string} representationId
729731
* @param {number} bandwidth
@@ -735,11 +737,14 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
735737
* @param {shaka.extern.aesKey|undefined} aesKey
736738
* @param {number} segmentSequenceCadence
737739
*/
738-
constructor(templateInfo, representationId, bandwidth, getBaseUris,
740+
constructor(dynamic, templateInfo, representationId, bandwidth, getBaseUris,
739741
urlParams, periodStart, periodEnd, initSegmentReference,
740742
aesKey, segmentSequenceCadence) {
741743
super([]);
742744

745+
/** @private {boolean} */
746+
this.dynamic_ = dynamic;
747+
743748
/** @private {?shaka.dash.SegmentTemplate.SegmentTemplateInfo} */
744749
this.templateInfo_ = templateInfo;
745750

@@ -839,9 +844,12 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
839844
* @param {number} periodStart
840845
* @param {number} periodEnd
841846
* @param {shaka.media.InitSegmentReference} initSegmentReference
847+
* @param {boolean} dynamic
842848
*/
843-
appendTemplateInfo(info, periodStart, periodEnd, initSegmentReference) {
849+
appendTemplateInfo(info, periodStart, periodEnd, initSegmentReference,
850+
dynamic) {
844851
this.updateInitSegmentReference(initSegmentReference);
852+
this.dynamic_ = dynamic;
845853
if (!this.templateInfo_) {
846854
this.templateInfo_ = info;
847855
this.periodStart_ = periodStart;
@@ -1033,7 +1041,7 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
10331041
if (correctedPosition === this.getNumReferences() - 1 &&
10341042
this.periodEnd_ !== Infinity) {
10351043
// See https://github.com/shaka-project/shaka-player/issues/8672
1036-
if (Math.abs(segmentEnd - this.periodEnd_) > 0.1) {
1044+
if (this.dynamic_ && Math.abs(segmentEnd - this.periodEnd_) > 0.1) {
10371045
segmentEnd = Math.min(segmentEnd, this.periodEnd_);
10381046
} else {
10391047
segmentEnd = this.periodEnd_;

0 commit comments

Comments
 (0)