Skip to main content

Crate dahua_camera

Crate dahua_camera 

Source
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.

FeatureImpliesAdds
rtsp (default)—RTSP ingest, supervision, fMP4 fan-out
decodertspH.264 → JPEG for snapshots and MJPEG
events—Event subscription (Dahua CGI, ONVIF PullPoint)
alarmseventsAlarm lifecycle: latch, auto-clear, acknowledge
discovery—WS-Discovery, Dahua discovery, IP-range scan
health—Health state machine, clock drift, freeze detection
recorddecodeRecording, playback, snapshot, storage
opcuaevents, healthOPC UA address space
mqttevents, healthMQTT publisher
full—Everything above
onvif—Device, Media, Imaging, Users SOAP services
controlonvifImaging, encoding, IVS rules, alarm I/O
serverrtspaxum 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.
BoundingBox
A detection region, in the camera’s normalized coordinate space.
Camera
One camera, as the rest of the program sees it.
CameraConfig
Everything needed to reach and interpret one camera.
CameraId
A camera’s stable identifier.
CameraService
Owns every configured camera and their supervisors.
CameraStats
Free-running counters for one camera.
CapabilitySet
What one camera reports it can do.
CodecParameters
Decoder configuration for an H.264 track.
Event
One thing a camera’s analytics reported.
Sample
One encoded H.264 access unit.
ServerConfig
HTTP listener settings.
ServiceDeps
The adapters a CameraService runs on.
StreamParams
CodecParameters tagged with the generation that produced them.

Enums§

CameraError
Everything that can go wrong handling a camera.
CameraStatus
Where a camera is in its connection lifecycle.
Capability
One thing a camera may or may not be able to do.
EventKind
What kind of event this is.
EventState
Which edge of an event this is.
Severity
How much an operator should care.

Type Aliases§

Frame
One encoded access unit. Alias for Sample.
Result
Convenience alias for fallible camera operations.