@camstack/addon-pipeline 1.2.59 → 1.2.60
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.
|
@@ -21552,11 +21552,13 @@ var AdaptiveController = class {
|
|
|
21552
21552
|
*/
|
|
21553
21553
|
armed = false;
|
|
21554
21554
|
failures;
|
|
21555
|
+
upgradeCount;
|
|
21555
21556
|
constructor(opts) {
|
|
21556
21557
|
this.opts = opts;
|
|
21557
21558
|
this.tracker = new LossTracker(opts.config);
|
|
21558
21559
|
this.tier = opts.initialTier;
|
|
21559
21560
|
this.failures = new Map(opts.priorFailures ?? []);
|
|
21561
|
+
this.upgradeCount = Math.max(0, opts.priorUpgradeCount ?? 0);
|
|
21560
21562
|
}
|
|
21561
21563
|
get currentTier() {
|
|
21562
21564
|
return this.tier;
|
|
@@ -21569,6 +21571,9 @@ var AdaptiveController = class {
|
|
|
21569
21571
|
get failureCounts() {
|
|
21570
21572
|
return this.failures;
|
|
21571
21573
|
}
|
|
21574
|
+
get successfulUpgradeCount() {
|
|
21575
|
+
return this.upgradeCount;
|
|
21576
|
+
}
|
|
21572
21577
|
onLoss(sample, now) {
|
|
21573
21578
|
this.tracker.track(sample, now);
|
|
21574
21579
|
}
|
|
@@ -21621,8 +21626,9 @@ var AdaptiveController = class {
|
|
|
21621
21626
|
*/
|
|
21622
21627
|
requiredHealthyMs(tier) {
|
|
21623
21628
|
const failures = this.failures.get(tier) ?? 0;
|
|
21624
|
-
|
|
21625
|
-
|
|
21629
|
+
const progressiveMs = Math.min(this.opts.config.upgradeHealthyMs * this.opts.config.upgradeHealthyGrowthFactor ** this.upgradeCount, this.opts.config.maxProgressiveUpgradeHealthyMs);
|
|
21630
|
+
if (failures <= 0) return progressiveMs;
|
|
21631
|
+
return Math.min(progressiveMs * 2 ** failures, this.opts.config.maxUpgradeBackoffMs);
|
|
21626
21632
|
}
|
|
21627
21633
|
commitChange(now) {
|
|
21628
21634
|
this.lastChangeAt = now;
|
|
@@ -21659,6 +21665,7 @@ var AdaptiveController = class {
|
|
|
21659
21665
|
this.tier = next;
|
|
21660
21666
|
this.mtuReduced = false;
|
|
21661
21667
|
this.transcodeEngaged = false;
|
|
21668
|
+
this.upgradeCount += 1;
|
|
21662
21669
|
this.opts.onSwitchTier(next);
|
|
21663
21670
|
this.commitChange(now);
|
|
21664
21671
|
this.healthySince = now;
|
|
@@ -31397,8 +31404,10 @@ var ADAPTIVE_CONFIG = {
|
|
|
31397
31404
|
analyzeWindowMs: 15e3,
|
|
31398
31405
|
minFailPercent: .05,
|
|
31399
31406
|
waitAfterResetMs: 8e3,
|
|
31400
|
-
upgradeHealthyMs:
|
|
31401
|
-
|
|
31407
|
+
upgradeHealthyMs: 4e3,
|
|
31408
|
+
upgradeHealthyGrowthFactor: 3,
|
|
31409
|
+
maxProgressiveUpgradeHealthyMs: 3e4,
|
|
31410
|
+
minTimeBetweenChangesMs: 4e3,
|
|
31402
31411
|
maxUpgradeBackoffMs: 9e5
|
|
31403
31412
|
};
|
|
31404
31413
|
/**
|
|
@@ -32466,7 +32475,7 @@ var BrokerWebrtcServer = class {
|
|
|
32466
32475
|
};
|
|
32467
32476
|
if (streamId.endsWith("/adaptive")) {
|
|
32468
32477
|
const initialTier = this.profileTierResolver?.(brokerId) ?? "high";
|
|
32469
|
-
this.startAdaptive(entry, deviceId, initialTier, sessionId, intent?.failures);
|
|
32478
|
+
this.startAdaptive(entry, deviceId, initialTier, sessionId, intent?.failures, intent?.upgradeCount);
|
|
32470
32479
|
}
|
|
32471
32480
|
return {
|
|
32472
32481
|
sessionId,
|
|
@@ -32567,10 +32576,11 @@ var BrokerWebrtcServer = class {
|
|
|
32567
32576
|
* whichever produces the higher loss ratio across its window. The async
|
|
32568
32577
|
* poll is guarded against overlapping ticks via `tickInFlight`.
|
|
32569
32578
|
*/
|
|
32570
|
-
startAdaptive(entry, deviceId, initialTier, sessionId, priorFailures) {
|
|
32579
|
+
startAdaptive(entry, deviceId, initialTier, sessionId, priorFailures, priorUpgradeCount) {
|
|
32571
32580
|
const controller = new AdaptiveController({
|
|
32572
32581
|
initialTier,
|
|
32573
32582
|
priorFailures,
|
|
32583
|
+
priorUpgradeCount,
|
|
32574
32584
|
config: ADAPTIVE_CONFIG,
|
|
32575
32585
|
onSwitchTier: (tier) => {
|
|
32576
32586
|
this.switchSessionTier(entry, deviceId, tier, sessionId);
|
|
@@ -32628,10 +32638,12 @@ var BrokerWebrtcServer = class {
|
|
|
32628
32638
|
switchSessionTier(entry, deviceId, tier, sessionId, forceTranscodeDown = false) {
|
|
32629
32639
|
const prev = this.adaptiveIntent.get(sessionId);
|
|
32630
32640
|
const failures = new Map(entry.adaptiveController?.failureCounts ?? prev?.failures);
|
|
32641
|
+
const upgradeCount = entry.adaptiveController?.successfulUpgradeCount ?? prev?.upgradeCount ?? 0;
|
|
32631
32642
|
this.adaptiveIntent.set(sessionId, {
|
|
32632
32643
|
prefersTier: tier,
|
|
32633
32644
|
forceTranscodeDown: forceTranscodeDown || (prev?.forceTranscodeDown ?? false),
|
|
32634
|
-
failures
|
|
32645
|
+
failures,
|
|
32646
|
+
upgradeCount
|
|
32635
32647
|
});
|
|
32636
32648
|
const epoch = (entry.session.pendingRenegotiation?.epoch ?? 0) + 1;
|
|
32637
32649
|
entry.session.pendingRenegotiation = {
|
|
@@ -32646,7 +32658,8 @@ var BrokerWebrtcServer = class {
|
|
|
32646
32658
|
tier,
|
|
32647
32659
|
forceTranscodeDown,
|
|
32648
32660
|
epoch,
|
|
32649
|
-
failures: Object.fromEntries(failures)
|
|
32661
|
+
failures: Object.fromEntries(failures),
|
|
32662
|
+
upgradeCount
|
|
32650
32663
|
}
|
|
32651
32664
|
});
|
|
32652
32665
|
}
|
|
@@ -21546,11 +21546,13 @@ var AdaptiveController = class {
|
|
|
21546
21546
|
*/
|
|
21547
21547
|
armed = false;
|
|
21548
21548
|
failures;
|
|
21549
|
+
upgradeCount;
|
|
21549
21550
|
constructor(opts) {
|
|
21550
21551
|
this.opts = opts;
|
|
21551
21552
|
this.tracker = new LossTracker(opts.config);
|
|
21552
21553
|
this.tier = opts.initialTier;
|
|
21553
21554
|
this.failures = new Map(opts.priorFailures ?? []);
|
|
21555
|
+
this.upgradeCount = Math.max(0, opts.priorUpgradeCount ?? 0);
|
|
21554
21556
|
}
|
|
21555
21557
|
get currentTier() {
|
|
21556
21558
|
return this.tier;
|
|
@@ -21563,6 +21565,9 @@ var AdaptiveController = class {
|
|
|
21563
21565
|
get failureCounts() {
|
|
21564
21566
|
return this.failures;
|
|
21565
21567
|
}
|
|
21568
|
+
get successfulUpgradeCount() {
|
|
21569
|
+
return this.upgradeCount;
|
|
21570
|
+
}
|
|
21566
21571
|
onLoss(sample, now) {
|
|
21567
21572
|
this.tracker.track(sample, now);
|
|
21568
21573
|
}
|
|
@@ -21615,8 +21620,9 @@ var AdaptiveController = class {
|
|
|
21615
21620
|
*/
|
|
21616
21621
|
requiredHealthyMs(tier) {
|
|
21617
21622
|
const failures = this.failures.get(tier) ?? 0;
|
|
21618
|
-
|
|
21619
|
-
|
|
21623
|
+
const progressiveMs = Math.min(this.opts.config.upgradeHealthyMs * this.opts.config.upgradeHealthyGrowthFactor ** this.upgradeCount, this.opts.config.maxProgressiveUpgradeHealthyMs);
|
|
21624
|
+
if (failures <= 0) return progressiveMs;
|
|
21625
|
+
return Math.min(progressiveMs * 2 ** failures, this.opts.config.maxUpgradeBackoffMs);
|
|
21620
21626
|
}
|
|
21621
21627
|
commitChange(now) {
|
|
21622
21628
|
this.lastChangeAt = now;
|
|
@@ -21653,6 +21659,7 @@ var AdaptiveController = class {
|
|
|
21653
21659
|
this.tier = next;
|
|
21654
21660
|
this.mtuReduced = false;
|
|
21655
21661
|
this.transcodeEngaged = false;
|
|
21662
|
+
this.upgradeCount += 1;
|
|
21656
21663
|
this.opts.onSwitchTier(next);
|
|
21657
21664
|
this.commitChange(now);
|
|
21658
21665
|
this.healthySince = now;
|
|
@@ -31388,8 +31395,10 @@ var ADAPTIVE_CONFIG = {
|
|
|
31388
31395
|
analyzeWindowMs: 15e3,
|
|
31389
31396
|
minFailPercent: .05,
|
|
31390
31397
|
waitAfterResetMs: 8e3,
|
|
31391
|
-
upgradeHealthyMs:
|
|
31392
|
-
|
|
31398
|
+
upgradeHealthyMs: 4e3,
|
|
31399
|
+
upgradeHealthyGrowthFactor: 3,
|
|
31400
|
+
maxProgressiveUpgradeHealthyMs: 3e4,
|
|
31401
|
+
minTimeBetweenChangesMs: 4e3,
|
|
31393
31402
|
maxUpgradeBackoffMs: 9e5
|
|
31394
31403
|
};
|
|
31395
31404
|
/**
|
|
@@ -32457,7 +32466,7 @@ var BrokerWebrtcServer = class {
|
|
|
32457
32466
|
};
|
|
32458
32467
|
if (streamId.endsWith("/adaptive")) {
|
|
32459
32468
|
const initialTier = this.profileTierResolver?.(brokerId) ?? "high";
|
|
32460
|
-
this.startAdaptive(entry, deviceId, initialTier, sessionId, intent?.failures);
|
|
32469
|
+
this.startAdaptive(entry, deviceId, initialTier, sessionId, intent?.failures, intent?.upgradeCount);
|
|
32461
32470
|
}
|
|
32462
32471
|
return {
|
|
32463
32472
|
sessionId,
|
|
@@ -32558,10 +32567,11 @@ var BrokerWebrtcServer = class {
|
|
|
32558
32567
|
* whichever produces the higher loss ratio across its window. The async
|
|
32559
32568
|
* poll is guarded against overlapping ticks via `tickInFlight`.
|
|
32560
32569
|
*/
|
|
32561
|
-
startAdaptive(entry, deviceId, initialTier, sessionId, priorFailures) {
|
|
32570
|
+
startAdaptive(entry, deviceId, initialTier, sessionId, priorFailures, priorUpgradeCount) {
|
|
32562
32571
|
const controller = new AdaptiveController({
|
|
32563
32572
|
initialTier,
|
|
32564
32573
|
priorFailures,
|
|
32574
|
+
priorUpgradeCount,
|
|
32565
32575
|
config: ADAPTIVE_CONFIG,
|
|
32566
32576
|
onSwitchTier: (tier) => {
|
|
32567
32577
|
this.switchSessionTier(entry, deviceId, tier, sessionId);
|
|
@@ -32619,10 +32629,12 @@ var BrokerWebrtcServer = class {
|
|
|
32619
32629
|
switchSessionTier(entry, deviceId, tier, sessionId, forceTranscodeDown = false) {
|
|
32620
32630
|
const prev = this.adaptiveIntent.get(sessionId);
|
|
32621
32631
|
const failures = new Map(entry.adaptiveController?.failureCounts ?? prev?.failures);
|
|
32632
|
+
const upgradeCount = entry.adaptiveController?.successfulUpgradeCount ?? prev?.upgradeCount ?? 0;
|
|
32622
32633
|
this.adaptiveIntent.set(sessionId, {
|
|
32623
32634
|
prefersTier: tier,
|
|
32624
32635
|
forceTranscodeDown: forceTranscodeDown || (prev?.forceTranscodeDown ?? false),
|
|
32625
|
-
failures
|
|
32636
|
+
failures,
|
|
32637
|
+
upgradeCount
|
|
32626
32638
|
});
|
|
32627
32639
|
const epoch = (entry.session.pendingRenegotiation?.epoch ?? 0) + 1;
|
|
32628
32640
|
entry.session.pendingRenegotiation = {
|
|
@@ -32637,7 +32649,8 @@ var BrokerWebrtcServer = class {
|
|
|
32637
32649
|
tier,
|
|
32638
32650
|
forceTranscodeDown,
|
|
32639
32651
|
epoch,
|
|
32640
|
-
failures: Object.fromEntries(failures)
|
|
32652
|
+
failures: Object.fromEntries(failures),
|
|
32653
|
+
upgradeCount
|
|
32641
32654
|
}
|
|
32642
32655
|
});
|
|
32643
32656
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-pipeline",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.60",
|
|
4
4
|
"description": "Pipeline bundle — runner, detection, motion, audio + stream broker. Multi-entry npm package shipping pipeline addons under a single bundle.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|