Skip to content

Commit

Permalink
We encountered an issue inside the rx-player base code. The Webkit
Browse files Browse the repository at this point in the history
implementation of EME update method is waiting for a uInt8Array, so it
means that if we would pass an other type like an ArrayBuffer, webkit
implementation would throw because he is waiting a strict uIn8Array (ttps://github.com/WebKit/WebKit/blob/8afe31a018b11741abdf9b4d5bb973d7c1d9ff05/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp#L134).

So, we are basically casting everything we receive into a uInt8Array to
pass it to the CDM then.
  • Loading branch information
PaulRosset committed Aug 27, 2021
1 parent f893fd0 commit 5cb9aea
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/compat/eme/custom_media_keys/webkit_media_keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class WebkitMediaKeySession
this.keyStatuses = new Map();
this.expiration = NaN;

this.update = (license: Uint8Array) => {
this.update = (license: BufferSource) => {
return new PPromise((resolve, reject) => {
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
if (this._nativeSession === undefined ||
Expand All @@ -122,9 +122,17 @@ class WebkitMediaKeySession
return reject("Unavailable WebKit key session.");
}
try {
let uInt8Arraylicense: Uint8Array;
if (license instanceof ArrayBuffer) {
uInt8Arraylicense = new Uint8Array(license);
} else if (license instanceof Uint8Array) {
uInt8Arraylicense = license;
} else {
uInt8Arraylicense = new Uint8Array(license.buffer);
}
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
resolve(this._nativeSession.update(license));
resolve(this._nativeSession.update(uInt8Arraylicense));
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
} catch (err) {
reject(err);
Expand Down

0 comments on commit 5cb9aea

Please sign in to comment.