From cca43ca3ed481a5db585974ac1176fdc6dbc69fe Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Wed, 7 Dec 2022 13:56:52 -0800 Subject: [PATCH] Add regression test --- test/hls/hls_parser_unit.js | 80 +++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/test/hls/hls_parser_unit.js b/test/hls/hls_parser_unit.js index 751f9be0e0..828d90c4b4 100644 --- a/test/hls/hls_parser_unit.js +++ b/test/hls/hls_parser_unit.js @@ -1089,6 +1089,86 @@ describe('HlsParser', () => { await testHlsParser(master, media, manifest); }); + // https://github.com/shaka-project/shaka-player/issues/4759 + it('makes roles available without loading tracks', async () => { + const master = [ + '#EXTM3U\n', + '#EXT-X-STREAM-INF:BANDWIDTH=200,CODECS="avc1",', + 'RESOLUTION=960x540,FRAME-RATE=60,AUDIO="aud1",SUBTITLES="sub1"\n', + 'video\n', + + '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud1",LANGUAGE="en",', + 'NAME="English",URI="audio"\n', + + '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud1",LANGUAGE="en",', + 'CHARACTERISTICS="public.accessibility.describes-video,', + 'public.accessibility.describes-music-and-sound",', + 'NAME="English (describes-video)",URI="audio2"\n', + + '#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="sub1",LANGUAGE="en",', + 'NAME="English (caption)",DEFAULT=YES,AUTOSELECT=YES,', + 'URI="text"\n', + + '#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="sub1",LANGUAGE="en",', + 'NAME="English (caption)",DEFAULT=YES,AUTOSELECT=YES,', + 'CHARACTERISTICS="public.accessibility.describes-spoken-dialog,', + 'public.accessibility.describes-music-and-sound",', + 'URI="text2"\n', + ].join(''); + + const media = [ + '#EXTM3U\n', + '#EXT-X-PLAYLIST-TYPE:VOD\n', + '#EXT-X-MAP:URI="init.mp4",BYTERANGE="616@0"\n', + '#EXTINF:5,\n', + '#EXT-X-BYTERANGE:121090@616\n', + 'main.mp4', + ].join(''); + + const manifest = shaka.test.ManifestGenerator.generate((manifest) => { + manifest.anyTimeline(); + manifest.addPartialVariant((variant) => { + variant.language = 'en'; + variant.addPartialStream(ContentType.VIDEO); + variant.addPartialStream(ContentType.AUDIO, (stream) => { + stream.language = 'en'; + }); + }); + manifest.addPartialVariant((variant) => { + variant.language = 'en'; + variant.addPartialStream(ContentType.VIDEO); + variant.addPartialStream(ContentType.AUDIO, (stream) => { + stream.language = 'en'; + stream.roles = [ + 'public.accessibility.describes-video', + 'public.accessibility.describes-music-and-sound', + ]; + }); + }); + manifest.addPartialTextStream((stream) => { + stream.language = 'en'; + stream.kind = TextStreamKind.SUBTITLE; + }); + manifest.addPartialTextStream((stream) => { + stream.language = 'en'; + stream.kind = TextStreamKind.SUBTITLE; + stream.roles = [ + 'public.accessibility.describes-spoken-dialog', + 'public.accessibility.describes-music-and-sound', + ]; + }); + manifest.sequenceMode = true; + }); + + fakeNetEngine.setResponseText('test:/master', master); + + // NOTE: Not using testHlsParser here because that unconditionally loads all + // streams. We need to test the behavior specifically when streams are + // _not_ loaded. + const actual = await parser.start('test:/master', playerInterface); + expect(actual).toEqual(manifest); + }); + it('gets mime type from header request', async () => { const master = [ '#EXTM3U\n',