Expand description
Unix-socket H.264 recording fan-out for external capture tools. Unix-socket video fan-out for external recording.
Frames are intercepted at the delivery layer (not inside each encoder), so the tap works uniformly for every full-frame encoder. The pixelflux wire header is skipped so consumers receive a plain elementary stream that is directly muxable: Annex-B for H.264 and H.265, a temporal-unit OBU stream for AV1 (each unit opened by a temporal delimiter), and IVF for VP8 and VP9, whose raw frames carry no framing of their own.
The tap must never perturb the live viewer transport, and it never copies frame bytes:
stripe payloads are Arc-shared, so the encode thread only clones a handle into a bounded
per-client channel drained by a dedicated writer thread. A slow or stalled recorder blocks
nothing but itself and is dropped once its queue overflows. A newly connected client arms
[RecordingSink::should_force_idr] so the next encode emits an IDR it can decode from.
Structs§
- Client
Handle 🔒 - The sink’s handle to one connected recorder: the feed end of its bounded queue, a kill switch for its writer thread, and how many frames it has been sent (the IVF frame index). The socket itself is owned solely by that writer thread.
- Queued
Frame 🔒 - A queued frame: the container bytes the stream needs ahead of it (an IVF file or frame
header, an AV1 temporal delimiter; usually nothing), the
Arc-shared payload, and the byte offset where the recordable stream starts (past the wire header, or0when the payload is bare). - Recording
Sink - Unix-socket fan-out that broadcasts every encoded video frame to connected consumers.
Constants§
- ACCEPT_
POLL_ 🔒INTERVAL - How often the non-blocking accept loop retries when no client is waiting.
- CLIENT_
QUEUE_ 🔒CAP - Per-client backlog bound. A recorder that falls this far behind is dropped rather than allowed to grow memory or push back on the shared encode thread.
- WRITE_
TIMEOUT 🔒 - Per-write timeout on a client stream; a stalled write surfaces as a soft error that
write_all_frameretries, keeping the writer thread responsive to teardown.
Functions§
- stream_
prefix 🔒 - The container bytes a client’s stream needs ahead of its
indexth frame: an IVF file header (on the first frame) and frame header for VP8 and VP9, a temporal delimiter for an AV1 unit that does not open with one, nothing for the Annex-B codecs. The IVF header’s time base is one frame atfps, which the frame index counts in. - write_
all_ 🔒frame - Write one whole frame to a recorder’s socket, resuming across the soft timeouts a slow reader
induces so a partial NAL or OBU is never left behind. Aborts if
stopis set (the client was dropped byRecordingSink::write_frame) or a hard error occurs.