Skip to content

Commit

Permalink
fix(HLS): Allow audio groups on audio-only content (#5578)
Browse files Browse the repository at this point in the history
Fixes #5577
  • Loading branch information
avelad authored and joeyparrish committed Sep 2, 2023
1 parent 8c66b7a commit 17e4ef2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions lib/hls/hls_parser.js
Expand Up @@ -1466,6 +1466,7 @@ shaka.hls.HlsParser = class {
// and no video codec, so it should be audio.
type = ContentType.AUDIO;
shaka.log.debug('Guessing audio-only.');
ignoreStream = res.audio.length > 0;
} else if (!streamInfos.length && audioCodecs && videoCodecs) {
// There are both audio and video codecs, so assume multiplexed content.
// Note that the default used when CODECS is missing assumes multiple
Expand Down
25 changes: 12 additions & 13 deletions test/hls/hls_parser_unit.js
Expand Up @@ -4180,19 +4180,11 @@ describe('HlsParser', () => {
expect(videoSegments2[2].endTime).toBe(10);
});

// Issue #1875
it('ignores audio groups on audio-only content', async () => {
// NOTE: To reproduce the original issue accurately, the two audio playlist
// URIs must differ. When the issue occurred, the audio-only variant would
// be detected as a video stream and combined with the audio group, leading
// the player to buffer "video" that was really audio, resulting in
// audio-only playback to the exclusion of any other streams. Since the
// root cause of that was the mis-detection, this repro case does not need
// to include any audio+video variants.
it('allow audio groups on audio-only content', async () => {
const master = [
'#EXTM3U\n',
'#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud",LANG="en",URI="audio1"\n',
'#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud",LANG="eo",URI="audio2"\n',
'#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud",LANGUAGE="en",URI="audio1"\n',
'#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud",LANGUAGE="eo",URI="audio2"\n',
'#EXT-X-STREAM-INF:BANDWIDTH=200,CODECS="mp4a",AUDIO="aud"\n',
'audio3\n',
].join('');
Expand All @@ -4210,7 +4202,14 @@ describe('HlsParser', () => {
manifest.anyTimeline();
manifest.addPartialVariant((variant) => {
variant.bandwidth = 200;
variant.language = 'und';
variant.language = 'en';
variant.addPartialStream(ContentType.AUDIO, (stream) => {
stream.mime('audio/mp4', 'mp4a');
});
});
manifest.addPartialVariant((variant) => {
variant.bandwidth = 200;
variant.language = 'eo';
variant.addPartialStream(ContentType.AUDIO, (stream) => {
stream.mime('audio/mp4', 'mp4a');
});
Expand All @@ -4229,7 +4228,7 @@ describe('HlsParser', () => {

const actual = await parser.start('test:/master', playerInterface);
await loadAllStreamsFor(actual);
expect(actual.variants.length).toBe(1);
expect(actual.variants.length).toBe(2);
expect(actual).toEqual(manifest);
});

Expand Down

0 comments on commit 17e4ef2

Please sign in to comment.