hls.js 1.5.17 → 1.5.18
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 +94 -67
- package/dist/hls.js.d.ts +7 -2
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +90 -64
- 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 +90 -64
- 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 +94 -67
- 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 +4 -2
- package/src/controller/base-stream-controller.ts +9 -0
- package/src/controller/buffer-controller.ts +1 -0
- package/src/controller/stream-controller.ts +4 -1
- package/src/hls.ts +24 -17
- package/src/remux/mp4-remuxer.ts +11 -7
- package/src/types/component-api.ts +2 -0
- package/src/utils/xhr-loader.ts +52 -49
package/dist/hls.js
CHANGED
@@ -552,7 +552,7 @@
|
|
552
552
|
// Some browsers don't allow to use bind on console object anyway
|
553
553
|
// fallback to default if needed
|
554
554
|
try {
|
555
|
-
exportedLogger.log("Debug logs enabled for \"" + id + "\" in hls.js version " + "1.5.
|
555
|
+
exportedLogger.log("Debug logs enabled for \"" + id + "\" in hls.js version " + "1.5.18");
|
556
556
|
} catch (e) {
|
557
557
|
exportedLogger = fakeLogger;
|
558
558
|
}
|
@@ -9542,6 +9542,7 @@
|
|
9542
9542
|
_this.startFragRequested = false;
|
9543
9543
|
_this.decrypter = void 0;
|
9544
9544
|
_this.initPTS = [];
|
9545
|
+
_this.buffering = true;
|
9545
9546
|
_this.onvseeking = null;
|
9546
9547
|
_this.onvended = null;
|
9547
9548
|
_this.logPrefix = '';
|
@@ -9584,6 +9585,12 @@
|
|
9584
9585
|
this.clearNextTick();
|
9585
9586
|
this.state = State.STOPPED;
|
9586
9587
|
};
|
9588
|
+
_proto.pauseBuffering = function pauseBuffering() {
|
9589
|
+
this.buffering = false;
|
9590
|
+
};
|
9591
|
+
_proto.resumeBuffering = function resumeBuffering() {
|
9592
|
+
this.buffering = true;
|
9593
|
+
};
|
9587
9594
|
_proto._streamEnded = function _streamEnded(bufferInfo, levelDetails) {
|
9588
9595
|
// If playlist is live, there is another buffered range after the current range, nothing buffered, media is detached,
|
9589
9596
|
// of nothing loading/loaded return false
|
@@ -14030,19 +14037,23 @@
|
|
14030
14037
|
this.videoTrackConfig = undefined;
|
14031
14038
|
};
|
14032
14039
|
_proto.getVideoStartPts = function getVideoStartPts(videoSamples) {
|
14040
|
+
// Get the minimum PTS value relative to the first sample's PTS, normalized for 33-bit wrapping
|
14033
14041
|
var rolloverDetected = false;
|
14042
|
+
var firstPts = videoSamples[0].pts;
|
14034
14043
|
var startPTS = videoSamples.reduce(function (minPTS, sample) {
|
14035
|
-
var
|
14044
|
+
var pts = sample.pts;
|
14045
|
+
var delta = pts - minPTS;
|
14036
14046
|
if (delta < -4294967296) {
|
14037
14047
|
// 2^32, see PTSNormalize for reasoning, but we're hitting a rollover here, and we don't want that to impact the timeOffset calculation
|
14038
14048
|
rolloverDetected = true;
|
14039
|
-
|
14040
|
-
|
14049
|
+
pts = normalizePts(pts, firstPts);
|
14050
|
+
delta = pts - minPTS;
|
14051
|
+
}
|
14052
|
+
if (delta > 0) {
|
14041
14053
|
return minPTS;
|
14042
|
-
} else {
|
14043
|
-
return sample.pts;
|
14044
14054
|
}
|
14045
|
-
|
14055
|
+
return pts;
|
14056
|
+
}, firstPts);
|
14046
14057
|
if (rolloverDetected) {
|
14047
14058
|
logger.debug('PTS rollover detected');
|
14048
14059
|
}
|
@@ -16487,12 +16498,13 @@
|
|
16487
16498
|
trackId = this.trackId;
|
16488
16499
|
var config = hls.config;
|
16489
16500
|
|
16490
|
-
// 1. if
|
16501
|
+
// 1. if buffering is suspended
|
16502
|
+
// 2. if video not attached AND
|
16491
16503
|
// start fragment already requested OR start frag prefetch not enabled
|
16492
|
-
//
|
16504
|
+
// 3. if tracks or track not loaded and selected
|
16493
16505
|
// then exit loop
|
16494
16506
|
// => if media not attached but start frag prefetch is enabled and start frag not requested yet, we will not exit loop
|
16495
|
-
if (!media && (this.startFragRequested || !config.startFragPrefetch) || !(levels != null && levels[trackId])) {
|
16507
|
+
if (!this.buffering || !media && (this.startFragRequested || !config.startFragPrefetch) || !(levels != null && levels[trackId])) {
|
16496
16508
|
return;
|
16497
16509
|
}
|
16498
16510
|
var levelInfo = levels[trackId];
|
@@ -18529,6 +18541,7 @@
|
|
18529
18541
|
_this2.resetBuffer(type);
|
18530
18542
|
});
|
18531
18543
|
this._initSourceBuffer();
|
18544
|
+
this.hls.resumeBuffering();
|
18532
18545
|
};
|
18533
18546
|
_proto.resetBuffer = function resetBuffer(type) {
|
18534
18547
|
var sb = this.sourceBuffer[type];
|
@@ -25370,47 +25383,51 @@
|
|
25370
25383
|
xhr.onprogress = null;
|
25371
25384
|
var _status = xhr.status;
|
25372
25385
|
// http status between 200 to 299 are all successful
|
25373
|
-
var
|
25374
|
-
if (_status >= 200 && _status < 300
|
25375
|
-
|
25376
|
-
|
25377
|
-
|
25378
|
-
|
25379
|
-
|
25380
|
-
|
25381
|
-
|
25382
|
-
|
25383
|
-
|
25384
|
-
|
25385
|
-
onProgress
|
25386
|
-
|
25387
|
-
|
25386
|
+
var useResponseText = xhr.responseType === 'text' ? xhr.responseText : null;
|
25387
|
+
if (_status >= 200 && _status < 300) {
|
25388
|
+
var data = useResponseText != null ? useResponseText : xhr.response;
|
25389
|
+
if (data != null) {
|
25390
|
+
stats.loading.end = Math.max(self.performance.now(), stats.loading.first);
|
25391
|
+
var len = xhr.responseType === 'arraybuffer' ? data.byteLength : data.length;
|
25392
|
+
stats.loaded = stats.total = len;
|
25393
|
+
stats.bwEstimate = stats.total * 8000 / (stats.loading.end - stats.loading.first);
|
25394
|
+
if (!this.callbacks) {
|
25395
|
+
return;
|
25396
|
+
}
|
25397
|
+
var onProgress = this.callbacks.onProgress;
|
25398
|
+
if (onProgress) {
|
25399
|
+
onProgress(stats, context, data, xhr);
|
25400
|
+
}
|
25401
|
+
if (!this.callbacks) {
|
25402
|
+
return;
|
25403
|
+
}
|
25404
|
+
var _response = {
|
25405
|
+
url: xhr.responseURL,
|
25406
|
+
data: data,
|
25407
|
+
code: _status
|
25408
|
+
};
|
25409
|
+
this.callbacks.onSuccess(_response, stats, context, xhr);
|
25388
25410
|
return;
|
25389
25411
|
}
|
25390
|
-
|
25391
|
-
|
25392
|
-
|
25393
|
-
|
25394
|
-
|
25395
|
-
|
25412
|
+
}
|
25413
|
+
|
25414
|
+
// Handle bad status or nullish response
|
25415
|
+
var retryConfig = config.loadPolicy.errorRetry;
|
25416
|
+
var retryCount = stats.retry;
|
25417
|
+
// if max nb of retries reached or if http status between 400 and 499 (such error cannot be recovered, retrying is useless), return error
|
25418
|
+
var response = {
|
25419
|
+
url: context.url,
|
25420
|
+
data: undefined,
|
25421
|
+
code: _status
|
25422
|
+
};
|
25423
|
+
if (shouldRetry(retryConfig, retryCount, false, response)) {
|
25424
|
+
this.retry(retryConfig);
|
25396
25425
|
} else {
|
25397
|
-
|
25398
|
-
|
25399
|
-
|
25400
|
-
|
25401
|
-
|
25402
|
-
data: undefined,
|
25403
|
-
code: _status
|
25404
|
-
};
|
25405
|
-
if (shouldRetry(retryConfig, retryCount, false, _response)) {
|
25406
|
-
this.retry(retryConfig);
|
25407
|
-
} else {
|
25408
|
-
logger.error(_status + " while loading " + context.url);
|
25409
|
-
this.callbacks.onError({
|
25410
|
-
code: _status,
|
25411
|
-
text: xhr.statusText
|
25412
|
-
}, context, xhr, stats);
|
25413
|
-
}
|
25426
|
+
logger.error(_status + " while loading " + context.url);
|
25427
|
+
this.callbacks.onError({
|
25428
|
+
code: _status,
|
25429
|
+
text: xhr.statusText
|
25430
|
+
}, context, xhr, stats);
|
25414
25431
|
}
|
25415
25432
|
}
|
25416
25433
|
}
|
@@ -27472,7 +27489,7 @@
|
|
27472
27489
|
if (this.altAudio && this.audioOnly) {
|
27473
27490
|
return;
|
27474
27491
|
}
|
27475
|
-
var level = hls.nextLoadLevel;
|
27492
|
+
var level = this.buffering ? hls.nextLoadLevel : hls.loadLevel;
|
27476
27493
|
if (!(levels != null && levels[level])) {
|
27477
27494
|
return;
|
27478
27495
|
}
|
@@ -27494,6 +27511,9 @@
|
|
27494
27511
|
this.state = State.ENDED;
|
27495
27512
|
return;
|
27496
27513
|
}
|
27514
|
+
if (!this.buffering) {
|
27515
|
+
return;
|
27516
|
+
}
|
27497
27517
|
|
27498
27518
|
// set next load level : this will trigger a playlist load if needed
|
27499
27519
|
if (hls.loadLevel !== level && hls.manualLevel === -1) {
|
@@ -28702,9 +28722,13 @@
|
|
28702
28722
|
}
|
28703
28723
|
logger.log("startLoad(" + startPosition + ")");
|
28704
28724
|
this.started = true;
|
28705
|
-
this.
|
28706
|
-
|
28707
|
-
|
28725
|
+
this.resumeBuffering();
|
28726
|
+
for (var i = 0; i < this.networkControllers.length; i++) {
|
28727
|
+
this.networkControllers[i].startLoad(startPosition);
|
28728
|
+
if (!this.started || !this.networkControllers) {
|
28729
|
+
break;
|
28730
|
+
}
|
28731
|
+
}
|
28708
28732
|
}
|
28709
28733
|
|
28710
28734
|
/**
|
@@ -28713,32 +28737,35 @@
|
|
28713
28737
|
_proto.stopLoad = function stopLoad() {
|
28714
28738
|
logger.log('stopLoad');
|
28715
28739
|
this.started = false;
|
28716
|
-
this.networkControllers.
|
28717
|
-
|
28718
|
-
|
28740
|
+
for (var i = 0; i < this.networkControllers.length; i++) {
|
28741
|
+
this.networkControllers[i].stopLoad();
|
28742
|
+
if (this.started || !this.networkControllers) {
|
28743
|
+
break;
|
28744
|
+
}
|
28745
|
+
}
|
28719
28746
|
}
|
28720
28747
|
|
28721
28748
|
/**
|
28722
|
-
* Resumes stream controller segment loading
|
28749
|
+
* Resumes stream controller segment loading after `pauseBuffering` has been called.
|
28723
28750
|
*/;
|
28724
28751
|
_proto.resumeBuffering = function resumeBuffering() {
|
28725
|
-
|
28726
|
-
|
28727
|
-
|
28728
|
-
|
28729
|
-
|
28730
|
-
|
28731
|
-
}
|
28752
|
+
logger.log("resume buffering");
|
28753
|
+
this.networkControllers.forEach(function (controller) {
|
28754
|
+
if (controller.resumeBuffering) {
|
28755
|
+
controller.resumeBuffering();
|
28756
|
+
}
|
28757
|
+
});
|
28732
28758
|
}
|
28733
28759
|
|
28734
28760
|
/**
|
28735
|
-
*
|
28761
|
+
* Prevents stream controller from loading new segments until `resumeBuffering` is called.
|
28736
28762
|
* This allows for media buffering to be paused without interupting playlist loading.
|
28737
28763
|
*/;
|
28738
28764
|
_proto.pauseBuffering = function pauseBuffering() {
|
28765
|
+
logger.log("pause buffering");
|
28739
28766
|
this.networkControllers.forEach(function (controller) {
|
28740
|
-
if (
|
28741
|
-
controller.
|
28767
|
+
if (controller.pauseBuffering) {
|
28768
|
+
controller.pauseBuffering();
|
28742
28769
|
}
|
28743
28770
|
});
|
28744
28771
|
}
|
@@ -29295,7 +29322,7 @@
|
|
29295
29322
|
* Get the video-dev/hls.js package version.
|
29296
29323
|
*/
|
29297
29324
|
function get() {
|
29298
|
-
return "1.5.
|
29325
|
+
return "1.5.18";
|
29299
29326
|
}
|
29300
29327
|
}, {
|
29301
29328
|
key: "Events",
|
package/dist/hls.js.d.ts
CHANGED
@@ -249,6 +249,7 @@ export declare class BaseStreamController extends TaskLoop implements NetworkCom
|
|
249
249
|
protected startFragRequested: boolean;
|
250
250
|
protected decrypter: Decrypter;
|
251
251
|
protected initPTS: RationalTimestamp[];
|
252
|
+
protected buffering: boolean;
|
252
253
|
protected onvseeking: EventListener | null;
|
253
254
|
protected onvended: EventListener | null;
|
254
255
|
private readonly logPrefix;
|
@@ -259,6 +260,8 @@ export declare class BaseStreamController extends TaskLoop implements NetworkCom
|
|
259
260
|
protected onTickEnd(): void;
|
260
261
|
startLoad(startPosition: number): void;
|
261
262
|
stopLoad(): void;
|
263
|
+
pauseBuffering(): void;
|
264
|
+
resumeBuffering(): void;
|
262
265
|
protected _streamEnded(bufferInfo: BufferInfo, levelDetails: LevelDetails): boolean;
|
263
266
|
protected getLevelDetails(): LevelDetails | undefined;
|
264
267
|
protected onMediaAttached(event: Events.MEDIA_ATTACHED, data: MediaAttachedData): void;
|
@@ -1410,11 +1413,11 @@ declare class Hls implements HlsEventEmitter {
|
|
1410
1413
|
*/
|
1411
1414
|
stopLoad(): void;
|
1412
1415
|
/**
|
1413
|
-
* Resumes stream controller segment loading
|
1416
|
+
* Resumes stream controller segment loading after `pauseBuffering` has been called.
|
1414
1417
|
*/
|
1415
1418
|
resumeBuffering(): void;
|
1416
1419
|
/**
|
1417
|
-
*
|
1420
|
+
* Prevents stream controller from loading new segments until `resumeBuffering` is called.
|
1418
1421
|
* This allows for media buffering to be paused without interupting playlist loading.
|
1419
1422
|
*/
|
1420
1423
|
pauseBuffering(): void;
|
@@ -2401,6 +2404,8 @@ export declare type MP4RemuxerConfig = {
|
|
2401
2404
|
export declare interface NetworkComponentAPI extends ComponentAPI {
|
2402
2405
|
startLoad(startPosition: number): void;
|
2403
2406
|
stopLoad(): void;
|
2407
|
+
pauseBuffering?(): void;
|
2408
|
+
resumeBuffering?(): void;
|
2404
2409
|
}
|
2405
2410
|
|
2406
2411
|
export declare const enum NetworkErrorAction {
|