# gb28181/gb28181.solution architecture

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

- Interactive diagram: https://gitdiagram.com/gb28181/gb28181.solution
- Repository: https://github.com/gb28181/gb28181.solution

## Overview

This repository provides a GB28181 surveillance-platform server, with supporting SIP/media protocol code and a gRPC interface for other services. The principal workflow is a client request entering the gRPC server, reaching a device-management, catalog, PTZ, or video service, and being handled through GB28181/SIP and media components. SIP registration and event handling form related device-facing capabilities; persistence stores SIP assets and bindings. WinTool and StreamingKit provide separate media/testing capabilities. The README documents the gRPC role, but sampled excerpts do not show server registration or service-to-core call wiring, so those links are not asserted.

Main entry points: [`GB28181.Server/Server/GrpcServer.cs`](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Server/GrpcServer.cs) (gRPC server), [`GB28181.SIPSorcery/core/SIP/SIPTransport.cs`](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/core/SIP/SIPTransport.cs) (SIP transport), [`GB28181.SIPSorcery/Persistence/SIPAssetPersistorFactory.cs`](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Persistence/SIPAssetPersistorFactory.cs) (Asset persistence), [`GB28181.Server/Services/DeviceCatalogImpl.cs`](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Services/DeviceCatalogImpl.cs) (Device catalog API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Server and API"]
  node_grpc["gRPC server<br/>[GrpcServer.cs]"]
  node_servicecatalog["Device catalog API"]
  node_servicedevice["Device management API"]
  node_serviceptz["PTZ control API<br/>[PtzControlImpl.cs]"]
  node_servicevod["Video on demand API"]
  node_events["Device event handlers"]
end

subgraph group_gb["GB28181 services"]
  node_catalog["GB28181 catalog<br/>[GB28181Catalog.cs]"]
  node_sipcore["SIP message core<br/>[SIPMessageCore.cs]"]
  node_director["SIP service director"]
end

subgraph group_sip["SIP signaling"]
  node_registrar["SIP registrar"]
  node_bindings["Registrar bindings"]
  node_uac["SIP client agent"]
  node_transactions["SIP transactions"]
  node_transport["SIP transport<br/>[SIPTransport.cs]"]
end

subgraph group_media["Media transport"]
  node_rtsp["RTSP sessions<br/>[RTSPServer.cs]"]
  node_rtp["RTP streams<br/>[RTPReceiver.cs]"]
  node_sdp["Media negotiation<br/>[SDP.cs]"]
end

subgraph group_state["Persistence"]
  node_assets["Asset persistence"]
  node_storage["Storage layer<br/>[StorageLayer.cs]"]
  node_store["Configured storage<br/>[SipStorage.cs]"]
end

node_client(("Service client"))
node_device(("GB28181 device"))

node_client -->|"requests"| node_grpc
node_grpc -->|"dispatches"| node_servicecatalog
node_grpc -->|"dispatches"| node_servicedevice
node_grpc -->|"dispatches"| node_serviceptz
node_grpc -->|"dispatches"| node_servicevod
node_device -->|"SIP messages"| node_transport
node_transport -->|"dispatches"| node_transactions
node_uac -->|"sends requests"| node_transport
node_director -->|"coordinates"| node_sipcore
node_registrar -->|"manages bindings"| node_bindings
node_bindings -->|"reads and writes"| node_assets
node_assets -->|"database operations"| node_storage
node_store -->|"configures"| node_assets
node_servicecatalog --> node_catalog
node_serviceptz --> node_sipcore
node_servicevod --> node_rtsp
node_rtsp -->|"streams media"| node_rtp
node_sdp -->|"describes streams"| node_rtp
node_events --> node_catalog

click node_grpc "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Server/GrpcServer.cs"
click node_servicecatalog "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Services/DeviceCatalogImpl.cs"
click node_servicedevice "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Services/DeviceManageImpl.cs"
click node_serviceptz "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Services/PtzControlImpl.cs"
click node_servicevod "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Services/VideoOnDemandImpl.cs"
click node_events "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Message/DeviceEventsProc.cs"
click node_catalog "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Servers/GB28181Catalog.cs"
click node_sipcore "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Servers/SIPMessage/SIPMessageCore.cs"
click node_director "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Servers/SIPDirector/SIPServiceDirector.cs"
click node_registrar "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Servers/SIPRegistrar/SIPRegistrarCore.cs"
click node_bindings "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Servers/SIPRegistrar/SIPRegistrarBindingsManager.cs"
click node_uac "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/app/SIPUserAgents/SIPClientUserAgent.cs"
click node_transactions "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/core/SIPTransactions/SIPTransactionEngine.cs"
click node_transport "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/core/SIP/SIPTransport.cs"
click node_rtsp "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Net/RTSP/RTSPServer.cs"
click node_rtp "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Net/RTP/RTPReceiver.cs"
click node_sdp "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Net/SDP/SDP.cs"
click node_assets "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Persistence/SIPAssetPersistorFactory.cs"
click node_storage "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Persistence/StorageLayer.cs"
click node_store "https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Config/SipStorage.cs"

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_grpc,node_servicecatalog,node_servicedevice,node_serviceptz,node_servicevod,node_events,node_client toneBlue
class node_catalog,node_sipcore,node_director toneAmber
class node_registrar,node_bindings,node_uac,node_transactions,node_transport toneMint
class node_rtsp,node_rtp,node_sdp toneRose
class node_assets,node_storage,node_store,node_device toneIndigo
```

## Components

### Server and API

- [gRPC server](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Server/GrpcServer.cs): `GB28181.Server/Server/GrpcServer.cs`
- [Device catalog API](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Services/DeviceCatalogImpl.cs): `GB28181.Server/Services/DeviceCatalogImpl.cs`
- [Device management API](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Services/DeviceManageImpl.cs): `GB28181.Server/Services/DeviceManageImpl.cs`
- [PTZ control API](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Services/PtzControlImpl.cs): `GB28181.Server/Services/PtzControlImpl.cs`
- [Video on demand API](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Services/VideoOnDemandImpl.cs): `GB28181.Server/Services/VideoOnDemandImpl.cs`
- [Device event handlers](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.Server/Message/DeviceEventsProc.cs): `GB28181.Server/Message/DeviceEventsProc.cs`

### GB28181 services

- [GB28181 catalog](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Servers/GB28181Catalog.cs): `GB28181.SIPSorcery/Servers/GB28181Catalog.cs`
- [SIP message core](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Servers/SIPMessage/SIPMessageCore.cs): `GB28181.SIPSorcery/Servers/SIPMessage/SIPMessageCore.cs`
- [SIP service director](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Servers/SIPDirector/SIPServiceDirector.cs): `GB28181.SIPSorcery/Servers/SIPDirector/SIPServiceDirector.cs`

### SIP signaling

- [SIP registrar](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Servers/SIPRegistrar/SIPRegistrarCore.cs): `GB28181.SIPSorcery/Servers/SIPRegistrar/SIPRegistrarCore.cs`
- [Registrar bindings](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Servers/SIPRegistrar/SIPRegistrarBindingsManager.cs): `GB28181.SIPSorcery/Servers/SIPRegistrar/SIPRegistrarBindingsManager.cs`
- [SIP client agent](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/app/SIPUserAgents/SIPClientUserAgent.cs): `GB28181.SIPSorcery/app/SIPUserAgents/SIPClientUserAgent.cs`
- [SIP transactions](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/core/SIPTransactions/SIPTransactionEngine.cs): `GB28181.SIPSorcery/core/SIPTransactions/SIPTransactionEngine.cs`
- [SIP transport](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/core/SIP/SIPTransport.cs): `GB28181.SIPSorcery/core/SIP/SIPTransport.cs`

### Media transport

- [RTSP sessions](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Net/RTSP/RTSPServer.cs): `GB28181.SIPSorcery/Net/RTSP/RTSPServer.cs`
- [RTP streams](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Net/RTP/RTPReceiver.cs): `GB28181.SIPSorcery/Net/RTP/RTPReceiver.cs`
- [Media negotiation](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Net/SDP/SDP.cs): `GB28181.SIPSorcery/Net/SDP/SDP.cs`

### Persistence

- [Asset persistence](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Persistence/SIPAssetPersistorFactory.cs): `GB28181.SIPSorcery/Persistence/SIPAssetPersistorFactory.cs`
- [Storage layer](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Persistence/StorageLayer.cs): `GB28181.SIPSorcery/Persistence/StorageLayer.cs`
- [Configured storage](https://github.com/gb28181/gb28181.solution/blob/develop/GB28181.SIPSorcery/Config/SipStorage.cs): `GB28181.SIPSorcery/Config/SipStorage.cs`

### Other components

- **Service client**
- **GB28181 device**

## Connections

- Service client → gRPC server: requests
- gRPC server → Device catalog API: dispatches
- gRPC server → Device management API: dispatches
- gRPC server → PTZ control API: dispatches
- gRPC server → Video on demand API: dispatches
- GB28181 device → SIP transport: SIP messages
- SIP transport → SIP transactions: dispatches
- SIP client agent → SIP transport: sends requests
- SIP service director → SIP message core: coordinates
- SIP registrar → Registrar bindings: manages bindings
- Registrar bindings → Asset persistence: reads and writes
- Asset persistence → Storage layer: database operations
- Configured storage → Asset persistence: configures
- Device catalog API → GB28181 catalog
- PTZ control API → SIP message core
- Video on demand API → RTSP sessions
- RTSP sessions → RTP streams: streams media
- Media negotiation → RTP streams: describes streams
- Device event handlers → GB28181 catalog
