Skip to content

Commit d11dc65

Browse files
committed
Fix Uint8Array believed to be an ArrayBuffer when blacklisting based on key-id
Since at least the v3.21.1 release, we had an issue that appeared when blacklisting Representation based on the keyID (e.g. when a `keystatuseschange` event indicates us that we are "output-restricted and when fallbacking is enabled through the related `keySystems` options). This issue prevented from fallbacking, it just threw an Error message along the lines of: `TypeError: DataView: expected ArrayBuffer, got Uint8Array` The root cause was linked to typing issues (we consequently cleverly redirect all wrong-doing to typescript, not our fault at all here :p: microsoft/TypeScript#42534) where an Uint8Array was considered to be a valid ArrayBuffer. At some point, a `new DataView(whatIThoughtToBeAnArrayBufferWhichIsInRealityAUint8Array)` was done, leading to the aforementioned error. The fix here is to now consider the type to be an Uint8Array and to do Uint8Array things instead (i.e. no DataView anymore).
1 parent ea8215b commit d11dc65

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/core/eme/check_key_statuses.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ export default function checkKeyStatuses(
6161
session : MediaKeySession | ICustomMediaKeySession,
6262
options: IKeyStatusesCheckingOptions,
6363
keySystem: string
64-
) : [IEMEWarningEvent[], ArrayBuffer[]] {
64+
) : [IEMEWarningEvent[], Uint8Array[]] {
6565
const warnings : IEMEWarningEvent[] = [];
66-
const blacklistedKeyIDs : ArrayBuffer[] = [];
66+
const blacklistedKeyIDs : Uint8Array[] = [];
6767
const { fallbackOn = {}, throwOnLicenseExpiration } = options;
6868

6969
/* eslint-disable @typescript-eslint/no-unsafe-member-access */

src/core/eme/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export interface ISessionUpdatedEvent {
152152
// blacklisted.
153153
// Emit the corresponding keyIDs as payload.
154154
export interface IBlacklistKeysEvent { type : "blacklist-keys";
155-
value: ArrayBuffer[]; }
155+
value: Uint8Array[]; }
156156

157157
/**
158158
* Event Emitted when specific "protection data" cannot be deciphered and is thus

src/manifest/manifest.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { ICustomError } from "../errors";
1818
import { IParsedManifest } from "../parsers/manifest";
1919
import areArraysOfNumbersEqual from "../utils/are_arrays_of_numbers_equal";
2020
import arrayFind from "../utils/array_find";
21-
import { isABEqualBytes } from "../utils/byte_parsing";
2221
import EventEmitter from "../utils/event_emitter";
2322
import idGenerator from "../utils/id_generator";
2423
import warnOnce from "../utils/warn_once";
@@ -472,7 +471,7 @@ export default class Manifest extends EventEmitter<IManifestEvents> {
472471
* performed.
473472
* @param {Array.<ArrayBuffer>} keyIDs
474473
*/
475-
public addUndecipherableKIDs(keyIDs : ArrayBuffer[]) : void {
474+
public addUndecipherableKIDs(keyIDs : Uint8Array[]) : void {
476475
const updates = updateDeciperability(this, (representation) => {
477476
if (representation.decipherable === false ||
478477
representation.contentProtections === undefined)
@@ -483,7 +482,7 @@ export default class Manifest extends EventEmitter<IManifestEvents> {
483482
for (let i = 0; i < contentKIDs.length; i++) {
484483
const elt = contentKIDs[i];
485484
for (let j = 0; j < keyIDs.length; j++) {
486-
if (isABEqualBytes(keyIDs[j], elt.keyId)) {
485+
if (areArraysOfNumbersEqual(keyIDs[j], elt.keyId)) {
487486
return false;
488487
}
489488
}

0 commit comments

Comments
 (0)