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.

113 lines
3.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
5 months ago
​
​
5 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
  1. #ifndef __BOSCH_RCP_CLASS_HEADER__
  2. #define __BOSCH_RCP_CLASS_HEADER__
  3. #include <curl/curl.h>
  4. #include <openssl/sha.h>
  5. #include <vector>
  6. #ifdef __linux__
  7. #include <arpa/inet.h>
  8. #include <netdb.h>
  9. #include <netinet/in.h>
  10. #include <pthread.h>
  11. #include <sys/socket.h>
  12. #include <unistd.h>
  13. #endif
  14. #include "../../alg/generic/base64.h"
  15. #include "../../components/base/basicLogCollection.h"
  16. #include "../../components/base/basicTypes.h"
  17. #include "../curl/curlRequestsManager.h"
  18. #include "../protocol/xmlParser.h"
  19. #ifndef CURL_MANAGER
  20. #define CURL_MANAGER
  21. #endif
  22. // #define DEBUG_BRCP_PRINTOUT_MESSAGES
  23. // #define DEBUG_BRCP_TRAFFIC
  24. #define BRCP_DEFAULT_URI_TPL (CSTR) "http://%s:%s@%s/rcp.xml"
  25. #define BRCP_DEFAULT_URI_TPL_NA (CSTR) "http://%s/rcp.xml"
  26. #define BRCP_CMD_GET_CAM_NAME 0x0019
  27. #define BRCP_CMD_GET_UNIT_NAME 0x0024
  28. #define BRCP_CMD_GET_DEV_NAME 0x097c
  29. #define BRCP_CMD_GET_SER_NUM 0x0ae7
  30. #define BRCP_CMD_GET_PRO_NAME 0x0aea
  31. #define BRCP_CMD_GET_DEV_MANUFAC 0x0d0b
  32. #define BRCP_CMD_GET_DTS 0x0ba8
  33. #define BRCP_CMD_PTZ_DRIVE 0x09A5
  34. class boschRCP{
  35. private:
  36. curlRequestsManager * m_pHttpAccessManager;
  37. basicMutex m_mResponseProtector;
  38. CURL * m_pCURL;
  39. basicLogCollection * m_pLog;
  40. CSTR m_pIpAddress;
  41. CSTR m_pUsername;
  42. CSTR m_pPassword;
  43. CSTR m_pDeviceURI;
  44. int m_pLastIndex;
  45. CSTR m_pBaseURI;
  46. time_t m_nDeltaTime;
  47. CSTR m_pProxyHost;
  48. int m_nProxyPort;
  49. CSTR m_pProxyUsername;
  50. CSTR m_pProxyPassword;
  51. CSTR m_pLastResponse;
  52. bool m_bIntransingent;
  53. volatile bool parser_done;
  54. uint8_t m_bAuthMode;
  55. #ifndef CURL_MANAGER
  56. static int _writer(char * data, size_t size, size_t nmemb, pOnvif * Ptr);
  57. #endif
  58. static void * parser(void * obj, void * ptr);
  59. size_t createRequestString( CSTR buffer, uint16_t CMD, bool RW, int8_t pl_type= -1, void *pl = NULL );
  60. bool updateDevURI(void);
  61. public:
  62. boschRCP();
  63. ~boschRCP();
  64. bool setProxyHost(CSTR proxyHost);
  65. CSTR getProxyHost(void);
  66. bool setProxyPort(int proxyPort);
  67. int getProxyPort(void);
  68. bool setProxyUsername(CSTR proxyUsername);
  69. CSTR getProxyUsername(void);
  70. bool setProxyPassword(CSTR proxyPassword);
  71. CSTR getProxyPassword(void);
  72. bool setUsername(CSTR username);
  73. CSTR getUsername(void);
  74. bool setPassword(CSTR password);
  75. bool setAuthMode(uint8_t Mode);
  76. CSTR getPassword(void);
  77. CSTR getDeviceUri(void);
  78. bool setDeviceUri(CSTR deviceUri);
  79. CSTR getIPAddress(void);
  80. bool setIPAddress(CSTR ipAddress);
  81. bool create(void);
  82. struct tm * core_GetSystemDateAndTime(void);
  83. bool ptz_GetStatus( ptzStatus * tStatus );
  84. bool ptz_GotoPreset( CSTR presetToken, float speed_pantilt_x, float speed_pantilt_y, float speed_zoom_x );
  85. bool ptz_AbsoluteMove( float position_pantilt_x, float position_pantilt_y, float zoom );
  86. bool ptz_ContinuousMove( float velocity_pantilt_x, float velocity_pantilt_y );
  87. bool ptz_ContinuousMoveZoom( float zoom );
  88. bool ptz_RemovePreset( CSTR presetToken );
  89. bool ptz_Stop( bool pantilt, bool zoom );
  90. bool ptz_SetPreset( CSTR presetName);
  91. private:
  92. // protected function _xml2array($response);
  93. accessToken _passwordDigest(CSTR username, CSTR password, time_t timestamp = 0, uint32_t nonce = 0);
  94. bool _send_request(CSTR url, CSTR post_string = NULL, bool mr = true);
  95. bool _post_request(CSTR url, CSTR post_string);
  96. };
  97. #endif