Expand description
The Dahua camera stack — one dependency, every capability behind a flag.
This is the crate consumers should depend on. It re-exports the workspace’s
internal crates behind the feature matrix below, and owns the two things
that are inherently composition concerns: loading config and choosing
adapters in wiring.
Advanced users may depend on an internal crate directly — dahua-camera-rtsp
alone, say, to embed the video path with no config loader. Everyone else
should stay here.
§Quick start
use dahua_camera::config::TomlConfigStore;
use dahua_camera::core::ports::ConfigStore;
use dahua_camera::rtsp::CameraService;
use dahua_camera::wiring;
use std::path::Path;
let config = TomlConfigStore::new().load(Path::new("config.toml"))?;
let service = CameraService::start(&config, wiring::production());
let listener = tokio::net::TcpListener::bind("127.0.0.1:8787").await?;
axum::serve(listener, dahua_camera::server::router(service)).await?;§Feature matrix
Every feature is off by default except rtsp, and every feature is
additive: turning one on never changes what another does. With only the
default enabled, this crate behaves exactly as the pre-split
camera-service crate did — same task count, same latency, same
allocations per frame.
| Feature | Implies | Adds |
|---|---|---|
rtsp (default) | — | RTSP ingest, supervision, fMP4 fan-out |
decode | rtsp | H.264 → JPEG for snapshots and MJPEG |
events | — | Event subscription (Dahua CGI, ONVIF PullPoint) |
alarms | events | Alarm lifecycle: latch, auto-clear, acknowledge |
discovery | — | WS-Discovery, Dahua discovery, IP-range scan |
health | — | Health state machine, clock drift, freeze detection |
record | decode | Recording, playback, snapshot, storage |
opcua | events, health | OPC UA address space |
mqtt | events, health | MQTT publisher |
full | — | Everything above |
onvif | — | Device, Media, Imaging, Users SOAP services |
control | onvif | Imaging, encoding, IVS rules, alarm I/O |
server | rtsp | axum HTTP + SSE + WebSocket API |
tls | — | HTTPS for management connections |
PERFORMANCE.md gives the cost of each one in tasks, threads, CPU and RSS.
The hard limits it records: no feature adds more than one task per
camera, none performs CPU work on the tokio runtime, and none may block,
delay, or share a channel with video frames.
§Safety
Camera IVS/SMD detection is an operator aid and is not safety-rated.
It must not be used as an interlock, a permissive, or a condition for
machine motion. Read SAFETY.md before using any detection this crate
reports.
§Security
No credential is ever written to a config file, a log line, an error
message, or a Debug output. Passwords come from the environment via
${VAR} indirection in the config, and every type that holds one
implements Debug by hand. See the Security section of README.md.
Re-exports§
pub use dahua_camera_core as core;pub use dahua_camera_http as http;pub use dahua_camera_rtsp as rtsp;pub use dahua_camera_events as events;pub use dahua_camera_alarms as alarms;pub use dahua_camera_health as health;pub use dahua_camera_discovery as discovery;pub use dahua_camera_record as record;pub use dahua_camera_opcua as opcua;pub use dahua_camera_mqtt as mqtt;pub use dahua_camera_onvif as onvif;pub use dahua_camera_control as control;pub use dahua_camera_server as server;
Modules§
- config
- Configuration loading and validation.
- wiring
- Composition root: the one place concrete types meet abstract ports.
Structs§
- AppConfig
- Fully resolved service configuration.
- Bounding
Box - A detection region, in the camera’s normalized coordinate space.
- Camera
- One camera, as the rest of the program sees it.
- Camera
Config - Everything needed to reach and interpret one camera.
- Camera
Id - A camera’s stable identifier.
- Camera
Service - Owns every configured camera and their supervisors.
- Camera
Stats - Free-running counters for one camera.
- Capability
Set - What one camera reports it can do.
- Codec
Parameters - Decoder configuration for an H.264 track.
- Event
- One thing a camera’s analytics reported.
- Sample
- One encoded H.264 access unit.
- Server
Config - HTTP listener settings.
- Service
Deps - The adapters a
CameraServiceruns on. - Stream
Params CodecParameterstagged with the generation that produced them.
Enums§
- Camera
Error - Everything that can go wrong handling a camera.
- Camera
Status - Where a camera is in its connection lifecycle.
- Capability
- One thing a camera may or may not be able to do.
- Event
Kind - What kind of event this is.
- Event
State - Which edge of an event this is.
- Severity
- How much an operator should care.