# rebots-online/onvifviewer architecture

> Architecture diagram of the GitHub repository rebots-online/onvifviewer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rebots-online/onvifviewer
- Repository: https://github.com/rebots-online/onvifviewer

## Overview

ONVIFViewer is a Qt/Kirigami application for discovering, configuring, and viewing ONVIF network cameras. The principal flow is launch and load saved devices, discover or select a camera, connect to its ONVIF services, obtain media profiles and stream/snapshot information, then display camera output and expose PTZ controls. The graph also preserves device management, snapshot retrieval, and the reusable ONVIF connection layer. Source excerpts establish startup and several service boundaries; QML behavior and some runtime wiring are not sampled, so those links are omitted or marked unverified.

Main entry points: [`src/onvifdevice.cpp`](https://github.com/rebots-online/onvifviewer/blob/master/src/onvifdevice.cpp) (Camera device), [`libOnvifConnect/onvifdeviceconnection.cpp`](https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifdeviceconnection.cpp) (ONVIF connection), [`src/main.cpp`](https://github.com/rebots-online/onvifviewer/blob/master/src/main.cpp) (Application startup), [`src`](https://github.com/rebots-online/onvifviewer/tree/master/src) (Camera UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application and UI"]
  node_startup["Application startup<br/>[main.cpp]"]
  node_qml["Camera UI"]
end

subgraph group_devices["Camera management"]
  node_discovery["Camera discovery"]
  node_manager["Device manager"]
  node_model["Device list model"]
  node_device["Camera device<br/>[onvifdevice.cpp]"]
end

subgraph group_protocol["ONVIF services"]
  node_connection["ONVIF connection"]
  node_device_service["Device information"]
  node_media_service["Media service"]
  node_media2_service["Media 2 service"]
  node_ptz_service["PTZ service"]
  node_profile["Media profiles"]
end

subgraph group_media["Media viewing"]
  node_snapshot_downloader["Snapshot downloader"]
  node_snapshot_viewer["Snapshot viewer"]
  node_stream_viewer["Video stream viewer"]
end

node_user(("Camera user"))
node_camera(("ONVIF camera"))

node_user -->|"launches"| node_startup
node_startup -->|"loads UI"| node_qml
node_startup -->|"loads devices"| node_manager
node_startup -->|"creates model"| node_model
node_startup -->|"starts discovery"| node_discovery
node_qml -.->|"uses discovery"| node_discovery
node_qml -.->|"manages cameras"| node_manager
node_manager -->|"creates devices"| node_device
node_manager -->|"connects saved"| node_device
node_model -->|"models list"| node_manager
node_device -->|"uses connection"| node_connection
node_device -->|"requests information"| node_device_service
node_device -->|"requests media"| node_media_service
node_device -->|"uses media 2"| node_media2_service
node_device -->|"sends PTZ"| node_ptz_service
node_device -->|"sets snapshot URI"| node_snapshot_downloader
node_media_service -->|"returns profiles"| node_profile
node_media2_service -->|"returns profiles"| node_profile
node_ptz_service -->|"uses profile"| node_profile
node_connection -->|"owns service"| node_device_service
node_connection -->|"owns service"| node_media_service
node_connection -->|"owns service"| node_media2_service
node_connection -->|"owns service"| node_ptz_service
node_snapshot_viewer -->|"uses downloader"| node_snapshot_downloader
node_qml -.->|"presents snapshots"| node_snapshot_viewer
node_qml -.->|"presents video"| node_stream_viewer
node_connection -.->|"exchanges ONVIF"| node_camera
node_stream_viewer -.->|"plays stream"| node_camera

click node_startup "https://github.com/rebots-online/onvifviewer/blob/master/src/main.cpp"
click node_qml "https://github.com/rebots-online/onvifviewer/tree/master/src"
click node_discovery "https://github.com/rebots-online/onvifviewer/blob/master/src/onvifdevicediscover.cpp"
click node_manager "https://github.com/rebots-online/onvifviewer/blob/master/src/onvifdevicemanager.cpp"
click node_model "https://github.com/rebots-online/onvifviewer/blob/master/src/onvifdevicemanagermodel.cpp"
click node_device "https://github.com/rebots-online/onvifviewer/blob/master/src/onvifdevice.cpp"
click node_connection "https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifdeviceconnection.cpp"
click node_device_service "https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifdeviceservice.cpp"
click node_media_service "https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifmediaservice.cpp"
click node_media2_service "https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifmedia2service.cpp"
click node_ptz_service "https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifptzservice.cpp"
click node_profile "https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifmediaprofile.cpp"
click node_snapshot_downloader "https://github.com/rebots-online/onvifviewer/blob/master/src/onvifsnapshotdownloader.cpp"
click node_snapshot_viewer "https://github.com/rebots-online/onvifviewer/blob/master/src/onvifsnapshotviewer.cpp"
click node_stream_viewer "https://github.com/rebots-online/onvifviewer/blob/master/src/OnvifStreamViewer.qml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_startup,node_qml,node_user toneBlue
class node_discovery,node_manager,node_model,node_device toneAmber
class node_connection,node_device_service,node_media_service,node_media2_service,node_ptz_service,node_profile toneMint
class node_snapshot_downloader,node_snapshot_viewer,node_stream_viewer toneRose
class node_camera toneIndigo
```

## Components

### Application and UI

- [Application startup](https://github.com/rebots-online/onvifviewer/blob/master/src/main.cpp): `src/main.cpp`
- [Camera UI](https://github.com/rebots-online/onvifviewer/tree/master/src): `src`

### Camera management

- [Camera discovery](https://github.com/rebots-online/onvifviewer/blob/master/src/onvifdevicediscover.cpp): `src/onvifdevicediscover.cpp`
- [Device manager](https://github.com/rebots-online/onvifviewer/blob/master/src/onvifdevicemanager.cpp): `src/onvifdevicemanager.cpp`
- [Device list model](https://github.com/rebots-online/onvifviewer/blob/master/src/onvifdevicemanagermodel.cpp): `src/onvifdevicemanagermodel.cpp`
- [Camera device](https://github.com/rebots-online/onvifviewer/blob/master/src/onvifdevice.cpp): `src/onvifdevice.cpp`

### ONVIF services

- [ONVIF connection](https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifdeviceconnection.cpp): `libOnvifConnect/onvifdeviceconnection.cpp`
- [Device information](https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifdeviceservice.cpp): `libOnvifConnect/onvifdeviceservice.cpp`
- [Media service](https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifmediaservice.cpp): `libOnvifConnect/onvifmediaservice.cpp`
- [Media 2 service](https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifmedia2service.cpp): `libOnvifConnect/onvifmedia2service.cpp`
- [PTZ service](https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifptzservice.cpp): `libOnvifConnect/onvifptzservice.cpp`
- [Media profiles](https://github.com/rebots-online/onvifviewer/blob/master/libOnvifConnect/onvifmediaprofile.cpp): `libOnvifConnect/onvifmediaprofile.cpp`

### Media viewing

- [Snapshot downloader](https://github.com/rebots-online/onvifviewer/blob/master/src/onvifsnapshotdownloader.cpp): `src/onvifsnapshotdownloader.cpp`
- [Snapshot viewer](https://github.com/rebots-online/onvifviewer/blob/master/src/onvifsnapshotviewer.cpp): `src/onvifsnapshotviewer.cpp`
- [Video stream viewer](https://github.com/rebots-online/onvifviewer/blob/master/src/OnvifStreamViewer.qml): `src/OnvifStreamViewer.qml`

### Other components

- **Camera user**
- **ONVIF camera**

## Connections

- Camera user → Application startup: launches (evidence: `README.md`)
- Application startup → Camera UI: loads UI (evidence: `src/main.cpp`)
- Application startup → Device manager: loads devices (evidence: `src/main.cpp`)
- Application startup → Device list model: creates model (evidence: `src/main.cpp`)
- Application startup → Camera discovery: starts discovery (evidence: `src/main.cpp`)
- Camera UI → Camera discovery: uses discovery (evidence: `src/onvifdevicediscover.cpp`)
- Camera UI → Device manager: manages cameras (evidence: `src/onvifdevicemanager.cpp`)
- Device manager → Camera device: creates devices (evidence: `src/onvifdevicemanager.cpp`)
- Device manager → Camera device: connects saved (evidence: `src/onvifdevicemanager.cpp`)
- Device list model → Device manager: models list (evidence: `src/onvifdevicemanagermodel.cpp`)
- Camera device → ONVIF connection: uses connection
- Camera device → Device information: requests information (evidence: `src/onvifdevice.cpp`)
- Camera device → Media service: requests media (evidence: `src/onvifdevice.cpp`)
- Camera device → Media 2 service: uses media 2 (evidence: `src/onvifdevice.cpp`)
- Camera device → PTZ service: sends PTZ (evidence: `src/onvifdevice.cpp`)
- Camera device → Snapshot downloader: sets snapshot URI (evidence: `src/onvifdevice.cpp`)
- Media service → Media profiles: returns profiles
- Media 2 service → Media profiles: returns profiles
- PTZ service → Media profiles: uses profile
- ONVIF connection → Device information: owns service (evidence: `libOnvifConnect/onvifdeviceconnection.cpp`)
- ONVIF connection → Media service: owns service (evidence: `libOnvifConnect/onvifdeviceconnection.cpp`)
- ONVIF connection → Media 2 service: owns service (evidence: `libOnvifConnect/onvifdeviceconnection.cpp`)
- ONVIF connection → PTZ service: owns service (evidence: `libOnvifConnect/onvifdeviceconnection.cpp`)
- Snapshot viewer → Snapshot downloader: uses downloader
- Camera UI → Snapshot viewer: presents snapshots (evidence: `src/onvifsnapshotviewer.cpp`)
- Camera UI → Video stream viewer: presents video
- ONVIF connection → ONVIF camera: exchanges ONVIF
- Video stream viewer → ONVIF camera: plays stream
