hls.js 1.6.3-0.canary.11254 → 1.6.3-0.canary.11257
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.d.mts +5 -1
- package/dist/hls.d.ts +5 -1
- package/dist/hls.js +163 -112
- package/dist/hls.js.d.ts +5 -1
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +40 -18
- package/dist/hls.light.js.map +1 -1
- package/dist/hls.light.min.js +1 -1
- package/dist/hls.light.min.js.map +1 -1
- package/dist/hls.light.mjs +35 -17
- package/dist/hls.light.mjs.map +1 -1
- package/dist/hls.min.js +1 -1
- package/dist/hls.min.js.map +1 -1
- package/dist/hls.mjs +67 -27
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +2 -2
- package/src/config.ts +2 -0
- package/src/controller/base-stream-controller.ts +9 -2
- package/src/controller/eme-controller.ts +47 -19
- package/src/loader/key-loader.ts +42 -17
package/dist/hls.mjs
CHANGED
@@ -523,7 +523,7 @@ function enableLogs(debugConfig, context, id) {
|
|
523
523
|
// Some browsers don't allow to use bind on console object anyway
|
524
524
|
// fallback to default if needed
|
525
525
|
try {
|
526
|
-
newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.3-0.canary.
|
526
|
+
newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.3-0.canary.11257"}`);
|
527
527
|
} catch (e) {
|
528
528
|
/* log fn threw an exception. All logger methods are no-ops. */
|
529
529
|
return createLogger();
|
@@ -8901,8 +8901,11 @@ class BaseStreamController extends TaskLoop {
|
|
8901
8901
|
if (this.fragCurrent === null) {
|
8902
8902
|
keyLoadingPromise = Promise.reject(new Error(`frag load aborted, context changed in KEY_LOADING`));
|
8903
8903
|
}
|
8904
|
-
} else if (!frag.encrypted
|
8905
|
-
this.keyLoader.loadClear(frag, details.encryptedFragments);
|
8904
|
+
} else if (!frag.encrypted) {
|
8905
|
+
keyLoadingPromise = this.keyLoader.loadClear(frag, details.encryptedFragments);
|
8906
|
+
if (keyLoadingPromise) {
|
8907
|
+
this.log(`[eme] blocking frag load until media-keys acquired`);
|
8908
|
+
}
|
8906
8909
|
}
|
8907
8910
|
const fragPrevious = this.fragPrevious;
|
8908
8911
|
if (isMediaFragment(frag) && (!fragPrevious || frag.sn !== fragPrevious.sn)) {
|
@@ -10231,7 +10234,7 @@ function requireEventemitter3 () {
|
|
10231
10234
|
var eventemitter3Exports = requireEventemitter3();
|
10232
10235
|
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
10233
10236
|
|
10234
|
-
const version = "1.6.3-0.canary.
|
10237
|
+
const version = "1.6.3-0.canary.11257";
|
10235
10238
|
|
10236
10239
|
// ensure the worker ends up in the bundle
|
10237
10240
|
// If the worker should not be included this gets aliased to empty.js
|
@@ -21832,6 +21835,7 @@ class EMEController extends Logger {
|
|
21832
21835
|
this.log(`Create media-keys for "${keySystem}"`);
|
21833
21836
|
_keySystemAccessPromises.mediaKeys = mediaKeySystemAccess.createMediaKeys().then(mediaKeys => {
|
21834
21837
|
this.log(`Media-keys created for "${keySystem}"`);
|
21838
|
+
_keySystemAccessPromises.hasMediaKeys = true;
|
21835
21839
|
return certificateRequest.then(certificate => {
|
21836
21840
|
if (certificate) {
|
21837
21841
|
return this.setMediaKeysServerCertificate(mediaKeys, keySystem, certificate);
|
@@ -21892,18 +21896,26 @@ class EMEController extends Logger {
|
|
21892
21896
|
} (data length: ${data ? data.byteLength : data})`);
|
21893
21897
|
return keySession.update(data);
|
21894
21898
|
}
|
21895
|
-
|
21896
|
-
|
21897
|
-
|
21898
|
-
|
21899
|
-
|
21900
|
-
|
21901
|
-
|
21899
|
+
getSelectedKeySystemFormats() {
|
21900
|
+
return Object.keys(this.keySystemAccessPromises).map(keySystem => ({
|
21901
|
+
keySystem,
|
21902
|
+
hasMediaKeys: this.keySystemAccessPromises[keySystem].hasMediaKeys
|
21903
|
+
})).filter(({
|
21904
|
+
hasMediaKeys
|
21905
|
+
}) => !!hasMediaKeys).map(({
|
21906
|
+
keySystem
|
21907
|
+
}) => keySystemDomainToKeySystemFormat(keySystem)).filter(keySystem => !!keySystem);
|
21908
|
+
}
|
21909
|
+
getKeySystemAccess(keySystemsToAttempt) {
|
21910
|
+
return this.getKeySystemSelectionPromise(keySystemsToAttempt).then(({
|
21911
|
+
keySystem,
|
21912
|
+
mediaKeys
|
21913
|
+
}) => {
|
21914
|
+
return this.attemptSetMediaKeys(keySystem, mediaKeys);
|
21915
|
+
});
|
21902
21916
|
}
|
21903
|
-
|
21917
|
+
selectKeySystem(keySystemsToAttempt) {
|
21904
21918
|
return new Promise((resolve, reject) => {
|
21905
|
-
const keySystemsInConfig = getKeySystemsForConfig(this.config);
|
21906
|
-
const keySystemsToAttempt = keyFormats.map(keySystemFormatToKeySystemDomain).filter(value => !!value && keySystemsInConfig.indexOf(value) !== -1);
|
21907
21919
|
return this.getKeySystemSelectionPromise(keySystemsToAttempt).then(({
|
21908
21920
|
keySystem
|
21909
21921
|
}) => {
|
@@ -21916,6 +21928,19 @@ class EMEController extends Logger {
|
|
21916
21928
|
}).catch(reject);
|
21917
21929
|
});
|
21918
21930
|
}
|
21931
|
+
selectKeySystemFormat(frag) {
|
21932
|
+
const keyFormats = Object.keys(frag.levelkeys || {});
|
21933
|
+
if (!this.keyFormatPromise) {
|
21934
|
+
this.log(`Selecting key-system from fragment (sn: ${frag.sn} ${frag.type}: ${frag.level}) key formats ${keyFormats.join(', ')}`);
|
21935
|
+
this.keyFormatPromise = this.getKeyFormatPromise(keyFormats);
|
21936
|
+
}
|
21937
|
+
return this.keyFormatPromise;
|
21938
|
+
}
|
21939
|
+
getKeyFormatPromise(keyFormats) {
|
21940
|
+
const keySystemsInConfig = getKeySystemsForConfig(this.config);
|
21941
|
+
const keySystemsToAttempt = keyFormats.map(keySystemFormatToKeySystemDomain).filter(value => !!value && keySystemsInConfig.indexOf(value) !== -1);
|
21942
|
+
return this.selectKeySystem(keySystemsToAttempt);
|
21943
|
+
}
|
21919
21944
|
loadKey(data) {
|
21920
21945
|
const decryptdata = data.keyInfo.decryptdata;
|
21921
21946
|
const keyId = this.getKeyIdString(decryptdata);
|
@@ -30296,6 +30321,8 @@ const hlsDefaultConfig = _objectSpread2(_objectSpread2({
|
|
30296
30321
|
// used by eme-controller
|
30297
30322
|
requestMediaKeySystemAccessFunc: requestMediaKeySystemAccess ,
|
30298
30323
|
// used by eme-controller
|
30324
|
+
requireKeySystemAccessOnStart: false,
|
30325
|
+
// used by eme-controller
|
30299
30326
|
testBandwidth: true,
|
30300
30327
|
progressive: false,
|
30301
30328
|
lowLatencyMode: true,
|
@@ -33686,22 +33713,35 @@ class KeyLoader {
|
|
33686
33713
|
});
|
33687
33714
|
}
|
33688
33715
|
loadClear(loadingFrag, encryptedFragments) {
|
33689
|
-
if (this.emeController && this.config.emeEnabled) {
|
33690
|
-
// access key-system with nearest key on start (
|
33691
|
-
|
33692
|
-
|
33693
|
-
|
33694
|
-
|
33695
|
-
|
33696
|
-
|
33697
|
-
|
33698
|
-
|
33699
|
-
frag.
|
33700
|
-
|
33701
|
-
|
33716
|
+
if (this.emeController && this.config.emeEnabled && !this.emeController.getSelectedKeySystemFormats().length) {
|
33717
|
+
// access key-system with nearest key on start (loading frag is unencrypted)
|
33718
|
+
if (encryptedFragments.length) {
|
33719
|
+
const {
|
33720
|
+
sn,
|
33721
|
+
cc
|
33722
|
+
} = loadingFrag;
|
33723
|
+
for (let i = 0; i < encryptedFragments.length; i++) {
|
33724
|
+
const frag = encryptedFragments[i];
|
33725
|
+
if (cc <= frag.cc && (sn === 'initSegment' || frag.sn === 'initSegment' || sn < frag.sn)) {
|
33726
|
+
return this.emeController.selectKeySystemFormat(frag).then(keySystemFormat => {
|
33727
|
+
frag.setKeyFormat(keySystemFormat);
|
33728
|
+
if (this.emeController && this.config.requireKeySystemAccessOnStart) {
|
33729
|
+
const keySystem = keySystemFormatToKeySystemDomain(keySystemFormat);
|
33730
|
+
if (keySystem) {
|
33731
|
+
return this.emeController.getKeySystemAccess([keySystem]);
|
33732
|
+
}
|
33733
|
+
}
|
33734
|
+
});
|
33735
|
+
}
|
33736
|
+
}
|
33737
|
+
} else if (this.config.requireKeySystemAccessOnStart) {
|
33738
|
+
const keySystemsInConfig = getKeySystemsForConfig(this.config);
|
33739
|
+
if (keySystemsInConfig.length) {
|
33740
|
+
return this.emeController.getKeySystemAccess(keySystemsInConfig);
|
33702
33741
|
}
|
33703
33742
|
}
|
33704
33743
|
}
|
33744
|
+
return null;
|
33705
33745
|
}
|
33706
33746
|
load(frag) {
|
33707
33747
|
if (!frag.decryptdata && frag.encrypted && this.emeController && this.config.emeEnabled) {
|