@torrent-tv/proxy 2.107.24 → 2.107.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torrent-tv/proxy",
3
- "version": "2.107.24",
3
+ "version": "2.107.25",
4
4
  "description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -1282,8 +1282,11 @@ export class ViewerRequests {
1282
1282
  const ranges = inventory.has(index) ? this.#host.encodeRuns.finishedMediaRangesOf(output, index) : undefined;
1283
1283
  const mediaRanges = ranges && output.segmentFormat?.servedMediaRanges ?
1284
1284
  output.segmentFormat.servedMediaRanges(ranges, { initBytes: sessionInit }) : undefined;
1285
+ // At a playlist boundary the player can request the fragment ending
1286
+ // exactly at its seek target. It is work needed to reach the target,
1287
+ // even though it adds no media after the viewer's position.
1285
1288
  if (index !== 0 && mediaRanges === undefined && !inventory.has(index) &&
1286
- Number.isFinite(endSeconds) && Number.isFinite(positionSeconds) && endSeconds <= positionSeconds) {
1289
+ Number.isFinite(endSeconds) && Number.isFinite(positionSeconds) && endSeconds < positionSeconds) {
1287
1290
  continue;
1288
1291
  }
1289
1292
  const startSeconds = timeline.publishedStartOf(index);
@@ -223,7 +223,7 @@ export function predictPlaybackReadiness(input = {}) {
223
223
  bitsPerMediaSecond: averageBitsPerMediaSecond(track, track.segments,
224
224
  new Set(Array.isArray(track.readySegmentIndices) ? track.readySegmentIndices : [])),
225
225
  segments: segmentsOf[trackIndex]
226
- .filter((segment) => isPiece(segment) && segment.endSeconds > position && segment.startSeconds < horizonEnd)
226
+ .filter((segment) => isPiece(segment) && segment.endSeconds >= position && segment.startSeconds < horizonEnd)
227
227
  .sort((left, right) => left.startSeconds - right.startSeconds || left.index - right.index),
228
228
  // The pieces after the near window, as the playlist cuts them, and the
229
229
  // offset the page's player placed them by.
@@ -290,9 +290,12 @@ export function predictPlaybackReadiness(input = {}) {
290
290
  for (const segment of segments) {
291
291
  // Media the page already holds is not transferred again: every range of
292
292
  // the piece still ahead of the viewer lies inside what the page holds.
293
+ const exactBoundaryPrerequisite = segment.endSeconds === position;
293
294
  let held = segment.ranges.length > 0;
294
295
  for (const range of segment.ranges) {
295
- if (compare(range.end, at) > 0 && !contains(state.clientRanges, latest(range.start, at), range.end)) {
296
+ const requiredStart = exactBoundaryPrerequisite ? range.start : latest(range.start, at);
297
+ if ((exactBoundaryPrerequisite || compare(range.end, at) > 0) &&
298
+ !contains(state.clientRanges, requiredStart, range.end)) {
296
299
  held = false;
297
300
  break;
298
301
  }
@@ -876,8 +879,10 @@ function withSeekStartTolerance(ranges, position, unit) {
876
879
 
877
880
  /**
878
881
  * The pieces of a track this forecast places in exact time: those still to
879
- * play (ending after `position`) that start before `horizonEnd`, the first
880
- * piece, every piece that has been read and every piece that is made. A piece
882
+ * play (ending at or after `position`) that start before `horizonEnd`, the first
883
+ * piece, every piece that has been read and every piece that is made. The piece
884
+ * ending exactly at a seek position is kept as a prerequisite: the playlist
885
+ * player can request it before the piece starting at that position. A piece
881
886
  * that is none of these changes no exact answer: after the near window it is
882
887
  * scheduled in seconds, it is not where the track starts, no unread piece is
883
888
  * placed by it (only read pieces are), it lends no frame to what the page
@@ -891,7 +896,7 @@ function withSeekStartTolerance(ranges, position, unit) {
891
896
  function piecesThatMatter(track, position, horizonEnd = Number.POSITIVE_INFINITY) {
892
897
  const made = new Set(Array.isArray(track.readySegmentIndices) ? track.readySegmentIndices : []);
893
898
  const kept = track.segments.filter((segment) => segment?.index === 0 || segment?.mediaRanges !== undefined ||
894
- made.has(segment?.index) || (!(Number.isFinite(segment?.endSeconds) && segment.endSeconds <= position) &&
899
+ made.has(segment?.index) || (!(Number.isFinite(segment?.endSeconds) && segment.endSeconds < position) &&
895
900
  !(Number.isFinite(segment?.startSeconds) && segment.startSeconds >= horizonEnd)));
896
901
  return kept.length === track.segments.length ? track.segments : kept;
897
902
  }