Skip to content

Commit

Permalink
Fix presentationDelay being set to NaN.
Browse files Browse the repository at this point in the history
In the DASH parser, if there was no suggestedPresentationDelay and
ignoreMinBufferTime was set to true, the parser would set the
presentationDelay to NaN. This was because Math.max() will return NaN
if undefined is passed into it.
This changes minBufferTime to default to 0, if ignoreMinBufferTime is
true.

Fixes #2015

Change-Id: I8fc61706a04d14fd729e2185ce993a8bc87e48e5
  • Loading branch information
theodab authored and TheModMaker committed Jul 2, 2019
1 parent 1327ab9 commit 1e4e5e3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ shaka.dash.DashParser.prototype.processManifest_ =
manifestBaseUris, uris);

let ignoreMinBufferTime = this.config_.dash.ignoreMinBufferTime;
let minBufferTime;
let minBufferTime = 0;
if (!ignoreMinBufferTime) {
minBufferTime =
XmlUtils.parseAttr(mpd, 'minBufferTime', XmlUtils.parseDuration);
Expand Down
29 changes: 29 additions & 0 deletions test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1215,4 +1215,33 @@ describe('DashParser Manifest', function() {
const minBufferTime = manifest.minBufferTime;
expect(minBufferTime).toEqual(75);
});

it('does not set presentationDelay to NaN', async () => {
// NOTE: This is a regression test for #2015. It ensures that, if
// ignoreMinBufferTime is true and there is no suggestedPresentationDelay,
// we do not erroneously set presentationDelay to NaN.
const manifestText = [
'<MPD minBufferTime="PT75S">',
' <Period id="1" duration="PT30S">',
' <AdaptationSet id="1" mimeType="video/mp4">',
' <Representation id="video-sd" width="640" height="480">',
' <BaseURL>v-sd.mp4</BaseURL>',
' <SegmentBase indexRange="100-200" />',
' </Representation>',
' </AdaptationSet>',
' </Period>',
'</MPD>',
].join('\n');

fakeNetEngine.setResponseText('dummy://foo', manifestText);
const config = shaka.util.PlayerConfiguration.createDefault().manifest;
config.dash.ignoreMinBufferTime = true;
parser.configure(config);

const manifest = await parser.start('dummy://foo', playerInterface);
const presentationTimeline = manifest.presentationTimeline;
const presentationDelay = presentationTimeline.getDelay();
expect(presentationDelay).not.toBeNaN();
expect(presentationDelay).toBe(config.dash.defaultPresentationDelay);
});
});

0 comments on commit 1e4e5e3

Please sign in to comment.