From 4f3152d40e6313a0f5481d4af930dfcbb4db0c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Diez?= Date: Fri, 3 Feb 2023 11:24:37 +0100 Subject: [PATCH 1/6] fix: check if the extended mime type is supported This should fix #4634 and possibly #4503 Some specific content was throwing 3016 error in some Tizen TV's, while playback worked fine in older versions of shaka. In these cases, one of the variants from the asset was not supported on these TV's, the lack of support was correctly detected in older versions, the variant was filtered out, and playback worked. In newer versions it was incorrectly identified as supported, and the playback error happened when we tried to play it. The difference comes from checking the extended MIME type, including info on the width, height, framerate, bitrate and channels as well. In the specific case that was failing, the variant was rejected if we included the width, and accepted if we didn't include it. --- lib/util/stream_utils.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index 412fc7210a..5917d83be1 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -462,9 +462,8 @@ shaka.util.StreamUtils = class { // Update the codec string with the (possibly) converted codecs. videoCodecs = [videoCodecs, audioCodecs].join(','); } - const fullType = shaka.util.MimeUtils.getFullOrConvertedType( - video.mimeType, videoCodecs, ContentType.VIDEO); - if (!Capabilities.isTypeSupported(fullType)) { + const extendedMimeType = shaka.util.MimeUtils.getExtendedType(video); + if (!Capabilities.isTypeSupported(extendedMimeType)) { return false; } // Update the codec string with the (possibly) converted codecs. @@ -474,9 +473,8 @@ shaka.util.StreamUtils = class { if (audio) { const codecs = shaka.util.StreamUtils.getCorrectAudioCodecs_(audio.codecs); - const fullType = shaka.util.MimeUtils.getFullOrConvertedType( - audio.mimeType, codecs, ContentType.AUDIO); - if (!Capabilities.isTypeSupported(fullType)) { + const extendedMimeType = shaka.util.MimeUtils.getExtendedType(audio); + if (!Capabilities.isTypeSupported(extendedMimeType)) { return false; } // Update the codec string with the (possibly) converted codecs. From 982d72f4dd694bbca018d87cec89a3f0ac2c8ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Diez?= Date: Fri, 3 Feb 2023 18:06:19 +0100 Subject: [PATCH 2/6] fix: Use codecs and mimeType converted values when checking the extended type With the previous commit 4f3152d40e6313a0f5481d4af930dfcbb4db0c90 I had lost the conversion of codecs and mimeType that is done in some cases at getFullOrConvertedType function. This change's purpose is to convert the values first and then use those converted values as the input to get the extended type, using it to check if it is supported or not. --- lib/util/stream_utils.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index 5917d83be1..3009b466e1 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -462,23 +462,33 @@ shaka.util.StreamUtils = class { // Update the codec string with the (possibly) converted codecs. videoCodecs = [videoCodecs, audioCodecs].join(','); } + const fullType = shaka.util.MimeUtils.getFullOrConvertedType( + video.mimeType, videoCodecs, ContentType.VIDEO); + // Update the codec and mimeType strings with their (possibly) + // converted values. + video.codecs = shaka.util.MimeUtils.getCodecs(fullType); + video.mimeType = shaka.util.MimeUtils.getBasicType(fullType); + const extendedMimeType = shaka.util.MimeUtils.getExtendedType(video); if (!Capabilities.isTypeSupported(extendedMimeType)) { return false; } - // Update the codec string with the (possibly) converted codecs. - video.codecs = videoCodecs; } const audio = variant.audio; if (audio) { const codecs = shaka.util.StreamUtils.getCorrectAudioCodecs_(audio.codecs); + const fullType = shaka.util.MimeUtils.getFullOrConvertedType( + audio.mimeType, codecs, ContentType.AUDIO); + // Update the codec and mimeType strings with their (possibly) + // converted values. + audio.codecs = shaka.util.MimeUtils.getCodecs(fullType); + audio.mimeType = shaka.util.MimeUtils.getBasicType(fullType); + const extendedMimeType = shaka.util.MimeUtils.getExtendedType(audio); if (!Capabilities.isTypeSupported(extendedMimeType)) { return false; } - // Update the codec string with the (possibly) converted codecs. - audio.codecs = codecs; } // See: https://github.com/shaka-project/shaka-player/issues/3380 From d6392e1ebf3d0b7e906e4e57a7bbf380bb67086b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Diez?= Date: Thu, 16 Feb 2023 19:03:47 +0100 Subject: [PATCH 3/6] Revert "fix: Use codecs and mimeType converted values when checking the extended type" This reverts commit 982d72f4dd694bbca018d87cec89a3f0ac2c8ac8. --- lib/util/stream_utils.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index 3009b466e1..5917d83be1 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -462,33 +462,23 @@ shaka.util.StreamUtils = class { // Update the codec string with the (possibly) converted codecs. videoCodecs = [videoCodecs, audioCodecs].join(','); } - const fullType = shaka.util.MimeUtils.getFullOrConvertedType( - video.mimeType, videoCodecs, ContentType.VIDEO); - // Update the codec and mimeType strings with their (possibly) - // converted values. - video.codecs = shaka.util.MimeUtils.getCodecs(fullType); - video.mimeType = shaka.util.MimeUtils.getBasicType(fullType); - const extendedMimeType = shaka.util.MimeUtils.getExtendedType(video); if (!Capabilities.isTypeSupported(extendedMimeType)) { return false; } + // Update the codec string with the (possibly) converted codecs. + video.codecs = videoCodecs; } const audio = variant.audio; if (audio) { const codecs = shaka.util.StreamUtils.getCorrectAudioCodecs_(audio.codecs); - const fullType = shaka.util.MimeUtils.getFullOrConvertedType( - audio.mimeType, codecs, ContentType.AUDIO); - // Update the codec and mimeType strings with their (possibly) - // converted values. - audio.codecs = shaka.util.MimeUtils.getCodecs(fullType); - audio.mimeType = shaka.util.MimeUtils.getBasicType(fullType); - const extendedMimeType = shaka.util.MimeUtils.getExtendedType(audio); if (!Capabilities.isTypeSupported(extendedMimeType)) { return false; } + // Update the codec string with the (possibly) converted codecs. + audio.codecs = codecs; } // See: https://github.com/shaka-project/shaka-player/issues/3380 From f1b52a79381de82cd62c11e0f8787b654021be51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Diez?= Date: Thu, 16 Feb 2023 19:03:55 +0100 Subject: [PATCH 4/6] Revert "fix: check if the extended mime type is supported" This reverts commit 4f3152d40e6313a0f5481d4af930dfcbb4db0c90. --- lib/util/stream_utils.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index 5917d83be1..412fc7210a 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -462,8 +462,9 @@ shaka.util.StreamUtils = class { // Update the codec string with the (possibly) converted codecs. videoCodecs = [videoCodecs, audioCodecs].join(','); } - const extendedMimeType = shaka.util.MimeUtils.getExtendedType(video); - if (!Capabilities.isTypeSupported(extendedMimeType)) { + const fullType = shaka.util.MimeUtils.getFullOrConvertedType( + video.mimeType, videoCodecs, ContentType.VIDEO); + if (!Capabilities.isTypeSupported(fullType)) { return false; } // Update the codec string with the (possibly) converted codecs. @@ -473,8 +474,9 @@ shaka.util.StreamUtils = class { if (audio) { const codecs = shaka.util.StreamUtils.getCorrectAudioCodecs_(audio.codecs); - const extendedMimeType = shaka.util.MimeUtils.getExtendedType(audio); - if (!Capabilities.isTypeSupported(extendedMimeType)) { + const fullType = shaka.util.MimeUtils.getFullOrConvertedType( + audio.mimeType, codecs, ContentType.AUDIO); + if (!Capabilities.isTypeSupported(fullType)) { return false; } // Update the codec string with the (possibly) converted codecs. From 49a6be3ef5dbbdc938ad46900c1c69dac0ab3d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Diez?= Date: Thu, 2 Mar 2023 15:35:13 +0100 Subject: [PATCH 5/6] fix: just for Tizen platform, check the if the extended mime type is supported Tizen platform can reject some videos due to their resolution, framerate or bitrate, so we should take into account all these parameters when we check if a video is supported. --- lib/polyfill/media_capabilities.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/polyfill/media_capabilities.js b/lib/polyfill/media_capabilities.js index ce9372cc90..6b819ebc53 100644 --- a/lib/polyfill/media_capabilities.js +++ b/lib/polyfill/media_capabilities.js @@ -119,6 +119,13 @@ shaka.polyfill.MediaCapabilities = class { if (shaka.util.Platform.isChromecast()) { isSupported = shaka.polyfill.MediaCapabilities.canCastDisplayType_(videoConfig); + } else if (shaka.util.Platform.isTizen()) { + let extendedType = videoConfig.contentType; + extendedType += `; width=${videoConfig.width}`; + extendedType += `; height=${videoConfig.height}`; + extendedType += `; framerate=${videoConfig.framerate}`; + extendedType += `; bitrate=${videoConfig.bitrate}`; + isSupported = Capabilities.isTypeSupported(extendedType); } else { isSupported = Capabilities.isTypeSupported(videoConfig.contentType); } From 0dde62bf1977f1565b7022e6cfbbf2c44cc32fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Garc=C3=ADa=20Diez?= Date: Thu, 2 Mar 2023 22:17:12 +0100 Subject: [PATCH 6/6] check potentially null parameters --- lib/polyfill/media_capabilities.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/polyfill/media_capabilities.js b/lib/polyfill/media_capabilities.js index 6b819ebc53..0734390b9f 100644 --- a/lib/polyfill/media_capabilities.js +++ b/lib/polyfill/media_capabilities.js @@ -121,10 +121,16 @@ shaka.polyfill.MediaCapabilities = class { shaka.polyfill.MediaCapabilities.canCastDisplayType_(videoConfig); } else if (shaka.util.Platform.isTizen()) { let extendedType = videoConfig.contentType; - extendedType += `; width=${videoConfig.width}`; - extendedType += `; height=${videoConfig.height}`; - extendedType += `; framerate=${videoConfig.framerate}`; - extendedType += `; bitrate=${videoConfig.bitrate}`; + if (videoConfig.width && videoConfig.height) { + extendedType += `; width=${videoConfig.width}`; + extendedType += `; height=${videoConfig.height}`; + } + if (videoConfig.framerate) { + extendedType += `; framerate=${videoConfig.framerate}`; + } + if (videoConfig.bitrate) { + extendedType += `; bitrate=${videoConfig.bitrate}`; + } isSupported = Capabilities.isTypeSupported(extendedType); } else { isSupported = Capabilities.isTypeSupported(videoConfig.contentType);