Skip to content

Commit

Permalink
fix parsing of HLS 'DEFAULT' attribute so variants can correctly be i…
Browse files Browse the repository at this point in the history
…dentified as primary, preventing arbitrary language selection in playlists with multiple variants
  • Loading branch information
Cruikshank, Patrick (pc386g) committed Nov 24, 2021
1 parent fb90679 commit 27b37dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ shaka.hls.HlsParser = class {
// "AUTOSELECT=YES". A value of "AUTOSELECT=NO" would imply that it may
// only be selected explicitly by the user, and we don't have a way to
// represent that in our model.
const defaultAttrValue = tag.getAttribute('DEFAULT');
const defaultAttrValue = tag.getAttributeValue('DEFAULT');
const primary = defaultAttrValue == 'YES';

const channelsCount = type == 'audio' ? this.getChannelsCount_(tag) : null;
Expand Down
4 changes: 3 additions & 1 deletion test/hls/hls_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ describe('HlsParser', () => {
'RESOLUTION=960x540,FRAME-RATE=120,AUDIO="aud2"\n',
'video2\n',
'#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud1",LANGUAGE="eng",',
'URI="audio"\n',
'DEFAULT=YES,URI="audio"\n',
'#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud2",LANGUAGE="fr",',
'URI="audio2"\n',
].join('');
Expand All @@ -803,6 +803,7 @@ describe('HlsParser', () => {
manifest.anyTimeline();
manifest.addPartialVariant((variant) => {
variant.bandwidth = 200;
variant.primary = true;
variant.addPartialStream(ContentType.VIDEO, (stream) => {
stream.size(960, 540);
});
Expand All @@ -812,6 +813,7 @@ describe('HlsParser', () => {
});
manifest.addPartialVariant((variant) => {
variant.bandwidth = 300;
variant.primary = false;
variant.addPartialStream(ContentType.VIDEO, (stream) => {
stream.size(960, 540);
});
Expand Down

0 comments on commit 27b37dc

Please sign in to comment.