diff --git a/lib/media/drm_engine.js b/lib/media/drm_engine.js index b8bf2687ee..462fd4e523 100644 --- a/lib/media/drm_engine.js +++ b/lib/media/drm_engine.js @@ -2005,6 +2005,10 @@ shaka.media.DrmEngine = class { return true; } + if (drms1 === drms2) { + return true; + } + return shaka.media.DrmEngine.getCommonDrmInfos( drms1, drms2).length > 0; } diff --git a/lib/util/periods.js b/lib/util/periods.js index dd54ad0df1..3a3e6939a0 100644 --- a/lib/util/periods.js +++ b/lib/util/periods.js @@ -1067,8 +1067,13 @@ shaka.util.PeriodCombiner = class { * @private */ static areAVStreamsCompatible_(outputStream, candidate) { - const getCodec = (codecs) => - shaka.util.MimeUtils.getNormalizedCodec(codecs); + const getCodec = (codecs) => { + if (!shaka.util.PeriodCombiner.memoizedCodecs.has(codecs)) { + const normalizedCodec = shaka.util.MimeUtils.getNormalizedCodec(codecs); + shaka.util.PeriodCombiner.memoizedCodecs.set(codecs, normalizedCodec); + } + return shaka.util.PeriodCombiner.memoizedCodecs.get(codecs); + }; // Check MIME type and codecs, which should always be the same. if (candidate.mimeType != outputStream.mimeType || getCodec(candidate.codecs) != getCodec(outputStream.codecs)) { @@ -1666,3 +1671,8 @@ shaka.util.PeriodCombiner.BetterOrWorse = { EQUAL: 0, WORSE: -1, }; + +/** + * @private {Map} + */ +shaka.util.PeriodCombiner.memoizedCodecs = new Map();