Implementing GB28181 Protocol Support in Video Surveillance Systems
GB28181 Protocol Overview
The GB/T 28181-2016 standard defines technical requirements for public security video surveillance networking systems. It specifies interconnection structures, transmission protocols, control mechanisms, and security requirements. The protocol uses SIP for signaling and RTP for media transport, building upon international standards with custom modifications for surveillance applications.
Key Components
- SIP Protocol: Handles session establishment and management
- RTP/RTCP: Transports encoded audio/viddeo streams
- Dual Channels:
- Session channel for control commands
- Media channel for stream data
SIP Message Exchange Examples
Device Registration Process
// Initial registration attempt
REGISTER sip:34020000002000000002@192.168.6.14:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.9.200:5060
From: <sip:34020000001110000011@192.168.9.200>
To: <sip:34020000001110000011@192.168.9.200>
Call-ID: 214776626@192.168.9.200
CSeq: 1 REGISTER
// Server challenges with 401
SIP/2.0 401 Unauthorized
WWW-Authenticate: Digest realm="3402000000",nonce="962535b552b6e298"
// Device responds with credentials
REGISTER sip:34020000002000000002@192.168.6.14:5060 SIP/2.0
Authorization: Digest username="34020000001110000011", response="77ed0f6d00ab1e0c"
// Successful registration
SIP/2.0 200 OK
Keepalive Mechanism
MESSAGE sip:34020000002000000002@192.168.6.14:5060 SIP/2.0
Content-Type: Application/MANSCDP+xml
Content-Length: 178
<?xml version="1.0"?>
<Notify>
<CmdType>Keepalive</CmdType>
<DeviceID>34020000001110000011</DeviceID>
</Notify>
// Server acknowledgment
SIP/2.0 200 OK
Device Catalog Query
MESSAGE sip:34020000001110000001@3402000000 SIP/2.0
Content-Type: Application/MANSCDP+xml
<?xml version="1.0"?>
<Query>
<CmdType>Catalog</CmdType>
<DeviceID>34020000001110000001</DeviceID>
</Query>
// Device response
MESSAGE sip:34020000002000000001@3402000000 SIP/2.0
Content-Type: Application/MANSCDP+xml
<?xml version="1.0"?>
<Response>
<DeviceList Num="2">
<Item>
<DeviceID>34020000001320000001</DeviceID>
<Status>ON</Status>
</Item>
</DeviceList>
</Response>
Implementation Resources
SIP Libraries
- PJSIP: https://github.com/pjsip/pjproject
- JAIN-SIP: https://gitee.com/mirrors/jain-sip
- GoSIP: https://github.com/jart/gosip
Media Servers
- ZLMediaKit: https://github.com/ZLMediaKit/ZLMediaKit
- WVP-GB28181: https://gitee.com/pan648540858/wvp-GB28181-pro