hls.js 1.6.3-0.canary.11252 → 1.6.3-0.canary.11254
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 +4 -3
- package/dist/hls.d.ts +4 -3
- package/dist/hls.js +61 -57
- package/dist/hls.js.d.ts +4 -3
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +36 -16
- 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 +38 -16
- 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 +64 -60
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +1 -1
- package/src/config.ts +2 -0
- package/src/controller/audio-stream-controller.ts +39 -31
- package/src/controller/base-stream-controller.ts +8 -4
- package/src/controller/error-controller.ts +1 -1
- package/src/controller/fragment-finders.ts +18 -14
- package/src/controller/interstitials-controller.ts +1 -1
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.11254"}`);
|
527
527
|
} catch (e) {
|
528
528
|
/* log fn threw an exception. All logger methods are no-ops. */
|
529
529
|
return createLogger();
|
@@ -4113,7 +4113,6 @@ function findFragmentByPDT(fragments, PDTValue, maxFragLookUpTolerance) {
|
|
4113
4113
|
if (PDTValue >= (endPDT || 0)) {
|
4114
4114
|
return null;
|
4115
4115
|
}
|
4116
|
-
maxFragLookUpTolerance = maxFragLookUpTolerance || 0;
|
4117
4116
|
for (let seg = 0; seg < fragments.length; ++seg) {
|
4118
4117
|
const frag = fragments[seg];
|
4119
4118
|
if (pdtWithinToleranceTest(PDTValue, maxFragLookUpTolerance, frag)) {
|
@@ -4224,40 +4223,34 @@ function pdtWithinToleranceTest(pdtBufferEnd, maxFragLookUpTolerance, candidate)
|
|
4224
4223
|
const endProgramDateTime = candidate.endProgramDateTime || 0;
|
4225
4224
|
return endProgramDateTime - candidateLookupTolerance > pdtBufferEnd;
|
4226
4225
|
}
|
4227
|
-
function
|
4228
|
-
return BinarySearch.search(fragments, candidate => {
|
4229
|
-
if (candidate.cc < cc) {
|
4230
|
-
return 1;
|
4231
|
-
} else if (candidate.cc > cc) {
|
4232
|
-
return -1;
|
4233
|
-
} else {
|
4234
|
-
return 0;
|
4235
|
-
}
|
4236
|
-
});
|
4237
|
-
}
|
4238
|
-
function findNearestWithCC(details, cc, fragment) {
|
4226
|
+
function findNearestWithCC(details, cc, pos) {
|
4239
4227
|
if (details) {
|
4240
4228
|
if (details.startCC <= cc && details.endCC >= cc) {
|
4241
|
-
const start = fragment.start;
|
4242
|
-
const end = fragment.end;
|
4243
4229
|
let fragments = details.fragments;
|
4244
|
-
|
4245
|
-
|
4246
|
-
|
4247
|
-
|
4248
|
-
|
4249
|
-
|
4230
|
+
const {
|
4231
|
+
fragmentHint
|
4232
|
+
} = details;
|
4233
|
+
if (fragmentHint) {
|
4234
|
+
fragments = fragments.concat(fragmentHint);
|
4235
|
+
}
|
4236
|
+
let closest;
|
4237
|
+
BinarySearch.search(fragments, candidate => {
|
4238
|
+
if (candidate.cc < cc) {
|
4239
|
+
return 1;
|
4250
4240
|
}
|
4251
|
-
|
4252
|
-
|
4253
|
-
|
4241
|
+
if (candidate.cc > cc) {
|
4242
|
+
return -1;
|
4243
|
+
}
|
4244
|
+
closest = candidate;
|
4245
|
+
if (candidate.end <= pos) {
|
4254
4246
|
return 1;
|
4255
|
-
}
|
4247
|
+
}
|
4248
|
+
if (candidate.start > pos) {
|
4256
4249
|
return -1;
|
4257
|
-
} else {
|
4258
|
-
return 0;
|
4259
4250
|
}
|
4251
|
+
return 0;
|
4260
4252
|
});
|
4253
|
+
return closest || null;
|
4261
4254
|
}
|
4262
4255
|
}
|
4263
4256
|
return null;
|
@@ -4548,7 +4541,7 @@ class ErrorController extends Logger {
|
|
4548
4541
|
minAutoLevel,
|
4549
4542
|
maxAutoLevel
|
4550
4543
|
} = hls;
|
4551
|
-
if (!hls.autoLevelEnabled) {
|
4544
|
+
if (!hls.autoLevelEnabled && !hls.config.preserveManualLevelOnError) {
|
4552
4545
|
hls.loadLevel = -1;
|
4553
4546
|
}
|
4554
4547
|
const fragErrorType = (_data$frag2 = data.frag) == null ? void 0 : _data$frag2.type;
|
@@ -9264,7 +9257,7 @@ class BaseStreamController extends TaskLoop {
|
|
9264
9257
|
this.log(`LL-Part loading ON for initial live fragment`);
|
9265
9258
|
this.loadingParts = true;
|
9266
9259
|
}
|
9267
|
-
frag = this.getInitialLiveFragment(levelDetails
|
9260
|
+
frag = this.getInitialLiveFragment(levelDetails);
|
9268
9261
|
const mainStart = this.hls.startPosition;
|
9269
9262
|
const liveSyncPosition = this.hls.liveSyncPosition;
|
9270
9263
|
const startPosition = frag ? (mainStart !== -1 && mainStart >= start ? mainStart : liveSyncPosition) || frag.start : pos;
|
@@ -9404,7 +9397,8 @@ class BaseStreamController extends TaskLoop {
|
|
9404
9397
|
"sliding" of the playlist, which is its offset from the start of playback. After sliding we can compute the real
|
9405
9398
|
start and end times for each fragment in the playlist (after which this method will not need to be called).
|
9406
9399
|
*/
|
9407
|
-
getInitialLiveFragment(levelDetails
|
9400
|
+
getInitialLiveFragment(levelDetails) {
|
9401
|
+
const fragments = levelDetails.fragments;
|
9408
9402
|
const fragPrevious = this.fragPrevious;
|
9409
9403
|
let frag = null;
|
9410
9404
|
if (fragPrevious) {
|
@@ -9427,7 +9421,7 @@ class BaseStreamController extends TaskLoop {
|
|
9427
9421
|
// It's important to stay within the continuity range if available; otherwise the fragments in the playlist
|
9428
9422
|
// will have the wrong start times
|
9429
9423
|
if (!frag) {
|
9430
|
-
frag =
|
9424
|
+
frag = findNearestWithCC(levelDetails, fragPrevious.cc, fragPrevious.end);
|
9431
9425
|
if (frag) {
|
9432
9426
|
this.log(`Live playlist, switching playlist, load frag with same CC: ${frag.sn}`);
|
9433
9427
|
}
|
@@ -10237,7 +10231,7 @@ function requireEventemitter3 () {
|
|
10237
10231
|
var eventemitter3Exports = requireEventemitter3();
|
10238
10232
|
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
10239
10233
|
|
10240
|
-
const version = "1.6.3-0.canary.
|
10234
|
+
const version = "1.6.3-0.canary.11254";
|
10241
10235
|
|
10242
10236
|
// ensure the worker ends up in the bundle
|
10243
10237
|
// If the worker should not be included this gets aliased to empty.js
|
@@ -16528,23 +16522,46 @@ class AudioStreamController extends BaseStreamController {
|
|
16528
16522
|
if (this.state === State.WAITING_INIT_PTS) {
|
16529
16523
|
const waitingData = this.waitingData;
|
16530
16524
|
if (!waitingData && !this.loadingParts || waitingData && waitingData.frag.cc !== cc) {
|
16531
|
-
this.
|
16525
|
+
this.syncWithAnchor(frag, waitingData == null ? void 0 : waitingData.frag);
|
16532
16526
|
}
|
16533
|
-
this.tick();
|
16534
16527
|
} else if (!this.hls.hasEnoughToStart && inFlightFrag && inFlightFrag.cc !== cc) {
|
16535
|
-
this.startFragRequested = false;
|
16536
|
-
this.nextLoadPosition = this.findSyncFrag(frag).start;
|
16537
16528
|
inFlightFrag.abortRequests();
|
16538
|
-
this.
|
16529
|
+
this.syncWithAnchor(frag, inFlightFrag);
|
16539
16530
|
} else if (this.state === State.IDLE) {
|
16540
16531
|
this.tick();
|
16541
16532
|
}
|
16542
16533
|
}
|
16543
16534
|
}
|
16544
|
-
|
16535
|
+
getLoadPosition() {
|
16536
|
+
if (!this.startFragRequested && this.nextLoadPosition >= 0) {
|
16537
|
+
return this.nextLoadPosition;
|
16538
|
+
}
|
16539
|
+
return super.getLoadPosition();
|
16540
|
+
}
|
16541
|
+
syncWithAnchor(mainAnchor, waitingToAppend) {
|
16542
|
+
var _this$mainFragLoading;
|
16543
|
+
// Drop waiting fragment if videoTrackCC has changed since waitingFragment was set and initPTS was not found
|
16544
|
+
const mainFragLoading = ((_this$mainFragLoading = this.mainFragLoading) == null ? void 0 : _this$mainFragLoading.frag) || null;
|
16545
|
+
if (waitingToAppend) {
|
16546
|
+
if ((mainFragLoading == null ? void 0 : mainFragLoading.cc) === waitingToAppend.cc) {
|
16547
|
+
// Wait for loading frag to complete and INIT_PTS_FOUND
|
16548
|
+
return;
|
16549
|
+
}
|
16550
|
+
}
|
16551
|
+
const targetDiscontinuity = (mainFragLoading || mainAnchor).cc;
|
16545
16552
|
const trackDetails = this.getLevelDetails();
|
16546
|
-
const
|
16547
|
-
|
16553
|
+
const pos = this.getLoadPosition();
|
16554
|
+
const syncFrag = findNearestWithCC(trackDetails, targetDiscontinuity, pos);
|
16555
|
+
// Only stop waiting for audioFrag.cc if an audio segment of the same discontinuity domain (cc) is found
|
16556
|
+
if (syncFrag) {
|
16557
|
+
this.log(`Waiting fragment cc (${waitingToAppend == null ? void 0 : waitingToAppend.cc}) cancelled because video is at cc ${mainAnchor.cc}`);
|
16558
|
+
this.startFragRequested = false;
|
16559
|
+
this.nextLoadPosition = syncFrag.start;
|
16560
|
+
this.resetLoadingState();
|
16561
|
+
if (this.state === State.IDLE) {
|
16562
|
+
this.doTickIdle();
|
16563
|
+
}
|
16564
|
+
}
|
16548
16565
|
}
|
16549
16566
|
startLoad(startPosition, skipSeekToStartPosition) {
|
16550
16567
|
if (!this.levels) {
|
@@ -16631,10 +16648,7 @@ class AudioStreamController extends BaseStreamController {
|
|
16631
16648
|
super._handleFragmentLoadComplete(data);
|
16632
16649
|
}
|
16633
16650
|
} else if (mainAnchor && mainAnchor.cc !== waitingData.frag.cc) {
|
16634
|
-
|
16635
|
-
this.log(`Waiting fragment cc (${frag.cc}) cancelled because video is at cc ${mainAnchor.cc}`);
|
16636
|
-
this.nextLoadPosition = this.findSyncFrag(mainAnchor).start;
|
16637
|
-
this.clearWaitingFragment();
|
16651
|
+
this.syncWithAnchor(mainAnchor, waitingData.frag);
|
16638
16652
|
}
|
16639
16653
|
} else {
|
16640
16654
|
this.state = State.IDLE;
|
@@ -16643,22 +16657,12 @@ class AudioStreamController extends BaseStreamController {
|
|
16643
16657
|
}
|
16644
16658
|
this.onTickEnd();
|
16645
16659
|
}
|
16646
|
-
|
16660
|
+
resetLoadingState() {
|
16647
16661
|
const waitingData = this.waitingData;
|
16648
16662
|
if (waitingData) {
|
16649
|
-
if (!this.hls.hasEnoughToStart) {
|
16650
|
-
// Load overlapping fragment on start when discontinuity start times are not aligned
|
16651
|
-
this.startFragRequested = false;
|
16652
|
-
}
|
16653
16663
|
this.fragmentTracker.removeFragment(waitingData.frag);
|
16654
16664
|
this.waitingData = null;
|
16655
|
-
if (this.state !== State.STOPPED) {
|
16656
|
-
this.state = State.IDLE;
|
16657
|
-
}
|
16658
16665
|
}
|
16659
|
-
}
|
16660
|
-
resetLoadingState() {
|
16661
|
-
this.clearWaitingFragment();
|
16662
16666
|
super.resetLoadingState();
|
16663
16667
|
}
|
16664
16668
|
onTickEnd() {
|
@@ -16672,7 +16676,7 @@ class AudioStreamController extends BaseStreamController {
|
|
16672
16676
|
this.lastCurrentTime = media.currentTime;
|
16673
16677
|
}
|
16674
16678
|
doTickIdle() {
|
16675
|
-
var _this$
|
16679
|
+
var _this$mainFragLoading2;
|
16676
16680
|
const {
|
16677
16681
|
hls,
|
16678
16682
|
levels,
|
@@ -16746,7 +16750,7 @@ class AudioStreamController extends BaseStreamController {
|
|
16746
16750
|
}
|
16747
16751
|
|
16748
16752
|
// Request audio segments up to one fragment ahead of main stream-controller
|
16749
|
-
let mainFragLoading = ((_this$
|
16753
|
+
let mainFragLoading = ((_this$mainFragLoading2 = this.mainFragLoading) == null ? void 0 : _this$mainFragLoading2.frag) || null;
|
16750
16754
|
if (!this.audioOnly && this.startFragRequested && mainFragLoading && isMediaFragment(frag) && !frag.endList && (!trackDetails.live || !this.loadingParts && targetBufferTime < this.hls.liveSyncPosition)) {
|
16751
16755
|
if (this.fragmentTracker.getState(mainFragLoading) === FragmentState.OK) {
|
16752
16756
|
this.mainFragLoading = mainFragLoading = null;
|
@@ -26061,8 +26065,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))} pos: ${this.timeline
|
|
26061
26065
|
var _this$schedule$items4, _this$detachedData5;
|
26062
26066
|
const {
|
26063
26067
|
interstitial,
|
26064
|
-
assetItem
|
26065
|
-
assetId
|
26068
|
+
assetItem
|
26066
26069
|
} = player;
|
26067
26070
|
const scheduleIndex = this.schedule.findEventIndex(interstitial.identifier);
|
26068
26071
|
const item = (_this$schedule$items4 = this.schedule.items) == null ? void 0 : _this$schedule$items4[scheduleIndex];
|
@@ -30305,6 +30308,7 @@ const hlsDefaultConfig = _objectSpread2(_objectSpread2({
|
|
30305
30308
|
interstitialAppendInPlace: true,
|
30306
30309
|
interstitialLiveLookAhead: 10,
|
30307
30310
|
useMediaCapabilities: true,
|
30311
|
+
preserveManualLevelOnError: false,
|
30308
30312
|
certLoadPolicy: {
|
30309
30313
|
default: defaultLoadPolicy
|
30310
30314
|
},
|