Skip to main content

Crate onvif_server

Crate onvif_server 

Source
Expand description

§onvif-server

A spec-compliant ONVIF Profile S device server library for Rust.

Implement the service traits for your camera hardware and get a fully functional ONVIF-compatible device accessible by any standard ONVIF client (VMS, NVR, Home Assistant, Frigate, python-onvif-zeep, ONVIF Device Manager, etc.).

§ONVIF Profile S coverage

ServiceStatus
DeviceSupported
MediaSupported
PTZSupported
ImagingSupported
EventsSupported

§Quick start

use onvif_server::{OnvifServer, DeviceService};

struct MyCamera;

#[async_trait::async_trait]
impl DeviceService for MyCamera {
    // Override methods as needed; defaults return NotImplemented.
}

#[tokio::main]
async fn main() {
    OnvifServer::builder()
        .port(8080)
        .advertised_host("192.168.1.10")
        .device_service(MyCamera)
        .auth("admin", "password")
        .build()
        .expect("build failed")
        .run()
        .await
        .expect("server error");
}

§WS-Security

Call .auth(username, password) on the builder to enable WS-Security UsernameToken digest authentication. GetSystemDateAndTime is automatically exempt from auth (required by ONVIF spec for clock synchronisation before the client has valid credentials).

§WS-Discovery

Enable the optional discovery feature to have the server respond to WS-Discovery multicast probes on 239.255.255.250:3702, making the device auto-discoverable on the local network.

[dependencies]
onvif-server = { version = "0.1", features = ["discovery"] }

Re-exports§

pub use generated::DeviceInfo;
pub use generated::HostnameInformation;
pub use generated::ImagingSettings;
pub use generated::MediaProfile;
pub use generated::NetworkInterface;
pub use generated::PTZPreset;
pub use generated::PTZStatusResult;
pub use generated::Scope;
pub use generated::ScopeDefinition;
pub use generated::VideoEncoderConfiguration;
pub use generated::VideoSource;
pub use generated::VideoSourceConfiguration;
pub use service::device::DeviceServiceHandler;
pub use service::events::EventServiceHandler;
pub use service::imaging::ImagingServiceHandler;
pub use service::media::MediaServiceHandler;
pub use service::ptz::PTZServiceHandler;
pub use traits::DeviceService;
pub use traits::EventService;
pub use traits::ImagingService;
pub use traits::MediaService;
pub use traits::PTZService;

Modules§

discovery
WS-Discovery support. The probe-detection and response-building functions are always compiled (pure XML, testable without sockets); the UDP multicast listener (run_discovery) is only compiled with the discovery feature.
generated
service
traits

Structs§

EmbeddedWsdlLoader
Serves bundled ONVIF WSDL and XSD files from bytes embedded at compile time.
OnvifServer
A built, configured ONVIF server handle.
OnvifServerBuilder
Builder for configuring and constructing an OnvifServer.

Enums§

BuildError
Error returned by OnvifServerBuilder::build when required configuration is missing.
OnvifError
ONVIF-specific error type that maps to SOAP faults with the ONVIF ter: namespace.
RunError
Error returned by OnvifServer::run.
WsdlError
Error type for WSDL parsing failures.

Constants§

PROFILE_TOKEN
Token for the single media profile exposed by this device. Used in GetProfiles, GetStreamUri, and all PTZ operations.
PTZ_CONFIG_TOKEN
Token for the PTZ configuration attached to the media profile. Used in GetConfiguration and PTZ service move operations.
PTZ_NODE_TOKEN
Token for the PTZ node describing the physical PTZ capabilities. Referenced in GetNodes and GetNode responses.
TRANSLATION_SPACE_FOV
ONVIF PTZ translation space URI for field-of-view relative moves. Used as the Space field in RelativeMove PanTilt arguments.
VIDEO_ENCODER_TOKEN
Token for the single video encoder configuration.
VIDEO_SOURCE_TOKEN
Token for the single video source. Referenced in VideoSourceConfiguration elements.

Traits§

WsdlLoader
Abstracts file/network I/O for loading WSDL files during recursive import resolution.

Functions§

discovery_build_probe_match
Build a WS-Discovery ProbeMatches response XML with a stable device_uuid embedded in EndpointReference/Address.
discovery_is_probe
Returns true when msg is a well-formed WS-Discovery Probe message (SOAP body first child = Probe in namespace http://schemas.xmlsoap.org/ws/2005/04/discovery).