Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to filter and reorder key systems prioritization order at application level #2953

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,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 @@ -754,6 +754,12 @@ function ProtectionController(config) {
return protectionKeyController ? protectionKeyController.getKeySystems() : [];
}

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

instance = {
initializeForMedia: initializeForMedia,
createKeySession: createKeySession,
Expand All @@ -767,6 +773,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