Skip to content

Commit 9ba8ceb

Browse files
authored
fix: Only expand robustness on each stream once (#8458)
Without this change, `expandRobustness` ended up running 480 times for the stream `Angel One (multicodec, multilingual, Widevine)` with `SW_SECURE_CRYPTO,SW_SECURE_CRYPTO,SW_SECURE_CRYPTO` set up as the multiple robustness. With it, it only runs 44 times, which is expected because there are 22 unique streams, and it expands `videoRobustness` and `audioRobustness` on each. Fixes #8408
1 parent 03fd784 commit 9ba8ceb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/drm/drm_engine.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,25 +446,32 @@ shaka.drm.DrmEngine = class {
446446
return newDrmInfos;
447447
};
448448

449+
const expandedStreams = new Set();
450+
449451
for (const variant of variants) {
450-
if (variant.video) {
452+
if (variant.video && !expandedStreams.has(variant.video)) {
451453
variant.video.drmInfos =
452454
expandRobustness(variant.video.drmInfos,
453455
'videoRobustness');
454456
variant.video.drmInfos =
455457
expandRobustness(variant.video.drmInfos,
456458
'audioRobustness');
459+
expandedStreams.add(variant.video);
457460
}
458-
if (variant.audio) {
461+
if (variant.audio && !expandedStreams.has(variant.audio)) {
459462
variant.audio.drmInfos =
460463
expandRobustness(variant.audio.drmInfos,
461464
'videoRobustness');
462465
variant.audio.drmInfos =
463466
expandRobustness(variant.audio.drmInfos,
464467
'audioRobustness');
468+
expandedStreams.add(variant.audio);
465469
}
466470
}
467471

472+
// expandedStreams is no longer needed, so, clear it
473+
expandedStreams.clear();
474+
468475
// We should get the decodingInfo results for the variants after we filling
469476
// in the drm infos, and before queryMediaKeys_().
470477
await shaka.util.StreamUtils.getDecodingInfosForVariants(variants,

0 commit comments

Comments
 (0)