mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-13 15:46:46 +03:00
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:
@@ -7,3 +7,4 @@ coverage/
|
||||
.DS_Store
|
||||
.vscode
|
||||
.babel-cache
|
||||
.idea/
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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_ -
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user