Skip to content

Commit

Permalink
Merge pull request #2953 from Orange-OpenSource/set-key-systems
Browse files Browse the repository at this point in the history
Add possibility to filter and reorder key systems prioritization order at application level
  • Loading branch information
epiclabsDASH authored Apr 5, 2019
2 parents fc8ce46 + dfd270f commit 61f8ac6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ declare namespace dashjs {
setProtectionData(protData: ProtectionData): void;
getSupportedKeySystemsFromContentProtection(cps: any[]): SupportedKeySystem[];
getKeySystems(): KeySystem[];
setKeySystems(keySystems: KeySystem[]);
stop(): void;
reset(): void;
}
Expand Down
7 changes: 7 additions & 0 deletions src/streaming/protection/controllers/ProtectionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,12 @@ function ProtectionController(config) {
return protectionKeyController ? protectionKeyController.getKeySystems() : [];
}

function setKeySystems(keySystems) {
if (protectionKeyController) {
protectionKeyController.setKeySystems(keySystems);
}
}

instance = {
initializeForMedia: initializeForMedia,
createKeySession: createKeySession,
Expand All @@ -774,6 +780,7 @@ function ProtectionController(config) {
setProtectionData: setProtectionData,
getSupportedKeySystemsFromContentProtection: getSupportedKeySystemsFromContentProtection,
getKeySystems: getKeySystems,
setKeySystems: setKeySystems,
stop: stop,
reset: reset
};
Expand Down
34 changes: 21 additions & 13 deletions src/streaming/protection/controllers/ProtectionKeyController.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ function ProtectionKeyController() {
return keySystems;
}

/**
* Sets the prioritized list of key systems to be supported
* by this player.
*
* @param {Array.<KeySystem>} 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')
Expand Down Expand Up @@ -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)
});
}
}
}
Expand Down Expand Up @@ -336,6 +343,7 @@ function ProtectionKeyController() {
isClearKey: isClearKey,
initDataEquals: initDataEquals,
getKeySystems: getKeySystems,
setKeySystems: setKeySystems,
getKeySystemBySystemString: getKeySystemBySystemString,
getSupportedKeySystemsFromContentProtection: getSupportedKeySystemsFromContentProtection,
getSupportedKeySystems: getSupportedKeySystems,
Expand Down

0 comments on commit 61f8ac6

Please sign in to comment.