From dc94fe49343ee22a5b1879555bef7fbabcceea55 Mon Sep 17 00:00:00 2001 From: Daniel Silhavy Date: Thu, 21 Nov 2024 09:01:01 +0100 Subject: [PATCH] Add a settings flag to ignore the keystatusmap (#4629) --- index.d.ts | 1 + src/core/Settings.js | 7 ++++++- .../protection/controllers/ProtectionController.js | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index c91f2841d9..ea6e3f7067 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1079,6 +1079,7 @@ declare namespace dashjs { keepProtectionMediaKeys?: boolean, ignoreEmeEncryptedEvent?: boolean, detectPlayreadyMessageFormat?: boolean, + ignoreKeyStatuses?: boolean, }, buffer?: { enableSeekDecorrelationFix?: boolean, diff --git a/src/core/Settings.js b/src/core/Settings.js index 422a032e0d..100289ace4 100644 --- a/src/core/Settings.js +++ b/src/core/Settings.js @@ -102,6 +102,7 @@ import Events from './events/Events.js'; * keepProtectionMediaKeys: false, * ignoreEmeEncryptedEvent: false, * detectPlayreadyMessageFormat: true, + * ignoreKeyStatuses: false * }, * buffer: { * enableSeekDecorrelationFix: false, @@ -673,6 +674,9 @@ import Events from './events/Events.js'; * * @property {boolean} [detectPlayreadyMessageFormat=true] * If set to true the player will use the raw unwrapped message from the Playready CDM + * + * @property {boolean} [ignoreKeyStatusest=false] + * If set to true the player will ignore the status of a key and try to play the corresponding track regardless whether the key is usable or not. */ /** @@ -885,7 +889,7 @@ import Events from './events/Events.js'; * If not specified this value defaults to ['segment']. * @property {number} [version=1] * The version of the CMCD to use. - * + * * If not specified this value defaults to 1. */ @@ -1109,6 +1113,7 @@ function Settings() { keepProtectionMediaKeys: false, ignoreEmeEncryptedEvent: false, detectPlayreadyMessageFormat: true, + ignoreKeyStatuses: false }, buffer: { enableSeekDecorrelationFix: false, diff --git a/src/streaming/protection/controllers/ProtectionController.js b/src/streaming/protection/controllers/ProtectionController.js index 89f8772a18..a0334c1de9 100644 --- a/src/streaming/protection/controllers/ProtectionController.js +++ b/src/streaming/protection/controllers/ProtectionController.js @@ -1138,7 +1138,9 @@ function ProtectionController(config) { } const keyIdInHex = Utils.bufferSourceToHex(keyStatus.keyId).slice(0, 32); - keyStatusMap.set(keyIdInHex, keyStatus.status); + if (keyIdInHex && keyIdInHex !== '') { + keyStatusMap.set(keyIdInHex, keyStatus.status); + } }) eventBus.trigger(events.KEY_STATUSES_MAP_UPDATED, { keyStatusMap }); } catch (e) { @@ -1159,7 +1161,7 @@ function ProtectionController(config) { function areKeyIdsUsable(normalizedKeyIds) { try { - if (!normalizedKeyIds || normalizedKeyIds.size === 0 || !keyStatusMap || keyStatusMap.size === 0) { + if (!normalizedKeyIds || normalizedKeyIds.size === 0 || !keyStatusMap || keyStatusMap.size === 0 || settings.get().streaming.protection.ignoreKeyStatuses) { return true; }