严格意义上来说,Onvif处理这块算不上音视频开发的内容,为何重新整理放在音视频开发这个类别,主要是为了方便统一管理,而且在视频监控处理这块,通过onvif来拿到音视频流这是必经的阶段,也算是搭边的东西。上一篇文章写的是onvif设备搜索,搜到这些设备以后,第一件事情就是要对设备信息获取一下,比如获取视频流地址,配置套件信息、码流信息、分辨率大小等,这些信息的获取根据具体的需要去获取,也没有必要全部获取,毕竟很可能大部分的信息用不到,按需编码永远都是第一原则,第二原则才是考虑拓展性和稳定性,如果基本的需求都实现不了,那就不是一个真正的软件,考虑再多的拓展性和稳定性都是白搭,说的严重一点就是:所有编程语言都是垃圾,能解决实际需求并变现才是王道!
onvif设备信息的获取需要注意的是,现在市场上绝大部分的摄像机都有密码验证的限定,先不管他默认是admin还是12345,起码有用户验证的机制摆在那,这样相对来说安全很多,不然谁也可以通过onvif协议拿到对应的信息,就没有安全性可言,记得几年前海康爆出了漏洞,导致很多监控摄像头被泄露,为此海康现在的摄像头默认onvif是关闭的,开启以后密码要求各种组合,哎,想要更安全就必须牺牲便捷性,这个也不知道谁能想出一个完美兼顾的方法。
onvif主要的功能:
onvif的处理流程:
OnvifDevice::DeviceInfo *OnvifBase::getDeviceInfo() { if (device->deviceUrl.isEmpty()) { return 0; } QString file = device->request->getSendData("GetDeviceInformation"); QByteArray dataSend = file.toUtf8(); QNetworkReply *reply = device->request->auth(device->deviceUrl, dataSend); emit sendData(dataSend, device->deviceUrl); OnvifDevice::DeviceInfo *deviceInfo = 0; QByteArray dataReceive; bool ok = device->checkData(reply, dataReceive, "获取设备信息"); if (ok) { OnvifQuery query; query.setData(dataReceive); QString wsdl = query.getDeviceWsdl(); QString name_path = QString("//%1:GetDeviceInformationResponse/%1:Manufacturer").arg(wsdl); QString mod_path = QString("//%1:GetDeviceInformationResponse/%1:Model").arg(wsdl); QString ver_path = QString("//%1:GetDeviceInformationResponse/%1:FirmwareVersion").arg(wsdl); QString ser_path = QString("//%1:GetDeviceInformationResponse/%1:SerialNumber").arg(wsdl); QString hard_path = QString("//%1:GetDeviceInformationResponse/%1:HardwareId").arg(wsdl); //先将广播搜索到的设备信息一起打包 deviceInfo = new OnvifDevice::DeviceInfo; deviceInfo->addr = device->deviceInfo.value("addr"); deviceInfo->ip = device->deviceInfo.value("ip"); deviceInfo->name = device->deviceInfo.value("name"); deviceInfo->location = device->deviceInfo.value("location"); deviceInfo->hardware = device->deviceInfo.value("hardware"); deviceInfo->manufacturer = query.getValue(name_path); deviceInfo->model = query.getValue(mod_path); deviceInfo->firmwareVersion = query.getValue(ver_path); deviceInfo->serialNumber = query.getValue(ser_path); deviceInfo->hardwareId = query.getValue(hard_path); } return deviceInfo; }
<?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"> <s:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:UsernameToken>%1</wsse:UsernameToken> </wsse:Security> </s:Header> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <GetDeviceInformation xmlns="http://www.onvif.org/ver10/device/wsdl"/> </s:Body> </s:Envelope>
原创声明,本文系作者授权云+社区发表,未经许可,不得转载。
如有侵权,请联系 yunjia_community@tencent.com 删除。
我来说两句