Avoid Redundant DRM License Requests for Already-Usable Keys#5016
Open
petegalt wants to merge 1 commit into
Open
Avoid Redundant DRM License Requests for Already-Usable Keys#5016petegalt wants to merge 1 commit into
petegalt wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature Request: Avoid Redundant DRM License Requests for Already-Usable Keys
Summary
When a multi-key DRM license has already been acquired, dash.js currently issues redundant license requests for key IDs (KIDs) that the CDM already reports as
usable. This feature adds checks at multiple points in the protection pipeline to skip unnecessary license exchanges, reducing network overhead and improving playback startup for multi-period or multi-key encrypted content.Motivation
In scenarios involving multi-key licenses (e.g. a single license response covers multiple KIDs), the player may encounter
needkey/encryptedevents or manifest-signaled init data for KIDs that are already available in the CDM. Without this optimization, each event triggers a full license server round-trip even though the CDM can already decrypt the content. This is wasteful and can introduce unnecessary latency, especially on low-bandwidth connections or with rate-limited license servers.Changes
1.
CommonEncryption.js— Extract Key IDs from PSSH boxesextractKeyIdsFromPssh(data)ProtectionControllerto determine which KIDs are referenced in incoming init data.2.
ProtectionController.js— Skip license requests when keys are already usableNew private function:
_isKeyIdUsableInCdm(keyId)keyStatusMapfor a normalized key ID.trueif the CDM reports the key asusable.createKeySession()before creating a new session, short-circuiting if the key is already available.New private function:
_areAllKeysUsableForInitData(initData)CommonEncryption.extractKeyIdsFromPssh()to get all KIDs from the init data.trueonly if every extracted KID is alreadyusablein the CDM._onNeedKey()to skip processingencryptedevents when all referenced keys are already available.Guard in
createKeySession(): Before enforcing session limits or creating a session, checks_isKeyIdUsableInCdm()and returns early with a debug log if the key is already usable.Guard in
_onNeedKey(): After duplicate init data checks but before dispatching to key system selection, checks_areAllKeysUsableForInitData()and returns early for non-SINF init data when all keys are usable.