onvif 验证过程
资料收集:
onvif获取rtsp地址流程
1.搜索Probe,设备发现,发现IPC,获取webService地址;
2.获取能力集,GetCapabilities,从中识别出媒体信息地址URI:http://192.168.73.231:8080/onvif/media_service
3.获取媒体信息,GetProfiles,获取媒体信息文件,识别主通道、子通道的视频编码分辨率
4.获取RTSP地址,GetStreamUri,获取指定通道的流媒体地址
链接:https://www.jianshu.com/p/03be66706c22
使用github.com/use-go/onvif包,实现go语言对接onvif协议
利用gSoap生成ONVIF Server框架
服务器端 UDP socket,监听239.255.255.250:3702
IPC工作原理:
首先,进程A获取来自AR0330摄像头模块的YUV原始视频图像,并使用H265压缩编码算法进行压缩编码获 得H265格式码流,该过程通过使用海思提供的媒体处理平台(MPP)实现;
其次,进程B负责响应网络客户端的请求,将进程A的输出码流通过千兆以太网接 口实时地发送出去,该过程通过对LIVE555开源代码(该代码原本只支持文件发送功能,而不支持内存实时数据发送功能)二次开发实现;
整体流程:
Probe: 发现网络摄像头,获取webserver地址 http://192.168.15.240/onvif/device_service
GetCapabilities:获取设备能力文件,从中识别出媒体信息地址URI: http://192.168.15.240/onvif/Media
GetProfiles: 获取媒体信息文件,识别主通道、子通道的视频编码分辨率
GetStreamUri:获取指定通道的流媒体地址 rtsp://192.168.15.240:554/Streaming/Channels/2?transportmode=unicast
onvif 设备发现的机制
从ONVIF的官方文档中可以了解到,客户端在UDP协议下,向网段内的组播地址239.255.255.250,端口3702,不断地向四周发送Probe消息探针,而网段内的服务器在接收到Probe这个探测消息后,通过回复ProbeMatch消息让客户端接收,从而让客户端识别到服务器。
所以服务器端就需要创建一个UDP协议的socket,去监听239.255.255.250:3702,接收到客户端的Probe探针后,进行响应,从而让客户端识别到onvif服务器。
Referenced from:https://blog.csdn.net/weixin_44362642/article/details/86750172
通过抓包,发现probe的包内容
通过udp工具发送出去也是可以的.
<?xml version="1.0" encoding="utf-8"?><Envelope xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns="http://www.w3.org/2003/05/soap-envelope"><Header><wsa:MessageID xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">uuid:cb9529cf-0a34-4971-b140-b5510c22d820</wsa:MessageID><wsa:To xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">urn:schemas-xmlsoap-org:ws:2005:04:discovery</wsa:To><wsa:Action xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</wsa:Action></Header><Body><Probe xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/ws/2005/04/discovery"><Types>tds:Device</Types><Scopes /></Probe></Body></Envelope><?xml version="1.0" encoding="utf-8"?><Envelope xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns="http://www.w3.org/2003/05/soap-envelope"><Header><wsa:MessageID xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">uuid:f5dfce18-8fb2-4a64-a680-3051a2e7970b</wsa:MessageID><wsa:To xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">urn:schemas-xmlsoap-org:ws:2005:04:discovery</wsa:To><wsa:Action xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</wsa:Action></Header><Body><Probe xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/ws/2005/04/discovery"><Types>dn:NetworkVideoTransmitter</Types><Scopes /></Probe></Body></Envelope>
应答示例:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns4="http://www.onvif.org/ver10/pacs" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:ns1="http://www.onvif.org/ver20/media/wsdl" xmlns:ns2="http://www.onvif.org/ver10/actionengine/wsdl" xmlns:ns3="http://www.onvif.org/ver10/accesscontrol/wsdl" xmlns:ns5="http://www.onvif.org/ver10/doorcontrol/wsdl" xmlns:ns6="http://www.onvif.org/ver10/advancedsecurity/wsdl" xmlns:ns7="http://www.onvif.org/ver10/accessrules/wsdl" xmlns:ns8="http://www.onvif.org/ver10/credential/wsdl" xmlns:ns9="http://www.onvif.org/ver10/schedule/wsdl" xmlns:tad="http://www.onvif.org/ver10/analyticsdevice/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tls="http://www.onvif.org/ver10/display/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:trv="http://www.onvif.org/ver10/receiver/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl"><SOAP-ENV:Header><wsa:MessageID>urn:uuid:ed2e0d23-207e-4211-85a0-a47c184ce6cb</wsa:MessageID><wsa:RelatesTo>uuid:cb9529cf-0a34-4971-b140-b5510c22d820</wsa:RelatesTo><wsa:To SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To><wsa:Action SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches</wsa:Action><wsdd:AppSequence MessageNumber="3" InstanceId="0"></wsdd:AppSequence></SOAP-ENV:Header><SOAP-ENV:Body><wsdd:ProbeMatches><wsdd:ProbeMatch><wsa:EndpointReference><wsa:Address>urn:uuid:4d474e6d-4e44-4131-5a6a-4d7a4d574e68</wsa:Address></wsa:EndpointReference><wsdd:Types>tdn:NetworkVideoTransmitter</wsdd:Types><wsdd:Scopes>onvif://www.onvif.org/Profile/Streaming onvif://www.onvif.org/location/city/Nanning onvif://www.onvif.org/location/street/Binhe onvif://www.onvif.org/location/floor/19 onvif://www.onvif.org/hardware/PCC300V8E onvif://www.onvif.org/name/CAMERA </wsdd:Scopes><wsdd:XAddrs>http://192.168.2.79:8080/onvif/device_service</wsdd:XAddrs><wsdd:MetadataVersion>1</wsdd:MetadataVersion></wsdd:ProbeMatch></wsdd:ProbeMatches></SOAP-ENV:Body></SOAP-ENV:Envelope>
本文链接地址:https://const.net.cn/755.html