Skip to content

Direct play: recover a plain-http body that ends early, goes silent or cannot be crossed - #817

Merged
GLinnik21 merged 6 commits into
plxnative:mainfrom
tiper:direct-play-heal
Oct 18, 2026
Merged

GLinnik21 merged 6 commits into
plxnative:mainfrom
tiper:direct-play-heal

Conversation

@tiper

@tiper tiper commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Before / After

Before: direct play over plain http had no recovery on the socket source. A server that closed the response before its Content-Length was read as the end of the file, and one that stopped sending without closing blocked the read forever. When a cut could not be crossed even by the curl source's ranged reopens, the demuxer still ended at AVERROR_EOF, EOS was pushed "at true EOF", and the player sat at "Playing (stalled)" with no error.

After: a plaintext body that ends early, or goes silent for 15 s, is reopened at the byte reached, the same way the curl source already healed a cut transfer. A cut that no reopen crosses is reported as a transport failure (AVERROR_IO with io_failed), so frame_read_failed raises demux_io_failed and the pump answers it instead of the stream silently ending.

How

Two commits, both in rust-modules/media/src/ff.rs read_cb:

  • Reopen a plaintext body that ends early or goes silent. Direct-play socket reads get a silence deadline (BODY_SILENCE, 15 s) when no other blocking deadline applies; a timeout, an error or a clean 0 below the length reopens through seek_cb at s.off (heal_at_offset).
  • A cut no reopen crosses is a transport failure, not EOF. The heal budget moved from a local per read_cb call to AvioState::heal (HealBudget), counted per byte offset across calls. libavformat retries a failed read with a fresh call, so the per-call budget gave every retry three fresh reopens (nine in the field log I hit). A read that delivers bytes refills it. HLS segment reads (which carry an acquisition) are untouched.

No FFI, linkage or new FFmpeg/curl calls.

Verification

  • Found while playing from a Jellyfin server over plain http on a webOS 6 TV (LG C1). Not tested on webOS 4.5, and not tested against a Plex Media Server.

tiper and others added 6 commits October 16, 2026 11:59
The socket source healed nothing: a server that closed the response
before its length read as end of file, and one that stopped sending
blocked the read forever. Both now reopen at the byte reached, as the
curl source already did for a cut transfer.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Tiago Pereira <[email protected]>
…e file

A direct-play body that stops below its Content-Length and that every
ranged reopen at that byte answers with nothing used to fall through to
AVERROR_EOF once the per-call heal budget ran out: the demuxer ended,
EOS was pushed "at true EOF" and the player sat at "Playing (stalled)".
read_cb now reports it as AVERROR_IO with io_failed set, so
frame_read_failed raises demux_io_failed for the pump to answer.

The heal budget is now per byte offset across read_cb calls
(HealBudget): libavformat retries a failed read with a fresh call, which
gave each retry a fresh budget (nine reopens in the field log). A read
that delivers bytes refills it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Tiago Pereira <[email protected]>
…at the wrong byte

A progressive transcode (start.mkv) is read through the same AVIO with no length: it gets no
silence deadline and no socket reopen, as before bodies were healed. A sized socket reopen must be
a 206 starting at the byte asked for (or a 200 for byte 0); the net crate now exposes the response's
Content-Range start (hs_range_start).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Opt-in, default off: reproduce a direct-play body cut mid-transfer, and a server that ignores Range
on the reopen, against the mock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…it cuts

drain_wire parks a reset or early close in io_failed while the demuxer waits on a full
AU queue; read_cb then answered EIO before any reopen. Reopen at the byte reached,
through one may_heal_at_offset predicate shared by every heal site. The mock's one-shot
--cut-part-after slot is no longer spent by a HEAD or a short ranged read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit d28ab64 into plxnative:main Oct 18, 2026
13 checks passed
RichiL10 added a commit to RichiL10/plx-native that referenced this pull request Oct 18, 2026
Brings in the upstream commits since 84759b9:
- plxnative#822 HEVC: strip HDR10+ wherever it sits in an SEI NAL
- plxnative#817 Direct play: recover a plain-http body that ends early, goes silent or cannot be crossed
- plxnative#825 Dolby Vision P7 -> 8.1 (the fork's own b0856d6, squashed upstream with the author's
  resolution against plxnative#822)
- plxnative#835 Hungarian UI language, plxnative#836 ARM binary size budget re-baseline, plxnative#666 webOS 1-3 opt-in
  interface resolution

Conflict in rust-modules/media/src/ff.rs only:
- the DV definitions and packet_to_annexb are taken from upstream, which is the author's own
  resolution of plxnative#825 against plxnative#822 (EL drop and RPU rewrite first, then strip_hdr10plus_sei);
  packet_to_annexb is now identical to upstream main
- the fork keeps its video-copy remux fallback that arms the P7 conversion from the route's
  frozen source facts when PMS's Matroska remux omits the DOVI configuration record (remux_dv)
@tiper
tiper deleted the direct-play-heal branch October 19, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants