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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,16 +90,22 @@ shaka.util.Pssh = class { | |
} | ||
|
||
/** | ||
* Creates a pssh blob from the given system ID and data. | ||
* Creates a pssh blob from the given system ID, data, keyIds and version. | ||
* | ||
* @param {!Uint8Array} data | ||
* @param {!Uint8Array} systemId | ||
* @param {!Set.<string>} keyIds | ||
* @param {number} version | ||
* @return {!Uint8Array} | ||
*/ | ||
static createPssh(data, systemId) { | ||
static createPssh(data, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. Will make the change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The line limit is 80 characters. :-) |
||
systemId, keyIds, version) { | ||
goog.asserts.assert(systemId.byteLength == 16, 'Invalid system ID length'); | ||
const dataLength = data.length; | ||
const psshSize = 0x4 + 0x4 + 0x4 + systemId.length + 0x4 + dataLength; | ||
let psshSize = 0x4 + 0x4 + 0x4 + systemId.length + 0x4 + dataLength; | ||
if (version > 0) { | ||
psshSize += 0x4 + (16 * keyIds.size); | ||
} | ||
|
||
/** @type {!Uint8Array} */ | ||
const psshBox = new Uint8Array(psshSize); | ||
|
@@ -111,10 +117,24 @@ shaka.util.Pssh = class { | |
byteCursor += 0x4; | ||
psshData.setUint32(byteCursor, 0x70737368); // 'pssh' | ||
byteCursor += 0x4; | ||
psshData.setUint32(byteCursor, 0); // flags | ||
(version < 1) ? psshData.setUint32(byteCursor, 0) : | ||
psshData.setUint32(byteCursor, 0x01000000); // version + flags | ||
byteCursor += 0x4; | ||
psshBox.set(systemId, byteCursor); | ||
byteCursor += systemId.length; | ||
|
||
// if version > 0, add KID count and kid values. | ||
if (version > 0) { | ||
psshData.setUint32(byteCursor, keyIds.size); // KID_count | ||
byteCursor += 0x4; | ||
const Uint8ArrayUtils = shaka.util.Uint8ArrayUtils; | ||
for (const keyId of keyIds) { | ||
const KID = Uint8ArrayUtils.fromHex(keyId); | ||
psshBox.set(KID, byteCursor); | ||
byteCursor += KID.length; | ||
} | ||
} | ||
|
||
psshData.setUint32(byteCursor, dataLength); | ||
byteCursor += 0x4; | ||
psshBox.set(data, byteCursor); | ||
|
@@ -124,7 +144,6 @@ shaka.util.Pssh = class { | |
return psshBox; | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added the line. |
||
/** | ||
* Normalise the initData array. This is to apply browser specific | ||
* work-arounds, e.g. removing duplicates which appears to occur | ||
|
There was a problem hiding this comment.
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.