Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: seeking in segment timeline returns incorrect index #5716

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/media/segment_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ shaka.media.MetaSegmentIndex = class extends shaka.media.SegmentIndex {
}

numPassedInEarlierIndexes += index.numEvicted_ +
index.references.length;
index.getNumReferences();
}

return null;
Expand All @@ -732,9 +732,9 @@ shaka.media.MetaSegmentIndex = class extends shaka.media.SegmentIndex {
return reference;
}

numPassedInEarlierIndexes += index.numEvicted_ +
index.references.length;
sawSegments = sawSegments || index.references.length != 0;
const num = index.getNumReferences();
numPassedInEarlierIndexes += index.numEvicted_ + num;
sawSegments = sawSegments || num != 0;
}

return null;
Expand Down
42 changes: 42 additions & 0 deletions test/dash/dash_parser_segment_template_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,48 @@ describe('DashParser SegmentTemplate', () => {
expect(pos).toBe(1);
});

it('finds correct position in multiperiod content', async () => {
const source = [
'<MPD type="static" availabilityStartTime="1970-01-01T00:00:00Z">',
' <Period duration="PT30S">',
' <AdaptationSet mimeType="video/mp4">',
' <Representation bandwidth="500">',
' <BaseURL>http://example.com</BaseURL>',
' <SegmentTemplate startNumber="0"',
' media="$Number$-$Time$-$Bandwidth$.mp4">',
' <SegmentTimeline>',
' <S t="0" d="5" r="6" />',
' </SegmentTimeline>',
' </SegmentTemplate>',
' </Representation>',
' </AdaptationSet>',
' </Period>',
' <Period duration="PT30S">',
' <AdaptationSet mimeType="video/mp4">',
' <Representation bandwidth="500">',
' <BaseURL>http://example.com</BaseURL>',
' <SegmentTemplate startNumber="6"',
' media="$Number$-$Time$-$Bandwidth$.mp4">',
' <SegmentTimeline>',
' <S t="0" d="5" r="6" />',
' </SegmentTimeline>',
' </SegmentTemplate>',
' </Representation>',
' </AdaptationSet>',
' </Period>',
'</MPD>',
].join('\n');

fakeNetEngine.setResponseText('dummy://foo', source);
const manifest = await parser.start('dummy://foo', playerInterface);
const stream = manifest.variants[0].video;
await stream.createSegmentIndex();

// simulate a seek into the second period
const segmentIterator = stream.segmentIndex.getIteratorForTime(42);
const ref = segmentIterator.next().value;
expect(ref.startTime).toBe(40);
});

it('returns null if time === last end time', async () => {
const info = makeTemplateInfo(makeRanges(0, 2.0, 2));
Expand Down