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/multiple temporary drm session #1185

Closed

Conversation

el-gringo
Copy link

On our live DASH + Widevine streams, the player creates many temporary DRM sessions and so trigger as many license resquest to our Widevine server.

This pull request tend to fix 2 issues.

  • The player tries to detect keyId in the MP4 initialization fragment in the tenc box to test it against our current DRM session's keyIds. In our streams, this keyId is filled with zero and will not be compatible with our current session's keyIds.
  • In KeySessionRecord.isCompatibleWith, the initializationData.values was never tested because testing initializationData.keys returns false before.

Note:

  • I have removed testing keys again in _checkInitializationDataCompatibility as I am not sure how useful it is.
  • Finally, after fixing the initializationData.keys test, the zero keyId does not fail the DRM session keyId tests. So I am not sure if we still want to key this test or consider the zero keyId as valid

Fix #1183

const keyId = tenc.subarray(8, 24);
return isValidKeyId(keyId)
? keyId
: null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a resource that tells that a all 0 key id is invalid?

* @returns {Boolean} True if value equals zero
*/
function isZero(value: number) {
return value === 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function's utility looks too small to me to justify creating a function

@@ -148,8 +148,8 @@ export default class KeySessionRecord {
if (this._keyIds !== null && areAllKeyIdsContainedIn(keyIds, this._keyIds)) {
return true;
}
if (this._initializationData.keyIds !== undefined) {
return areAllKeyIdsContainedIn(keyIds, this._initializationData.keyIds);
if (this._initializationData.keyIds !== undefined && areAllKeyIdsContainedIn(keyIds, this._initializationData.keyIds)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, if a wanted key id is not linked to a session, then the license has to be loaded, else we would be breaking legitimate use cases.

{
return areAllKeyIdsContainedIn(initializationData.keyIds,
this._initializationData.keyIds);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're removing this, we may want to rename the method.
Maybe the best thing would be to inline the method altogether as moreover it seems to be used only once?

Copy link
Collaborator

@peaBerberian peaBerberian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some reserves with this PR:

  • Is an all 0 key-id guaranteed to be invalid? Ignoring some key ids seems dangerous to me.
  • To me if key ids are known both for the current initialization data and for the one associated to a KeySessionRecord, then it should be the preferred token to determine if a MediaKeySession already handles a key (through the KeySessionRecord). Comparing what here is called initializationData values, which are actually the full pssh, seems less precize to me. If the issue was with the former logic, then it may be a bug that I would prefer to fix instead.

@peaBerberian
Copy link
Collaborator

Closing this as it is an old stale PR (I'm cleaning them up). Do not hesitate to re-open if you have updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Many DRM session created
2 participants