Skip to content

Commit 5ed1ce8

Browse files
committed
Multi-key handling #7474
1 parent f9e23c0 commit 5ed1ce8

File tree

8 files changed

+514
-377
lines changed

8 files changed

+514
-377
lines changed

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

Lines changed: 16 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;
@@ -1172,6 +1172,8 @@ export class EMEController extends Logger implements ComponentAPI {
11721172
// (undocumented)
11731173
destroy(): void;
11741174
// (undocumented)
1175+
getKeyStatus(decryptdata: LevelKey): MediaKeyStatus | undefined;
1176+
// (undocumented)
11751177
getKeySystemAccess(keySystemsToAttempt: KeySystems[]): Promise<void>;
11761178
// (undocumented)
11771179
getSelectedKeySystemFormats(): KeySystemFormats[];
@@ -1187,8 +1189,8 @@ export class EMEController extends Logger implements ComponentAPI {
11871189
//
11881190
// @public (undocumented)
11891191
export type EMEControllerConfig = {
1190-
licenseXhrSetup?: (this: Hls, xhr: XMLHttpRequest, url: string, keyContext: MediaKeySessionContext, licenseChallenge: Uint8Array) => void | Uint8Array | Promise<Uint8Array | void>;
1191-
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;
11921194
emeEnabled: boolean;
11931195
widevineLicenseUrl?: string;
11941196
drmSystems: DRMSystemsConfiguration | undefined;
@@ -3381,6 +3383,8 @@ export class LevelKey implements DecryptData {
33813383
// (undocumented)
33823384
pssh: Uint8Array<ArrayBuffer> | null;
33833385
// (undocumented)
3386+
static setKeyIdForUri(uri: string, keyId: Uint8Array<ArrayBuffer>): void;
3387+
// (undocumented)
33843388
readonly uri: string;
33853389
}
33863390

@@ -3992,12 +3996,14 @@ export type MediaKeyFunc = (keySystem: KeySystems, supportedConfigurations: Medi
39923996
// @public (undocumented)
39933997
export interface MediaKeySessionContext {
39943998
// (undocumented)
3995-
decryptdata: LevelKey;
3996-
// (undocumented)
3997-
keyStatus: MediaKeyStatus;
3999+
keyStatuses: {
4000+
[keyId: string]: MediaKeyStatus;
4001+
};
39984002
// (undocumented)
39994003
keySystem: KeySystems;
40004004
// (undocumented)
4005+
levelKeys: LevelKey[];
4006+
// (undocumented)
40014007
licenseXhr?: XMLHttpRequest;
40024008
// (undocumented)
40034009
mediaKeys: MediaKeys;
@@ -5006,6 +5012,10 @@ export class XhrLoader implements Loader<LoaderContext> {
50065012
stats: LoaderStats;
50075013
}
50085014

5015+
// Warnings were encountered during analysis:
5016+
//
5017+
// src/config.ts:91:3 - (ae-forgotten-export) The symbol "MediaKeySessionContextAndLevelKey" needs to be exported by the entry point hls.d.ts
5018+
50095019
// (No @packageDocumentation comment for this package)
50105020

50115021
```

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)