diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index f31657112b..f01a2207f1 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -444,6 +444,23 @@ shaka.util.StreamUtils = class { * @private */ static checkVariantSupported_(variant, keySystem) { + const variantSupported = variant.decodingInfos.some((decodingInfo) => { + if (!decodingInfo.supported) { + return false; + } + if (keySystem) { + const keySystemAccess = decodingInfo.keySystemAccess; + if (keySystemAccess) { + if (keySystemAccess.keySystem != keySystem) { + return false; + } + } + } + return true; + }); + if (!variantSupported) { + return false; + } const ContentType = shaka.util.ManifestParserUtils.ContentType; const Capabilities = shaka.media.Capabilities; const ManifestParserUtils = shaka.util.ManifestParserUtils; @@ -492,15 +509,17 @@ shaka.util.StreamUtils = class { videoCodecs = [videoCodecs, audioCodecs].join(','); } - const fullType = MimeUtils.getFullOrConvertedType( - video.mimeType, videoCodecs, ContentType.VIDEO); + if (video.codecs != videoCodecs) { + const fullType = MimeUtils.getFullOrConvertedType( + video.mimeType, videoCodecs, ContentType.VIDEO); - if (!Capabilities.isTypeSupported(fullType)) { - return false; - } + if (!Capabilities.isTypeSupported(fullType)) { + return false; + } - // Update the codec string with the (possibly) converted codecs. - video.codecs = videoCodecs; + // Update the codec string with the (possibly) converted codecs. + video.codecs = videoCodecs; + } } const audio = variant.audio; @@ -517,31 +536,20 @@ shaka.util.StreamUtils = class { if (audio) { const codecs = StreamUtils.getCorrectAudioCodecs( audio.codecs, audio.mimeType); - const fullType = MimeUtils.getFullOrConvertedType( - audio.mimeType, codecs, ContentType.AUDIO); + if (audio.codecs != codecs) { + const fullType = MimeUtils.getFullOrConvertedType( + audio.mimeType, codecs, ContentType.AUDIO); - if (!Capabilities.isTypeSupported(fullType)) { - return false; - } + if (!Capabilities.isTypeSupported(fullType)) { + return false; + } - // Update the codec string with the (possibly) converted codecs. - audio.codecs = codecs; + // Update the codec string with the (possibly) converted codecs. + audio.codecs = codecs; + } } - return variant.decodingInfos.some((decodingInfo) => { - if (!decodingInfo.supported) { - return false; - } - if (keySystem) { - const keySystemAccess = decodingInfo.keySystemAccess; - if (keySystemAccess) { - if (keySystemAccess.keySystem != keySystem) { - return false; - } - } - } - return true; - }); + return true; } diff --git a/test/player_unit.js b/test/player_unit.js index e89066c72e..478bfa6f79 100644 --- a/test/player_unit.js +++ b/test/player_unit.js @@ -3563,6 +3563,8 @@ describe('Player', () => { stream.mimeType = 'video'; stream.codecs = 'unsupported'; stream.addDrmInfo('foo.bar'); + stream.fullMimeTypes = new Set([shaka.util.MimeUtils.getFullType( + stream.mimeType, stream.codecs)]); }); }); manifest.addVariant(1, (variant) => {