void UserGetProfiles(struct soap *soap, struct _tds__GetCapabilitiesResponse *capa_resp) { struct _trt__GetProfiles trt__GetProfiles; struct _trt__GetProfilesResponse trt__GetProfilesResponse; int result= SOAP_OK ; printf("\n-------------------Getting Onvif Devices Profiles--------------\n\n"); soap_wsse_add_UsernameTokenDigest(soap,"user", ONVIF_USER, ONVIF_PASSWORD); result = soap_call___trt__GetProfiles(soap, capa_resp->Capabilities->Media->XAddr, NULL, &trt__GetProfiles, &trt__GetProfilesResponse); if (result==-1) //NOTE: it may be regular if result isn't SOAP_OK.Because some attributes aren't supported by server. { printf("soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); result = soap->error; exit(-1); } else{ printf("\n-------------------Profiles Get OK--------------\n\n"); if(trt__GetProfilesResponse.Profiles!=NULL) { int profile_cnt = trt__GetProfilesResponse.__sizeProfiles; printf("the number of profiles are: %d\n", profile_cnt); if(trt__GetProfilesResponse.Profiles->Name!=NULL) printf("Profiles Name:%s \n",trt__GetProfilesResponse.Profiles->Name); if(trt__GetProfilesResponse.Profiles->token!=NULL) printf("Profiles Taken:%s\n",trt__GetProfilesResponse.Profiles->token); UserGetUri(soap, &trt__GetProfilesResponse, capa_resp); } else printf("Profiles Get inner Error\n"); } printf("Profiles Get Procedure over\n"); }
int OnvifClientPTZ::continuousMove(std::string profileToken, float panSpeed, float tiltSpeed, float zoomSpeed){ if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str())) { return -1; } _tptz__ContinuousMove *tptz__ContinuousMove = soap_new__tptz__ContinuousMove(soap, -1); _tptz__ContinuousMoveResponse *tptz__ContinuousMoveResponse = soap_new__tptz__ContinuousMoveResponse(soap, -1); tptz__ContinuousMove->ProfileToken = profileToken; //setting pan and tilt speed tptz__ContinuousMove->Velocity = soap_new_tt__PTZSpeed(soap, -1); tptz__ContinuousMove->Velocity->PanTilt = soap_new_tt__Vector2D(soap, -1); tptz__ContinuousMove->Velocity->PanTilt->x = panSpeed; tptz__ContinuousMove->Velocity->PanTilt->y = tiltSpeed; //setting zoom speed tptz__ContinuousMove->Velocity->Zoom = soap_new_tt__Vector1D(soap, -1); tptz__ContinuousMove->Velocity->Zoom->x = zoomSpeed; long long tempo = 1; tptz__ContinuousMove->Timeout = &tempo; if(SOAP_OK == proxyPTZ.ContinuousMove(tptz__ContinuousMove, tptz__ContinuousMoveResponse)){ }else{ std::cout << "ContinuousMove ERROR:" << std::endl; //PrintErr(proxyPTZ.soap); std::cout; } soap_destroy(soap); soap_end(soap); }
void addSecurity(struct soap* soap, const std::string& username, const std::string & password) { if (!username.empty()) { soap_wsse_add_Timestamp(soap, "Time", 600); soap_wsse_add_UsernameTokenDigest(soap, "User", username.c_str() , password.c_str()); } }
int CSetSoapSecurityDigest2Impl::setSecurity(struct soap* psoap, CBaseSoapSecurityInfo* securityInfo) { if (NULL == psoap) { return RET_CODE_ERROR_NULL_OBJECT; } if (NULL == securityInfo) { return RET_CODE_ERROR_NULL_OBJECT; } return soap_wsse_add_UsernameTokenDigest(psoap, securityInfo->getUserName().c_str(), securityInfo->getPassword().c_str()); }
int ONVIF_Capabilities(struct __wsdd__ProbeMatches *resp) { struct _tds__GetCapabilities capa_req; struct _tds__GetCapabilitiesResponse capa_resp; struct soap *soap = NULL; struct SOAP_ENV__Header header; int retval = 0; soap = ONVIF_Initsoap(&header, NULL, NULL, 5); char *soap_endpoint = (char *)malloc(256); memset(soap_endpoint, '\0', 256); //海康的设备,固定ip连接设备获取能力值 ,实际开发的时候,"172.18.14.22"地址以及80端口号需要填写在动态搜索到的具体信息 sprintf(soap_endpoint, resp->wsdd__ProbeMatches->ProbeMatch->XAddrs); capa_req.Category = (enum tt__CapabilityCategory *)soap_malloc(soap, sizeof(int)); capa_req.__sizeCategory = 1; *(capa_req.Category) = (enum tt__CapabilityCategory)0; //此句也可以不要,因为在接口soap_call___tds__GetCapabilities中判断了,如果此值为NULL,则会给它赋值 const char *soap_action = "http://www.onvif.org/ver10/device/wsdl/GetCapabilities"; capa_resp.Capabilities = (struct tt__Capabilities*)soap_malloc(soap,sizeof(struct tt__Capabilities)) ; //这里处理鉴权函数 soap_wsse_add_UsernameTokenDigest(soap, "user", ONVIF_USER, ONVIF_PASSWORD); do { int result = soap_call___tds__GetCapabilities(soap, soap_endpoint, soap_action, &capa_req, &capa_resp); if (soap->error) { printf("[%s][%d]--->>> soap error: %d, %s, %s\n", __func__, __LINE__, soap->error, *soap_faultcode(soap), *soap_faultstring(soap)); retval = soap->error; break; } else //获取参数成功 { // 走到这里的时候,已经就是验证成功了,可以获取到参数了, // 在实际开发的时候,可以把capa_resp结构体的那些需要的值匹配到自己的私有协议中去,简单的赋值操作就好 printf("[%s][%d] Get capabilities success !\n", __func__, __LINE__); if(capa_resp.Capabilities == NULL) printf("GetCapabilities failed! result = %d\n", result); else { printf(" Media->XAddr=%s \n", capa_resp.Capabilities->Media->XAddr); UserGetProfiles(soap, &capa_resp);// } } }while(0); free(soap_endpoint); soap_endpoint = NULL; soap_destroy(soap); return retval; }
int OnvifClientPTZ::getConfiguration(std::string configurationToken){ if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str())){ return -1; } _tptz__GetConfiguration *tptz__GetConfiguration = soap_new__tptz__GetConfiguration(soap,-1); _tptz__GetConfigurationResponse *tptz__GetConfigurationResponse = soap_new__tptz__GetConfigurationResponse(soap,-1); tptz__GetConfiguration->PTZConfigurationToken = configurationToken; if(SOAP_OK == proxyPTZ.GetConfiguration(tptz__GetConfiguration, tptz__GetConfigurationResponse)){ std::cout << std::endl; std::cout << "Absolute Pan Tilt Position Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultAbsolutePantTiltPositionSpace-> c_str() << std::endl; std::cout << "Absolute Zoom Position Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultAbsoluteZoomPositionSpace-> c_str() << std::endl; std::cout << "Relative Pan Tilt Translation Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultRelativeZoomTranslationSpace->c_str() << std::endl; std::cout << "Relative Zoom Translation Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultContinuousPanTiltVelocitySpace->c_str() << std::endl; std::cout << "Continuous Pan Tilt Velocity Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultContinuousZoomVelocitySpace->c_str() << std::endl; std::cout << "Continuous Zoom Velocity Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultContinuousZoomVelocitySpace->c_str() << std::endl << std::endl; printf("Default PTZ Timeout: %ds\n", *tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZTimeout/1000); printf("Pan Min Limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->PanTiltLimits->Range->XRange->Min); printf("Pan Max Limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->PanTiltLimits->Range->XRange->Max); printf("Tilt Min limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->PanTiltLimits->Range->YRange->Min); printf("Tilt Max limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->PanTiltLimits->Range->YRange->Max); std::cout << "Coordinate System: " << tptz__GetConfigurationResponse->PTZConfiguration->PanTiltLimits->Range->URI.c_str() << std::endl; std::cout << std::endl; printf("Zoom Min limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->ZoomLimits->Range->XRange->Min); printf("Zoom Max limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->ZoomLimits->Range->XRange->Max); printf("Default Pan Speed: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZSpeed->PanTilt->x); printf("Default Tilt Speed: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZSpeed->PanTilt->y); std::cout << "Coordinate System: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZSpeed->PanTilt->space->c_str() << std::endl; printf("Default Zoom Speed: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZSpeed->Zoom->x); std::cout << "Coordinate System: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZSpeed->Zoom->space->c_str() << std::endl; std::cout << std::endl << std::endl; }else{ //PrintErr(proxyPTZ.soap); } soap_destroy(soap); soap_end(soap); }
int OnvifClientDevice::GetNTP(_tds__GetNTPResponse &GetNTPResponse) { string strUrl; string strUser; string strPass; if (this->GetUserPasswd(strUser, strPass) == false || this->GetUrl(strUrl) == false) { return SOAP_ERR; } deviceBindProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&deviceBindProxy); soap_wsse_add_UsernameTokenDigest(&deviceBindProxy, "Id", strUser.c_str() , strPass.c_str()); _tds__GetNTP GetNTPReq; return deviceBindProxy.GetNTP(&GetNTPReq,GetNTPResponse); }
inline int OnvifClientMedia::GetProfile(_trt__GetProfileResponse &profileResponse,string profileToken) { string strUrl; string strUser; string strPass; if (m_Device.GetUserPasswd(strUser, strPass) == false || m_Device.GetMediaUrl(strUrl) == false) { return SOAP_ERR; } mediaProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&mediaProxy); soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str()); _trt__GetProfile profileReq; profileReq.ProfileToken = profileToken; return mediaProxy.GetProfile( &profileReq, profileResponse) ; }
int OnvifClientMedia::GetMetadataConfigurations(_trt__GetMetadataConfigurationsResponse &GetMetadataConfigurationsResponse) { string strUrl; string strUser; string strPass; if (m_Device.GetUserPasswd(strUser, strPass) == false || m_Device.GetMediaUrl(strUrl) == false) { return SOAP_ERR; } mediaProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&mediaProxy); soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str()); _trt__GetMetadataConfigurations GetMetadataConfigurationsReq; return mediaProxy.GetMetadataConfigurations(&GetMetadataConfigurationsReq,GetMetadataConfigurationsResponse); }
//(focus) inline int OnvifClientImaging::Stop(_timg__StopResponse &StopResponse,string VideoSourceToken) { string strUrl; string strUser; string strPass; if (m_Device.GetUserPasswd(strUser, strPass) == false || m_Device.GetImagingUrl(strUrl) == false) { return SOAP_ERR; } ImageProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&ImageProxy); soap_wsse_add_UsernameTokenDigest(&ImageProxy, "Id", strUser.c_str() , strPass.c_str()); _timg__Stop StopReq; StopReq.VideoSourceToken = VideoSourceToken; return ImageProxy.Stop(&StopReq,StopResponse); }
int OnvifClientMedia::SetVideoSourceConfiguration(_trt__SetVideoSourceConfigurationResponse &SetVideoSourceConfigResponse) { string strUrl; string strUser; string strPass; if (m_Device.GetUserPasswd(strUser, strPass) == false || m_Device.GetMediaUrl(strUrl) == false) { return SOAP_ERR; } mediaProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&mediaProxy); soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str()); _trt__SetVideoSourceConfiguration SetVideoSourceConfigReq; return mediaProxy.SetVideoSourceConfiguration(&SetVideoSourceConfigReq,SetVideoSourceConfigResponse); }
int OnvifClientDevice::SetHostname(_tds__SetHostnameResponse &SetHostnameResponse, string Name) { string strUrl; string strUser; string strPass; if (this->GetUserPasswd(strUser, strPass) == false || this->GetUrl(strUrl) == false) { return SOAP_ERR; } deviceBindProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&deviceBindProxy); soap_wsse_add_UsernameTokenDigest(&deviceBindProxy, "Id", strUser.c_str() , strPass.c_str()); _tds__SetHostname SetHostnameReq; SetHostnameReq.Name = Name; return deviceBindProxy.SetHostname(&SetHostnameReq,SetHostnameResponse); }
int OnvifClientDevice::SetNetworkProtocols(_tds__SetNetworkProtocolsResponse &SetNetworkProtocolsResponse,vector<tt__NetworkProtocol*> &NetworkProtocols) { string strUrl; string strUser; string strPass; if (this->GetUserPasswd(strUser, strPass) == false || this->GetUrl(strUrl) == false) { return SOAP_ERR; } deviceBindProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&deviceBindProxy); soap_wsse_add_UsernameTokenDigest(&deviceBindProxy, "Id", strUser.c_str() , strPass.c_str()); _tds__SetNetworkProtocols SetNetworkProtocolsReq; SetNetworkProtocolsReq.NetworkProtocols = NetworkProtocols; return deviceBindProxy.SetNetworkProtocols(&SetNetworkProtocolsReq,SetNetworkProtocolsResponse); }
inline int OnvifClientImaging::GetServiceCapabilities(_timg__GetServiceCapabilitiesResponse &GetServiceCapResponse) { string strUrl; string strUser; string strPass; if (m_Device.GetUserPasswd(strUser, strPass) == false || m_Device.GetImagingUrl(strUrl) == false) { return SOAP_ERR; } ImageProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&ImageProxy); soap_wsse_add_UsernameTokenDigest(&ImageProxy, "Id", strUser.c_str() , strPass.c_str()); _timg__GetServiceCapabilities GetServiceCapReq; return ImageProxy.GetServiceCapabilities(&GetServiceCapReq,GetServiceCapResponse); }
int OnvifClientDevice::SetNTP(_tds__SetNTPResponse &SetNTPResponse, bool FromDHCP, vector<tt__NetworkHost*> &NTPManual) { string strUrl; string strUser; string strPass; if (this->GetUserPasswd(strUser, strPass) == false || this->GetUrl(strUrl) == false) { return SOAP_ERR; } deviceBindProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&deviceBindProxy); soap_wsse_add_UsernameTokenDigest(&deviceBindProxy, "Id", strUser.c_str() , strPass.c_str()); _tds__SetNTP SetNTPReq; SetNTPReq.FromDHCP = FromDHCP; SetNTPReq.NTPManual = NTPManual; return deviceBindProxy.SetNTP(&SetNTPReq,SetNTPResponse); }
int OnvifClientMedia::StartMulticastStreaming(_trt__StartMulticastStreamingResponse &StartMulticastResponse,string profileToken) { string strUrl; string strUser; string strPass; if (m_Device.GetUserPasswd(strUser, strPass) == false || m_Device.GetMediaUrl(strUrl) == false) { return SOAP_ERR; } mediaProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&mediaProxy); soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str()); _trt__StartMulticastStreaming StartMulticastReq; StartMulticastReq.ProfileToken = profileToken; return mediaProxy.StartMulticastStreaming(&StartMulticastReq,StartMulticastResponse); }
int OnvifClientDevice::SetNetworkDefaultGateway(_tds__SetNetworkDefaultGatewayResponse &SetNetworkDefaultGatewayResponse,vector<string> &IPv4,vector<string> &IPv6) { string strUrl; string strUser; string strPass; if (this->GetUserPasswd(strUser, strPass) == false || this->GetUrl(strUrl) == false) { return SOAP_ERR; } deviceBindProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&deviceBindProxy); soap_wsse_add_UsernameTokenDigest(&deviceBindProxy, "Id", strUser.c_str() , strPass.c_str()); _tds__SetNetworkDefaultGateway SetNetworkDefaultGatewayReq; SetNetworkDefaultGatewayReq.IPv4Address = IPv4; SetNetworkDefaultGatewayReq.IPv6Address = IPv6; return deviceBindProxy.SetNetworkDefaultGateway(&SetNetworkDefaultGatewayReq,SetNetworkDefaultGatewayResponse); }
int OnvifClientDevice::SetNetworkInterfaces(_tds__SetNetworkInterfacesResponse &SetNetworkInterfacesResponse,string InterfaceToken,tt__NetworkInterfaceSetConfiguration &NetworkInterface) { string strUrl; string strUser; string strPass; if (this->GetUserPasswd(strUser, strPass) == false || this->GetUrl(strUrl) == false) { return SOAP_ERR; } deviceBindProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&deviceBindProxy); soap_wsse_add_UsernameTokenDigest(&deviceBindProxy, "Id", strUser.c_str() , strPass.c_str()); _tds__SetNetworkInterfaces SetNetworkInterfacesReq; SetNetworkInterfacesReq.InterfaceToken = InterfaceToken; SetNetworkInterfacesReq.NetworkInterface = &NetworkInterface; return deviceBindProxy.SetNetworkInterfaces(&SetNetworkInterfacesReq,SetNetworkInterfacesResponse); }
//move (focus) inline int OnvifClientImaging::Move(_timg__MoveResponse &MoveResponse, tt__FocusMove &Focus, string VideoSourceToken) { string strUrl; string strUser; string strPass; if (m_Device.GetUserPasswd(strUser, strPass) == false || m_Device.GetImagingUrl(strUrl) == false) { return SOAP_ERR; } ImageProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&ImageProxy); soap_wsse_add_UsernameTokenDigest(&ImageProxy, "Id", strUser.c_str() , strPass.c_str()); _timg__Move MoveReq; MoveReq.Focus = &Focus; MoveReq.VideoSourceToken = VideoSourceToken; return ImageProxy.Move(&MoveReq,MoveResponse); }
int OnvifClientPTZ::goToHomePosition(std::string profileToken){ if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str())){ return -1; } _tptz__GotoHomePosition *tptz__GotoHomePosition = soap_new__tptz__GotoHomePosition(soap, -1); _tptz__GotoHomePositionResponse *tptz__GotoHomePositionResponse = soap_new__tptz__GotoHomePositionResponse(soap, -1); tptz__GotoHomePosition->ProfileToken = profileToken; if(SOAP_OK == proxyPTZ.GotoHomePosition(tptz__GotoHomePosition, tptz__GotoHomePositionResponse)){ }else{ //PrintErr(proxyPTZ.soap); } soap_destroy(soap); soap_end(soap); }
int OnvifClientPTZ::getPTZConfigurations(){ if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str())){ return -1; } _tptz__GetConfigurations *tptz__GetConfigurations = soap_new__tptz__GetConfigurations(soap, -1); _tptz__GetConfigurationsResponse *tptz__GetConfigurationsResponse = soap_new__tptz__GetConfigurationsResponse(soap, -1); if(SOAP_OK == proxyPTZ.GetConfigurations(tptz__GetConfigurations, tptz__GetConfigurationsResponse)){ for(int i = 0; i<tptz__GetConfigurationsResponse->PTZConfiguration.size(); ++i){ std::cout << "ConfigurationToken #" << i << ": " << tptz__GetConfigurationsResponse->PTZConfiguration[i]->token << std::endl; } }else{ //PrintErr(proxyPTZ.soap); } soap_destroy(soap); soap_end(soap); }
int OnvifClientDevice::SetDynamicDNS(_tds__SetDynamicDNSResponse &SetDynamicDNSResponse,tt__DynamicDNSType &Type,tt__DNSName &Name, LONG64 &durationTTL) { string strUrl; string strUser; string strPass; if (this->GetUserPasswd(strUser, strPass) == false || this->GetUrl(strUrl) == false) { return SOAP_ERR; } deviceBindProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&deviceBindProxy); soap_wsse_add_UsernameTokenDigest(&deviceBindProxy, "Id", strUser.c_str() , strPass.c_str()); _tds__SetDynamicDNS SetDynamicDNSReq; SetDynamicDNSReq.Name = &Name; SetDynamicDNSReq.TTL = &durationTTL; SetDynamicDNSReq.Type = Type; return deviceBindProxy.SetDynamicDNS(&SetDynamicDNSReq,SetDynamicDNSResponse); }
int OnvifClientDevice::SetDNS(_tds__SetDNSResponse &SetDNSResponse, bool FromDHCP, vector<string> SearchDomain, vector<tt__IPAddress*> &DNSManual) { string strUrl; string strUser; string strPass; if (this->GetUserPasswd(strUser, strPass) == false || this->GetUrl(strUrl) == false) { return SOAP_ERR; } deviceBindProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&deviceBindProxy); soap_wsse_add_UsernameTokenDigest(&deviceBindProxy, "Id", strUser.c_str() , strPass.c_str()); _tds__SetDNS SetDNSReq; SetDNSReq.FromDHCP = FromDHCP; SetDNSReq.SearchDomain = SearchDomain; SetDNSReq.DNSManual = DNSManual; return deviceBindProxy.SetDNS(&SetDNSReq,SetDNSResponse); }
int OnvifClientMedia::GetVideoSourceConfigurationOptions(_trt__GetVideoSourceConfigurationOptionsResponse &GetVideoSourceConfigOptionsResponse, string ConfigurationToken,string profileToken) { string strUrl; string strUser; string strPass; if (m_Device.GetUserPasswd(strUser, strPass) == false || m_Device.GetMediaUrl(strUrl) == false) { return SOAP_ERR; } mediaProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&mediaProxy); soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str()); _trt__GetVideoSourceConfigurationOptions GetVideoSourceConfigOptionsReq; GetVideoSourceConfigOptionsReq.ConfigurationToken = &ConfigurationToken; GetVideoSourceConfigOptionsReq.ProfileToken = &profileToken; return mediaProxy.GetVideoSourceConfigurationOptions(&GetVideoSourceConfigOptionsReq,GetVideoSourceConfigOptionsResponse); }
int OnvifClientMedia::CreateProfile(_trt__CreateProfileResponse &CreateProfileResponse,string Name,string token) { string strUrl; string strUser; string strPass; if (m_Device.GetUserPasswd(strUser, strPass) == false || m_Device.GetMediaUrl(strUrl) == false) { return SOAP_ERR; } mediaProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&mediaProxy); soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str()); _trt__CreateProfile CreateProfileReq; CreateProfileReq.Name = Name; CreateProfileReq.Token = &token; return mediaProxy.CreateProfile(&CreateProfileReq,CreateProfileResponse); }
inline int OnvifClientImaging::SetImagingSettings(_timg__SetImagingSettingsResponse &SetImagingSettingsResponse, string VideoSourceToken, tt__ImagingSettings20 &ImagingSettings,bool ForcePersistence) { string strUrl; string strUser; string strPass; if (m_Device.GetUserPasswd(strUser, strPass) == false || m_Device.GetImagingUrl(strUrl) == false) { return SOAP_ERR; } ImageProxy.soap_endpoint = strUrl.c_str(); soap_wsse_add_Security(&ImageProxy); soap_wsse_add_UsernameTokenDigest(&ImageProxy, "Id", strUser.c_str() , strPass.c_str()); _timg__SetImagingSettings SetImagingSettingsReq; SetImagingSettingsReq.VideoSourceToken = VideoSourceToken; SetImagingSettingsReq.ImagingSettings = &ImagingSettings; SetImagingSettingsReq.ForcePersistence = &ForcePersistence; return ImageProxy.SetImagingSettings(&SetImagingSettingsReq,SetImagingSettingsResponse); }
int OnvifClientPTZ::absoluteMove(std::string profileToken, float pan, float panSpeed, float tilt, float tiltSpeed, float zoom, float zoomSpeed){ if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str())) { return -1; } _tptz__AbsoluteMove *tptz__AbsoluteMove = soap_new__tptz__AbsoluteMove(soap, -1); _tptz__AbsoluteMoveResponse *tptz__AbsoluteMoveResponse = soap_new__tptz__AbsoluteMoveResponse(soap, -1); tptz__AbsoluteMove->ProfileToken = profileToken; //setting pan and tilt tptz__AbsoluteMove->Position = soap_new_tt__PTZVector(soap, -1); tptz__AbsoluteMove->Position->PanTilt = soap_new_tt__Vector2D(soap, -1); tptz__AbsoluteMove->Speed = soap_new_tt__PTZSpeed(soap, -1); tptz__AbsoluteMove->Speed->PanTilt = soap_new_tt__Vector2D(soap, -1); //pan tptz__AbsoluteMove->Position->PanTilt->x = pan; tptz__AbsoluteMove->Speed->PanTilt->x = panSpeed; //tilt tptz__AbsoluteMove->Position->PanTilt->y = tilt; tptz__AbsoluteMove->Speed->PanTilt->y = tiltSpeed; //setting zoom tptz__AbsoluteMove->Position->Zoom = soap_new_tt__Vector1D(soap, -1); tptz__AbsoluteMove->Speed->Zoom = soap_new_tt__Vector1D(soap, -1); tptz__AbsoluteMove->Position->Zoom->x = zoom; tptz__AbsoluteMove->Speed->Zoom->x = zoomSpeed; if(SOAP_OK == proxyPTZ.AbsoluteMove(tptz__AbsoluteMove, tptz__AbsoluteMoveResponse)){ }else{ std::cout << "AbsoluteMove ERROR:" << std::endl; //PrintErr(proxyPTZ.soap); std::cout << std::endl; } soap_destroy(soap); soap_end(soap); }
int OnvifClientPTZ::getStatus(std::string profileToken){ if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str())) { return -1; } _tptz__GetStatus *tptz__GetStatus = soap_new__tptz__GetStatus(soap, -1); _tptz__GetStatusResponse *tptz__GetStatusResponse = soap_new__tptz__GetStatusResponse(soap, -1); tptz__GetStatus->ProfileToken = profileToken.c_str(); if(SOAP_OK == proxyPTZ.GetStatus(tptz__GetStatus, tptz__GetStatusResponse)){ std::cout << "PAN: " << tptz__GetStatusResponse->PTZStatus->Position->PanTilt->x << std::endl << "TILT: " <<tptz__GetStatusResponse->PTZStatus->Position->PanTilt->y << std::endl; std::cout << "ZOOM:" << tptz__GetStatusResponse->PTZStatus->Position->Zoom->x << std::endl; //std::cout << "PanTilt:" << tptz__GetStatusResponse->PTZStatus->MoveStatus->PanTilt << std::endl << "ZoomStatus" << tptz__GetStatusResponse->PTZStatus->MoveStatus->Zoom << std::endl << "ERROR: " << tptz__GetStatusResponse->PTZStatus->Error << std::endl << "UtcTime: " << tptz__GetStatusResponse->PTZStatus->UtcTime << std::endl; }else{ //PrintErr(proxyPTZ.soap); } soap_destroy(soap); soap_end(soap); }
int OnvifClientPTZ::stop(std::string profileToken, bool panTilt, bool zoom){ if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str())) { return -1; } _tptz__Stop *tptz__Stop= soap_new__tptz__Stop(soap, -1); _tptz__StopResponse *tptz__StopResponse = soap_new__tptz__StopResponse(soap, -1); tptz__Stop->ProfileToken = profileToken; tptz__Stop->PanTilt = &panTilt; tptz__Stop->Zoom = &zoom; if(SOAP_OK == proxyPTZ.Stop(tptz__Stop, tptz__StopResponse)){ }else{ //PrintErr(proxyPTZ.soap); } soap_destroy(soap); soap_end(soap); }
int ns1__div(struct soap *soap, double a, double b, double *result) { const char *username = soap_wsse_get_Username(soap); if (username) fprintf(stderr, "Hello %s, want to divide %g / %g = ?\n", username, a, b); if (soap_wsse_verify_Timestamp(soap) || soap_wsse_verify_Password(soap, "userPass")) { soap_wsse_delete_Security(soap); return soap->error; } if (soap_wsse_verify_element(soap, "http://www.genivia.com/schemas/wssetest.xsd", "div") == 0) { soap_wsse_delete_Security(soap); return soap_sender_fault(soap, "Service operation not signed", NULL); } soap_wsse_delete_Security(soap); soap_wsse_add_Timestamp(soap, "Time", 10); /* lifetime of 10 seconds */ soap_wsse_add_UsernameTokenDigest(soap, "User", "server", "serverPass"); /* In this case we leave out the signature and the receiver will reject this unsigned message. */ if (b == 0.0) return soap_sender_fault(soap, "Division by zero", NULL); *result = a / b; return SOAP_OK; }