Skip to main content

heldar_kernel/models/
devices.rs

1use chrono::{DateTime, Utc};
2use serde::Serialize;
3use serde_json::Value;
4use sqlx::types::Json;
5use sqlx::FromRow;
6
7/// Per-camera ONVIF device profile, populated by [`crate::services::onvif::probe`]. `scopes` is a
8/// JSON array of ONVIF scope URIs. `ptz_enabled` is true when the device exposes a PTZ service and
9/// the chosen media profile carries a PTZConfiguration.
10#[derive(Debug, Clone, Serialize, FromRow)]
11pub struct CameraOnvif {
12    pub camera_id: String,
13    pub device_url: String,
14    pub manufacturer: Option<String>,
15    pub model: Option<String>,
16    pub firmware_version: Option<String>,
17    pub serial_number: Option<String>,
18    pub hardware_id: Option<String>,
19    pub scopes: Json<Value>,
20    pub media_url: Option<String>,
21    pub ptz_url: Option<String>,
22    pub profile_token: Option<String>,
23    pub ptz_node_token: Option<String>,
24    pub ptz_enabled: bool,
25    pub probed_at: DateTime<Utc>,
26}
27
28/// A PTZ preset fetched from a camera's ONVIF PTZ service (GetPresets). One row per (camera, token).
29#[derive(Debug, Clone, Serialize, FromRow)]
30pub struct PtzPreset {
31    pub id: String,
32    pub camera_id: String,
33    pub token: String,
34    pub name: Option<String>,
35    pub fetched_at: DateTime<Utc>,
36}
37
38/// Per-camera HikVision ISAPI configuration state, populated by the camera-config service. Mirrors
39/// `GET /ISAPI/System/deviceInfo` (identity), `/System/Network/Integrate` (`onvif_enabled`), the
40/// kernel-provisioned ONVIF user (`onvif_user_created`), and `/System/time` (`time_mode`/`ntp_server`).
41#[derive(Debug, Clone, FromRow, Serialize)]
42pub struct CameraIsapi {
43    pub camera_id: String,
44    pub device_name: Option<String>,
45    pub model: Option<String>,
46    pub firmware_version: Option<String>,
47    pub serial_number: Option<String>,
48    pub onvif_enabled: bool,
49    pub onvif_user_created: bool,
50    pub time_mode: Option<String>,
51    pub ntp_server: Option<String>,
52    pub fetched_at: DateTime<Utc>,
53}