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

Fix regression in key system selection based on priority #3935

Merged
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
14 changes: 7 additions & 7 deletions src/streaming/protection/controllers/ProtectionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ function ProtectionController(config) {
// and video will be the same. Just use one valid MediaInfo object
let supportedKS = protectionKeyController.getSupportedKeySystemsFromContentProtection(mediaInfo.contentProtection, protDataSet, sessionType);

// 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;
});

if (supportedKS && supportedKS.length > 0) {
_selectKeySystem(supportedKS, true);
}
Expand Down Expand Up @@ -174,6 +167,13 @@ function ProtectionController(config) {
keySystemSelectionInProgress = true;
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;
});

pendingKeySystemData.push(supportedKS);

// Add all key systems to our request list since we have yet to select a key system
Expand Down