@torrent-tv/proxy 2.80.9 → 2.80.10

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.
@@ -10,7 +10,7 @@
10
10
  import assert from "node:assert/strict";
11
11
  import test from "node:test";
12
12
 
13
- import { contentionPenalty, costWithContention, penaltiesFrom } from "../services/contention.js";
13
+ import { contentionPenalty, costWithContention, penaltiesFrom } from "../services/encode/contention.js";
14
14
 
15
15
  /** The addon host's own readings. */
16
16
  const ALONE = 2.2;
@@ -15,7 +15,7 @@ import { EncodeRun } from "../services/encode/EncodeRun.js";
15
15
  import { ENCODE_EXIT } from "../services/encode/encode-exit.js";
16
16
  import { SoftwareEncoder } from "../services/encode/SoftwareEncoder.js";
17
17
  import { EncodeOrchestrator } from "../services/orchestrators/EncodeOrchestrator.js";
18
- import { contentionPenalty, penaltiesFrom } from "../services/contention.js";
18
+ import { penaltiesFrom } from "../services/encode/contention.js";
19
19
 
20
20
  // WHAT A SECOND ENCODER COSTS THE FIRST — measured, never a formula.
21
21
  //
@@ -25,7 +25,6 @@ import { contentionPenalty, penaltiesFrom } from "../services/contention.js";
25
25
  // so nothing here invents a shape: beyond what was measured the reading is held
26
26
  // rather than extrapolated.
27
27
  const MEASURED_PENALTIES = penaltiesFrom(7.12, [{ others: 1, speed: 4.18 }]);
28
- const penaltyFor = (others) => contentionPenalty(others, MEASURED_PENALTIES).penalty;
29
28
 
30
29
  // What a start and a stop cost, measured on the same host: a spawn with its
31
30
  // input open is 0.12 s there.
@@ -31,7 +31,7 @@ import { EncodeRun } from "../services/encode/EncodeRun.js";
31
31
  import { SoftwareEncoder } from "../services/encode/SoftwareEncoder.js";
32
32
  import { EncodeOrchestrator } from "../services/orchestrators/EncodeOrchestrator.js";
33
33
  import { mapForViewer, mergeMaps, runsOf } from "../services/priority/PriorityMap.js";
34
- import { contentionPenalty, penaltiesFrom } from "../services/contention.js";
34
+ import { penaltiesFrom } from "../services/encode/contention.js";
35
35
 
36
36
  // WHAT A SECOND ENCODER COSTS THE FIRST — measured, never a formula.
37
37
  //
@@ -41,7 +41,6 @@ import { contentionPenalty, penaltiesFrom } from "../services/contention.js";
41
41
  // so nothing here invents a shape: beyond what was measured the reading is held
42
42
  // rather than extrapolated.
43
43
  const MEASURED_PENALTIES = penaltiesFrom(7.12, [{ others: 1, speed: 4.18 }]);
44
- const penaltyFor = (others) => contentionPenalty(others, MEASURED_PENALTIES).penalty;
45
44
 
46
45
  // What a start and a stop cost, measured on the same host: a spawn with its
47
46
  // input open is 0.12 s there.
