diff --git a/index.d.ts b/index.d.ts index 23f0f34a2d..64b5a70c53 100644 --- a/index.d.ts +++ b/index.d.ts @@ -39,6 +39,7 @@ declare namespace dashjs { setProtectionData(protData: ProtectionData): void; getSupportedKeySystemsFromContentProtection(cps: any[]): SupportedKeySystem[]; getKeySystems(): KeySystem[]; + setKeySystems(keySystems: KeySystem[]); stop(): void; reset(): void; } diff --git a/src/streaming/protection/controllers/ProtectionController.js b/src/streaming/protection/controllers/ProtectionController.js index 0239ddabb5..f6fa4d0d8f 100644 --- a/src/streaming/protection/controllers/ProtectionController.js +++ b/src/streaming/protection/controllers/ProtectionController.js @@ -761,6 +761,12 @@ function ProtectionController(config) { return protectionKeyController ? protectionKeyController.getKeySystems() : []; } + function setKeySystems(keySystems) { + if (protectionKeyController) { + protectionKeyController.setKeySystems(keySystems); + } + } + instance = { initializeForMedia: initializeForMedia, createKeySession: createKeySession, @@ -774,6 +780,7 @@ function ProtectionController(config) { setProtectionData: setProtectionData, getSupportedKeySystemsFromContentProtection: getSupportedKeySystemsFromContentProtection, getKeySystems: getKeySystems, + setKeySystems: setKeySystems, stop: stop, reset: reset }; diff --git a/src/streaming/protection/controllers/ProtectionKeyController.js b/src/streaming/protection/controllers/ProtectionKeyController.js index 5bc26deead..f3ca487996 100644 --- a/src/streaming/protection/controllers/ProtectionKeyController.js +++ b/src/streaming/protection/controllers/ProtectionKeyController.js @@ -106,6 +106,19 @@ function ProtectionKeyController() { return keySystems; } + /** + * Sets the prioritized list of key systems to be supported + * by this player. + * + * @param {Array.} newKeySystems the new prioritized + * list of key systems + * @memberof module:ProtectionKeyController + * @instance + */ + function setKeySystems(newKeySystems) { + keySystems = newKeySystems; + } + /** * Returns the key system associated with the given key system string * name (i.e. 'org.w3.clearkey') @@ -195,19 +208,13 @@ function ProtectionKeyController() { if (cp.schemeIdUri.toLowerCase() === ks.schemeIdURI) { // Look for DRM-specific ContentProtection let initData = ks.getInitData(cp); - if (!!initData) { - supportedKS.push({ - ks: keySystems[ksIdx], - initData: initData, - cdmData: ks.getCDMData(), - sessionId: ks.getSessionId(cp) - }); - } else if (this.isClearKey(ks)) { - supportedKS.push({ - ks: ks, - initData: null - }); - } + + supportedKS.push({ + ks: keySystems[ksIdx], + initData: initData, + cdmData: ks.getCDMData(), + sessionId: ks.getSessionId(cp) + }); } } } @@ -336,6 +343,7 @@ function ProtectionKeyController() { isClearKey: isClearKey, initDataEquals: initDataEquals, getKeySystems: getKeySystems, + setKeySystems: setKeySystems, getKeySystemBySystemString: getKeySystemBySystemString, getSupportedKeySystemsFromContentProtection: getSupportedKeySystemsFromContentProtection, getSupportedKeySystems: getSupportedKeySystems,