Skip to content

Commit

Permalink
fix(DRM): Fix drm choice when the user provide a server in the manife…
Browse files Browse the repository at this point in the history
…st (#8067)

Fixes #8066

Backported to v4.9.x
  • Loading branch information
avelad authored and joeyparrish committed Feb 22, 2025
1 parent 3fdbd13 commit 79e47af
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,17 @@ shaka.media.DrmEngine = class {

// If we have configured preferredKeySystems, choose a preferred keySystem
// if available.
for (const preferredKeySystem of this.config_.preferredKeySystems) {
let preferredKeySystems = this.config_.preferredKeySystems;
if (!preferredKeySystems.length) {
// If there is no preference set and we only have one license server, we
// use this as preference. This is used to override manifests on those
// that have the embedded license and the browser supports multiple DRMs.
const servers = shaka.util.MapUtils.asMap(this.config_.servers);
if (servers.size == 1) {
preferredKeySystems = Array.from(servers.keys());
}
}
for (const preferredKeySystem of preferredKeySystems) {
for (const variant of variants) {
const decodingInfo = variant.decodingInfos.find((decodingInfo) => {
return decodingInfo.supported &&
Expand All @@ -1028,8 +1038,15 @@ shaka.media.DrmEngine = class {
if (!decodingInfo.supported || !decodingInfo.keySystemAccess) {
continue;
}
const drmInfos =
drmInfosByKeySystem.get(decodingInfo.keySystemAccess.keySystem);
const originalKeySystem = decodingInfo.keySystemAccess.keySystem;
if (preferredKeySystems.includes(originalKeySystem)) {
continue;
}
let drmInfos = drmInfosByKeySystem.get(originalKeySystem);
if (!drmInfos && this.config_.keySystemsMapping[originalKeySystem]) {
drmInfos = drmInfosByKeySystem.get(
this.config_.keySystemsMapping[originalKeySystem]);
}
for (const info of drmInfos) {
if (!!info.licenseServerUri == shouldHaveLicenseServer) {
return decodingInfo.keySystemAccess;
Expand Down

0 comments on commit 79e47af

Please sign in to comment.