Skip to content

Commit

Permalink
fix(HLS): Fix interpretation of DEFAULT and AUTOSELECT
Browse files Browse the repository at this point in the history
Previously, we treated the mere presense of either the DEFAULT or
AUTOSELECT attributes as an indication of a primary language.
However, AUTOSELECT should not be used in this way at all, and both
attributes can have a value of NO, so mere presence or absence is not
enough.

Instead, we must check for DEFAULT=YES to indicate a primary language.

Fixes shaka-project#2880

Change-Id: Ie107f079c06beb89ee5a6a51375af7a72fdd9021
  • Loading branch information
joeyparrish committed Sep 28, 2020
1 parent d4d014b commit 3d9510a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1108,9 +1108,16 @@ shaka.hls.HlsParser = class {

const language = this.getLanguage_(tag);
const name = tag.getAttributeValue('NAME');
const defaultAttr = tag.getAttribute('DEFAULT');
const autoselectAttr = tag.getAttribute('AUTOSELECT');
const primary = !!defaultAttr || !!autoselectAttr;

// NOTE: According to the HLS spec, "DEFAULT=YES" requires "AUTOSELECT=YES".
// However, we don't bother to validate "AUTOSELECT", since we don't
// actually use it in our streaming model, and we treat everything as
// "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 primary = defaultAttrValue == 'YES';

const channelsCount = type == 'audio' ? this.getChannelsCount_(tag) : null;
const characteristics = tag.getAttributeValue('CHARACTERISTICS');
// TODO: Should we take into account some of the currently ignored
Expand Down

0 comments on commit 3d9510a

Please sign in to comment.