GB28181
GB28181 简单理解
示例数据
SIP服务信息
SIP服务编码: 41010500002000000001
SIP服务域: 4101050000
SIP服务IP:192.168.31.186
SIP服务端口:5060
SIP设备信息
设备SIP编码: 34020000001320000001
设备SIP域: 3402000000
设备IP: 192.168.31.68
设备SIP端口: 5060
设备SIP密码:123
# 信令
# 基本注册
# 流程图
信令格式
设备向SIP服务器发送注册请求
信令格式
REGISTER sip:SIP服务编码@目的域名或者IP地址端口 SIP/2.0
Via: SIP/2.0/UDP SIP服务域名或IP端口;rport=SIP服务端口;branch=z9hG4bK1555480323;received=SIP服务IP
From: <sip:设备SIP编码@SIP源服务域名>;tag=224638776
To: <sip:设备SIP编码@SIP源服务域名>
Call-ID: 78046639
CSeq: 1 REGISTER
Contact: <sip:设备SIP编码@SIP源服务域名或IP端口>
Max-Forwards: 70
User-Agent: IP Camera
Expires: 3600
Content-Length: 0
示例
REGISTER sip:41010500002000000001@4101050000 SIP/2.0
Via: SIP/2.0/UDP 192.168.31.68:5060;rport=5060;branch=z9hG4bK1555480323;received=192.168.31.186
From: <sip:34020000001320000001@4101050000>;tag=224638776
To: <sip:34020000001320000001@4101050000>
Call-ID: 78046639
CSeq: 1 REGISTER
Contact: <sip:34020000001320000001@192.168.31.68:5060>
Max-Forwards: 70
User-Agent: IP Camera
Expires: 3600
Content-Length: 0
服务器回复设备未授权
信令格式
SIP/2.0 401 Unauthorized
CSeq: 1 REGISTER
Call-ID: 78046639
From: <sip:设备SIP编码@SIP服务域>;tag=224638776
To: <sip:设备SIP编码@SIP服务域>
Via: SIP/2.0/UDP SIP服务域或IP端口;rport=SIP服务端口;branch=z9hG4bK1555480323;received=SIP服务IP
WWW-Authenticate: Digest realm="SIP服务域名",qop="auth",nonce="SIP服务生成的随机数",algorithm=MD5
User-Agent: LHY-SIP
Content-Length: 0
示例
SIP/2.0 401 Unauthorized
CSeq: 1 REGISTER
Call-ID: 78046639
From: <sip:34020000001320000001@4101050000>;tag=224638776
To: <sip:34020000001320000001@4101050000>
Via: SIP/2.0/UDP 192.168.31.68:5060;rport=5060;branch=z9hG4bK1555480323;received=192.168.31.168
WWW-Authenticate: Digest realm="4101050000",qop="auth",nonce="9f1482a8a132395030bee31d6f9838c4",algorithm=MD5
User-Agent: LHY-SIP
Content-Length: 0
设备再次提交注册请求
信令格式
REGISTER sip:SIP服务编码@SIP服务域 SIP/2.0
Via: SIP/2.0/UDP SIP服务源域名或者IP端口;rport=SIP服务端口;branch=z9hG4bK614477408;received=SIP服务IP端口
From: <sip:设备SIP编码@SIP服务域>;tag=224638776
To: <sip:设备SIP编码@SIP服务域>
Call-ID: 78046639
CSeq: 2 REGISTER
Contact: <sip:设备SIP编码@SIP服务源域名或者IP端口>
Authorization: Digest username="设备SIP编码",realm="SIP服务域",nonce="SIP服务生成的随机数",uri="sip:SIP服务编码@SIP服务域",response="最终响应",algorithm=MD5,cnonce="客户端随机数",qop=auth,nc=00000001
Max-Forwards: 70
User-Agent: IP Camera
Expires: 3600
Content-Length: 0
response生成算法
A1 = {username}:{realm}:{pwd}
A2 = {Method(当前为:REGISTER)}:{uri}
response = MD5(MD5(A1) + ":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" + MD5(A2))
示例
REGISTER sip:41010500002000000001@4101050000 SIP/2.0
Via: SIP/2.0/UDP 192.168.31.68:5060;rport=5060;branch=z9hG4bK614477408;received=192.168.31.186
From: <sip:34020000001320000001@4101050000>;tag=224638776
To: <sip:34020000001320000001@4101050000>
Call-ID: 78046639
CSeq: 2 REGISTER
Contact: <sip:34020000001320000001@192.168.31.68:5060>
Authorization: Digest username="34020000001320000001",realm="4101050000",nonce="9f1482a8a132395030bee31d6f9838c4",uri="sip:41010500002000000001@4101050000",response="cb4b905751fc22fc17f0d9e4720c4c0a",algorithm=MD5,cnonce="0a4f113b",qop=auth,nc=00000001
Max-Forwards: 70
User-Agent: IP Camera
Expires: 3600
Content-Length: 0
服务器响应200
信令格式
SIP/2.0 200 OK
CSeq: 2 REGISTER
Call-ID: 78046639
From: <sip:设备SIP编码@SIP服务域>;tag=224638776
To: <sip:设备SIP编码@SIP服务域>
Via: SIP/2.0/UDP SIP服务源域名或者IP端口;rport=SIP服务端口;branch=z9hG4bK614477408;received=SIP服务IP
Date: 当前时间
Contact: <sip:设备SIP编码@SIP服务源域名或者IP端口>
Expires: 3600
User-Agent: LHY-SIP
Content-Length: 0
示例
SIP/2.0 200 OK
CSeq: 2 REGISTER
Call-ID: 78046639
From: <sip:34020000001320000001@4101050000>;tag=224638776
To: <sip:34020000001320000001@4101050000>
Via: SIP/2.0/UDP 192.168.31.68:5060;rport=5060;branch=z9hG4bK614477408;received=192.168.31.186
Date: Mon, 08 Jan 2024 05:39:52 GMT
Contact: <sip:34020000001320000001@192.168.31.68:5060>
Expires: 3600
User-Agent: LHY-SIP
Content-Length: 0
# 无应答消息(心跳)
# 流程图
点击查看
设备向服务发送 MESSAGE
MESSAGE sip:41010500002000000001@4101050000 SIP/2.0
Via: SIP/2.0/UDP 192.168.31.68:5060;rport=5060;branch=z9hG4bK837898845;received=192.168.31.168
From: <sip:34020000001320000001@3402000000>;tag=915180001
To: <sip:41010500002000000001@4101050000>
Call-ID: 319359727
CSeq: 20 MESSAGE
Content-Type: Application/MANSCDP+xml
Max-Forwards: 70
User-Agent: IP Camera
Content-Length: 179
<?xml version="1.0" encoding="GB2312"?>
<Notify>
<CmdType>Keepalive</CmdType>
<SN>1111</SN>
<DeviceID>34020000001320000001</DeviceID>
<Status>OK</Status>
<Info>
</Info>
</Notify>
服务器响应设备200
SIP/2.0 200 OK
CSeq: 20 MESSAGE
Call-ID: 319359727
From: <sip:34020000001320000001@3402000000>;tag=915180001
To: <sip:41010500002000000001@4101050000>
Via: SIP/2.0/UDP 192.168.31.68:5060;rport=5060;branch=z9hG4bK837898845;received=192.168.31.68
User-Agent: LHY-SIP
Content-Length: 0
# 流媒体播放
# 流程图
点击查看
服务端下发设备 INVITE
信令格式
INVITE sip:流媒体发送者(设备SIP)编码@SIP服务域或IP地址 SIP/2.0
Call-ID: 3f6f91a8447b6a3290ecba4d8e00bd0f@192.168.31.186
CSeq: 800 INVITE
From: <sip:SIP服务编码@SIP服务域>;tag=720a55fa75174f118475bc787efdc962
To: <sip:SIP设备编码@SIP服务域或IP地址>
Via: SIP/2.0/UDP SIP服务域或IP地址;branch=z9hG4bK1704725836355;rport
Max-Forwards: 70
Content-Type: APPLICATION/SDP
User-Agent: LHY-SIP
Contact: <sip:SIP服务编码@SIP服务IP地址>
Subject: 流媒体发送者(设备SIP)编码:媒体序列号,流媒体接受者编码(SIP服务编码):接受流媒体序列号
Content-Length: 251
v=0
o=流媒体发送者(设备SIP)编码 0 0 IN IP4 流媒体服务器IP
s=Play
c=IN IP4 流媒体服务器IP
t=0 0
m=video 流媒体服务器端口 RTP/AVP 96 97 98 99
a=recvonly
a=rtpmap:96 PS/90000
a=rtpmap:98 H264/90000
a=rtpmap:97 MPEG4/90000
a=rtpmap:99 H265/90000
y=媒体序列号
示例
INVITE sip:34020000001320000001@192.168.31.68:5060 SIP/2.0
Call-ID: 3f6f91a8447b6a3290ecba4d8e00bd0f@192.168.31.186
CSeq: 800 INVITE
From: <sip:41010500002000000001@4101050000>;tag=720a55fa75174f118475bc787efdc962
To: <sip:34020000001320000001@192.168.31.68:5060>
Via: SIP/2.0/UDP 192.168.31.186:5060;branch=z9hG4bK1704725836355;rport
Max-Forwards: 70
Content-Type: APPLICATION/SDP
User-Agent: LHY-SIP
Contact: <sip:41010500002000000001@192.168.31.186:5060>
Subject: 34020000001320000001:0105000179,41010500002000000001:0
Content-Length: 251
v=0
o=34020000001320000001 0 0 IN IP4 192.168.31.107
s=Play
c=IN IP4 192.168.31.107
t=0 0
m=video 35057 RTP/AVP 96 97 98 99
a=recvonly
a=rtpmap:96 PS/90000
a=rtpmap:98 H264/90000
a=rtpmap:97 MPEG4/90000
a=rtpmap:99 H265/90000
y=0105000179
设备回复服务端 OK
信令格式
SIP/2.0 200 OK
Via: SIP/2.0/UDP SIP服务域或IP端口;branch=z9hG4bK1704725836355;rport=SIP服务端口
From: <sip:SIP服务编码@SIP服务域>;tag=720a55fa75174f118475bc787efdc962
To: <sip:SIP设备编码@SIP服务域或IP端口>;tag=1894430947
Call-ID: 3f6f91a8447b6a3290ecba4d8e00bd0f@192.168.31.186
CSeq: 800 INVITE
Contact: <sip:SIP设备编码@SIP服务域或IP端口>
Content-Type: application/sdp
User-Agent: IP Camera
Content-Length: 187
v=0
o=流媒体发送者(设备SIP)编码 3016 3016 IN IP4 流媒体服务器IP
s=Play
c=IN IP4 流媒体服务器IP
t=0 0
m=video 15060 RTP/AVP 96
a=sendonly
a=rtpmap:96 PS/90000
a=filesize:0
y=媒体序列号
示例
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.31.186:5060;branch=z9hG4bK1704725836355;rport=5060
From: <sip:41010500002000000001@4101050000>;tag=720a55fa75174f118475bc787efdc962
To: <sip:34020000001320000001@192.168.31.68:5060>;tag=1894430947
Call-ID: 3f6f91a8447b6a3290ecba4d8e00bd0f@192.168.31.186
CSeq: 800 INVITE
Contact: <sip:34020000001320000001@192.168.31.68:5060>
Content-Type: application/sdp
User-Agent: IP Camera
Content-Length: 187
v=0
o=34020000001320000001 3016 3016 IN IP4 192.168.31.68
s=Play
c=IN IP4 192.168.31.68
t=0 0
m=video 15060 RTP/AVP 96
a=sendonly
a=rtpmap:96 PS/90000
a=filesize:0
y=0105000179
服务端回复设备 ACK
信令格式
ACK sip:SIP设备编码@SIP服务域或IP端口 SIP/2.0
Call-ID: 3f6f91a8447b6a3290ecba4d8e00bd0f@192.168.31.186
CSeq: 800 ACK
From: <sip:SIP服务编码@SIP服务域>;tag=720a55fa75174f118475bc787efdc962
To: <sip:SIP设备编码@SIP服务域或IP端口>;tag=1894430947
Via: SIP/2.0/UDP SIP服务域或IP端口;branch=z9hG4bK1704725836377;rport
Max-Forwards: 70
User-Agent: LHY-SIP
Contact: <sip:SIP服务编码@SIP服务域或IP端口>
Content-Length: 0
示例
ACK sip:34020000001320000001@192.168.31.68:5060 SIP/2.0
Call-ID: 3f6f91a8447b6a3290ecba4d8e00bd0f@192.168.31.186
CSeq: 800 ACK
From: <sip:41010500002000000001@4101050000>;tag=720a55fa75174f118475bc787efdc962
To: <sip:34020000001320000001@192.168.31.68:5060>;tag=1894430947
Via: SIP/2.0/UDP 192.168.31.186:5060;branch=z9hG4bK1704725836377;rport
Max-Forwards: 70
User-Agent: LHY-SIP
Contact: <sip:41010500002000000001@192.168.31.186:5060>
Content-Length: 0
上次更新: 2024/11/05, 08:29:31