Skip to content

Commit 9066d8b

Browse files
aveladjoeyparrish
authored andcommitted
fix(HLS): Fix switching between muxed MP4 and muxed TS (#8061)
Backported to v4.9.x
1 parent d4bb311 commit 9066d8b

File tree

9 files changed

+58
-1
lines changed

9 files changed

+58
-1
lines changed

karma.conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ module.exports = (config) => {
264264
{pattern: 'test/test/assets/dash-clearkey/*', included: false},
265265
{pattern: 'test/test/assets/dash-vr/*', included: false},
266266
{pattern: 'test/test/assets/hls-aes-256/*', included: false},
267+
{pattern: 'test/test/assets/hls-muxed-mp4-ts/*', included: false},
267268
{pattern: 'test/test/assets/hls-raw-aac/*', included: false},
268269
{pattern: 'test/test/assets/hls-raw-ac3/*', included: false},
269270
{pattern: 'test/test/assets/hls-raw-ec3/*', included: false},

lib/media/media_source_engine.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,8 @@ shaka.media.MediaSourceEngine = class {
21862186
const newMimeType = realInfo.mimeType;
21872187

21882188
let muxedContentCheck = true;
2189-
if (transmuxerMuxed) {
2189+
if (transmuxerMuxed &&
2190+
ContentType.AUDIO in this.sourceBufferTypes_) {
21902191
const muxedRealInfo =
21912192
this.getRealInfo_(ContentType.AUDIO, mimeType, codecs);
21922193
const muxedCurrentCodec = MimeUtils.getNormalizedCodec(

test/hls/hls_parser_integration.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,36 @@ describe('HlsParser', () => {
153153

154154
await player.unload();
155155
});
156+
157+
it('allow switch between mp4 muxed and ts muxed', async () => {
158+
if (!await Util.isTypeSupported(
159+
'video/mp4; codecs="av01.0.31M.08"',
160+
/* width= */ 1920, /* height= */ 1080)) {
161+
pending('Codec AV1 is not supported by the platform.');
162+
}
163+
player.configure('abr.enabled', false);
164+
await player.load('/base/test/test/assets/hls-muxed-mp4-ts/master.m3u8');
165+
await video.play();
166+
167+
expect(player.getVariantTracks().length).toBe(2);
168+
169+
// We want to test TS --> MP4 and MP4 --> TS, that's why
170+
// selectVariantTrack is called twice
171+
172+
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 1, 30);
173+
174+
let nonActiveVariant = player.getVariantTracks().find((v) => !v.active);
175+
goog.asserts.assert(nonActiveVariant, 'variant should be non-null!');
176+
player.selectVariantTrack(nonActiveVariant, /* clearBuffer= */ true);
177+
178+
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 3, 30);
179+
180+
nonActiveVariant = player.getVariantTracks().find((v) => !v.active);
181+
goog.asserts.assert(nonActiveVariant, 'variant should be non-null!');
182+
player.selectVariantTrack(nonActiveVariant, /* clearBuffer= */ true);
183+
184+
await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 5, 30);
185+
186+
await player.unload();
187+
});
156188
});
4.17 MB
Binary file not shown.
1.78 MB
Binary file not shown.
1.31 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#EXTM3U
2+
#EXT-X-VERSION:3
3+
#EXT-X-STREAM-INF:BANDWIDTH=3500000,RESOLUTION=1920x1080,FRAMERATE=60,CODECS="av01.0.31M.08,mp4a.40.2",NAME="1080p60 AV1"
4+
mp4.m3u8
5+
#EXT-X-STREAM-INF:BANDWIDTH=2600000,RESOLUTION=1280x720,FRAMERATE=30,CODECS="avc1.4D401F,mp4a.40.2",NAME="720p"
6+
ts.m3u8
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#EXTM3U
2+
#EXT-X-VERSION:7
3+
#EXT-X-TARGETDURATION:8
4+
#EXT-X-MEDIA-SEQUENCE:0
5+
#EXT-X-PLAYLIST-TYPE:VOD
6+
#EXT-X-MAP:URI="init.mp4"
7+
#EXTINF:8.000000,
8+
000000000.m4s
9+
#EXT-X-ENDLIST
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#EXTM3U
2+
#EXT-X-VERSION:3
3+
#EXT-X-TARGETDURATION:8
4+
#EXT-X-MEDIA-SEQUENCE:0
5+
#EXT-X-PLAYLIST-TYPE:VOD
6+
#EXTINF:8.000000,
7+
000000000.ts
8+
#EXT-X-ENDLIST

0 commit comments

Comments
 (0)