Skip to content

Commit

Permalink
fix(PeriodCombiner): Use normalized codec to remove duplicates (#7032)
Browse files Browse the repository at this point in the history
  • Loading branch information
tykus160 committed Jul 12, 2024
1 parent 226c740 commit 0669d24
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions lib/util/periods.js
Original file line number Diff line number Diff line change
Expand Up @@ -1057,18 +1057,8 @@ shaka.util.PeriodCombiner = class {
if (a.mimeType != b.mimeType) {
return false;
}
/**
* @param {string} codecs
* @return {string}
*/
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);
};
return getCodec(a.codecs) == getCodec(b.codecs);
return shaka.util.PeriodCombiner.getCodec_(a.codecs) ===
shaka.util.PeriodCombiner.getCodec_(b.codecs);
}

/**
Expand Down Expand Up @@ -1705,7 +1695,7 @@ shaka.util.PeriodCombiner = class {
v.fastSwitching,
v.width,
v.frameRate,
v.codecs,
shaka.util.PeriodCombiner.getCodec_(v.codecs),
v.mimeType,
v.label,
v.roles,
Expand All @@ -1728,7 +1718,7 @@ shaka.util.PeriodCombiner = class {
a.language,
a.bandwidth,
a.label,
a.codecs,
shaka.util.PeriodCombiner.getCodec_(a.codecs),
a.mimeType,
a.roles,
a.audioSamplingRate,
Expand Down Expand Up @@ -1777,6 +1767,19 @@ shaka.util.PeriodCombiner = class {
static generateKey_(values) {
return JSON.stringify(values);
}

/**
* @param {string} codecs
* @return {string}
* @private
*/
static 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);
}
};

/**
Expand Down

0 comments on commit 0669d24

Please sign in to comment.