hls.js 1.6.0-beta.2.0.canary.10876 → 1.6.0-beta.2.0.canary.10878

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hls.mjs CHANGED
@@ -401,7 +401,7 @@ function enableLogs(debugConfig, context, id) {
401
401
  // Some browsers don't allow to use bind on console object anyway
402
402
  // fallback to default if needed
403
403
  try {
404
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.10876"}`);
404
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.10878"}`);
405
405
  } catch (e) {
406
406
  /* log fn threw an exception. All logger methods are no-ops. */
407
407
  return createLogger();
@@ -9847,7 +9847,7 @@ var eventemitter3 = {exports: {}};
9847
9847
  var eventemitter3Exports = eventemitter3.exports;
9848
9848
  var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
9849
9849
 
9850
- const version = "1.6.0-beta.2.0.canary.10876";
9850
+ const version = "1.6.0-beta.2.0.canary.10878";
9851
9851
 
9852
9852
  // ensure the worker ends up in the bundle
9853
9853
  // If the worker should not be included this gets aliased to empty.js
@@ -21102,109 +21102,127 @@ class EMEController extends Logger {
21102
21102
  if (initData === null) {
21103
21103
  return;
21104
21104
  }
21105
- let keyId;
21106
- let keySystemDomain;
21107
- if (initDataType === 'sinf' && this.getLicenseServerUrl(KeySystems.FAIRPLAY)) {
21108
- // Match sinf keyId to playlist skd://keyId=
21109
- const json = bin2str(new Uint8Array(initData));
21110
- try {
21111
- const sinf = base64Decode(JSON.parse(json).sinf);
21112
- const tenc = parseSinf(sinf);
21113
- if (!tenc) {
21114
- throw new Error(`'schm' box missing or not cbcs/cenc with schi > tenc`);
21115
- }
21116
- keyId = tenc.subarray(8, 24);
21117
- keySystemDomain = KeySystems.FAIRPLAY;
21118
- } catch (error) {
21119
- this.warn(`${logMessage} Failed to parse sinf: ${error}`);
21120
- return;
21121
- }
21122
- } else if (this.getLicenseServerUrl(KeySystems.WIDEVINE)) {
21123
- // Support Widevine clear-lead key-session creation (otherwise depend on playlist keys)
21124
- const psshResults = parseMultiPssh(initData);
21125
-
21126
- // TODO: If using keySystemAccessPromises we might want to wait until one is resolved
21105
+ if (!this.keyFormatPromise) {
21127
21106
  let keySystems = Object.keys(this.keySystemAccessPromises);
21128
21107
  if (!keySystems.length) {
21129
21108
  keySystems = getKeySystemsForConfig(this.config);
21130
21109
  }
21131
- const psshInfo = psshResults.filter(pssh => {
21132
- const keySystem = pssh.systemId ? keySystemIdToKeySystemDomain(pssh.systemId) : null;
21133
- return keySystem ? keySystems.indexOf(keySystem) > -1 : false;
21134
- })[0];
21135
- if (!psshInfo) {
21136
- if (psshResults.length === 0 || psshResults.some(pssh => !pssh.systemId)) {
21137
- this.warn(`${logMessage} contains incomplete or invalid pssh data`);
21138
- } else {
21139
- this.log(`ignoring ${logMessage} for ${psshResults.map(pssh => keySystemIdToKeySystemDomain(pssh.systemId)).join(',')} pssh data in favor of playlist keys`);
21110
+ const keyFormats = keySystems.map(keySystemDomainToKeySystemFormat).filter(k => !!k);
21111
+ this.keyFormatPromise = this.getKeyFormatPromise(keyFormats);
21112
+ }
21113
+ this.keyFormatPromise.then(keySystemFormat => {
21114
+ const keySystem = keySystemFormatToKeySystemDomain(keySystemFormat);
21115
+ let keyId;
21116
+ let keySystemDomain;
21117
+ if (initDataType === 'sinf') {
21118
+ if (keySystem !== KeySystems.FAIRPLAY) {
21119
+ this.warn(`Ignoring unexpected "${event.type}" event with init data type: "${initDataType}" for selected key-system ${keySystem}`);
21120
+ return;
21140
21121
  }
21141
- return;
21142
- }
21143
- keySystemDomain = keySystemIdToKeySystemDomain(psshInfo.systemId);
21144
- if (psshInfo.version === 0 && psshInfo.data) {
21145
- if (keySystemDomain === KeySystems.WIDEVINE) {
21146
- const offset = psshInfo.data.length - 22;
21147
- keyId = psshInfo.data.subarray(offset, offset + 16);
21148
- } else if (keySystemDomain === KeySystems.PLAYREADY) {
21149
- keyId = parsePlayReadyWRM(psshInfo.data);
21122
+ // Match sinf keyId to playlist skd://keyId=
21123
+ const json = bin2str(new Uint8Array(initData));
21124
+ try {
21125
+ const sinf = base64Decode(JSON.parse(json).sinf);
21126
+ const tenc = parseSinf(sinf);
21127
+ if (!tenc) {
21128
+ throw new Error(`'schm' box missing or not cbcs/cenc with schi > tenc`);
21129
+ }
21130
+ keyId = tenc.subarray(8, 24);
21131
+ keySystemDomain = KeySystems.FAIRPLAY;
21132
+ } catch (error) {
21133
+ this.warn(`${logMessage} Failed to parse sinf: ${error}`);
21134
+ return;
21135
+ }
21136
+ } else {
21137
+ if (keySystem !== KeySystems.WIDEVINE && keySystem !== KeySystems.PLAYREADY) {
21138
+ this.warn(`Ignoring unexpected "${event.type}" event with init data type: "${initDataType}" for selected key-system ${keySystem}`);
21139
+ return;
21140
+ }
21141
+ // Support Widevine/PlayReady clear-lead key-session creation (otherwise depend on playlist keys)
21142
+ const psshResults = parseMultiPssh(initData);
21143
+ const psshInfos = psshResults.filter(pssh => !!pssh.systemId && keySystemIdToKeySystemDomain(pssh.systemId) === keySystem);
21144
+ if (psshInfos.length > 1) {
21145
+ this.warn(`${logMessage} Using first of ${psshInfos.length} pssh found for selected key-system ${keySystem}`);
21146
+ }
21147
+ const psshInfo = psshInfos[0];
21148
+ if (!psshInfo) {
21149
+ if (psshResults.length === 0 || psshResults.some(pssh => !pssh.systemId)) {
21150
+ this.warn(`${logMessage} contains incomplete or invalid pssh data`);
21151
+ } else {
21152
+ this.log(`ignoring ${logMessage} for ${psshResults.map(pssh => keySystemIdToKeySystemDomain(pssh.systemId)).join(',')} pssh data in favor of playlist keys`);
21153
+ }
21154
+ return;
21155
+ }
21156
+ keySystemDomain = keySystemIdToKeySystemDomain(psshInfo.systemId);
21157
+ if (psshInfo.version === 0 && psshInfo.data) {
21158
+ if (keySystemDomain === KeySystems.WIDEVINE) {
21159
+ const offset = psshInfo.data.length - 22;
21160
+ keyId = psshInfo.data.subarray(offset, offset + 16);
21161
+ } else if (keySystemDomain === KeySystems.PLAYREADY) {
21162
+ keyId = parsePlayReadyWRM(psshInfo.data);
21163
+ }
21150
21164
  }
21151
21165
  }
21152
- }
21153
- if (!keySystemDomain || !keyId) {
21154
- return;
21155
- }
21156
- const keyIdHex = Hex.hexDump(keyId);
21157
- const {
21158
- keyIdToKeySessionPromise,
21159
- mediaKeySessions
21160
- } = this;
21161
- let keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex];
21162
- for (let i = 0; i < mediaKeySessions.length; i++) {
21163
- // Match playlist key
21164
- const keyContext = mediaKeySessions[i];
21165
- const decryptdata = keyContext.decryptdata;
21166
- if (!decryptdata.keyId) {
21167
- continue;
21166
+ if (!keySystemDomain || !keyId) {
21167
+ return;
21168
21168
  }
21169
- const oldKeyIdHex = Hex.hexDump(decryptdata.keyId);
21170
- if (keyIdHex === oldKeyIdHex || decryptdata.uri.replace(/-/g, '').indexOf(keyIdHex) !== -1) {
21171
- keySessionContextPromise = keyIdToKeySessionPromise[oldKeyIdHex];
21172
- if (decryptdata.pssh) {
21169
+ const keyIdHex = Hex.hexDump(keyId);
21170
+ const {
21171
+ keyIdToKeySessionPromise,
21172
+ mediaKeySessions
21173
+ } = this;
21174
+ let keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex];
21175
+ for (let i = 0; i < mediaKeySessions.length; i++) {
21176
+ // Match playlist key
21177
+ const keyContext = mediaKeySessions[i];
21178
+ const decryptdata = keyContext.decryptdata;
21179
+ if (!decryptdata.keyId) {
21180
+ continue;
21181
+ }
21182
+ const oldKeyIdHex = Hex.hexDump(decryptdata.keyId);
21183
+ if (keyIdHex === oldKeyIdHex || decryptdata.uri.replace(/-/g, '').indexOf(keyIdHex) !== -1) {
21184
+ keySessionContextPromise = keyIdToKeySessionPromise[oldKeyIdHex];
21185
+ if (decryptdata.pssh) {
21186
+ break;
21187
+ }
21188
+ delete keyIdToKeySessionPromise[oldKeyIdHex];
21189
+ decryptdata.pssh = new Uint8Array(initData);
21190
+ decryptdata.keyId = keyId;
21191
+ keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = keySessionContextPromise.then(() => {
21192
+ return this.generateRequestWithPreferredKeySession(keyContext, initDataType, initData, 'encrypted-event-key-match');
21193
+ });
21194
+ keySessionContextPromise.catch(error => this.handleError(error));
21173
21195
  break;
21174
21196
  }
21175
- delete keyIdToKeySessionPromise[oldKeyIdHex];
21176
- decryptdata.pssh = new Uint8Array(initData);
21177
- decryptdata.keyId = keyId;
21178
- keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = keySessionContextPromise.then(() => {
21179
- return this.generateRequestWithPreferredKeySession(keyContext, initDataType, initData, 'encrypted-event-key-match');
21180
- });
21181
- keySessionContextPromise.catch(error => this.handleError(error));
21182
- break;
21183
21197
  }
21184
- }
21185
- if (!keySessionContextPromise) {
21186
- // Clear-lead key (not encountered in playlist)
21187
- keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = this.getKeySystemSelectionPromise([keySystemDomain]).then(({
21188
- keySystem,
21189
- mediaKeys
21190
- }) => {
21191
- var _keySystemToKeySystem;
21192
- this.throwIfDestroyed();
21193
- const decryptdata = new LevelKey('ISO-23001-7', keyIdHex, (_keySystemToKeySystem = keySystemDomainToKeySystemFormat(keySystem)) != null ? _keySystemToKeySystem : '');
21194
- decryptdata.pssh = new Uint8Array(initData);
21195
- decryptdata.keyId = keyId;
21196
- return this.attemptSetMediaKeys(keySystem, mediaKeys).then(() => {
21198
+ if (!keySessionContextPromise) {
21199
+ if (keySystemDomain !== keySystem) {
21200
+ this.log(`Ignoring "${event.type}" event with ${keySystemDomain} init data for selected key-system ${keySystem}`);
21201
+ return;
21202
+ }
21203
+ // "Clear-lead" (misc key not encountered in playlist)
21204
+ keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = this.getKeySystemSelectionPromise([keySystemDomain]).then(({
21205
+ keySystem,
21206
+ mediaKeys
21207
+ }) => {
21208
+ var _keySystemToKeySystem;
21197
21209
  this.throwIfDestroyed();
21198
- const keySessionContext = this.createMediaKeySessionContext({
21199
- decryptdata,
21200
- keySystem,
21201
- mediaKeys
21210
+ const decryptdata = new LevelKey('ISO-23001-7', keyIdHex, (_keySystemToKeySystem = keySystemDomainToKeySystemFormat(keySystem)) != null ? _keySystemToKeySystem : '');
21211
+ decryptdata.pssh = new Uint8Array(initData);
21212
+ decryptdata.keyId = keyId;
21213
+ return this.attemptSetMediaKeys(keySystem, mediaKeys).then(() => {
21214
+ this.throwIfDestroyed();
21215
+ const keySessionContext = this.createMediaKeySessionContext({
21216
+ decryptdata,
21217
+ keySystem,
21218
+ mediaKeys
21219
+ });
21220
+ return this.generateRequestWithPreferredKeySession(keySessionContext, initDataType, initData, 'encrypted-event-no-match');
21202
21221
  });
21203
- return this.generateRequestWithPreferredKeySession(keySessionContext, initDataType, initData, 'encrypted-event-no-match');
21204
21222
  });
21205
- });
21206
- keySessionContextPromise.catch(error => this.handleError(error));
21207
- }
21223
+ keySessionContextPromise.catch(error => this.handleError(error));
21224
+ }
21225
+ });
21208
21226
  };
21209
21227
  this.onWaitingForKey = event => {
21210
21228
  this.log(`"${event.type}" event`);
@@ -32567,7 +32585,7 @@ class KeyLoader {
32567
32585
  }
32568
32586
  }
32569
32587
  load(frag) {
32570
- if (!frag.decryptdata && frag.encrypted && this.emeController) {
32588
+ if (!frag.decryptdata && frag.encrypted && this.emeController && this.config.emeEnabled) {
32571
32589
  // Multiple keys, but none selected, resolve in eme-controller
32572
32590
  return this.emeController.selectKeySystemFormat(frag).then(keySystemFormat => {
32573
32591
  return this.loadInternal(frag, keySystemFormat);