Skip to main content

Module stream_record

Module stream_record 

Source
Expand description

Recording a camera’s MJPEG stream to disk for the “plain” timelapse. For a camera that exposes a real /stream, this captures the actual continuous video instead of time-sampling /snapshot. The copy + reconnect logic is pure (the stream opener and the sink are injected), so it’s unit-tested without a network: tests feed canned readers and a Vec sink, and drive the cancel signal.

Structs§

RecordStats
Aggregate outcome of a full recording run.

Enums§

CopyEnd
How a single-connection copy ended.

Functions§

copy_until
Copy from reader to sink until EOF, cancellation, the byte cap, or an error. cancel is checked between reads — a read already in flight finishes first, so this is cooperative (paired with a short read timeout on the real stream). Always returns the bytes written (even on error), so the caller’s cap and totals stay correct across reconnects. Never writes past cap_remaining.
record_loop
Record open’s stream into sink: open → copy → on EOF/error reconnect (after backoff) until cancel fires or max_bytes is reached. backoff(attempt) is the inter-attempt pause (the real one sleeps; tests pass a no-op). The loop only ends on cancel/cap — a persistently-failing source keeps retrying because the recorder is meant to run for as long as the print is active, and the caller flips cancel when the print ends.