Skip to content

Commit bdce076

Browse files
authored
fix(DRM): Fix drm choice when the user provide a server in the manifest (#8067)
Fixes #8066
1 parent 171bdb3 commit bdce076

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/drm/drm_engine.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,17 @@ shaka.drm.DrmEngine = class {
10831083

10841084
// If we have configured preferredKeySystems, choose a preferred keySystem
10851085
// if available.
1086-
for (const preferredKeySystem of this.config_.preferredKeySystems) {
1086+
let preferredKeySystems = this.config_.preferredKeySystems;
1087+
if (!preferredKeySystems.length) {
1088+
// If there is no preference set and we only have one license server, we
1089+
// use this as preference. This is used to override manifests on those
1090+
// that have the embedded license and the browser supports multiple DRMs.
1091+
const servers = shaka.util.MapUtils.asMap(this.config_.servers);
1092+
if (servers.size == 1) {
1093+
preferredKeySystems = Array.from(servers.keys());
1094+
}
1095+
}
1096+
for (const preferredKeySystem of preferredKeySystems) {
10871097
for (const variant of variants) {
10881098
const decodingInfo = variant.decodingInfos.find((decodingInfo) => {
10891099
return decodingInfo.supported &&
@@ -1108,6 +1118,9 @@ shaka.drm.DrmEngine = class {
11081118
continue;
11091119
}
11101120
const originalKeySystem = decodingInfo.keySystemAccess.keySystem;
1121+
if (preferredKeySystems.includes(originalKeySystem)) {
1122+
continue;
1123+
}
11111124
let drmInfos = drmInfosByKeySystem.get(originalKeySystem);
11121125
if (!drmInfos && this.config_.keySystemsMapping[originalKeySystem]) {
11131126
drmInfos = drmInfosByKeySystem.get(

0 commit comments

Comments
 (0)