@torrent-tv/proxy 2.88.1 → 2.88.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.88.2
2
+
3
+ - **Fix**: Report the first failing playback forecast boundary and per-track ranges instead of only a generic no-safe-start result.
4
+
1
5
  ## 2.88.1
2
6
 
3
7
  - **New**: Preserve bounded ASS/SSA work-title and release-year header fields in a WebVTT metadata note, without additional subtitle reads.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torrent-tv/proxy",
3
- "version": "2.88.1",
3
+ "version": "2.88.2",
4
4
  "description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "publishConfig": {
@@ -327,7 +327,7 @@ export function predictPlaybackReadiness(input = {}) {
327
327
  : productions;
328
328
  const safety = isSafeSchedule(usefulCompletions, usefulProductions, trackState, position, duration,
329
329
  buffered, capacity, reserve, startDelaySeconds);
330
- return { safe: safety.safe,
330
+ return { safe: safety.safe, failure: safety.failure,
331
331
  bufferedAtStart: safety.bufferedAtStart,
332
332
  neededSeconds: safety.neededSeconds,
333
333
  completionTimes: usefulCompletions.map(({ at }) => at),
@@ -346,7 +346,7 @@ export function predictPlaybackReadiness(input = {}) {
346
346
  }
347
347
  const searchLimit = maximumUsefulDelay;
348
348
  if (!(searchLimit > 0)) {
349
- return result(false, null, buffered, reserve, null, "no-safe-start-found", preparedSegments);
349
+ return { ...result(false, null, buffered, reserve, null, "no-safe-start-found", preparedSegments), failure: immediate.failure };
350
350
  }
351
351
 
352
352
  let low = 0;
@@ -369,7 +369,7 @@ export function predictPlaybackReadiness(input = {}) {
369
369
  }
370
370
  }
371
371
  if (high === null) {
372
- return result(false, null, buffered, reserve, null, "no-safe-start-found", preparedSegments);
372
+ return { ...result(false, null, buffered, reserve, null, "no-safe-start-found", preparedSegments), failure: immediate.failure };
373
373
  }
374
374
 
375
375
  while (true) {
@@ -559,6 +559,12 @@ function isSafeSchedule(completions, productions, trackState, position, duration
559
559
  const available = Math.min(capacity, ...clientRanges.map((trackRanges, index) =>
560
560
  playerPosition >= trackEnd(index) ? Number.POSITIVE_INFINITY :
561
561
  Math.max(0, contiguousEnd(trackRanges, playerPosition) - playerPosition)));
562
+ const trackStatus = clientRanges.map((ranges, index) => ({
563
+ track: trackState[index].track.id,
564
+ end: contiguousEnd(ranges, playerPosition),
565
+ next: ranges.find(range => range.start > playerPosition)?.start ?? null,
566
+ last: trackEnd(index)
567
+ }));
562
568
  let neededSeconds = 0;
563
569
  let stockSafe = true;
564
570
  for (let trackIndex = 0; trackIndex < trackState.length; trackIndex += 1) {
@@ -575,14 +581,15 @@ function isSafeSchedule(completions, productions, trackState, position, duration
575
581
  safe: (!checkClient || available > 0) && stockSafe,
576
582
  stockSafe,
577
583
  available,
578
- neededSeconds
584
+ neededSeconds,
585
+ failure: { time, playerPosition, available, stockSafe, tracks: trackStatus }
579
586
  };
580
587
  };
581
588
 
582
589
  addThrough(startDelay);
583
590
  const atStart = safeAt(startDelay);
584
591
  if (!atStart.safe) {
585
- return { safe: false, bufferedAtStart: atStart.available, neededSeconds: atStart.neededSeconds };
592
+ return { safe: false, bufferedAtStart: atStart.available, neededSeconds: atStart.neededSeconds, failure: atStart.failure };
586
593
  }
587
594
 
588
595
  const playbackEnd = startDelay + Math.max(0, duration - position);
@@ -605,17 +612,17 @@ function isSafeSchedule(completions, productions, trackState, position, duration
605
612
  for (const time of eventTimes) {
606
613
  const beforeArrival = safeAt(time, false);
607
614
  if (!beforeArrival.stockSafe) {
608
- return { safe: false, bufferedAtStart: atStart.available, neededSeconds: beforeArrival.neededSeconds };
615
+ return { safe: false, bufferedAtStart: atStart.available, neededSeconds: beforeArrival.neededSeconds, failure: beforeArrival.failure };
609
616
  }
610
617
  addThrough(time);
611
618
  const afterArrival = safeAt(time);
612
619
  if (!afterArrival.safe) {
613
- return { safe: false, bufferedAtStart: atStart.available, neededSeconds: afterArrival.neededSeconds };
620
+ return { safe: false, bufferedAtStart: atStart.available, neededSeconds: afterArrival.neededSeconds, failure: afterArrival.failure };
614
621
  }
615
622
  }
616
623
 
617
624
  const atEnd = safeAt(playbackEnd);
618
- return { safe: atEnd.safe, bufferedAtStart: atStart.available, neededSeconds: atStart.neededSeconds };
625
+ return { safe: atEnd.safe, bufferedAtStart: atStart.available, neededSeconds: atStart.neededSeconds, failure: atStart.failure };
619
626
  }
620
627
 
621
628
  function addRange(ranges, start, end) {