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.

335 lines
11 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "onvifclientmedia.hpp"
  2. ONVIFLIB_API int OnvifClientMedia::GetMetadataConfigurationOptions(_trt__GetMetadataConfigurationOptionsResponse &GetMetadataConfigurationOptionsResponse,string ConfigToken,string profileToken)
  3. {
  4. string strUrl;
  5. string strUser;
  6. string strPass;
  7. if (m_Device.GetUserPasswd(strUser, strPass) == false
  8. || m_Device.GetMediaUrl(strUrl) == false)
  9. {
  10. return SOAP_ERR;
  11. }
  12. mediaProxy.soap_endpoint = strUrl.c_str();
  13. soap_wsse_add_Security(&mediaProxy);
  14. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  15. _trt__GetMetadataConfigurationOptions GetMetadataConfigurationOptionsReq;
  16. GetMetadataConfigurationOptionsReq.ConfigurationToken = &ConfigToken;
  17. GetMetadataConfigurationOptionsReq.ProfileToken = &profileToken;
  18. return mediaProxy.GetMetadataConfigurationOptions(&GetMetadataConfigurationOptionsReq,&GetMetadataConfigurationOptionsResponse);
  19. }
  20. ONVIFLIB_API int OnvifClientMedia::GetMetadataConfiguration(_trt__GetMetadataConfigurationResponse &GetMetadataConfigurationResponse,string profileToken)
  21. {
  22. string strUrl;
  23. string strUser;
  24. string strPass;
  25. if (m_Device.GetUserPasswd(strUser, strPass) == false
  26. || m_Device.GetMediaUrl(strUrl) == false)
  27. {
  28. return SOAP_ERR;
  29. }
  30. mediaProxy.soap_endpoint = strUrl.c_str();
  31. soap_wsse_add_Security(&mediaProxy);
  32. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  33. _trt__GetMetadataConfiguration GetMetadataConfigurationReq;
  34. GetMetadataConfigurationReq.ConfigurationToken = profileToken;
  35. return mediaProxy.GetMetadataConfiguration(&GetMetadataConfigurationReq,&GetMetadataConfigurationResponse);
  36. }
  37. ONVIFLIB_API int OnvifClientMedia::GetMetadataConfigurations(_trt__GetMetadataConfigurationsResponse &GetMetadataConfigurationsResponse)
  38. {
  39. string strUrl;
  40. string strUser;
  41. string strPass;
  42. if (m_Device.GetUserPasswd(strUser, strPass) == false
  43. || m_Device.GetMediaUrl(strUrl) == false)
  44. {
  45. return SOAP_ERR;
  46. }
  47. mediaProxy.soap_endpoint = strUrl.c_str();
  48. soap_wsse_add_Security(&mediaProxy);
  49. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  50. _trt__GetMetadataConfigurations GetMetadataConfigurationsReq;
  51. return mediaProxy.GetMetadataConfigurations(&GetMetadataConfigurationsReq,&GetMetadataConfigurationsResponse);
  52. }
  53. ONVIFLIB_API int OnvifClientMedia::GetVideoSourceConfigurationOptions(_trt__GetVideoSourceConfigurationOptionsResponse &GetVideoSourceConfigOptionsResponse, string ConfigurationToken,string profileToken)
  54. {
  55. string strUrl;
  56. string strUser;
  57. string strPass;
  58. if (m_Device.GetUserPasswd(strUser, strPass) == false
  59. || m_Device.GetMediaUrl(strUrl) == false)
  60. {
  61. return SOAP_ERR;
  62. }
  63. mediaProxy.soap_endpoint = strUrl.c_str();
  64. soap_wsse_add_Security(&mediaProxy);
  65. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  66. _trt__GetVideoSourceConfigurationOptions GetVideoSourceConfigOptionsReq;
  67. GetVideoSourceConfigOptionsReq.ConfigurationToken = &ConfigurationToken;
  68. GetVideoSourceConfigOptionsReq.ProfileToken = &profileToken;
  69. return mediaProxy.GetVideoSourceConfigurationOptions(&GetVideoSourceConfigOptionsReq,&GetVideoSourceConfigOptionsResponse);
  70. }
  71. ONVIFLIB_API int OnvifClientMedia::SetVideoSourceConfiguration(_trt__SetVideoSourceConfigurationResponse &SetVideoSourceConfigResponse)
  72. {
  73. string strUrl;
  74. string strUser;
  75. string strPass;
  76. if (m_Device.GetUserPasswd(strUser, strPass) == false
  77. || m_Device.GetMediaUrl(strUrl) == false)
  78. {
  79. return SOAP_ERR;
  80. }
  81. mediaProxy.soap_endpoint = strUrl.c_str();
  82. soap_wsse_add_Security(&mediaProxy);
  83. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  84. _trt__SetVideoSourceConfiguration SetVideoSourceConfigReq;
  85. return mediaProxy.SetVideoSourceConfiguration(&SetVideoSourceConfigReq,&SetVideoSourceConfigResponse);
  86. }
  87. ONVIFLIB_API int OnvifClientMedia::GetVideoSourceConfiguration(_trt__GetVideoSourceConfigurationResponse &GetVideoSourceConfigResponse,string ConfigurationToken)
  88. {
  89. string strUrl;
  90. string strUser;
  91. string strPass;
  92. if (m_Device.GetUserPasswd(strUser, strPass) == false
  93. || m_Device.GetMediaUrl(strUrl) == false)
  94. {
  95. return SOAP_ERR;
  96. }
  97. mediaProxy.soap_endpoint = strUrl.c_str();
  98. soap_wsse_add_Security(&mediaProxy);
  99. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  100. _trt__GetVideoSourceConfiguration GetVideoSourceConfigReq;
  101. GetVideoSourceConfigReq.ConfigurationToken = ConfigurationToken;
  102. return mediaProxy.GetVideoSourceConfiguration(&GetVideoSourceConfigReq,&GetVideoSourceConfigResponse);
  103. }
  104. ONVIFLIB_API int OnvifClientMedia::GetVideoSourceConfigurations(_trt__GetVideoSourceConfigurationsResponse &GetVideoSourceConfigResponse)
  105. {
  106. string strUrl;
  107. string strUser;
  108. string strPass;
  109. if (m_Device.GetUserPasswd(strUser, strPass) == false
  110. || m_Device.GetMediaUrl(strUrl) == false)
  111. {
  112. return SOAP_ERR;
  113. }
  114. mediaProxy.soap_endpoint = strUrl.c_str();
  115. soap_wsse_add_Security(&mediaProxy);
  116. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  117. _trt__GetVideoSourceConfigurations GetVideoSourceConfigReq;
  118. return mediaProxy.GetVideoSourceConfigurations(&GetVideoSourceConfigReq,&GetVideoSourceConfigResponse);
  119. }
  120. ONVIFLIB_API int OnvifClientMedia::GetVideoSources(_trt__GetVideoSourcesResponse &GetVideoSourcesResponse)
  121. {
  122. string strUrl;
  123. string strUser;
  124. string strPass;
  125. if (m_Device.GetUserPasswd(strUser, strPass) == false
  126. || m_Device.GetMediaUrl(strUrl) == false)
  127. {
  128. return SOAP_ERR;
  129. }
  130. mediaProxy.soap_endpoint = strUrl.c_str();
  131. soap_wsse_add_Security(&mediaProxy);
  132. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  133. _trt__GetVideoSources GetVideoSourcesReq;
  134. return mediaProxy.GetVideoSources(&GetVideoSourcesReq,&GetVideoSourcesResponse);
  135. }
  136. ONVIFLIB_API int OnvifClientMedia::CreateProfile(_trt__CreateProfileResponse &CreateProfileResponse,string Name,string token)
  137. {
  138. string strUrl;
  139. string strUser;
  140. string strPass;
  141. if (m_Device.GetUserPasswd(strUser, strPass) == false
  142. || m_Device.GetMediaUrl(strUrl) == false)
  143. {
  144. return SOAP_ERR;
  145. }
  146. mediaProxy.soap_endpoint = strUrl.c_str();
  147. soap_wsse_add_Security(&mediaProxy);
  148. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  149. _trt__CreateProfile CreateProfileReq;
  150. CreateProfileReq.Name = Name;
  151. CreateProfileReq.Token = &token;
  152. return mediaProxy.CreateProfile(&CreateProfileReq,&CreateProfileResponse);
  153. }
  154. ONVIFLIB_API int OnvifClientMedia::StopMulticastStreaming(_trt__StopMulticastStreamingResponse &StopMulticastResponse,string profileToken)
  155. {
  156. string strUrl;
  157. string strUser;
  158. string strPass;
  159. if (m_Device.GetUserPasswd(strUser, strPass) == false
  160. || m_Device.GetMediaUrl(strUrl) == false)
  161. {
  162. return SOAP_ERR;
  163. }
  164. mediaProxy.soap_endpoint = strUrl.c_str();
  165. soap_wsse_add_Security(&mediaProxy);
  166. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  167. _trt__StopMulticastStreaming StopMulticastReq;
  168. StopMulticastReq.ProfileToken = profileToken;
  169. return mediaProxy.StopMulticastStreaming(&StopMulticastReq,&StopMulticastResponse);
  170. }
  171. ONVIFLIB_API int OnvifClientMedia::StartMulticastStreaming(_trt__StartMulticastStreamingResponse &StartMulticastResponse,string profileToken)
  172. {
  173. string strUrl;
  174. string strUser;
  175. string strPass;
  176. if (m_Device.GetUserPasswd(strUser, strPass) == false
  177. || m_Device.GetMediaUrl(strUrl) == false)
  178. {
  179. return SOAP_ERR;
  180. }
  181. mediaProxy.soap_endpoint = strUrl.c_str();
  182. soap_wsse_add_Security(&mediaProxy);
  183. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  184. _trt__StartMulticastStreaming StartMulticastReq;
  185. StartMulticastReq.ProfileToken = profileToken;
  186. return mediaProxy.StartMulticastStreaming(&StartMulticastReq,&StartMulticastResponse);
  187. }
  188. ONVIFLIB_API int OnvifClientMedia::GetServiceCapabilities(_trt__GetServiceCapabilitiesResponse &GetServiceCapResponse)
  189. {
  190. string strUrl;
  191. string strUser;
  192. string strPass;
  193. if (m_Device.GetUserPasswd(strUser, strPass) == false
  194. || m_Device.GetMediaUrl(strUrl) == false)
  195. {
  196. return SOAP_ERR;
  197. }
  198. mediaProxy.soap_endpoint = strUrl.c_str();
  199. soap_wsse_add_Security(&mediaProxy);
  200. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  201. _trt__GetServiceCapabilities GetServiceCapReq;
  202. return mediaProxy.GetServiceCapabilities(&GetServiceCapReq,&GetServiceCapResponse);
  203. }
  204. ONVIFLIB_API int OnvifClientMedia::GetStreamUri(_trt__GetStreamUriResponse &StreamUriResponse,tt__StreamSetup &StreamSetup, string profileToken)
  205. {
  206. string strUrl;
  207. string strUser;
  208. string strPass;
  209. if (m_Device.GetUserPasswd(strUser, strPass) == false
  210. || m_Device.GetMediaUrl(strUrl) == false)
  211. {
  212. return SOAP_ERR;
  213. }
  214. mediaProxy.soap_endpoint = strUrl.c_str();
  215. soap_wsse_add_Security(&mediaProxy);
  216. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str() , strPass.c_str());
  217. _trt__GetStreamUri StreamUriReq;
  218. StreamUriReq.ProfileToken = profileToken;
  219. StreamUriReq.StreamSetup = &StreamSetup;
  220. return mediaProxy.GetStreamUri(&StreamUriReq, &StreamUriResponse);
  221. }
  222. ONVIFLIB_API int OnvifClientMedia::GetSnapshotUri(_trt__GetSnapshotUriResponse &SnapshotUriResponse, string profileToken)
  223. {
  224. string strUrl;
  225. string strUser;
  226. string strPass;
  227. if (m_Device.GetUserPasswd(strUser, strPass) == false
  228. || m_Device.GetMediaUrl(strUrl) == false)
  229. {
  230. return SOAP_ERR;
  231. }
  232. mediaProxy.soap_endpoint = strUrl.c_str();
  233. soap_wsse_add_Security(&mediaProxy);
  234. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id", strUser.c_str(), strPass.c_str());
  235. _trt__GetSnapshotUri SnapshotUriReq;
  236. return mediaProxy.GetSnapshotUri(&SnapshotUriReq, &SnapshotUriResponse);
  237. }
  238. OnvifClientMedia::OnvifClientMedia(OnvifClientDevice &device)
  239. : m_Device(device), mediaProxy(SOAP_C_UTFSTRING)
  240. {
  241. }
  242. OnvifClientMedia::~OnvifClientMedia()
  243. {
  244. }
  245. ONVIFLIB_API int OnvifClientMedia::GetProfiles(_trt__GetProfilesResponse &profilesResponse)
  246. {
  247. string strUrl;
  248. string strUser;
  249. string strPass;
  250. _trt__GetProfiles profilesReq;
  251. if (m_Device.GetUserPasswd(strUser, strPass) == false
  252. || m_Device.GetMediaUrl(strUrl) == false)
  253. {
  254. return SOAP_ERR;
  255. }
  256. mediaProxy.soap_endpoint = strUrl.c_str();
  257. soap_wsse_add_Security(&mediaProxy);
  258. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id",
  259. strUser.c_str() , strPass.c_str());
  260. return mediaProxy.GetProfiles( &profilesReq, &profilesResponse) ;
  261. }
  262. ONVIFLIB_API inline int OnvifClientMedia::GetProfile(_trt__GetProfileResponse &profileResponse,string profileToken)
  263. {
  264. string strUrl;
  265. string strUser;
  266. string strPass;
  267. if (m_Device.GetUserPasswd(strUser, strPass) == false || m_Device.GetMediaUrl(strUrl) == false)
  268. {
  269. return SOAP_ERR;
  270. }
  271. mediaProxy.soap_endpoint = strUrl.c_str();
  272. soap_wsse_add_Security(&mediaProxy);
  273. soap_wsse_add_UsernameTokenDigest(&mediaProxy, "Id",
  274. strUser.c_str() , strPass.c_str());
  275. _trt__GetProfile profileReq;
  276. profileReq.ProfileToken = profileToken;
  277. return mediaProxy.GetProfile( &profileReq, &profileResponse) ;
  278. }