Linux下onvif客戶端獲取h265 IPC攝像頭的RTSP地址

一、 設備搜索,去獲取webserver 的地址 ,目的是在獲取能力提供服務地址,demo:https://www.cnblogs.com/croxd/p/10683429.htmlhtml

二、 GetCapabilities獲取能力,目的是在GetProfiles時提供媒體地址,demo:https://www.cnblogs.com/croxd/p/10683503.html
web

若是GetCapabilities獲取能力失敗,soap error 4 或者 52的話,能夠參考:https://www.cnblogs.com/croxd/p/10684712.html框架

char sercer_addr[] = "http://172.168.0.211/onvif/device_service";//設備搜索獲取到的地址
    struct SOAP_ENV__Header header; struct soap* soap = ONVIF_Initsoap(&header, NULL, NULL, 5); struct _tds__GetCapabilities *req; struct _tds__GetCapabilitiesResponse *Response; req->__sizeCategory = 1; req->Category = (enum tt__CapabilityCategory *)soap_malloc(soap, sizeof(int)); *(req->Category) = (enum tt__CapabilityCategory)5; //5表示:tt__CapabilityCategory__Media
 ONVIF_SetAuthInfo(soap,"admin","123456");  //鑑權,輸入攝像頭的用戶名、密碼
    ret = soap_call___tds__GetCapabilities(soap, sercer_addr, NULL,req, Response);

 

3 、GetServices獲取多個媒體地址 demo:https://www.cnblogs.com/croxd/p/10683576.html
tcp

要是在獲取GetProfiles時,用第二步的媒體地址不支持h265,那麼你就須要調用這個接口。在這個接口的tds__GetServicesResponse結構體中能夠獲取兩個媒體地址  。要是以前沒有安裝h265的gsoap環境,這邊也是隻能獲取一個媒體地址,安裝h265的環境請查看上一篇的文章 :Linux下onvi支持h265環境的的搭建 url

char secvre_addr[] = "http://172.168.0.211/onvif/device_service"; //設備搜索獲取獲得的服務地址
    struct SOAP_ENV__Header header; struct _tds__GetServices *tds__GetServices; struct _tds__GetServicesResponse *tds__GetServicesResponse; struct soap* soap = ONVIF_Initsoap(&header, NULL, NULL, 5); tds__GetServices->IncludeCapability = 0; ONVIF_SetAuthInfo(soap,"admin","123456");  //鑑權
    soap_call___tds__GetServices(soap,secvre_addr,NULL, tds__GetServices, tds__GetServicesResponse);

 

四、GetProfiles 獲取媒體信息文件 demo:https://www.cnblogs.com/croxd/p/10683598.html
spa

從tr2__GetProfilesResponse結構體獲取媒體信息文件,soap_call___tr2__GetProfiles接口是安裝h265的環境時,gsoap框架所生成的接口。.net

char media_addr2[] = "http://172.168.0.211/onvif/media2_service"; //GetServices獲得的地址
    struct SOAP_ENV__Header header; struct soap* soap = ONVIF_Initsoap(&header, NULL, NULL, 5); struct _tr2__GetProfiles tr2__GetProfiles; struct _tr2__GetProfilesResponse tr2__GetProfilesResponse; tr2__GetProfiles.__sizeType = 1; tr2__GetProfiles.Token = NULL; tr2__GetProfiles.Type = NULL; ONVIF_SetAuthInfo(soap,"admin","123456");  //鑑權
    soap_call___tr2__GetProfiles(soap, media_addr2, NULL, &tr2__GetProfiles, &tr2__GetProfilesResponse);

 

五、 GetStreamUri 獲取RTSP地址 demo:https://www.cnblogs.com/croxd/p/10683616.html
code

從tr2__GetStreamUriResponse結構體中獲取h265的RTSP地址,soap_call___tr2__GetStreamUri接口是安裝h265的環境時,gsoap框架所生成的接口。server

char media_addr2[] = "http://172.168.0.211/onvif/media2_service"; //GetServices獲得的地址
    char taken[] = "Profile000";   //get_profiles獲取
    struct SOAP_ENV__Header header; struct soap* soap = ONVIF_Initsoap(&header, NULL, NULL, 5); struct _tr2__GetStreamUri tr2__GetStreamUri; struct _tr2__GetStreamUriResponse tr2__GetStreamUriResponse; tr2__GetStreamUri.Protocol = (char *)soap_malloc(soap, 128*sizeof(char));//     if (NULL == tr2__GetStreamUri.Protocol){ printf("soap_malloc is error\n"); ret = -1; } tr2__GetStreamUri.ProfileToken = (char *)soap_malloc(soap, 128*sizeof(char ));//     if (NULL == tr2__GetStreamUri.ProfileToken){ printf("soap_malloc is error\n"); ret = -1; } strcpy(tr2__GetStreamUri.Protocol, "tcp"); strcpy(tr2__GetStreamUri.ProfileToken, taken); ONVIF_SetAuthInfo(soap,"admin","123456");  //鑑權
    soap_call___tr2__GetStreamUri(soap, media_addr2, NULL, &tr2__GetStreamUri, &tr2__GetStreamUriResponse); 
相關文章
相關標籤/搜索