Skip to content

Commit cfd3af9

Browse files
committed
fix(DRM): Fix drm choice when the user provide a server in the manifest (#8067)
Fixes #8066
1 parent e3ea9c0 commit cfd3af9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/media/drm_engine.js

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

10291029
// If we have configured preferredKeySystems, choose a preferred keySystem
10301030
// if available.
1031-
for (const preferredKeySystem of this.config_.preferredKeySystems) {
1031+
let preferredKeySystems = this.config_.preferredKeySystems;
1032+
if (!preferredKeySystems.length) {
1033+
// If there is no preference set and we only have one license server, we
1034+
// use this as preference. This is used to override manifests on those
1035+
// that have the embedded license and the browser supports multiple DRMs.
1036+
const servers = shaka.util.MapUtils.asMap(this.config_.servers);
1037+
if (servers.size == 1) {
1038+
preferredKeySystems = Array.from(servers.keys());
1039+
}
1040+
}
1041+
for (const preferredKeySystem of preferredKeySystems) {
10321042
for (const variant of variants) {
10331043
const decodingInfo = variant.decodingInfos.find((decodingInfo) => {
10341044
return decodingInfo.supported &&
@@ -1053,6 +1063,9 @@ shaka.media.DrmEngine = class {
10531063
continue;
10541064
}
10551065
const originalKeySystem = decodingInfo.keySystemAccess.keySystem;
1066+
if (preferredKeySystems.includes(originalKeySystem)) {
1067+
continue;
1068+
}
10561069
let drmInfos = drmInfosByKeySystem.get(originalKeySystem);
10571070
if (!drmInfos && this.config_.keySystemsMapping[originalKeySystem]) {
10581071
drmInfos = drmInfosByKeySystem.get(

0 commit comments

Comments
 (0)