Atitti onvif 設備發現與原理
1.3. Ws disconvert 的組播地址和端口就是37022
1)發現ipcam
客戶端首先發起ws-discovery,查找所在網絡段內的所有的ipcam。Ipcam在接收到ws-discovery之后可以進行響應
在android下的實現方式
在android下的實現方式
1)DatagramPacket類,UDP的方式
2)計算廣播地址(192.168.1.255)
3)socket send probe
4)開啟一個線程去receive
5)解析收到的probematch
1.1. ,有以下幾個步驟:
1、創建組播用的udp socket,
2、綁定組播地址為239.255.255.250,端口為3702,因為ws-discovery的組播地址和端口就是為239.255.255.250和3702
1.2. 設備搜索原理及編程技巧:
搜索發現的基本原理是:設備上服務器監聽239.255.255.250的3702端口。所以,如果要實現跨網段搜索onvif設備需要路由的支持。只要組播數據包能收到,設備就能被搜到。原理是這樣。參考代碼:
1.3. Ws disconvert 的組播地址和端口就是3702
關於cxf報:Cannot create URL for this address soap.udp://239.255.255.250:3702的原因
the ONVIF discovery process is based onhttp://specs.xmlsoap.org/ws/2005/04/discovery it use SOAP over UDP.
If you are using apache-cxf, this can be achieve using
org.apache.cxf.ws.discovery.WSDiscoveryClient
A simple sample code could be :
import java.util.List;
import javax.xml.ws.EndpointReference;
import org.apache.cxf.ws.discovery.WSDiscoveryClient;
public class Main
{
public static void main(String[] args)
{
WSDiscoveryClient client = new WSDiscoveryClient();
client.setVersion10(); // use WS-discovery 1.0
client.setDefaultProbeTimeout(1000); // timeout 1s
System.out.println("Probe:" + client.getAddress());
List<EndpointReference> references = client.probe();
System.out.println("Nb answsers:" + references.size());
for (EndpointReference ref : references)
{
System.out.println(ref.toString());
}
}
}
Probe is :soap.udp://239.255.255.250:3702
Nb answsers:1
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><EndpointReference xmlns="http://www.w3.org/2005/08/addressing"><Address>http://192.168.31.144:10080/onvif/device_service</Address><ReferenceParameters/></EndpointReference>
1.4. 參考資料
Onvif協議及其在Android下的實現 - 青草 綠葉 百合 - 博客頻道 - CSDN.NET.html
android ONVIF 組播探測在線攝像機 - 天賜良恩 - 博客園.html
Android Wifi獲取組播 - 雲上 - 博客頻道 - CSDN.NET.html
android ONVIF 組播探測在線攝像機 - 天賜良恩 - 博客園.html
ONVIF 組播探測在線攝像機 - zhangkunbin的專欄 - 博客頻道 - CSDN.NET.html
ONVIF客戶端搜索設備獲取rtsp地址開發筆記(精華篇) - 推酷.html
使用 CXF 做 webservice 簡單例子 - 烽火編程 - 博客園.html
作者:: 綽號:老哇的爪子claw of Eagle 偶像破壞者Iconoclast image-smasher
捕鳥王"Bird Catcher 王中之王King of Kings 虔誠者Pious 宗教信仰捍衛者 Defender of the Faith. 卡拉卡拉紅斗篷 Caracalla red cloak
簡稱:: Emir Attilax Akbar 埃米爾 阿提拉克斯 阿克巴
全名::Emir Attilax Akbar bin Mahmud bin attila bin Solomon Al Rapanui
埃米爾 阿提拉克斯 阿克巴 本 馬哈茂德 本 阿提拉 本 所羅門 阿爾 拉帕努伊
常用名:艾提拉(艾龍), EMAIL:1466519819@qq.com
頭銜:uke總部o2o負責人,全球網格化項目創始人,uke宗教與文化融合事務部部長,Uke部落首席大酋長,uke制度與重大會議委員會委員長,uke保安部首席大隊長,uke制度檢查委員會副會長,奶牛科技cto ,uke波利尼西亞區大區連鎖負責人,克爾格倫群島區連鎖負責人,萊恩群島區連鎖負責人,uke湯加王國區域負責人。布維島和南喬治亞和南桑威奇群島大區連鎖負責人
轉載請注明來源:attilax的專欄 http://www.cnblogs.com/attilax/
--Atiend