Skip to content

Commit 2a192fb

Browse files
committed
Multi-key handling #7474
1 parent 0ce3f5b commit 2a192fb

File tree

7 files changed

+325
-220
lines changed

7 files changed

+325
-220
lines changed

api-extractor/report/hls.js.api.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ export const enum DecrypterAesMode {
11041104
export type DRMSystemConfiguration = {
11051105
licenseUrl: string;
11061106
serverCertificateUrl?: string;
1107-
generateRequest?: (this: Hls, initDataType: string, initData: ArrayBuffer | null, keyContext: MediaKeySessionContext) => {
1107+
generateRequest?: (this: Hls, initDataType: string, initData: ArrayBuffer | null, keyContext: MediaKeySessionContextAndLevelKey) => {
11081108
initDataType: string;
11091109
initData: ArrayBuffer | null;
11101110
} | undefined | never;
@@ -1189,8 +1189,8 @@ export class EMEController extends Logger implements ComponentAPI {
11891189
//
11901190
// @public (undocumented)
11911191
export type EMEControllerConfig = {
1192-
licenseXhrSetup?: (this: Hls, xhr: XMLHttpRequest, url: string, keyContext: MediaKeySessionContext, licenseChallenge: Uint8Array) => void | Uint8Array | Promise<Uint8Array | void>;
1193-
licenseResponseCallback?: (this: Hls, xhr: XMLHttpRequest, url: string, keyContext: MediaKeySessionContext) => ArrayBuffer;
1192+
licenseXhrSetup?: (this: Hls, xhr: XMLHttpRequest, url: string, keyContext: MediaKeySessionContextAndLevelKey, licenseChallenge: Uint8Array) => void | Uint8Array | Promise<Uint8Array | void>;
1193+
licenseResponseCallback?: (this: Hls, xhr: XMLHttpRequest, url: string, keyContext: MediaKeySessionContextAndLevelKey) => ArrayBuffer;
11941194
emeEnabled: boolean;
11951195
widevineLicenseUrl?: string;
11961196
drmSystems: DRMSystemsConfiguration | undefined;
@@ -3996,16 +3996,18 @@ export type MediaKeyFunc = (keySystem: KeySystems, supportedConfigurations: Medi
39963996
// @public (undocumented)
39973997
export interface MediaKeySessionContext {
39983998
// (undocumented)
3999-
decryptdata: LevelKey;
4000-
// (undocumented)
4001-
keyStatus?: MediaKeyStatus;
3999+
keyStatuses: {
4000+
[keyId: string]: MediaKeyStatus;
4001+
};
40024002
// (undocumented)
40034003
keyStatusTimeouts?: {
40044004
[keyId: string]: number;
40054005
};
40064006
// (undocumented)
40074007
keySystem: KeySystems;
40084008
// (undocumented)
4009+
levelKeys: LevelKey[];
4010+
// (undocumented)
40094011
licenseXhr?: XMLHttpRequest;
40104012
// (undocumented)
40114013
mediaKeys: MediaKeys;
@@ -4017,6 +4019,24 @@ export interface MediaKeySessionContext {
40174019
_onmessage?: (this: MediaKeySession, ev: MediaKeyMessageEvent) => any;
40184020
}
40194021

4022+
// Warning: (ae-missing-release-tag) "MediaKeySessionContextAndLevelKey" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
4023+
//
4024+
// @public (undocumented)
4025+
export type MediaKeySessionContextAndLevelKey = {
4026+
decryptdata: LevelKey;
4027+
keySystem: KeySystems;
4028+
levelKeys: LevelKey[];
4029+
mediaKeys: MediaKeys;
4030+
mediaKeysSession: MediaKeySession;
4031+
keyStatuses: {
4032+
[keyId: string]: MediaKeyStatus;
4033+
};
4034+
keyStatusTimeouts?: {
4035+
[keyId: string]: number;
4036+
};
4037+
licenseXhr?: XMLHttpRequest;
4038+
};
4039+
40204040
// Warning: (ae-missing-release-tag) "MediaOverrides" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
40214041
//
40224042
// @public (undocumented)

src/config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import FetchLoader, { fetchSupported } from './utils/fetch-loader';
1717
import { requestMediaKeySystemAccess } from './utils/mediakeys-helper';
1818
import { stringify } from './utils/safe-json-stringify';
1919
import XhrLoader from './utils/xhr-loader';
20-
import type { MediaKeySessionContext } from './controller/eme-controller';
20+
import type { MediaKeySessionContextAndLevelKey } from './controller/eme-controller';
2121
import type Hls from './hls';
2222
import type {
2323
FragmentLoaderContext,
@@ -92,7 +92,7 @@ export type DRMSystemConfiguration = {
9292
this: Hls,
9393
initDataType: string,
9494
initData: ArrayBuffer | null,
95-
keyContext: MediaKeySessionContext,
95+
keyContext: MediaKeySessionContextAndLevelKey,
9696
) =>
9797
| { initDataType: string; initData: ArrayBuffer | null }
9898
| undefined
@@ -108,14 +108,14 @@ export type EMEControllerConfig = {
108108
this: Hls,
109109
xhr: XMLHttpRequest,
110110
url: string,
111-
keyContext: MediaKeySessionContext,
111+
keyContext: MediaKeySessionContextAndLevelKey,
112112
licenseChallenge: Uint8Array,
113113
) => void | Uint8Array | Promise<Uint8Array | void>;
114114
licenseResponseCallback?: (
115115
this: Hls,
116116
xhr: XMLHttpRequest,
117117
url: string,
118-
keyContext: MediaKeySessionContext,
118+
keyContext: MediaKeySessionContextAndLevelKey,
119119
) => ArrayBuffer;
120120
emeEnabled: boolean;
121121
widevineLicenseUrl?: string;

0 commit comments

Comments
 (0)