diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index 59e73e0617..2dd1b121b4 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -270,6 +270,11 @@ shaka.media.MediaSourceEngine = class { for (const ref of stream.segmentIndex) { const mimeType = ref.mimeType || stream.mimeType || ''; let codecs = ref.codecs || stream.codecs || ''; + // Optimization for the case where the codecs and mimetype of the stream + // match the reference. + if (mimeType == stream.mimeType && codecs == stream.codecs) { + continue; + } // Don't check the same combination of mimetype + codecs twice. const combo = mimeType + ':' + codecs; if (seenCombos.has(combo)) { diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index f01a2207f1..0dfbeda86c 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -461,11 +461,6 @@ shaka.util.StreamUtils = class { if (!variantSupported) { return false; } - 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(); const isFirefoxAndroid = shaka.util.Platform.isFirefox() && @@ -483,45 +478,6 @@ shaka.util.StreamUtils = class { 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(',')) { - const allCodecs = video.codecs.split(','); - - videoCodecs = ManifestParserUtils.guessCodecs( - ContentType.VIDEO, allCodecs); - videoCodecs = StreamUtils.getCorrectVideoCodecs(videoCodecs); - let audioCodecs = ManifestParserUtils.guessCodecs( - ContentType.AUDIO, allCodecs); - audioCodecs = StreamUtils.getCorrectAudioCodecs( - audioCodecs, video.mimeType); - - const audioFullType = MimeUtils.getFullOrConvertedType( - video.mimeType, audioCodecs, ContentType.AUDIO); - - if (!Capabilities.isTypeSupported(audioFullType)) { - return false; - } - - // Update the codec string with the (possibly) converted codecs. - videoCodecs = [videoCodecs, audioCodecs].join(','); - } - - if (video.codecs != videoCodecs) { - const fullType = MimeUtils.getFullOrConvertedType( - video.mimeType, videoCodecs, ContentType.VIDEO); - - if (!Capabilities.isTypeSupported(fullType)) { - return false; - } - - // Update the codec string with the (possibly) converted codecs. - video.codecs = videoCodecs; - } - } - const audio = variant.audio; // See: https://github.com/shaka-project/shaka-player/issues/6111 @@ -533,22 +489,6 @@ shaka.util.StreamUtils = class { return false; } - if (audio) { - const codecs = StreamUtils.getCorrectAudioCodecs( - audio.codecs, audio.mimeType); - if (audio.codecs != codecs) { - const fullType = MimeUtils.getFullOrConvertedType( - audio.mimeType, codecs, ContentType.AUDIO); - - if (!Capabilities.isTypeSupported(fullType)) { - return false; - } - - // Update the codec string with the (possibly) converted codecs. - audio.codecs = codecs; - } - } - return true; } diff --git a/test/transmuxer/transmuxer_integration.js b/test/transmuxer/transmuxer_integration.js index 4c7601cb89..400fa9b6f3 100644 --- a/test/transmuxer/transmuxer_integration.js +++ b/test/transmuxer/transmuxer_integration.js @@ -340,13 +340,22 @@ describe('Transmuxer Player', () => { }); it('H.264+MP3 in TS', async () => { - if (!await Util.isTypeSupported('audio/mp4; codecs="mp3"')) { - pending('Codec MP3 in MP4 is not supported by the platform.'); + if (!await Util.isTypeSupported('audio/mp4; codecs="mp3"') && + !await Util.isTypeSupported('audio/mpeg')) { + pending('Codec MP3 is not supported by the platform.'); + } + if (!shaka.util.Platform.supportsSequenceMode()) { + pending('Sequence mode is not supported by the platform.'); } // eslint-disable-next-line max-len await player.load('/base/test/test/assets/hls-ts-muxed-mp3-h264/index.m3u8'); - await video.play(); + try { + await video.play(); + // eslint-disable-next-line no-restricted-syntax + } catch (e) { + // Ignore play errors + } expect(player.isLive()).toBe(false); // Wait for the video to start playback. If it takes longer than 10