Skip to content

Commit

Permalink
add manifest.dash.ignoreEmptyAdaptationSet config option (#2330)
Browse files Browse the repository at this point in the history
Closes #2023

Backported to v2.5.x

Change-Id: I3a0402e7f2caf46f72e4adee5e4eb82dfed332ef
  • Loading branch information
leonchen authored and joeyparrish committed Jan 15, 2020
1 parent 9273b86 commit bd3cbc2
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ shakaDemo.Config = class {
'manifest.dash.autoCorrectDrift')
.addBoolInput_('Xlink Should Fail Gracefully',
'manifest.dash.xlinkFailGracefully')
.addBoolInput_('Ignore DASH Suggested Presentation Delay',
'manifest.dash.ignoreSuggestedPresentationDelay')
.addBoolInput_('Ignore DASH Empty Adaptation Set',
'manifest.dash.ignoreEmptyAdaptationSet')
.addBoolInput_('Ignore HLS Text Stream Failures',
'manifest.hls.ignoreTextStreamFailures')
.addNumberInput_('Availability Window Override',
Expand Down
7 changes: 6 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,8 @@ shaka.extern.DrmConfiguration;
* defaultPresentationDelay: number,
* ignoreMinBufferTime: boolean,
* autoCorrectDrift: boolean,
* ignoreSuggestedPresentationDelay: boolean
* ignoreSuggestedPresentationDelay: boolean,
* ignoreEmptyAdaptationSet: boolean
* }}
*
* @property {shaka.extern.DashContentProtectionCallback} customScheme
Expand Down Expand Up @@ -597,6 +598,10 @@ shaka.extern.DrmConfiguration;
* If true will cause DASH parser to ignore
* <code>suggestedPresentationDelay</code> from manifest. Defaults to
* <code>false</code> if not provided.
* @property {boolean} ignoreEmptyAdaptationSet
* If true will cause DASH parser to ignore
* empty <code>AdaptationSet</code> from manifest. Defaults to
* <code>false</code> if not provided.
* @exportDoc
*/
shaka.extern.DashManifestConfiguration;
Expand Down
4 changes: 2 additions & 2 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,8 @@ shaka.dash.DashParser.prototype.parseAdaptationSet_ = function(context, elem) {
.filter(function(s) { return !!s; });

if (streams.length == 0) {
// Ignore empty AdaptationSets if they are for text content.
if (isText) {
// Ignore empty AdaptationSets if ignoreEmptyAdaptationSet is true
if (this.config_.dash.ignoreEmptyAdaptationSet || isText) {
return null;
}
throw new shaka.util.Error(
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ shaka.util.PlayerConfiguration = class {
ignoreMinBufferTime: false,
autoCorrectDrift: true,
ignoreSuggestedPresentationDelay: false,
ignoreEmptyAdaptationSet: false,
},
hls: {
ignoreTextStreamFailures: false,
Expand Down
26 changes: 26 additions & 0 deletions test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,32 @@ describe('DashParser Manifest', function() {
expect(presentationDelay).toBe(config.dash.defaultPresentationDelay);
});

it('Honors the ignoreEmptyAdaptationSet config', async () => {
const manifestText = [
'<MPD minBufferTime="PT2S" suggestedPresentationDelay="PT25S">',
' <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>',
' <AdaptationSet id="2" mimeType="audio/mp4">',
' </AdaptationSet>',
' </Period>',
'</MPD>',
].join('\n');

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

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

it('converts Accessibility element to "kind"', async () => {
const manifestText = [
'<MPD minBufferTime="PT75S">',
Expand Down

0 comments on commit bd3cbc2

Please sign in to comment.