#ifndef __BOSCH_RCP_CLASS_HEADER__ #define __BOSCH_RCP_CLASS_HEADER__ #include #include #include #ifdef __linux__ #include #include #include #include #include #include #endif #include "../../alg/generic/base64.h" #include "../../components/base/basicLogCollection.h" #include "../../components/base/basicTypes.h" #include "../curl/curlRequestsManager.h" #include "../protocol/xmlParser.h" #include "../ponvif/ponvif.h" #define CURL_MANAGER // #define DEBUG_BRCP_PRINTOUT_MESSAGES // #define DEBUG_BRCP_TRAFFIC #define BRCP_PACK_GET_SYS_DTS \ (CSTR)"" #define BRCP_PACK_GET_CAPABILITIES \ (CSTR)"%s%s%s%sAll" #define BRCP_PACK_GET_VIDEO_SOURCES \ (CSTR)"%s%s%s%s" #define BRCP_PACK_GET_PROFILES \ (CSTR)"%s%s%s%s" #define BRCP_PACK_GET_SERVICES \ (CSTR)"%s%s%s%sfalse" #define BRCP_PACK_GET_DEV_INFO \ (CSTR)"%s%s%s%s" #define BRCP_PACK_GET_STREAM_URI \ (CSTR)"%s%s%s%s%s%s%s" #define BRCP_PACK_GET_PICTURE_URI \ (CSTR)"%s%s%s%s%s" #define BRCP_PACK_GET_PRESETS \ (CSTR)"%s%s%s%s%s" #define BRCP_PACK_GET_PTZ_NODE \ (CSTR)"%s%s%s%s%s" #define BRCP_PACK_GET_PTZ_STATUS \ (CSTR)"%s%s%s%s%s" #define BRCP_PACK_GOTO_PRESET \ (CSTR)"%s%s%s%s%s%s" #define BRCP_PACK_REMOVE_PRESET \ (CSTR)"%s%s%s%s%s%s" #define BRCP_PACK_SET_PRESET \ (CSTR)"%s%s%s%s%s%s" #define BRCP_PACK_RELATIVE_MOVE \ (CSTR)"%s%s%s%s%s" #define BRCP_PACK_RELATIVE_ZOOM \ (CSTR)"%s%s%s%s%s" #define BRCP_PACK_ABSOLUTE_MOVE \ (CSTR)"%s%s%s%s%s" #define BRCP_PACK_CONTINUOUS_MOVE \ (CSTR)"%s%s%s%s%s" // #define BRCP_PACK_CONTINUOUS_MOVE_A (CSTR)"Profile_1" #define BRCP_PACK_CONTINUOUS_ZOOM \ (CSTR)"%s%s%s%s%s" #define BRCP_PACK_PTZ_STOP \ (CSTR)"%s%s%s%s%struetrue" #define BRCP_ENVELOPE_EXT \ (CSTR)"%s%s" #define PONVIF_ENVELOPE_SIM (CSTR) "%s%s" #define PONVIF_BODY (CSTR) "%s" #define BRCP_HEADER_PROBE \ (CSTR)"uuid:84ede3de-7dec-11d0-c360-f01234567890urn:schemas-xmlsoap-org:ws:2005:04:discoveryhttp://schemas.xmlsoap.org/ws/2005/04/discovery/Probe" #define BRCP_HEADER_SECUR \ (CSTR)"%s%s%s%s" #define BRCP_PCK_GET_CAPABILITIES (CSTR) "All" #define BRCP_DEFAULT_URI_TPL (CSTR) "https://%s/rcp.xml" #define BRCP_CMD_GET_CAM_NAME 0x0019 #define BRCP_CMD_GET_UNIT_NAME 0x0024 #define BRCP_CMD_GET_DEV_NAME 0x097c #define BRCP_CMD_GET_SER_NUM 0x0ae7 #define BRCP_CMD_GET_PRO_NAME 0x0aea #define BRCP_CMD_GET_DEV_MANUFAC 0x0d0b #define BRCP_CMD_GET_DTS 0x0ba8 class boschRCP; //typedef std::vector videoSourceProfiles; //typedef std::vector videoSources; //typedef std::vector discoveryResults; class boschRCP{ private: curlRequestsManager * m_pHttpAccessManager; basicMutex m_mResponseProtector; CURL * m_pCURL; basicLogCollection * m_pLog; CSTR m_pIpAddress; CSTR m_pUsername; CSTR m_pPassword; CSTR m_pDeviceURI; int m_pLastIndex; CSTR m_pMediaURI; CSTR m_pSnapshotURI; CSTR m_pPTZURI; CSTR m_pBaseURI; // onvifSupportedVersions m_sOnvifVersion; time_t m_nDeltaTime; // videoSources m_vVideoSources; //videoSourceProfiles m_vVideoProfiles; //videoSourceProfiles m_vActiveSources; nodeCapability m_sCapabilities; CSTR m_pProxyHost; int m_nProxyPort; CSTR m_pProxyUsername; CSTR m_pProxyPassword; CSTR m_pLastResponse; bool m_bIntransingent; time_t m_nDiscoveryTimeout; CSTR m_pDiscoveryBindIP; CSTR m_pDiscoveryMCastIP; int m_nDiscoveryMCastPort; bool m_bDiscoveryHideDuplicates; volatile bool parser_done; uint8_t m_bAuthMode; #ifndef CURL_MANAGER static int _writer(char * data, size_t size, size_t nmemb, pOnvif * Ptr); #endif static void * parser(void * obj, void * ptr); size_t createRequestString( CSTR buffer, uint16_t CMD, bool RW, int8_t pl_type= -1, void *pl = NULL ); public: boschRCP(); ~boschRCP(); bool setProxyHost(CSTR proxyHost); CSTR getProxyHost(void); bool setProxyPort(int proxyPort); int getProxyPort(void); bool setProxyUsername(CSTR proxyUsername); CSTR getProxyUsername(void); bool setProxyPassword(CSTR proxyPassword); CSTR getProxyPassword(void); bool setUsername(CSTR username); CSTR getUsername(void); bool setPassword(CSTR password); bool setAuthMode(uint8_t Mode); CSTR getPassword(void); CSTR getDeviceUri(void); bool setDeviceUri(CSTR deviceUri); CSTR getIPAddress(void); bool setIPAddress(CSTR ipAddress); /*videoSources * getSources(void); videoSourceProfiles * getProfiles(void); videoSourceProfiles * getActiveProfiles(void); CSTR getMediaUri(void); CSTR getPTZUri(void); CSTR getBaseUrl(void); void getSupportedVersion(void); nodeCapability * getCapabilities(void); bool setBreakOnError(bool intransingent); CSTR getLastResponse(void); bool setDiscoveryTimeout(int discoverytimeout); bool setDiscoveryBindIp(CSTR discoverybindip); bool setDiscoveryMcastIp(CSTR discoverymcastip); bool setDiscoveryMcastPort(int discoverymcastport); bool setDiscoveryHideDuplicates(bool discoveryhideduplicates); CSTR getSnapshotUri(void); discoveryResults discover(void); */ bool create(void); struct tm * core_GetSystemDateAndTime(void); //bool core_GetCapabilities(); //bool core_GetDeviceInformation(); //bool media_GetVideoSources(); //bool media_GetProfiles(); //bool media_GetServices(); //CSTR media_GetStreamUri(CSTR profileToken, CSTR stream = (CSTR) "RTP-Unicast", CSTR protocol = (CSTR) "RTSP"); //CSTR media_GetSnapshotUri(CSTR profileToken); //bool ptz_GetPresets(CSTR profileToken); //bool ptz_GetNode(CSTR ptzNodeToken); bool ptz_GetStatus(CSTR profileToken, ptzStatus * tStatus); //bool ptz_GotoPreset(CSTR profileToken, CSTR presetToken, float speed_pantilt_x, float speed_pantilt_y, float speed_zoom_x); //bool ptz_RemovePreset(CSTR profileToken, CSTR presetToken); //bool ptz_SetPreset(CSTR profileToken, CSTR presetName); bool ptz_RelativeMove(CSTR profileToken, float translation_pantilt_x, float translation_pantilt_y, float speed_pantilt_x, float speed_pantilt_y); bool ptz_RelativeMoveZoom(CSTR profileToken, float zoom, float speedZoom); bool ptz_AbsoluteMove(CSTR profileToken, float position_pantilt_x, float position_pantilt_y, float zoom); bool ptz_ContinuousMove(CSTR profileToken, float velocity_pantilt_x, float velocity_pantilt_y); bool ptz_ContinuousMoveZoom(CSTR profileToken, float zoom); bool ptz_Stop(CSTR profileToken, bool pantilt, bool zoom); /* Internal functions */ private: accessToken _makeToken(void); //void _getBRCPVersion(nodeCapability & capabilities); //void _getActiveSources(videoSourceProfiles & videoSources, videoSourceProfiles profiles); //void _getProfileData(videoSourceProfiles & videoSources, videoSourceProfiles profiles); // protected function _xml2array($response); accessToken _passwordDigest(CSTR username, CSTR password, time_t timestamp = 0, uint32_t nonce = 0); bool _send_request(CSTR url, CSTR post_string = NULL, bool mr = true); bool _post_request(CSTR url, CSTR post_string); }; #endif