@@ -195,7 +194,7 @@ function assertNoOverlap(made) {
195
194
  // ---------------------------------------------------------------- one viewer
196
195
 
197
196
  test("one viewer playing: one encoder, exactly where they are", () => {
198
- const { made, watches, leaves } = orchestrator();
197
+ const { made, watches } = orchestrator();
199
198
  watches("one", { atSeconds: 400 });
200
199
  made.reconcile();
201
200
  assert.deepEqual(placements(made), [100], "at their own position, 400s / 4s");
@@ -206,7 +205,7 @@ test("one viewer playing: the encoder keeping up buys no second one", () => {
206
205
  // The peak moves forward on its own as they watch, and an encoder that stays
207
206
  // in front of it is never late. This is the case that must NOT spend a
208
207
  // process, and the one the old head-as-a-barrier rule got wrong.
209
- const { made, watches, leaves } = orchestrator();
208
+ const { made, watches } = orchestrator();
210
209
  watches("one", { atSeconds: 400 });
211
210
  made.reconcile();
212
211
  const [run] = made.runsOn(PICTURE);
@@ -223,7 +222,7 @@ test("one viewer playing: the encoder keeping up buys no second one", () => {
223
222
  });
224
223
 
225
224
  test("one viewer seeking far ahead: an encoder is placed there", () => {
226
- const { made, watches, leaves } = orchestrator();
225
+ const { made, watches } = orchestrator();
227
226
  watches("one", { atSeconds: 400 });
228
227
  made.reconcile();
229
228
  made.runsOn(PICTURE)[0].noteSpeed(6);
@@ -241,7 +240,7 @@ test("one viewer paused: nothing is late, so no encoder is added", () => {
241
240
  // A paused viewer states the whole film at one undifferentiated rank and no
242
241
  // time by which any of it must exist. The encoder already working goes on
243
242
  // encoding the track; nothing justifies a second process.
244
- const { made, watches, leaves } = orchestrator();
243
+ const { made, watches } = orchestrator();
245
244
  watches("one", { atSeconds: 400 });
246
245
  made.reconcile();
247
246
  made.runsOn(PICTURE)[0].noteSpeed(1);
@@ -280,7 +279,7 @@ test("one viewer paused states no deadline anywhere", () => {
280
279
  test("two viewers close together share one encoder", () => {
281
280
  // Film both of them want is made once. This is what merging the map is for,
282
281
  // and it must survive the deadline being carried alongside the rank.
283
- const { made, watches, leaves } = orchestrator();
282
+ const { made, watches } = orchestrator();
284
283
  watches("one", { atSeconds: 400 });
285
284
  watches("two", { atSeconds: 408 });
286
285
  made.reconcile();
@@ -293,7 +292,7 @@ test("two viewers close together share one encoder", () => {
293
292
  });
294
293
 
295
294
  test("two viewers far apart get an encoder each", () => {
296
- const { made, watches, leaves } = orchestrator();
295
+ const { made, watches } = orchestrator();
297
296
  watches("one", { atSeconds: 400 });
298
297
  made.reconcile();
299
298
  made.runsOn(PICTURE)[0].noteSpeed(6);
@@ -308,7 +307,7 @@ test("two viewers far apart get an encoder each", () => {
308
307
  });
309
308
 
310
309
  test("two viewers: one seeking does not take the other's encoder", () => {
311
- const { made, watches, leaves } = orchestrator();
310
+ const { made, watches } = orchestrator();
312
311
  watches("one", { atSeconds: 400 });
313
312
  made.reconcile();
314
313
  // A speed has to be measured before a second encoder can be justified: how
@@ -338,7 +337,7 @@ test("two viewers: one seeking does not take the other's encoder", () => {
338
337
  });
339
338
 
340
339
  test("two viewers: one pausing leaves the other served", () => {
341
- const { made, watches, leaves } = orchestrator();
340
+ const { made, watches } = orchestrator();
342
341
  watches("one", { atSeconds: 400 });
343
342
  watches("two", { atSeconds: 3000 });
344
343
  made.reconcile();
@@ -374,7 +373,7 @@ test("two viewers: the one who leaves takes nothing from the one who stays", ()
374
373
  // ------------------------------------------------------------- three viewers
375
374
 
376
375
  test("three viewers far apart get an encoder each when the machine affords it", () => {
377
- const { made, watches, leaves } = orchestrator({ maxRuns: 3 });
376
+ const { made, watches } = orchestrator({ maxRuns: 3 });
378
377
  watches("one", { atSeconds: 400 });
379
378
  watches("two", { atSeconds: 2000 });
380
379
  watches("three", { atSeconds: 3600 });
@@ -397,7 +396,7 @@ test("three viewers, a machine that affords two: the budget binds, not the map",
397
396
  // machine can hold. Which two are served follows from the order the work is
398
397
  // taken in; what must not happen is a third process on a host that cannot
399
398
  // hold it, or two processes writing one number.
400
- const { made, watches, leaves } = orchestrator({ maxRuns: 2 });
399
+ const { made, watches } = orchestrator({ maxRuns: 2 });
401
400
  watches("one", { atSeconds: 400 });
402
401
  watches("two", { atSeconds: 2000 });
403
402
  watches("three", { atSeconds: 3600 });
@@ -413,7 +412,7 @@ test("three viewers, a machine that affords two: the budget binds, not the map",
413
412
  });
414
413
 
415
414
  test("three viewers: one seeks onto another, and the two of them share", () => {
416
- const { made, watches, leaves } = orchestrator({ maxRuns: 3 });
415
+ const { made, watches } = orchestrator({ maxRuns: 3 });
417
416
  watches("one", { atSeconds: 400 });
418
417
  made.reconcile();
419
418
  made.runsOn(PICTURE)[0].noteSpeed(6);
@@ -436,7 +435,7 @@ test("three viewers: one seeks onto another, and the two of them share", () => {
436
435
  });
437
436
 
438
437
  test("three viewers: all paused, and no encoder is added for any of them", () => {
439
- const { made, watches, leaves } = orchestrator({ maxRuns: 3 });
438
+ const { made, watches } = orchestrator({ maxRuns: 3 });
440
439
  watches("one", { atSeconds: 400 });
441
440
  made.reconcile();
442
441
  made.runsOn(PICTURE)[0].noteSpeed(1);
@@ -457,7 +456,7 @@ test("three viewers: all paused, and no encoder is added for any of them", () =>
457
456
  test("the plan is a function of the state: the same state twice gives the same answer", () => {
458
457
  // What stops a moving map from becoming a thrash: the decision is arithmetic
459
458
  // over the state, so a pass that finds nothing changed changes nothing.
460
- const { made, watches, leaves } = orchestrator({ maxRuns: 3 });
459
+ const { made, watches } = orchestrator({ maxRuns: 3 });
461
460
  watches("one", { atSeconds: 400 });
462
461
  watches("two", { atSeconds: 2000 });
463
462
  made.reconcile();
@@ -481,7 +480,7 @@ test("exactly realtime arrives exactly on time, and no second encoder is bought"
481
480
  // something quite different — `speed / (1 - speed)` divides by zero here and
482
481
  // claims the encoder stays ahead FOR EVER, which is the same answer arrived
483
482
  // at by nonsense.
484
- const { made, watches, leaves } = orchestrator({ maxRuns: 3 });
483
+ const { made, watches } = orchestrator({ maxRuns: 3 });
485
484
  watches("one", { atSeconds: 400 });
486
485
  made.reconcile();
487
486
  made.runsOn(PICTURE)[0].noteSpeed(1);
@@ -525,7 +524,7 @@ test("two viewers arriving together on a cold output get one encoder, then are m
525
524
  // would take to reach the second viewer is not a known quantity. Buying a
526
525
  // process on that is buying it on no evidence, which is refused; one is placed
527
526
  // and the speed it reports is what justifies the next.
528
- const { made, watches, leaves } = orchestrator({ maxRuns: 3 });
527
+ const { made, watches } = orchestrator({ maxRuns: 3 });
529
528
  watches("one", { atSeconds: 400 });
530
529
  watches("two", { atSeconds: 3000 });
531
530
  made.reconcile();
@@ -540,7 +539,7 @@ test("two viewers arriving together on a cold output get one encoder, then are m
540
539
  });
541
540
 
542
541
  test("an encoder comfortably faster than realtime is left to do the whole stretch", () => {
543
- const { made, watches, leaves } = orchestrator({ maxRuns: 3 });
542
+ const { made, watches } = orchestrator({ maxRuns: 3 });
544
543
  watches("one", { atSeconds: 400 });
545
544
  made.reconcile();
546
545
  made.runsOn(PICTURE)[0].noteSpeed(6);
@@ -556,7 +555,7 @@ test("a swarm that feeds one encoder moves it to whoever is late, rather than se
556
555
  // the viewer left — so it is moved to the soonest number that IS due. Without
557
556
  // this the viewer who seeked was served by nobody at all: the run kept its
558
557
  // road because nothing covered what lay in front of IT.
559
- const { made, watches, leaves } = orchestrator({ maxRuns: 3 });
558
+ const { made, watches } = orchestrator({ maxRuns: 3 });
560
559
  watches("one", { atSeconds: 400 });
561
560
  made.reconcile();
562
561
  const [run] = made.runsOn(PICTURE);