From d319718eded6e36f4fc705588de84a301a428d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Tue, 18 Oct 2022 07:31:30 +0200 Subject: [PATCH] fix(hls): Fix raw format detection when the main playlist hasn't type (#4583) --- lib/hls/hls_parser.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 68581b0a4e..5524369fe6 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -2714,6 +2714,11 @@ shaka.hls.HlsParser = class { return mimeType; } + mimeType = HlsParser.RAW_FORMATS_TO_MIME_TYPES_[extension]; + if (mimeType) { + return mimeType; + } + // The extension map didn't work, so guess based on codecs. mimeType = this.guessMimeTypeBeforeLoading_(contentType, codecs); if (mimeType) { @@ -3091,6 +3096,18 @@ shaka.hls.HlsParser.StreamInfo; shaka.hls.HlsParser.StreamInfos; +/** + * @const {!Object.} + * @private + */ +shaka.hls.HlsParser.RAW_FORMATS_TO_MIME_TYPES_ = { + 'aac': 'audio/aac', + 'ac3': 'audio/ac3', + 'ec3': 'audio/ec3', + 'mp3': 'audio/mpeg', +}; + + /** * @const {!Object.} * @private @@ -3105,12 +3122,6 @@ shaka.hls.HlsParser.AUDIO_EXTENSIONS_TO_MIME_TYPES_ = { 'cmfa': 'audio/mp4', // MPEG2-TS also uses video/ for audio: https://bit.ly/TsMse 'ts': 'video/mp2t', - - // Raw formats: - 'aac': 'audio/aac', - 'ac3': 'audio/ac3', - 'ec3': 'audio/ec3', - 'mp3': 'audio/mpeg', };