Wvp外部调用关系
代码结构
数据表
主要配置
Sip及zlm配置
海康摄像头配置
代码解析
Wvp 启动流程
ZLMRunner
默认zlm初始化:
- 修改zlm【hook】配置
- 获取zlm配置
- 更新zlm信息
在线事件监听器,监听到离线后,修改设备离在线状态。 设备在线有两个来源:
* 1、设备主动注销,发送注销指令
* 2、设备未知原因离线,心跳超时
ZLMStatusEventListener
启动sipServer 监听信令消息
SipLayer
监听sip信令(udp)
Tcp
处理接收IPCamera发来的SIP协议请求消息
SIPRequestProcessorParent
类型包括:
Request
message、info、 ack、bye、cancel、invite、 notify、register、subscribe
Response
bye、cancel、invite、register
设备能力接口,用于定义设备的控制、查询能力(sip指令)
SIPCommander
查询设备状态
deviceStatusQuery
查询设备信息
deviceInfoQuery
查询目录列表
catalogQuery
请求预览视频流
playStreamCmd
平台能力接口
SIPCommanderFroPlatform
事件推送
事件通知推送器,支持推送在线事件、离线事件
EventPublisher
事件监听:报警事件监听、catalog事件、录像查询结束时间
SIPProcessorObserver
Zlm回调接口
ZLMHttpHookListener
针对 ZLMediaServer的hook事件监听
服务器定时上报
on_server_keepalive
流量统计事件
on_flow_report
访问http文件服务器上hls之外的文件时触发
on_http_access
播放器鉴权事件,rtsp/rtmp/http-flv/ws-flv/hls的播放都将触发此鉴权事件
on_play
rtsp/rtmp/rtp推流鉴权事件
on_publish
rtsp专用的鉴权事件,先触发on_rtsp_realm事件然后才会触发on_rtsp_auth事件
on_rtsp_realm
该rtsp流是否开启rtsp专用方式的鉴权事件,开启后才会触发on_rtsp_auth事件。需要指出的是rtsp也支持url参数鉴权,它支持两种方式鉴权
on_rtsp_auth
rtsp/rtmp流注册或注销时触发此事件;此事件对回复不敏感
on_stream_changed
流无人观看时事件,用户可以通过此事件选择是否关闭无人看的流
on_stream_none_reader
流未找到事件,用户可以在此事件触发时,立即去拉流,这样可以实现按需拉流;此事件对回复不敏感
on_stream_not_found
服务器启动事件,可以用于监听服务器崩溃重启;此事件对回复不敏感
on_server_started
信令消息示例
注册消息
REGISTER sip:65010200002150000005@6501020000 SIP/2.0
Via: SIP/2.0/UDP 192.168.3.183:5060;rport=5060;branch=z9hG4bK2139069604;received=192.168.3.183
From: <sip:65010200002160000006@6501020000>;tag=703769995
To: <sip:65010200002160000006@6501020000>
Call-ID: 195837539
CSeq: 1 REGISTER
Contact: <sip:65010200002160000006@192.168.3.183:5060>
Max-Forwards: 70
User-Agent: IP Camera
Expires: 3600
Content-Length: 0
心跳消息
MESSAGE sip:65010200002150000005@6501020000 SIP/2.0
Via: SIP/2.0/UDP 192.168.3.183:5060;rport=5060;branch=z9hG4bK135969284;received=192.168.3.183
From: <sip:65010200002160000006@6501020000>;tag=902635500
To: <sip:65010200002150000005@6501020000>
Call-ID: 555677928
CSeq: 20 MESSAGE
Content-Type: Application/MANSCDP+xml
Max-Forwards: 70
User-Agent: IP Camera
Content-Length: 177
<?xml version="1.0" encoding="GB2312"?>
<Notify>
<CmdType>Keepalive</CmdType>
<SN>31</SN>
<DeviceID>65010200002160000006</DeviceID>
<Status>OK</Status>
<Info>
</Info>
</Notify>
设备信息消息
MESSAGE sip:65010200002150000005@6501020000 SIP/2.0
Via: SIP/2.0/UDP 192.168.3.183:5060;rport=5060;branch=z9hG4bK1441176947;received=192.168.3.183
From: <sip:65010200002160000006@6501020000>;tag=2111771881
To: <sip:65010200002150000005@6501020000>
Call-ID: 1785981557
CSeq: 20 MESSAGE
Content-Type: Application/MANSCDP+xml
Max-Forwards: 70
User-Agent: IP Camera
Content-Length: 320
<?xml version="1.0" encoding="GB2312"?>
<Response>
<CmdType>DeviceInfo</CmdType>
<SN>530013</SN>
<DeviceID>65010200002160000006</DeviceID>
<Result>OK</Result>
<DeviceName>hk01</DeviceName>
<Manufacturer>Hikvision</Manufacturer>
<Model>DS-2CD3T25D-I5</Model>
<Firmware>V5.5.80</Firmware>
<Channel>1</Channel>
</Response>
设备告警消息
MESSAGE sip:65010200002150000005@6501020000 SIP/2.0
Via: SIP/2.0/UDP 192.168.3.183:5060;rport=5060;branch=z9hG4bK2049632037;received=192.168.3.183
From: <sip:65010200002160000006@6501020000>;tag=1700755851
To: <sip:65010200002150000005@6501020000>
Call-ID: 1513477884
CSeq: 20 MESSAGE
Content-Type: Application/MANSCDP+xml
Max-Forwards: 70
User-Agent: IP Camera
Content-Length: 284
<?xml version="1.0" encoding="GB2312"?>
<Notify>
<CmdType>Alarm</CmdType>
<SN>348</SN>
<DeviceID>65010200001320000107</DeviceID>
<AlarmPriority>4</AlarmPriority>
<AlarmMethod>5</AlarmMethod>
<AlarmTime>2022-10-10T15:56:39</AlarmTime>
<Info>
<AlarmType>2</AlarmType>
</Info>
</Notify>
订阅目录消息
MESSAGE sip:65010200002150000005@192.168.3.248:5060 SIP/2.0
Call-ID: 75d8c1da2c273dbfa941fec19c323647@0.0.0.0
CSeq: 52 MESSAGE
From: <sip:65010200002150000004@6501020000>;tag=882ff21fc2214be382e1ff663a4c7454
To: <sip:65010200002150000005@192.168.3.248:5060>
Via: SIP/2.0/UDP 192.168.3.248:5061;branch=z9hG4bK1665640059254;rport
Max-Forwards: 70
User-Agent: WVP-Pro vnull.null
Content-Type: Application/MANSCDP+xml
Content-Length: 154
<?xml version="1.0" encoding="GB2312"?>
<Query>
<CmdType>Catalog</CmdType>
<SN>954685</SN>
<DeviceID>65010200002150000005</DeviceID>
</Query>
订阅目录返回消息
<?xml version="1.0" encoding="GB2312"?>
<Response>
<CmdType>Catalog</CmdType>
<SN>193590</SN>
<DeviceID>65010200002160000006</DeviceID>
<SumNum>1</SumNum>
<DeviceList Num="1">
<Item>
<DeviceID>65010200001320000107</DeviceID>
<Name>R-Cam-C01</Name>
<Manufacturer>Hikvision</Manufacturer>
<Model>IP Camera</Model>
<Owner>Owner</Owner>
<CivilCode>6501020000</CivilCode>
<Address>Address</Address>
<Parental>0</Parental>
<ParentID>65010200002150000005</ParentID>
<SafetyWay>0</SafetyWay>
<RegisterWay>1</RegisterWay>
<Secrecy>0</Secrecy>
<Status>ON</Status>
</Item>
</DeviceList>
</Response>
地址订阅消息
SUBSCRIBE sip:65010200002160000006@192.168.3.183:5060 SIP/2.0
Call-ID: 8077272d9edfa6a966870f8ab2b32159@0.0.0.0
CSeq: 757 SUBSCRIBE
From: <sip:65010200002150000005@6501020000>;tag=4655db1469fb46a7b48909d331d750d3
To: <sip:65010200002160000006@192.168.3.183:5060>
Via: SIP/2.0/UDP 192.168.3.248:5060;branch=z9hG4bK1665476193501;rport
Max-Forwards: 70
Contact: <sip:65010200002150000005@192.168.3.248:5060>
Expires: 1
Event: presence;id=5887
Content-Type: Application/MANSCDP+xml
User-Agent: WVP-Pro vnull.null
Content-Length: 179
<?xml version="1.0" encoding="GB2312"?>
<Query>
<CmdType>MobilePosition</CmdType>
<SN>513896</SN>
<DeviceID>65010200002160000006</DeviceID>
<Interval>5</Interval>
</Query>
实时视频播放
INVITE sip:65010200001320000107@192.168.3.183:5060 SIP/2.0
Call-ID: 4764797ea3aebe1446626d1d1b11fe3f@0.0.0.0
CSeq: 5289 INVITE
From: <sip:65010200002150000005@6501020000>;tag=0fb81fc8fbb94286ab60adff79a21d7e
To: <sip:65010200001320000107@192.168.3.183:5060>
Via: SIP/2.0/UDP 192.168.3.248:5060;branch=z9hG4bK1665641368035;rport
Max-Forwards: 70
User-Agent: WVP-Pro vnull.null
Contact: <sip:65010200002150000005@192.168.3.248:5060>
Subject: 65010200001320000107:0102008396,65010200002150000005:0
Content-Type: APPLICATION/SDP
Content-Length: 249
v=0 //协议版本
o=65010200001320000107 0 0 IN IP4 192.168.3.158
s=Play //Play标识为点播请求 Playback标识回播请求
c=IN IP4 192.168.3.158 //音视频流目的地址
t=0 0 //t行第一参数为视频开始时间 第二个参数为结束时间 t = 0 0表示实时视音频点播
m=video 30012 RTP/AVP 96 97 98 99 //video:表示请求音视频流 audio:表示请求音频流 5522:音视频流目的端口 RTP/AVP:视频流使用协议 96 97 98:客户端支持码流格式
a=recvonly
a=rtpmap:96 PS/90000
a=rtpmap:98 H264/90000
a=rtpmap:97 MPEG4/90000
a=rtpmap:99 H265/90000
y=0102008396
INVITE sip:34020000001320000001@192.168.3.248:5060 SIP/2.0
Call-ID: cf614612a6385b482e3b14440e9c9bff@0.0.0.0
CSeq: 71 INVITE
From: <sip:65010200002150000004@6501020000>;tag=9ea5d61b982a460792aab495789f1dbd
To: <sip:34020000001320000001@192.168.3.248:5060>
Via: SIP/2.0/UDP 192.168.3.248:5061;branch=z9hG4bK1665727931231;rport
Max-Forwards: 70
User-Agent: WVP-Pro vnull.null
Contact: <sip:65010200002150000004@192.168.3.248:5061>
Subject: 34020000001320000001:0102007919,65010200002150000004:0
Content-Type: APPLICATION/SDP
Content-Length: 249
v=0
o=34020000001320000001 0 0 IN IP4 192.168.3.225
s=Play
c=IN IP4 192.168.3.225
t=0 0
m=video 30006 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=0102007919
INVITE sip:65010200002150000005@192.168.3.248:5060 SIP/2.0
Call-ID: 466127031be4f1299eb41ff746350fa3@0.0.0.0
CSeq: 219 INVITE
From: <sip:65010200002150000004@6501020000>;tag=2199eb650cb5443b9987095caa4ec492
To: <sip:65010200002150000005@192.168.3.248:5060>;tag=1666065556591
Via: SIP/2.0/UDP 192.168.3.248:5061;branch=z9hG4bK1666065554697;rport=5061;received=192.168.3.248
Max-Forwards: 70
User-Agent: WVP-Pro vnull.null
Contact: <sip:65010200002150000004@192.168.3.248:5061>
Subject: 65010200002150000005:0102009847,65010200002150000004:0
Content-Type: APPLICATION/SDP
Content-Length: 249
v=0
o=65010200002150000005 0 0 IN IP4 192.168.3.225
s=Play
c=IN IP4 192.168.3.225
t=0 0
m=video 30068 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=0102009847
SIP/2.0 200 OK
CSeq: 230 INVITE
Call-ID: 8d0de76029bd8a543047bf1b4cc4a432@0.0.0.0
From: <sip:65010200002150000004@6501020000>;tag=894ea82882db4bdda5530ecc8749c8ce
To: <sip:65010200002150000005@192.168.3.248:5060>;tag=1666072779036
Via: SIP/2.0/UDP 192.168.3.248:5061;branch=z9hG4bK1666072775503;rport=5061;received=192.168.3.248
Contact: <sip:65010200002150000005@192.168.3.248:5060>
Content-Type: APPLICATION/SDP
Content-Length: 171
v=0
o=65010200002150000005 0 0 IN IP4 192.168.3.158
s=Play
c=IN IP4 192.168.3.158
t=0 0
m=video 30000 RTP/AVP 96
a=sendonly
a=rtpmap:96 PS/90000
y=0102001275
f=
ACK sip:65010200002150000005@192.168.3.248:5060 SIP/2.0
Call-ID: 4fd4d2ee71c8a8aa7128e4a12002f110@0.0.0.0
CSeq: 239 ACK
From: <sip:65010200002150000004@6501020000>;tag=8c75989cb61c40799a7fbb622a31d0ea
To: <sip:65010200002150000005@192.168.3.248:5060>;tag=1666073953466
Via: SIP/2.0/UDP 192.168.3.248:5061;branch=z9hG4bK1666073956155
Max-Forwards: 70
User-Agent: WVP-Pro vnull.null
Contact: <sip:65010200002150000004@192.168.3.248:5061>
Content-Length: 0