diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index 3d1aae036c..8d872b236e 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -347,19 +347,33 @@ shaka.util.StreamUtils = class { await shaka.util.StreamUtils.getDecodingInfosForVariants( manifest.variants, usePersistentLicenses, /* srcEquals= */ false, /** preferredKeySystems= */ []); + + const ContentType = shaka.util.ManifestParserUtils.ContentType; + const Capabilities = shaka.media.Capabilities; + const ManifestParserUtils = shaka.util.ManifestParserUtils; + const MimeUtils = shaka.util.MimeUtils; + const StreamUtils = shaka.util.StreamUtils; + const isXboxOne = shaka.util.Platform.isXboxOne(); + manifest.variants = manifest.variants.filter((variant) => { // See: https://github.com/shaka-project/shaka-player/issues/3860 const video = variant.video; + const videoWidth = (video && video.width) || 0; + const videoHeight = (video && video.height) || 0; - const ContentType = shaka.util.ManifestParserUtils.ContentType; - const Capabilities = shaka.media.Capabilities; - const ManifestParserUtils = shaka.util.ManifestParserUtils; - const MimeUtils = shaka.util.MimeUtils; - const StreamUtils = shaka.util.StreamUtils; + // See: https://github.com/shaka-project/shaka-player/issues/3380 + // Note: it makes sense to drop early + if (isXboxOne && video && + (videoWidth > 1920 || videoHeight > 1080) && + (video.codecs.includes('avc1.') || video.codecs.includes('avc3.')) + ) { + shaka.log.debug('Dropping variant - not compatible with platform', + StreamUtils.getVariantSummaryString_(variant)); + return false; + } if (video) { let videoCodecs = StreamUtils.getCorrectVideoCodecs_(video.codecs); - // For multiplexed streams. Here we must check the audio of the // stream to see if it is compatible. if (video.codecs.includes(',')) { @@ -368,7 +382,6 @@ shaka.util.StreamUtils = class { videoCodecs = ManifestParserUtils.guessCodecs( ContentType.VIDEO, allCodecs); videoCodecs = StreamUtils.getCorrectVideoCodecs_(videoCodecs); - let audioCodecs = ManifestParserUtils.guessCodecs( ContentType.AUDIO, allCodecs); audioCodecs = StreamUtils.getCorrectAudioCodecs_(audioCodecs); @@ -410,17 +423,6 @@ shaka.util.StreamUtils = class { audio.codecs = codecs; } - // See: https://github.com/shaka-project/shaka-player/issues/3380 - if (shaka.util.Platform.isXboxOne() && video && - ((video.width && video.width > 1920) || - (video.height && video.height > 1080)) && - (video.codecs.includes('avc1.') || - video.codecs.includes('avc3.'))) { - shaka.log.debug('Dropping variant - not compatible with platform', - StreamUtils.getVariantSummaryString_(variant)); - return false; - } - const supported = variant.decodingInfos.some((decodingInfo) => { return decodingInfo.supported; });