Skip to content

Commit

Permalink
chore: add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
littlespex committed Oct 3, 2023
1 parent 71a0f63 commit 102e8ec
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/media/segment_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,9 @@ shaka.media.MetaSegmentIndex = class extends shaka.media.SegmentIndex {
return reference;
}

numPassedInEarlierIndexes += index.numEvicted_ +
index.getNumReferences();
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

0 comments on commit 102e8ec

Please sign in to comment.