fix(DASH): Segments being fetched out of the range of the timeline (#5889)

Fixes: https://github.com/shaka-project/shaka-player/issues/3952
This commit is contained in:
Dave Nicholas
2023-11-16 08:48:12 +00:00
committed by GitHub
parent 8e0ee8a8a7
commit d8aa24f41d
5 changed files with 12 additions and 5 deletions
+1
View File
@@ -7,3 +7,4 @@ coverage/
.DS_Store
.vscode
.babel-cache
.idea/
+4 -2
View File
@@ -128,11 +128,12 @@ shaka.dash.MpdUtils = class {
* @param {number} unscaledPresentationTimeOffset
* @param {number} periodDuration The Period's duration in seconds.
* Infinity indicates that the Period continues indefinitely.
* @param {number} startNumber
* @return {!Array.<shaka.media.PresentationTimeline.TimeRange>}
*/
static createTimeline(
segmentTimeline, timescale, unscaledPresentationTimeOffset,
periodDuration) {
periodDuration, startNumber) {
goog.asserts.assert(
timescale > 0 && timescale < Infinity,
'timescale must be a positive, finite integer');
@@ -243,6 +244,7 @@ shaka.dash.MpdUtils = class {
end: endTime / timescale,
unscaledStart: startTime,
partialSegments: partialSegments,
segmentPosition: timeline.length + startNumber,
};
timeline.push(item);
@@ -306,7 +308,7 @@ shaka.dash.MpdUtils = class {
if (timelineNode) {
timeline = MpdUtils.createTimeline(
timelineNode, timescale, unscaledPresentationTimeOffset,
context.periodInfo.duration || Infinity);
context.periodInfo.duration || Infinity, startNumber);
}
const scaledPresentationTimeOffset =
+1 -1
View File
@@ -820,7 +820,7 @@ shaka.dash.TimelineSegmentIndex = class extends shaka.media.SegmentIndex {
if (!ref) {
const mediaTemplate = this.templateInfo_.mediaTemplate;
const range = this.templateInfo_.timeline[correctedPosition];
const segmentReplacement = position + this.templateInfo_.startNumber;
const segmentReplacement = range.segmentPosition;
const timeReplacement = this.templateInfo_
.unscaledPresentationTimeOffset + range.unscaledStart;
const timestampOffset = this.periodStart_ -
+4 -1
View File
@@ -620,7 +620,8 @@ shaka.media.PresentationTimeline = class {
* start: number,
* unscaledStart: number,
* end: number,
* partialSegments: number
* partialSegments: number,
* segmentPosition: number
* }}
*
* @description
@@ -634,6 +635,8 @@ shaka.media.PresentationTimeline = class {
* The end time (exclusive) of the range.
* @property {number} partialSegments
* The number of partial segments
* @property {number} segmentPosition
* The segment position of the timeline entry as it appears in the manifest
*
* @export
*/
+2 -1
View File
@@ -459,7 +459,8 @@ describe('MpdUtils', () => {
console.assert(segmentTimeline);
const timeline = MpdUtils.createTimeline(
segmentTimeline, timescale, presentationTimeOffset, periodDuration);
segmentTimeline, timescale, presentationTimeOffset,
periodDuration, 0);
expect(timeline).toEqual(
expected.map((c) => jasmine.objectContaining(c)));
}