You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

326 lines
9.2 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "onvifclientptz.hpp"
  2. /* Added by John 7/2/14 */
  3. ONVIFLIB_API int OnvifClientPTZ::Initialize()
  4. {
  5. _tptz__GetConfigurationsResponse GetConfigsResp;
  6. if(GetConfigurations(GetConfigsResp)!=0)
  7. return -1;
  8. if(GetConfigsResp.PTZConfiguration[0]->DefaultAbsolutePantTiltPositionSpace)
  9. m_bHasAbsolutePTMove = true; else m_bHasAbsolutePTMove = false;
  10. if(GetConfigsResp.PTZConfiguration[0]->DefaultAbsoluteZoomPositionSpace)
  11. m_bHasAbsoluteZoomMove = true; else m_bHasAbsoluteZoomMove = false;
  12. if(GetConfigsResp.PTZConfiguration[0]->DefaultRelativePanTiltTranslationSpace)
  13. m_bHasRelativePTMove = true; else m_bHasRelativePTMove = false;
  14. if(GetConfigsResp.PTZConfiguration[0]->DefaultRelativeZoomTranslationSpace)
  15. m_bHasRelativeZoomMove = true; else m_bHasRelativeZoomMove = false;
  16. if(GetConfigsResp.PTZConfiguration[0]->DefaultContinuousPanTiltVelocitySpace)
  17. m_bHasContinuousPTMove = true; else m_bHasContinuousPTMove = false;
  18. if(GetConfigsResp.PTZConfiguration[0]->DefaultContinuousZoomVelocitySpace)
  19. m_bHasContinuousZoomMove = true; else m_bHasContinuousZoomMove = false;
  20. return 0;
  21. }
  22. ONVIFLIB_API int OnvifClientPTZ::Stop(_tptz__StopResponse &StopResponse,bool PanTilt,bool Zoom,string profileToken)
  23. {
  24. string strUrl;
  25. string strUser;
  26. string strPass;
  27. if (m_Device.GetUserPasswd(strUser, strPass) == false
  28. || m_Device.GetPTZUrl(strUrl) == false)
  29. {
  30. return SOAP_ERR;
  31. }
  32. ptzProxy.soap_endpoint = strUrl.c_str();
  33. soap_wsse_add_Security(&ptzProxy);
  34. soap_wsse_add_UsernameTokenDigest(&ptzProxy, "Id", strUser.c_str() , strPass.c_str());
  35. _tptz__Stop StopReq;
  36. StopReq.PanTilt = &PanTilt;
  37. StopReq.ProfileToken = profileToken;
  38. StopReq.Zoom = &Zoom;
  39. return ptzProxy.Stop(&StopReq,&StopResponse);
  40. }
  41. ONVIFLIB_API int OnvifClientPTZ::AbsoluteMove(_tptz__AbsoluteMoveResponse &AbsoluteMoveResponse, tt__PTZSpeed &Speed, tt__PTZVector &position, string profileToken)
  42. {
  43. if(!m_bHasAbsolutePTMove || !m_bHasAbsoluteZoomMove) {
  44. cout << "Error, device does not support Absolute movement" << endl;
  45. //return -1;
  46. }
  47. string strUrl;
  48. string strUser;
  49. string strPass;
  50. if (m_Device.GetUserPasswd(strUser, strPass) == false
  51. || m_Device.GetPTZUrl(strUrl) == false)
  52. {
  53. return SOAP_ERR;
  54. }
  55. ptzProxy.soap_endpoint = strUrl.c_str();
  56. soap_wsse_add_Security(&ptzProxy);
  57. soap_wsse_add_UsernameTokenDigest(&ptzProxy, "Id", strUser.c_str() , strPass.c_str());
  58. _tptz__AbsoluteMove AbsoluteMoveReq;
  59. AbsoluteMoveReq.ProfileToken = profileToken;
  60. AbsoluteMoveReq.Position = &position;
  61. AbsoluteMoveReq.Speed = &Speed;
  62. return ptzProxy.AbsoluteMove(&AbsoluteMoveReq,&AbsoluteMoveResponse);
  63. }
  64. ONVIFLIB_API int OnvifClientPTZ::RelativeMove(_tptz__RelativeMoveResponse &relMoveResponse, tt__PTZVector &Translation, tt__PTZSpeed &Speed, string profileToken)
  65. {
  66. if(!m_bHasRelativePTMove || !m_bHasRelativeZoomMove) {
  67. cout << "Error, device does not support Relative movement" << endl;
  68. //return -1;
  69. }
  70. string strUrl;
  71. string strUser;
  72. string strPass;
  73. _tptz__RelativeMove relMoveReq;
  74. relMoveReq.ProfileToken = profileToken;
  75. relMoveReq.Translation = &Translation;
  76. relMoveReq.Speed = &Speed;
  77. if (m_Device.GetUserPasswd(strUser, strPass) == false
  78. || m_Device.GetPTZUrl(strUrl) == false)
  79. {
  80. return SOAP_ERR;
  81. }
  82. return ptzProxy.RelativeMove(&relMoveReq,&relMoveResponse);
  83. //_tptz__GetNodes getNodesReq;
  84. //_tptz__GetNodesResponse getNodesResp;
  85. //ptzProxy.GetNodes(&getNodesReq,&getNodesResp);
  86. }
  87. ONVIFLIB_API int OnvifClientPTZ::ContinuousMove(_tptz__ContinuousMoveResponse &ContMoveResponse, tt__PTZSpeed &Speed, LONG64 &Timeout, string profileToken)
  88. {
  89. if(!m_bHasContinuousPTMove || !m_bHasContinuousZoomMove) {
  90. cout << "Error, device does not support Continuous movement" << endl;
  91. //return -1;
  92. }
  93. string strUrl;
  94. string strUser;
  95. string strPass;
  96. if (m_Device.GetUserPasswd(strUser, strPass) == false
  97. || m_Device.GetPTZUrl(strUrl) == false)
  98. {
  99. return SOAP_ERR;
  100. }
  101. ptzProxy.soap_endpoint = strUrl.c_str();
  102. soap_wsse_add_Security(&ptzProxy);
  103. soap_wsse_add_UsernameTokenDigest(&ptzProxy, "Id", strUser.c_str() , strPass.c_str());
  104. _tptz__ContinuousMove ContMoveReq;
  105. ContMoveReq.ProfileToken = profileToken;
  106. ContMoveReq.Velocity = &Speed;
  107. ContMoveReq.Timeout = &Timeout;
  108. return ptzProxy.ContinuousMove(&ContMoveReq,&ContMoveResponse);
  109. }
  110. ONVIFLIB_API int OnvifClientPTZ::SetConfiguration(_tptz__SetConfigurationResponse &SetConfigurationResponse, tt__PTZConfiguration &PTZConfiguration,bool ForcePersist)
  111. {
  112. string strUrl;
  113. string strUser;
  114. string strPass;
  115. if (m_Device.GetUserPasswd(strUser, strPass) == false
  116. || m_Device.GetPTZUrl(strUrl) == false)
  117. {
  118. return SOAP_ERR;
  119. }
  120. ptzProxy.soap_endpoint = strUrl.c_str();
  121. soap_wsse_add_Security(&ptzProxy);
  122. soap_wsse_add_UsernameTokenDigest(&ptzProxy, "Id", strUser.c_str() , strPass.c_str());
  123. _tptz__SetConfiguration SetConfigurationReq;
  124. SetConfigurationReq.PTZConfiguration = &PTZConfiguration;
  125. SetConfigurationReq.ForcePersistence = ForcePersist;
  126. return ptzProxy.SetConfiguration(&SetConfigurationReq,&SetConfigurationResponse);
  127. }
  128. ONVIFLIB_API int OnvifClientPTZ::GetServiceCapabilities(_tptz__GetServiceCapabilitiesResponse &ServiceCapResponse)
  129. {
  130. string strUrl;
  131. string strUser;
  132. string strPass;
  133. if (m_Device.GetUserPasswd(strUser, strPass) == false
  134. || m_Device.GetPTZUrl(strUrl) == false)
  135. {
  136. return SOAP_ERR;
  137. }
  138. ptzProxy.soap_endpoint = strUrl.c_str();
  139. soap_wsse_add_Security(&ptzProxy);
  140. soap_wsse_add_UsernameTokenDigest(&ptzProxy, "Id", strUser.c_str() , strPass.c_str());
  141. _tptz__GetServiceCapabilities ServiceCapReq;
  142. return ptzProxy.GetServiceCapabilities(&ServiceCapReq,&ServiceCapResponse);
  143. }
  144. ONVIFLIB_API int OnvifClientPTZ::GetStatus(_tptz__GetStatusResponse &StatusResponse,string profileToken)
  145. {
  146. string strUrl;
  147. string strUser;
  148. string strPass;
  149. if (m_Device.GetUserPasswd(strUser, strPass) == false
  150. || m_Device.GetPTZUrl(strUrl) == false)
  151. {
  152. return SOAP_ERR;
  153. }
  154. ptzProxy.soap_endpoint = strUrl.c_str();
  155. soap_wsse_add_Security(&ptzProxy);
  156. soap_wsse_add_UsernameTokenDigest(&ptzProxy, "Id", strUser.c_str() , strPass.c_str());
  157. _tptz__GetStatus StatusReq;
  158. StatusReq.ProfileToken = profileToken;
  159. return ptzProxy.GetStatus(&StatusReq,&StatusResponse);
  160. }
  161. ONVIFLIB_API int OnvifClientPTZ::GetNode(_tptz__GetNodeResponse &GetNodeResponse, string nodeToken)
  162. {
  163. string strUrl;
  164. string strUser;
  165. string strPass;
  166. if (m_Device.GetUserPasswd(strUser, strPass) == false
  167. || m_Device.GetPTZUrl(strUrl) == false)
  168. {
  169. return SOAP_ERR;
  170. }
  171. ptzProxy.soap_endpoint = strUrl.c_str();
  172. soap_wsse_add_Security(&ptzProxy);
  173. soap_wsse_add_UsernameTokenDigest(&ptzProxy, "Id", strUser.c_str() , strPass.c_str());
  174. _tptz__GetNode GetNodeReq;
  175. GetNodeReq.NodeToken = nodeToken;
  176. return ptzProxy.GetNode(&GetNodeReq,&GetNodeResponse);
  177. }
  178. ONVIFLIB_API int OnvifClientPTZ::GetNodes(_tptz__GetNodesResponse &GetNodesResponse)
  179. {
  180. string strUrl;
  181. string strUser;
  182. string strPass;
  183. _tptz__GetNodes GetNodesReq;
  184. //ptzProxy.GetNodes(&GetNodesReq, &GetNodesResponse);
  185. if (m_Device.GetUserPasswd(strUser, strPass) == false
  186. || m_Device.GetPTZUrl(strUrl) == false)
  187. {
  188. return SOAP_ERR;
  189. }
  190. ptzProxy.soap_endpoint = strUrl.c_str();
  191. soap_wsse_add_Security(&ptzProxy);
  192. soap_wsse_add_UsernameTokenDigest(&ptzProxy, "Id", strUser.c_str() , strPass.c_str());
  193. return ptzProxy.GetNodes(&GetNodesReq,&GetNodesResponse);
  194. }
  195. ONVIFLIB_API int OnvifClientPTZ::GetConfigurations(_tptz__GetConfigurationsResponse &configurationsResp)
  196. {
  197. string strUrl;
  198. string strUser;
  199. string strPass;
  200. _tptz__GetConfigurations configurationsReq;
  201. if (m_Device.GetUserPasswd(strUser, strPass) == false
  202. || m_Device.GetPTZUrl(strUrl) == false)
  203. {
  204. return SOAP_ERR;
  205. }
  206. ptzProxy.soap_endpoint = strUrl.c_str();
  207. soap_wsse_add_Security(&ptzProxy);
  208. soap_wsse_add_UsernameTokenDigest(&ptzProxy, "Id",
  209. strUser.c_str() , strPass.c_str());
  210. return ptzProxy.GetConfigurations( &configurationsReq, &configurationsResp) ;
  211. }
  212. ONVIFLIB_API int OnvifClientPTZ::GetConfiguration(_tptz__GetConfigurationResponse &configurationResp)
  213. {
  214. string strUrl;
  215. string strUser;
  216. string strPass;
  217. _tptz__GetConfiguration configurationReq;
  218. if (m_Device.GetUserPasswd(strUser, strPass) == false
  219. || m_Device.GetPTZUrl(strUrl) == false)
  220. {
  221. return SOAP_ERR;
  222. }
  223. ptzProxy.soap_endpoint = strUrl.c_str();
  224. soap_wsse_add_Security(&ptzProxy);
  225. soap_wsse_add_UsernameTokenDigest(&ptzProxy, "Id",
  226. strUser.c_str() , strPass.c_str());
  227. return ptzProxy.GetConfiguration( &configurationReq, &configurationResp) ;
  228. }
  229. ONVIFLIB_API int OnvifClientPTZ::GetConfigurationOptions(_tptz__GetConfigurationOptionsResponse &configOptions, string configToken)
  230. {
  231. string strUrl;
  232. string strUser;
  233. string strPass;
  234. _tptz__GetConfigurationOptions configurationOptionsReq;
  235. configurationOptionsReq.ConfigurationToken = configToken;
  236. if (m_Device.GetUserPasswd(strUser, strPass) == false
  237. || m_Device.GetPTZUrl(strUrl) == false)
  238. {
  239. return SOAP_ERR;
  240. }
  241. ptzProxy.soap_endpoint = strUrl.c_str();
  242. soap_wsse_add_Security(&ptzProxy);
  243. soap_wsse_add_UsernameTokenDigest(&ptzProxy, "Id",
  244. strUser.c_str() , strPass.c_str());
  245. return ptzProxy.GetConfigurationOptions( &configurationOptionsReq, &configOptions) ;
  246. }
  247. /* END - Added by John 7/2/14 */
  248. OnvifClientPTZ::OnvifClientPTZ(OnvifClientDevice &device)
  249. : m_Device(device)
  250. {
  251. if(m_Device.GetCapabilities()==SOAP_OK)
  252. Initialize();
  253. }
  254. OnvifClientPTZ::~OnvifClientPTZ()
  255. {
  256. }