onvif访问的整体过程请参考:https://blog.csdn.net/benkaoya/article/details/72424335?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task
推荐基于rapidonvif源代码实现:https://www.cnblogs.com/rongpmcu/p/10351204.html
1.源代码基本过程解读:
OnvifClientDevice::GetCapabilities
soap_wsse_add_Security 添加wsse鉴权方式
soap_wsse_add_UsernameTokenDigest 添加用户名和密码
deviceBindProxy.GetCapabilities
DeviceBindingProxy::GetCapabilities
soap_connect
soap_connect_command connect请求
soap_try_connect_command
soap_set_endpoint(soap, endpoint) 将url解析到host和port
tcp_connect 连接该host和port
2、鉴权注意:
IPC相机上需要设置鉴权方式为包括wsse的方式,相机上一般需要单独配置onvif的用户名和密码(不同于WEB访问的密码),onvif客户端访问需要一致即可保证每次操作鉴权通过,顺利完成onvif操作过程
3、得到rtsp地址后获取视频码流:
请参考https://blog.csdn.net/bluish_white/article/details/78453709,注意要验证的话需要采用如下形式添加用户名和密码去访问:rtsp://username:pwd@hostIP:port/xxx。windows的rtsp server(happytime)不支持携带username:pwd
4、存在依赖库openssl要编译:
重新编译openssl 1.0.1(1.1.1版本本身有问题,不完整): https://www.jianshu.com/p/5f260723f5f8
版本下载路径:https://github.com/openssl/openssl/tree/OpenSSL_1_0_1-stable
海思3559A芯片编译过程:
unzip openssl-OpenSSL_1_0_1-stable.zip
cd openssl-OpenSSL_1_0_1-stable
CC=aarch64-himix100-linux-gcc
CXX=aarch64-himix100-linux-g++
./config no-asm no-async shared --prefix=3559a --cross-compile-prefix=aarch64-himix100-linux-
make
存在编译错误,需要删除Makefile的m64内容(两处), prefix如果相对路径找不到需使用绝对路径
make install
X86 linux下编译:
./config no-asm no-async shared --prefix=x86
make
sudo make install
5、建议封装为单独的库:
由于onvif client编译起来较慢,建议将其单独封装为一个动态库。
修改原rapidonvif的include下的onvifclientdevice.hpp、onvifclientmedia.hpp,去掉class声明函数时加的class类名,否则编译会报错;
Makefile需要打开-DWITH_OPENSSL -DWITH_DOM -DWITH_PURE_VIRTUAL,link时添加-shared即可编译为动态库。
6、其他供参考材料:
许振坪的专栏:https://blog.csdn.net/benkaoya/category_6924052.html
ONVIF协议网络摄像机(IPC)客户端程序开发(1):https://blog.csdn.net/benkaoya/article/details/72424335
ONVIF协议开发之网络摄像头云台控制(C版)
https://blog.csdn.net/zong596568821xp/article/details/90108569
ONVIF协议网络摄像机
https://www.jianshu.com/p/0bde641c20ca
gSOAP官网:http://www.cs.fsu.edu/~engelen/soap.html
gSOAP源码下载地址:http://sourceforge.net/projects/gsoap2
嵌入式环境下基于onvif协议取得的RTSP视频流以及opencv的交叉编译
https://blog.csdn.net/weixin_36198067/article/details/86581955
hisi3559A平台接入IPC视频流(二) - 使用gSOAP生成ONVIF框架
https://blog.csdn.net/zhenglie110/article/details/96202208?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task
hisi3559A平台接入IPC视频流(一) -使用gSOAP
https://blog.csdn.net/zhenglie110/article/details/93667469
ONVIF Device(IP camera) Service server (Linux daemon)
https://github.com/KoynovStas/onvif_srvd