Expand description
RTSP ingest, per-camera supervision, and frame fan-out.
This is the video path, moved out of the pre-split camera-service crate
unchanged. Eight simultaneous Dahua cameras stream to a browser for roughly
10% of one CPU because nothing here decodes: H.264 access units are handed
to subscribers as-is and rewrapped into fMP4 fragments, so the client’s
hardware decoder does the work.
Decoding to JPEG exists behind the decode feature, runs on its own OS
thread, and starts only while something is consuming it.
§The seven invariants
These are performance and correctness requirements, not style preferences. Each is documented at the module that enforces it. Do not “simplify” any of them — each corresponds to a specific failure that will otherwise happen in a vehicle.
- No CPU work on the tokio runtime. Decode and encode run on a
dedicated OS thread —
decoder. - Bounded broadcast with IDR resync. A slow consumer is dropped
forward and rejoins at a random-access point, never applying
backpressure —
frame_router. watchfor latest-value consumers. Status, parameters and the JPEG lane deliver the newest value, not a backlog —frame_router.- Lazy work. No RTSP traffic until something subscribes —
supervisor. - Panic isolation. One camera’s panic never reaches another —
supervisor. - Stall watchdog. A silent session is torn down in bounded time —
session. Bytesfor frame data. Fan-out costs refcount bumps, not copies —dahua_camera_core::frame.
§Supervision is shared
supervisor holds the only supervision loop in the workspace. Event
subscription, health polling and every other long-lived connection run on
it too, so they all inherit the same backoff, stall watchdog and panic
isolation. Video and non-video links reconnect independently: an
event-stream failure never disturbs video, and vice versa.
§Features
decode— the H.264 → JPEG lane. Off by default.
Re-exports§
pub use camera_service::Camera;pub use camera_service::CameraService;pub use camera_service::ServiceDeps;pub use frame_router::FrameEvent;pub use frame_router::FrameRouter;pub use frame_router::Subscription;pub use frame_router::BUS_CAPACITY;pub use rtsp::RtspSourceFactory;pub use rtsp::RtspVideoSource;pub use supervisor::RestartPolicy;pub use video::Fmp4Muxer;
Modules§
- camera_
service - The service: owns every camera, and is the only thing HTTP talks to.
- decoder
- The optional JPEG lane: H.264 → RGB → JPEG, on its own thread.
- frame_
router - Fan-out of one camera’s frames, parameters and status to many consumers.
- ports
- The abstract boundary between the video path and the outside world.
- rtsp
- RTSP video ingest.
- session
- The frame pump: drives one
VideoSourceand publishes what it yields. - supervisor
- The restart loop. One implementation, shared by every long-lived link.
- testing
- Test doubles for the ports.
- video
- Video container and codec adapters: fMP4 muxing, and the optional codecs.