Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Key system priority (Dash-Industry-Forum#3107)
Browse files Browse the repository at this point in the history
* Add priorityIndex field in ProtectionData

* Reorder key systems according to priority index provided for each key system in input protection data

* rename priorityIndex by priority

* rename priorityIndex by priority

* Reorder key systems according to priority index provided for each key system in input protection data
  • Loading branch information
bbert committed Mar 31, 2020
1 parent 20a8fe9 commit 4adafb4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,9 @@ declare namespace dashjs {
* Corresponding property values are keys, base64-encoded (no padding).
*/
clearkeys?: { [key: string]: string };

/** Priority level of the key system to be selected (0 is the highest prority, -1 for undefined priority) */
priority?: number = -1;
}

export interface KeySystem {
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 @@ -392,6 +392,13 @@ function ProtectionController(config) {
const self = this;
const requestedKeySystems = [];

// Reorder key systems according to priority order provided in protectionData
supportedKS = supportedKS.sort((ksA, ksB) => {
let indexA = (protDataSet && protDataSet[ksA.ks.systemString] && protDataSet[ksA.ks.systemString].priority >= 0) ? protDataSet[ksA.ks.systemString].priority : supportedKS.length;
let indexB = (protDataSet && protDataSet[ksB.ks.systemString] && protDataSet[ksB.ks.systemString].priority >= 0) ? protDataSet[ksB.ks.systemString].priority : supportedKS.length;
return indexA - indexB;
});

let ksIdx;
if (keySystem) {
// We have a key system
Expand Down

0 comments on commit 4adafb4

Please sign in to comment.