From 77121fa033ced17a4e627bd22363c2d4701c2cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20C=C3=B4t=C3=A9?= Date: Fri, 26 Jan 2024 09:29:25 -0500 Subject: [PATCH] fix: AC-3 audio codec support on Tizen (#6166) Fixes https://github.com/shaka-project/shaka-player/issues/6160 --- AUTHORS | 1 + CONTRIBUTORS | 1 + lib/polyfill/media_capabilities.js | 15 ++++++++++++++- lib/util/stream_utils.js | 10 +--------- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/AUTHORS b/AUTHORS index 4e4bf4dbe8..74bff17d9e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -60,6 +60,7 @@ Lucas Gabriel Sánchez Martin Stark Matthias Van Parijs Mattias Wadman +Mirego <*@mirego.com> Mohamed Rashid Morten Hansen Nick Desaulniers diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7eb3701cc7..017b50a658 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -88,6 +88,7 @@ Loïc Raux Lucas Gabriel Sánchez Martin Stark Matias Russitto +Mathieu Côté Matthias Van Parijs Mattias Wadman Michelle Zhuo diff --git a/lib/polyfill/media_capabilities.js b/lib/polyfill/media_capabilities.js index 875c5f9f48..0b885f8fd8 100644 --- a/lib/polyfill/media_capabilities.js +++ b/lib/polyfill/media_capabilities.js @@ -191,10 +191,23 @@ shaka.polyfill.MediaCapabilities = class { const videoCapabilities = []; if (mediaCapkeySystemConfig.audio) { - const capability = { + let capability = { robustness: mediaCapkeySystemConfig.audio.robustness || '', contentType: mediaDecodingConfig.audio.contentType, }; + + // Some Tizen devices seem to misreport AC-3 support, but correctly + // report EC-3 support. So query EC-3 as a fallback for AC-3. + // See https://github.com/shaka-project/shaka-player/issues/2989 for + // details. + if (shaka.util.Platform.isTizen() && + mediaDecodingConfig.audio.contentType.includes('codecs="ac-3"')) { + capability = { + robustness: capability.robustness, + contentType: 'audio/mp4; codecs="ec-3"', + }; + } + audioCapabilities.push(capability); } diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index 6bd9bcd362..64293ccb91 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -848,15 +848,7 @@ shaka.util.StreamUtils = class { return 'opus'; } - // Some Tizen devices seem to misreport AC-3 support, but correctly - // report EC-3 support. So query EC-3 as a fallback for AC-3. - // See https://github.com/shaka-project/shaka-player/issues/2989 for - // details. - if (shaka.util.Platform.isTizen()) { - return codecs.toLowerCase() == 'ac-3' ? 'ec-3' : codecs; - } else { - return codecs; - } + return codecs; }