From 974f5dcb630977fcdb8ac67d1af001919cf40f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Mon, 30 Jan 2023 18:29:32 +0100 Subject: [PATCH] fix(HLS): IMSC1 subtitles not working in a HLS stream (#4942) Fixes #4350 The current code initially parses the subtitle track as text/vtt (mimetype) since it has no codec. Subsequently, the stpp.ttml.im1t codec is assigned but the mimetype of text/vtt is not changed to application/mp4. This PR changes this so that once the codec is assigned, the mimetype is recalculated. --- lib/hls/hls_parser.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index d0c62cc3b5..21b07f0db8 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -1195,6 +1195,8 @@ shaka.hls.HlsParser = class { } }); + const type = shaka.util.ManifestParserUtils.ContentType.TEXT; + // Set the codecs for text streams. for (const tag of subtitleTags) { const groupId = tag.getRequiredAttrValue('GROUP-ID'); @@ -1204,6 +1206,9 @@ shaka.hls.HlsParser = class { if (textStreamInfos) { for (const textStreamInfo of textStreamInfos) { textStreamInfo.stream.codecs = codecs; + textStreamInfo.stream.mimeType = + this.guessMimeTypeBeforeLoading_(type, codecs) || + this.guessMimeTypeFallback_(type); } } }