Skip to content

Commit af092db

Browse files
aveladjoeyparrish
authored andcommitted
fix: Fix usage of keySystemsMapping (#7736)
Related to #7613
1 parent 4fa236e commit af092db

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

lib/media/drm_engine.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -928,14 +928,16 @@ shaka.media.DrmEngine = class {
928928
'Got MediaKeySystemAccess with configuration',
929929
realConfig);
930930

931+
const keySystem =
932+
this.config_.keySystemsMapping[mediaKeySystemAccess.keySystem] ||
933+
mediaKeySystemAccess.keySystem;
934+
931935
if (variants.length) {
932936
this.currentDrmInfo_ = this.createDrmInfoByInfos_(
933-
mediaKeySystemAccess.keySystem,
934-
drmInfosByKeySystem.get(mediaKeySystemAccess.keySystem));
937+
keySystem, drmInfosByKeySystem.get(keySystem));
935938
} else {
936939
this.currentDrmInfo_ = shaka.media.DrmEngine.createDrmInfoByConfigs_(
937-
mediaKeySystemAccess.keySystem,
938-
configsByKeySystem.get(mediaKeySystemAccess.keySystem));
940+
keySystem, configsByKeySystem.get(keySystem));
939941
}
940942
if (!this.currentDrmInfo_.licenseServerUri) {
941943
throw new shaka.util.Error(
@@ -1050,8 +1052,12 @@ shaka.media.DrmEngine = class {
10501052
if (!decodingInfo.supported || !decodingInfo.keySystemAccess) {
10511053
continue;
10521054
}
1053-
const drmInfos =
1054-
drmInfosByKeySystem.get(decodingInfo.keySystemAccess.keySystem);
1055+
const originalKeySystem = decodingInfo.keySystemAccess.keySystem;
1056+
let drmInfos = drmInfosByKeySystem.get(originalKeySystem);
1057+
if (!drmInfos && this.config_.keySystemsMapping[originalKeySystem]) {
1058+
drmInfos = drmInfosByKeySystem.get(
1059+
this.config_.keySystemsMapping[originalKeySystem]);
1060+
}
10551061
for (const info of drmInfos) {
10561062
if (!!info.licenseServerUri == shouldHaveLicenseServer) {
10571063
return decodingInfo.keySystemAccess;

lib/media/manifest_filterer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ shaka.media.ManifestFilterer = class {
5050
async filterManifest(manifest) {
5151
goog.asserts.assert(manifest, 'Manifest should exist!');
5252
await shaka.util.StreamUtils.filterManifest(this.drmEngine_, manifest,
53-
this.config_.drm.preferredKeySystems);
53+
this.config_.drm.preferredKeySystems,
54+
this.config_.drm.keySystemsMapping);
5455
if (!this.config_.streaming.dontChooseCodecs) {
5556
shaka.util.StreamUtils.chooseCodecsAndFilterManifest(
5657
manifest,

lib/offline/storage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ shaka.offline.Storage = class {
702702
// to play later (no point storing something we can't play).
703703
await shaka.util.StreamUtils.filterManifestByMediaCapabilities(
704704
drmEngine, manifest, config.offline.usePersistentLicense,
705-
config.drm.preferredKeySystems);
705+
config.drm.preferredKeySystems, config.drm.keySystemsMapping);
706706

707707
// Gather all tracks.
708708
const allTracks = [];

lib/util/stream_utils.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,13 @@ shaka.util.StreamUtils = class {
393393
* @param {shaka.media.DrmEngine} drmEngine
394394
* @param {shaka.extern.Manifest} manifest
395395
* @param {!Array<string>=} preferredKeySystems
396+
* @param {!Object.<string, string>=} keySystemsMapping
396397
*/
397-
static async filterManifest(drmEngine, manifest, preferredKeySystems = []) {
398+
static async filterManifest(drmEngine, manifest, preferredKeySystems = [],
399+
keySystemsMapping = {}) {
398400
await shaka.util.StreamUtils.filterManifestByMediaCapabilities(
399401
drmEngine, manifest, manifest.offlineSessionIds.length > 0,
400-
preferredKeySystems);
402+
preferredKeySystems, keySystemsMapping);
401403
shaka.util.StreamUtils.filterTextStreams_(manifest);
402404
await shaka.util.StreamUtils.filterImageStreams_(manifest);
403405
}
@@ -411,9 +413,11 @@ shaka.util.StreamUtils = class {
411413
* @param {shaka.extern.Manifest} manifest
412414
* @param {boolean} usePersistentLicenses
413415
* @param {!Array<string>} preferredKeySystems
416+
* @param {!Object.<string, string>} keySystemsMapping
414417
*/
415418
static async filterManifestByMediaCapabilities(
416-
drmEngine, manifest, usePersistentLicenses, preferredKeySystems) {
419+
drmEngine, manifest, usePersistentLicenses, preferredKeySystems,
420+
keySystemsMapping) {
417421
goog.asserts.assert(navigator.mediaCapabilities,
418422
'MediaCapabilities should be valid.');
419423

@@ -435,7 +439,8 @@ shaka.util.StreamUtils = class {
435439
const StreamUtils = shaka.util.StreamUtils;
436440

437441
manifest.variants = manifest.variants.filter((variant) => {
438-
const supported = StreamUtils.checkVariantSupported_(variant, keySystem);
442+
const supported = StreamUtils.checkVariantSupported_(
443+
variant, keySystem, keySystemsMapping);
439444
// Filter out all unsupported variants.
440445
if (!supported) {
441446
shaka.log.debug('Dropping variant - not compatible with platform',
@@ -485,18 +490,22 @@ shaka.util.StreamUtils = class {
485490
/**
486491
* @param {!shaka.extern.Variant} variant
487492
* @param {?string} keySystem
493+
* @param {!Object.<string, string>} keySystemsMapping
488494
* @return {boolean}
489495
* @private
490496
*/
491-
static checkVariantSupported_(variant, keySystem) {
497+
static checkVariantSupported_(variant, keySystem, keySystemsMapping) {
492498
const variantSupported = variant.decodingInfos.some((decodingInfo) => {
493499
if (!decodingInfo.supported) {
494500
return false;
495501
}
496502
if (keySystem) {
497503
const keySystemAccess = decodingInfo.keySystemAccess;
498504
if (keySystemAccess) {
499-
if (keySystemAccess.keySystem != keySystem) {
505+
const currentKeySystem =
506+
keySystemsMapping[keySystemAccess.keySystem] ||
507+
keySystemAccess.keySystem;
508+
if (currentKeySystem != keySystem) {
500509
return false;
501510
}
502511
}

0 commit comments

Comments
 (0)