Skip to content

Commit

Permalink
fix(DASH): Fix bad segment URLs in SegmentTimeline
Browse files Browse the repository at this point in the history
When Representations have different BaseURLs, segment URLs generated
for SegmentTimeline were always using the BaseURL of the last
Representation because the wrong parsing context was being used.  This
fixes the issue and adds a regression test.

This only affected v3.0.0.

Closes shaka-project#2650

Change-Id: I04df950b5d3205e102f9c74f52ece9773ce92282
  • Loading branch information
joeyparrish committed Jun 15, 2020
1 parent 1ce2aa8 commit 486123c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dash/segment_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ shaka.dash.SegmentTemplate = class {
}

const references = SegmentTemplate.createFromTimeline_(
context, info, initSegmentReference);
shallowCopyOfContext, info, initSegmentReference);

const periodStart = context.periodInfo.start;
const periodEnd = context.periodInfo.duration ?
Expand Down
45 changes: 45 additions & 0 deletions test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1583,4 +1583,49 @@ describe('DashParser Manifest', () => {
expect(variant.audio).toBeTruthy();
expect(variant.video).toBeTruthy();
});

// Regression #2650 in v3.0.0
// A later BaseURL was being applied to earlier Representations, specifically
// in the context of SegmentTimeline.
it('uses the correct BaseURL for SegmentTimeline', async () => {
const manifestText = [
'<MPD type="static">',
' <Period id="1" duration="PT30S">',
' <AdaptationSet id="2" mimeType="video/mp4">',
' <SegmentTemplate media="$Number$.mp4" startNumber="1">',
' <SegmentTimeline>',
' <S t="0" d="30" />',
' </SegmentTimeline>',
' </SegmentTemplate>',
' <Representation id="video-sd" width="640" height="480">',
' <BaseURL>http://example.com/r0/</BaseURL>',
' </Representation>',
' <Representation id="video-hd" width="1920" height="1080">',
' <BaseURL>http://example.com/r1/</BaseURL>',
' </Representation>',
' </AdaptationSet>',
' </Period>',
'</MPD>',
].join('\n');

fakeNetEngine.setResponseText('dummy://foo', manifestText);

/** @type {shaka.extern.Manifest} */
const manifest = await parser.start('dummy://foo', playerInterface);

const video0 = manifest.variants[0].video;
await video0.createSegmentIndex();
goog.asserts.assert(video0.segmentIndex, 'Null segmentIndex!');
const segment0 = Array.from(video0.segmentIndex)[0];
const uri0 = segment0.getUris()[0];

const video1 = manifest.variants[1].video;
await video1.createSegmentIndex();
goog.asserts.assert(video1.segmentIndex, 'Null segmentIndex!');
const segment1 = Array.from(video1.segmentIndex)[0];
const uri1 = segment1.getUris()[0];

expect(uri0).toBe('http://example.com/r0/1.mp4');
expect(uri1).toBe('http://example.com/r1/1.mp4');
});
});

0 comments on commit 486123c

Please sign in to comment.