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
  • Loading branch information
leonchen authored and joeyparrish committed Jan 8, 2020
1 parent 7875619 commit c6f0a86
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
1 change: 1 addition & 0 deletions demo/common/message_ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ shakaDemo.MessageIds = {
AUTO_CORRECT_DASH_DRIFT: 'DEMO_AUTO_CORRECT_DASH_DRIFT',
XLINK_FAIL_GRACEFULLY: 'DEMO_XLINK_FAIL_GRACEFULLY',
IGNORE_DASH_SUGGESTED_PRESENTATION_DELAY: 'DEMO_IGNORE_DASH_SUGGESTED_PRESENTATION_DELAY',
IGNORE_DASH_EMPTY_ADAPTATION_SET: 'DEMO_IGNORE_DASH_EMPTY_ADAPTATION_SET',
IGNORE_HLS_TEXT_FAILURES: 'DEMO_IGNORE_HLS_TEXT_FAILURES',
AVAILABILITY_WINDOW_OVERRIDE: 'DEMO_AVAILABILITY_WINDOW_OVERRIDE',
CLOCK_SYNC_URI: 'DEMO_CLOCK_SYNC_URI',
Expand Down
2 changes: 2 additions & 0 deletions demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ shakaDemo.Config = class {
'manifest.dash.xlinkFailGracefully')
.addBoolInput_(MessageIds.IGNORE_DASH_SUGGESTED_PRESENTATION_DELAY,
'manifest.dash.ignoreSuggestedPresentationDelay')
.addBoolInput_(MessageIds.IGNORE_DASH_EMPTY_ADAPTATION_SET,
'manifest.dash.ignoreEmptyAdaptationSet')
.addBoolInput_(MessageIds.IGNORE_HLS_TEXT_FAILURES,
'manifest.hls.ignoreTextStreamFailures')
.addNumberInput_(MessageIds.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 @@ -539,7 +539,8 @@ shaka.extern.DrmConfiguration;
* ignoreMinBufferTime: boolean,
* autoCorrectDrift: boolean,
* initialSegmentLimit: number,
* ignoreSuggestedPresentationDelay: boolean
* ignoreSuggestedPresentationDelay: boolean,
* ignoreEmptyAdaptationSet: boolean
* }}
*
* @property {shaka.extern.DashContentProtectionCallback} customScheme
Expand Down Expand Up @@ -583,6 +584,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
5 changes: 3 additions & 2 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,9 @@ shaka.dash.DashParser = class {
}).filter((s) => !!s);

if (streams.length == 0) {
// Ignore empty AdaptationSets if they are for text content.
if (isText) {
// Ignore empty AdaptationSets if ignoreEmptyAdaptationSet is true
// or they are for text content.
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 @@ -94,6 +94,7 @@ shaka.util.PlayerConfiguration = class {
autoCorrectDrift: true,
initialSegmentLimit: 1000,
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 @@ -1430,6 +1430,32 @@ describe('DashParser Manifest', () => {
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 c6f0a86

Please sign in to comment.