Skip to content

Commit

Permalink
Add extended error code for failed license request
Browse files Browse the repository at this point in the history
Issue #1689

Change-Id: I7d3b4eee487395fdb8c121a4b6acc11ec461f0e3
  • Loading branch information
TheModMaker committed Nov 28, 2018
1 parent c8de10b commit 76f7818
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
11 changes: 10 additions & 1 deletion lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1077,11 +1077,20 @@ shaka.media.DrmEngine.prototype.createTemporarySession_ =

this.activeSessions_.delete(session);

let extended;
if (error.errorCode && error.errorCode.systemCode) {
extended = error.errorCode.systemCode;
if (extended < 0) {
extended += Math.pow(2, 32);
}
extended = '0x' + extended.toString(16);
}

this.onError_(new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,
shaka.util.Error.Code.FAILED_TO_GENERATE_LICENSE_REQUEST,
error.message));
error.message, error, extended));
});
};

Expand Down
2 changes: 2 additions & 0 deletions lib/util/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,8 @@ shaka.util.Error.Code = {
* The CDM was unable to generate a license request for the init data it was
* given. The init data may be malformed or in an unsupported format.
* <br> error.data[0] is an error message string from the browser.
* <br> error.data[1] is the error object from the browser.
* <br> error.data[2] is a string with the extended error code, if available.
*/
'FAILED_TO_GENERATE_LICENSE_REQUEST': 6006,

Expand Down
7 changes: 3 additions & 4 deletions test/media/drm_engine_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,8 @@ describe('DrmEngine', function() {

// Fail generateRequest.
let session1 = createMockSession();
session1.generateRequest.and.returnValue(Promise.reject({
message: 'whoops!',
}));
const nativeError = {message: 'whoops!'};
session1.generateRequest.and.returnValue(Promise.reject(nativeError));
mockMediaKeys.createSession.and.returnValue(session1);

onErrorSpy.and.stub();
Expand All @@ -796,7 +795,7 @@ describe('DrmEngine', function() {
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.DRM,
shaka.util.Error.Code.FAILED_TO_GENERATE_LICENSE_REQUEST,
'whoops!'));
nativeError.message, nativeError, undefined));
});
}); // describe('attach')

Expand Down

0 comments on commit 76f7818

Please sign in to comment.