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

feat(dash): Construct ClearKey PSSH based on MPD ContentProtection #4104

Merged
merged 3 commits into from Apr 13, 2022

Conversation

sr1990
Copy link
Contributor

@sr1990 sr1990 commented Apr 8, 2022

This PR parses default_KID from ContentProtection in the manifest and constructs a PSSH box from it to feed to the ClearKey CDM only if clear key content is detected.

Example:

<ContentProtection
    schemeIdUri="urn:mpeg:dash:mp4protection:2011" value="cenc"
    cenc:default_KID="9eb4050d-e44b-4802-932e-27d75083e266" />
<ContentProtection
    value="ClearKey1.0" schemeIdUri="urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e">
         <clearkey:Laurl Lic_type="EME-1.0">https://drm-clearkey-testvectors.axtest.net/AcquireLicense</clearkey:Laurl>
 </ContentProtection>

PSSH is based on https://www.w3.org/TR/eme-initdata-cenc/

Tested content:
https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p_ClearKey.mpd

lib/util/pssh.js Outdated
@@ -124,6 +124,49 @@ shaka.util.Pssh = class {
return psshBox;
}

/**
* Creates a ClearKey cenc pssh blob from the given system ID and data.
Copy link
Member

Choose a reason for hiding this comment

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

In fact, this only creates a ClearKey PSSH blob if the system ID is right. It seems more that what this method does is create a v1 PSSH.

It's confusing, though, because you treat "data" as a single key ID, and leave the "data" payload of the PSSH box empty.

There are very few differences between this method and createPssh. If you add version and key ID parameters to createPssh, you could make that method support v1 PSSHs. Then, you could make a convenience method for ClearKey that provides the correct system ID, an empty data field, and passes along a list of key IDs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. Your suggestion sounds good.
Sorry about the confusion regarding "data".
Have made the changes. Please take a look.

if (element.schemeUri ===
shaka.dash.ContentProtection.ClearKeySchemeUri_) {
clearKeyInitData =
ContentProtection.getInitDataClearKey_(element, keyIds);
Copy link
Member

Choose a reason for hiding this comment

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

Should be indented 4, not 2, if I'm not mistaken.

}

const Uint8ArrayUtils = shaka.util.Uint8ArrayUtils;
const [first] = keyIds;
Copy link
Member

Choose a reason for hiding this comment

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

It seems like you should probably use all the key IDs in constructing the PSSH, instead of just the first one.

lib/util/pssh.js Outdated
* @return {!Uint8Array}
*/
static createPssh(data, systemId) {
static createPssh(data,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think all the parameters should go into one line. There is no need to have two lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. Will make the change.
Thought there was a line length limit.

Copy link
Member

Choose a reason for hiding this comment

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

The line limit is 80 characters. :-)

lib/util/pssh.js Outdated
@@ -124,7 +144,6 @@ shaka.util.Pssh = class {
return psshBox;
}


Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the line.

@sr1990 sr1990 requested a review from joeyparrish April 13, 2022 06:31
Copy link
Member

@joeyparrish joeyparrish left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks!

@joeyparrish joeyparrish changed the title feat(dash): [ClearKey] Construct pssh box based on ContentProtection … feat(dash): Construct ClearKey PSSH based on MPD ContentProtection Apr 13, 2022
@joeyparrish joeyparrish merged commit b83b412 into shaka-project:main Apr 13, 2022
@avelad avelad added this to the v4.0 milestone May 4, 2022
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants