Skip to content

Commit

Permalink
feat(dash): Add support for mpegB:cicp:ChannelConfiguration (shaka-pr…
Browse files Browse the repository at this point in the history
  • Loading branch information
Álvaro Velad Galván authored Dec 23, 2020
1 parent e68ac92 commit 607deb7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,26 @@ shaka.dash.DashParser = class {
return numBits;
}

// Defined by https://dashif.org/identifiers/audio_source_metadata/ and clause 8.2, in ISO/IEC 23001-8.
case 'urn:mpeg:mpegB:cicp:ChannelConfiguration': {
const noValue = 0;
const channelCountMapping = [
noValue, 1, 2, 3, 4, 5, 6, 8, 2, 3, /* 0--9 */
4, 7, 8, 24, 8, 12, 10, 12, 14, 12, /* 10--19 */
14, /* 20 */
];
const intValue = parseInt(value, 10);
if (!intValue) { // 0 or NaN
shaka.log.warning('Channel parsing failure! ' +
'Ignoring scheme and value', scheme, value);
continue;
}
if (intValue > noValue && intValue < channelCountMapping.length) {
return channelCountMapping[intValue];
}
continue;
}

default:
shaka.log.warning(
'Unrecognized audio channel scheme:', scheme, value);
Expand Down
18 changes: 18 additions & 0 deletions test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,24 @@ describe('DashParser Manifest', () => {
{'urn:dolby:dash:audio_channel_configuration:2011': 'x'});
});

it('parses MPEG channel configuration scheme', async () => {
// Parses a simple channel count.
await testAudioChannelConfiguration(2,
{'urn:mpeg:mpegB:cicp:ChannelConfiguration': '2'});

// Parses a high channel count.
await testAudioChannelConfiguration(24,
{'urn:mpeg:mpegB:cicp:ChannelConfiguration': '13'});

// Results in null if the value is not an integer.
await testAudioChannelConfiguration(null,
{'urn:mpeg:mpegB:cicp:ChannelConfiguration': 'foo'});

// Results in null if the value is not in a spec range.
await testAudioChannelConfiguration(null,
{'urn:mpeg:mpegB:cicp:ChannelConfiguration': '100'});
});

it('ignores unrecognized schemes', async () => {
await testAudioChannelConfiguration(null, {'foo': 'bar'});

Expand Down

0 comments on commit 607deb7

Please sign in to comment.