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(DRM): add initData and initDataType to license requests #4039

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions externs/shaka/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ shaka.extern.RetryParameters;
* licenseRequestType: ?string,
* sessionId: ?string,
* drmInfo: ?shaka.extern.DrmInfo,
* initData: ?Uint8Array,
* initDataType: ?string,
* streamDataCallback: ?function(BufferSource):!Promise
* }}
*
Expand Down Expand Up @@ -94,6 +96,12 @@ shaka.extern.RetryParameters;
* @property {?shaka.extern.DrmInfo} drmInfo
* If this is a LICENSE request, this field contains the DRM info used to
* initialize EME.
* @property {?Uint8Array} initData
* If this is a LICENSE request, this field contains the initData info used
* to initialize EME.
* @property {?string} initDataType
* If this is a LICENSE request, this field contains the initDataType info
* used to initialize EME.
* @property {?function(BufferSource):!Promise} streamDataCallback
* A callback function to handle the chunked data of the ReadableStream.
* @exportDoc
Expand Down
9 changes: 9 additions & 0 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,7 @@ shaka.media.DrmEngine = class {

const metadata = {
initData: null,
initDataType: null,
loaded: false,
oldExpiration: Infinity,
updatePromise: null,
Expand Down Expand Up @@ -1245,6 +1246,7 @@ shaka.media.DrmEngine = class {

const metadata = {
initData: initData,
initDataType: initDataType,
loaded: false,
oldExpiration: Infinity,
updatePromise: null,
Expand Down Expand Up @@ -1386,6 +1388,10 @@ shaka.media.DrmEngine = class {
request.licenseRequestType = event.messageType;
request.sessionId = session.sessionId;
request.drmInfo = this.currentDrmInfo_;
if (metadata) {
request.initData = metadata.initData;
request.initDataType = metadata.initDataType;
}
// NOTE: allowCrossSiteCredentials can be set in a request filter.

if (shaka.media.DrmEngine.isPlayReadyKeySystem(
Expand Down Expand Up @@ -2342,6 +2348,7 @@ shaka.media.DrmEngine = class {
* @typedef {{
* loaded: boolean,
* initData: Uint8Array,
* initDataType: ?string,
* oldExpiration: number,
* type: string,
* updatePromise: shaka.util.PublicPromise
Expand All @@ -2353,6 +2360,8 @@ shaka.media.DrmEngine = class {
* does not mean the session is 'usable'.
* @property {Uint8Array} initData
* The init data used to create the session.
* @property {?string} initDataType
* The init data type used to create the session.
* @property {!MediaKeySession} session
* The session object.
* @property {number} oldExpiration
Expand Down
2 changes: 2 additions & 0 deletions lib/net/networking_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ shaka.net.NetworkingEngine = class extends shaka.util.FakeEventTarget {
licenseRequestType: null,
sessionId: null,
drmInfo: null,
initData: null,
initDataType: null,
streamDataCallback: streamDataCallback,
};
}
Expand Down
2 changes: 2 additions & 0 deletions test/util/cmcd_manager_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ describe('CmcdManager', () => {
licenseRequestType: null,
sessionId: null,
drmInfo: null,
initData: null,
initDataType: null,
streamDataCallback: null,
};

Expand Down