hls.js 1.6.0-beta.1.0.canary.10808 → 1.6.0-beta.1.0.canary.10810
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.js +32 -23
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +17 -12
- 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 +17 -12
- 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 +32 -23
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/dist/hls.worker.js.map +1 -1
- package/package.json +1 -1
- package/src/controller/audio-stream-controller.ts +1 -1
- package/src/controller/audio-track-controller.ts +4 -4
- package/src/controller/eme-controller.ts +6 -6
- package/src/controller/interstitials-controller.ts +4 -0
- package/src/controller/stream-controller.ts +4 -4
- package/src/controller/timeline-controller.ts +1 -1
- package/src/crypt/decrypter.ts +2 -1
- package/src/demux/chunk-cache.ts +1 -1
- package/src/demux/transmuxer.ts +3 -2
- package/src/types/buffer.ts +9 -0
- package/src/utils/fetch-loader.ts +3 -3
- package/src/utils/rendition-helper.ts +5 -0
package/dist/hls.mjs
CHANGED
@@ -400,7 +400,7 @@ function enableLogs(debugConfig, context, id) {
|
|
400
400
|
// Some browsers don't allow to use bind on console object anyway
|
401
401
|
// fallback to default if needed
|
402
402
|
try {
|
403
|
-
newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.1.0.canary.
|
403
|
+
newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.1.0.canary.10810"}`);
|
404
404
|
} catch (e) {
|
405
405
|
/* log fn threw an exception. All logger methods are no-ops. */
|
406
406
|
return createLogger();
|
@@ -1305,6 +1305,10 @@ function searchDownAndUpList(arr, searchIndex, predicate) {
|
|
1305
1305
|
}
|
1306
1306
|
return -1;
|
1307
1307
|
}
|
1308
|
+
function useAlternateAudio(audioTrackUrl, hls) {
|
1309
|
+
var _hls$levels$hls$loadL;
|
1310
|
+
return !!audioTrackUrl && audioTrackUrl !== ((_hls$levels$hls$loadL = hls.levels[hls.loadLevel]) == null ? void 0 : _hls$levels$hls$loadL.uri);
|
1311
|
+
}
|
1308
1312
|
|
1309
1313
|
class AbrController extends Logger {
|
1310
1314
|
constructor(_hls) {
|
@@ -5235,7 +5239,8 @@ class Decrypter {
|
|
5235
5239
|
decrypt(data, key, iv, aesMode) {
|
5236
5240
|
if (this.useSoftware) {
|
5237
5241
|
return new Promise((resolve, reject) => {
|
5238
|
-
|
5242
|
+
const dataView = ArrayBuffer.isView(data) ? data : new Uint8Array(data);
|
5243
|
+
this.softwareDecrypt(dataView, key, iv, aesMode);
|
5239
5244
|
const decryptResult = this.flush();
|
5240
5245
|
if (decryptResult) {
|
5241
5246
|
resolve(decryptResult.buffer);
|
@@ -9830,7 +9835,7 @@ var eventemitter3 = {exports: {}};
|
|
9830
9835
|
var eventemitter3Exports = eventemitter3.exports;
|
9831
9836
|
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
9832
9837
|
|
9833
|
-
const version = "1.6.0-beta.1.0.canary.
|
9838
|
+
const version = "1.6.0-beta.1.0.canary.10810";
|
9834
9839
|
|
9835
9840
|
// ensure the worker ends up in the bundle
|
9836
9841
|
// If the worker should not be included this gets aliased to empty.js
|
@@ -15445,7 +15450,8 @@ class Transmuxer {
|
|
15445
15450
|
// For Low-Latency HLS Parts, decrypt in place, since part parsing is expected on push progress
|
15446
15451
|
const loadingParts = chunkMeta.part > -1;
|
15447
15452
|
if (loadingParts) {
|
15448
|
-
|
15453
|
+
const _data = decrypter.flush();
|
15454
|
+
decryptedData = _data ? _data.buffer : _data;
|
15449
15455
|
}
|
15450
15456
|
if (!decryptedData) {
|
15451
15457
|
stats.executeEnd = now();
|
@@ -15527,7 +15533,7 @@ class Transmuxer {
|
|
15527
15533
|
const decryptedData = decrypter.flush();
|
15528
15534
|
if (decryptedData) {
|
15529
15535
|
// Push always returns a TransmuxerResult if decryptdata is null
|
15530
|
-
transmuxResults.push(this.push(decryptedData, null, chunkMeta));
|
15536
|
+
transmuxResults.push(this.push(decryptedData.buffer, null, chunkMeta));
|
15531
15537
|
}
|
15532
15538
|
}
|
15533
15539
|
const {
|
@@ -16260,7 +16266,7 @@ class AudioStreamController extends BaseStreamController {
|
|
16260
16266
|
if (this.initPTS[frag.cc] !== undefined) {
|
16261
16267
|
this.waitingData = null;
|
16262
16268
|
this.state = State.FRAG_LOADING;
|
16263
|
-
const payload = cache.flush();
|
16269
|
+
const payload = cache.flush().buffer;
|
16264
16270
|
const data = {
|
16265
16271
|
frag,
|
16266
16272
|
part,
|
@@ -17436,17 +17442,15 @@ class AudioTrackController extends BasePlaylistController {
|
|
17436
17442
|
return -1;
|
17437
17443
|
}
|
17438
17444
|
loadPlaylist(hlsUrlParameters) {
|
17439
|
-
var _this$hls$levels$this;
|
17440
17445
|
super.loadPlaylist();
|
17441
17446
|
const audioTrack = this.currentTrack;
|
17442
17447
|
if (!this.shouldLoadPlaylist(audioTrack)) {
|
17443
17448
|
return;
|
17444
17449
|
}
|
17445
|
-
|
17446
|
-
|
17447
|
-
|
17450
|
+
// Do not load audio rendition with URI matching main variant URI
|
17451
|
+
if (useAlternateAudio(audioTrack.url, this.hls)) {
|
17452
|
+
this.scheduleLoading(audioTrack, hlsUrlParameters);
|
17448
17453
|
}
|
17449
|
-
this.scheduleLoading(audioTrack, hlsUrlParameters);
|
17450
17454
|
}
|
17451
17455
|
loadingPlaylist(audioTrack, hlsUrlParameters) {
|
17452
17456
|
super.loadingPlaylist(audioTrack, hlsUrlParameters);
|
@@ -21067,7 +21071,7 @@ class EMEController extends Logger {
|
|
21067
21071
|
const json = bin2str(new Uint8Array(initData));
|
21068
21072
|
try {
|
21069
21073
|
const sinf = base64Decode(JSON.parse(json).sinf);
|
21070
|
-
const tenc = parseSinf(
|
21074
|
+
const tenc = parseSinf(sinf);
|
21071
21075
|
if (!tenc) {
|
21072
21076
|
throw new Error(`'schm' box missing or not cbcs/cenc with schi > tenc`);
|
21073
21077
|
}
|
@@ -21332,7 +21336,7 @@ class EMEController extends Logger {
|
|
21332
21336
|
const keySessionContext = this.createMediaKeySessionContext(mediaKeySessionContext);
|
21333
21337
|
const keyId = this.getKeyIdString(decryptdata);
|
21334
21338
|
const scheme = 'cenc';
|
21335
|
-
this.keyIdToKeySessionPromise[keyId] = this.generateRequestWithPreferredKeySession(keySessionContext, scheme, decryptdata.pssh, 'expired');
|
21339
|
+
this.keyIdToKeySessionPromise[keyId] = this.generateRequestWithPreferredKeySession(keySessionContext, scheme, decryptdata.pssh.buffer, 'expired');
|
21336
21340
|
} else {
|
21337
21341
|
this.warn(`Could not renew expired session. Missing pssh initData.`);
|
21338
21342
|
}
|
@@ -21402,7 +21406,8 @@ class EMEController extends Logger {
|
|
21402
21406
|
});
|
21403
21407
|
const keySessionContextPromise = this.keyIdToKeySessionPromise[keyId] = keyContextPromise.then(keySessionContext => {
|
21404
21408
|
const scheme = 'cenc';
|
21405
|
-
|
21409
|
+
const initData = decryptdata.pssh ? decryptdata.pssh.buffer : null;
|
21410
|
+
return this.generateRequestWithPreferredKeySession(keySessionContext, scheme, initData, 'playlist-key');
|
21406
21411
|
});
|
21407
21412
|
keySessionContextPromise.catch(error => this.handleError(error));
|
21408
21413
|
}
|
@@ -21482,7 +21487,8 @@ class EMEController extends Logger {
|
|
21482
21487
|
throw new Error('Invalid response from configured generateRequest filter');
|
21483
21488
|
}
|
21484
21489
|
initDataType = mappedInitData.initDataType;
|
21485
|
-
initData =
|
21490
|
+
initData = mappedInitData.initData ? mappedInitData.initData : null;
|
21491
|
+
context.decryptdata.pssh = initData ? new Uint8Array(initData) : null;
|
21486
21492
|
} catch (error) {
|
21487
21493
|
var _this$hls;
|
21488
21494
|
this.warn(error.message);
|
@@ -24577,6 +24583,10 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24577
24583
|
this.hls.on(Events.BUFFER_CODECS, this.onBufferCodecs, this);
|
24578
24584
|
}
|
24579
24585
|
onLevelUpdated(event, data) {
|
24586
|
+
if (data.level === -1) {
|
24587
|
+
// level was removed
|
24588
|
+
return;
|
24589
|
+
}
|
24580
24590
|
const main = this.hls.levels[data.level];
|
24581
24591
|
const currentSelection = _objectSpread2(_objectSpread2({}, this.mediaSelection || this.altSelection), {}, {
|
24582
24592
|
main
|
@@ -28445,7 +28455,7 @@ class TimelineController {
|
|
28445
28455
|
}
|
28446
28456
|
const hls = this.hls;
|
28447
28457
|
// Parse the WebVTT file contents.
|
28448
|
-
const payloadWebVTT = (_frag$initSegment = frag.initSegment) != null && _frag$initSegment.data ? appendUint8Array(frag.initSegment.data, new Uint8Array(payload)) : payload;
|
28458
|
+
const payloadWebVTT = (_frag$initSegment = frag.initSegment) != null && _frag$initSegment.data ? appendUint8Array(frag.initSegment.data, new Uint8Array(payload)).buffer : payload;
|
28449
28459
|
parseWebVTT(payloadWebVTT, this.initPTS[frag.cc], this.vttCCs, frag.cc, frag.start, cues => {
|
28450
28460
|
this._appendCues(cues, frag.level);
|
28451
28461
|
hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, {
|
@@ -28853,7 +28863,7 @@ class FetchLoader {
|
|
28853
28863
|
return reader.read().then(data => {
|
28854
28864
|
if (data.done) {
|
28855
28865
|
if (chunkCache.dataLength) {
|
28856
|
-
onProgress(stats, context, chunkCache.flush(), response);
|
28866
|
+
onProgress(stats, context, chunkCache.flush().buffer, response);
|
28857
28867
|
}
|
28858
28868
|
return Promise.resolve(new ArrayBuffer(0));
|
28859
28869
|
}
|
@@ -28866,12 +28876,12 @@ class FetchLoader {
|
|
28866
28876
|
chunkCache.push(chunk);
|
28867
28877
|
if (chunkCache.dataLength >= highWaterMark) {
|
28868
28878
|
// flush in order to join the typed arrays
|
28869
|
-
onProgress(stats, context, chunkCache.flush(), response);
|
28879
|
+
onProgress(stats, context, chunkCache.flush().buffer, response);
|
28870
28880
|
}
|
28871
28881
|
} else {
|
28872
28882
|
// If there's nothing cached already, and the chache is large enough
|
28873
28883
|
// just emit the progress event
|
28874
|
-
onProgress(stats, context, chunk, response);
|
28884
|
+
onProgress(stats, context, chunk.buffer, response);
|
28875
28885
|
}
|
28876
28886
|
return pump();
|
28877
28887
|
}).catch(() => {
|
@@ -31711,9 +31721,10 @@ class StreamController extends BaseStreamController {
|
|
31711
31721
|
transmuxer.push(payload, initSegmentData, audioCodec, videoCodec, frag, part, details.totalduration, accurateTimeOffset, chunkMeta, initPTS);
|
31712
31722
|
}
|
31713
31723
|
onAudioTrackSwitching(event, data) {
|
31724
|
+
const hls = this.hls;
|
31714
31725
|
// if any URL found on new audio track, it is an alternate audio track
|
31715
31726
|
const fromAltAudio = this.altAudio === 2;
|
31716
|
-
const altAudio =
|
31727
|
+
const altAudio = useAlternateAudio(data.url, hls);
|
31717
31728
|
// if we switch on main audio, ensure that main fragment scheduling is synced with media.buffered
|
31718
31729
|
// don't do anything if we switch to alt audio: audio stream controller is handling it.
|
31719
31730
|
// we will just have to change buffer scheduling on audioTrackSwitched
|
@@ -31736,7 +31747,6 @@ class StreamController extends BaseStreamController {
|
|
31736
31747
|
// Reset audio transmuxer so when switching back to main audio we're not still appending where we left off
|
31737
31748
|
this.resetTransmuxer();
|
31738
31749
|
}
|
31739
|
-
const hls = this.hls;
|
31740
31750
|
// If switching from alt to main audio, flush all audio and trigger track switched
|
31741
31751
|
if (fromAltAudio) {
|
31742
31752
|
hls.trigger(Events.BUFFER_FLUSHING, {
|
@@ -31752,8 +31762,7 @@ class StreamController extends BaseStreamController {
|
|
31752
31762
|
}
|
31753
31763
|
}
|
31754
31764
|
onAudioTrackSwitched(event, data) {
|
31755
|
-
const
|
31756
|
-
const altAudio = !!this.hls.audioTracks[trackId].url;
|
31765
|
+
const altAudio = useAlternateAudio(data.url, this.hls);
|
31757
31766
|
if (altAudio) {
|
31758
31767
|
const videoBuffer = this.videoBuffer;
|
31759
31768
|
// if we switched on alternate audio, ensure that main fragment scheduling is synced with video sourcebuffer buffered
|