From ff1712196431527fb29747c61adc81acf8ece794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 8 Dec 2022 22:08:00 +0100 Subject: [PATCH] fix(HLS): Fix detection of Media Playlist for audio and video only in MP4 (#4803) --- lib/hls/hls_parser.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 8e4982f7a5..037281d45e 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -614,9 +614,23 @@ shaka.hls.HlsParser = class { if (playlist.segments.length) { const parsedUri = new goog.Uri(playlist.segments[0].absoluteUri); const extension = parsedUri.getPath().split('.').pop(); - const mimeType = HlsParser.RAW_FORMATS_TO_MIME_TYPES_[extension]; + let mimeType = HlsParser.RAW_FORMATS_TO_MIME_TYPES_[extension]; if (mimeType) { fullMimeType = mimeType; + } else if (extension === 'ts') { + // TODO: Fetch one segment a use the TsParser to analize if there is + // video, audio or both. + } else if (extension === 'mp4') { + // TODO: Fetch one segment a use the Mp4Parser to analize if there is + // video, audio or both. + } else if (HlsParser.AUDIO_EXTENSIONS_TO_MIME_TYPES_[extension]) { + mimeType = HlsParser.AUDIO_EXTENSIONS_TO_MIME_TYPES_[extension]; + const defaultAudioCodec = this.config_.hls.defaultAudioCodec; + fullMimeType = `${mimeType}; codecs="${defaultAudioCodec}"`; + } else if (HlsParser.VIDEO_EXTENSIONS_TO_MIME_TYPES_[extension]) { + mimeType = HlsParser.VIDEO_EXTENSIONS_TO_MIME_TYPES_[extension]; + const defaultVideoCodec = this.config_.hls.defaultVideoCodec; + fullMimeType = `${mimeType}; codecs="${defaultVideoCodec}"`; } }