├── .gitignore ├── OnvifSDK ├── source │ ├── MediaServiceImpl.cpp │ ├── SearchServiceImpl.cpp │ ├── ReplayServiceImpl.cpp │ ├── ReplayTypes.cpp │ ├── SearchTypes.cpp │ ├── DeviceIOClient.cpp │ ├── DeviceIOServiceImpl.cpp │ ├── DisplayClient.cpp │ ├── ReceiverClient.cpp │ ├── RecordingClient.cpp │ ├── DeviceIOTypes.cpp │ ├── ReceiverServiceImpl.cpp │ ├── RecordingServiceImpl.cpp │ ├── DeviceClient.cpp │ ├── DisplayServiceImpl.cpp │ ├── DeviceServiceImpl.cpp │ ├── RecordingTypes.cpp │ ├── ReceiverTypes.cpp │ ├── BaseClient.cpp │ ├── BaseServer.cpp │ ├── DeviceTypes.cpp │ └── DisplayTypes.cpp ├── WsDiscovery │ ├── WsddLib.cpp │ ├── WsddLib.h │ ├── onvifxx.cpp │ ├── remotediscovery.hpp │ ├── wsdd.hpp │ ├── onvifxx.hpp │ ├── wsa.hpp │ ├── wsdd.cpp │ └── wsa.cpp ├── README ├── include │ ├── DeviceIOClient.h │ ├── stringGenerator.h │ ├── commonTypes.h │ ├── ReceiverClient.h │ ├── DisplayClient.h │ ├── DeviceClient.h │ ├── RecordingClient.h │ ├── ReplayServiceImpl.h │ ├── ReceiverServiceImpl.h │ ├── BaseClient.h │ ├── BaseServer.h │ ├── DisplayServiceImpl.h │ ├── SearchServiceImpl.h │ ├── RecordingServiceImpl.h │ ├── DeviceIOServiceImpl.h │ └── OnvifSDK.h ├── xml │ ├── CMakeLists.txt │ ├── patch.xslt │ ├── bf-2.xsd │ ├── remotediscovery.wsdl │ ├── addressing.xsd │ ├── t-1.xsd │ ├── replay.wsdl │ └── ws-discovery.xsd ├── typemapWsdd.dat ├── typemapWeb.dat ├── gen │ ├── include │ │ └── duration.h │ └── source │ │ └── duration.cpp ├── cmake │ └── FindGSOAP.cmake └── CMakeLists.txt ├── examples ├── OnvifServer │ ├── mainServ.cpp │ ├── README │ ├── OnvifTestServer.cpp │ ├── CMakeLists.txt │ └── OnvifTestServer.h └── OnvifClient │ ├── README │ ├── CMakeLists.txt │ └── mainClient.cpp └── common └── sigrlog.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.user 2 | -------------------------------------------------------------------------------- /OnvifSDK/source/MediaServiceImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "MediaServiceImpl.h" 2 | 3 | namespace Web { 4 | }; // namespace Web 5 | -------------------------------------------------------------------------------- /OnvifSDK/source/SearchServiceImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "SearchServiceImpl.h" 2 | 3 | namespace Web { 4 | } // namespace Web 5 | -------------------------------------------------------------------------------- /OnvifSDK/source/ReplayServiceImpl.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "ReplayServiceImpl.h" 3 | 4 | namespace Web { 5 | } // namespace Web 6 | -------------------------------------------------------------------------------- /OnvifSDK/WsDiscovery/WsddLib.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "WsddLib.h" 3 | #include "wsdd.hpp" 4 | 5 | IWsdd * getWsdd() 6 | { 7 | return Wsdd::Wsdd::Instance(); 8 | } 9 | -------------------------------------------------------------------------------- /OnvifSDK/source/ReplayTypes.cpp: -------------------------------------------------------------------------------- 1 | #include "OnvifSDK.h" 2 | #include "commonTypes.h" 3 | #include "WebReplayBindingProxy.h" 4 | 5 | namespace Web { 6 | } // namespace Web 7 | -------------------------------------------------------------------------------- /OnvifSDK/source/SearchTypes.cpp: -------------------------------------------------------------------------------- 1 | #include "OnvifSDK.h" 2 | #include "commonTypes.h" 3 | #include "WebSearchBindingProxy.h" 4 | 5 | namespace Web { 6 | } // namespace Web 7 | -------------------------------------------------------------------------------- /OnvifSDK/README: -------------------------------------------------------------------------------- 1 | 2 | === OnvifSDK === 3 | ### desc ### 4 | library implements ONVIF specification; library interface described in OnvifSDK.h 5 | ### prerequisites ### 6 | gsoap 2.8.15 or above 7 | ### build ### 8 | mkdir OnvifSDK-build 9 | cd OnvifSDK-build 10 | cmake ../OnvifSDK 11 | make 12 | 13 | -------------------------------------------------------------------------------- /OnvifSDK/WsDiscovery/WsddLib.h: -------------------------------------------------------------------------------- 1 | #ifndef WSDD_LIB__H 2 | #define WSDD_LIB__H 3 | 4 | #include 5 | #include 6 | 7 | class IWsdd 8 | { 9 | public: 10 | virtual int start(bool bIsDevice) = 0; 11 | virtual std::vector getMembers() = 0; 12 | virtual int stop() = 0; 13 | 14 | }; 15 | 16 | IWsdd* getWsdd(); 17 | 18 | #endif //WSDD_LIB__H 19 | 20 | -------------------------------------------------------------------------------- /examples/OnvifServer/mainServ.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "OnvifSDK.h" 3 | #include "OnvifTestServer.h" 4 | 5 | int main() 6 | { 7 | IOnvifServer * srv = getOnvifServer(); 8 | 9 | OnvifTestServer handler; 10 | int iRet = srv->Init(DEV_S, 8080, &handler); 11 | if(iRet != 0) 12 | return -1; 13 | if(srv->Run() != 0) 14 | return -1; 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /examples/OnvifClient/README: -------------------------------------------------------------------------------- 1 | 2 | === OnvifTestClient === 3 | ### desc ### 4 | It is a simple Onvif client, which use DeviceManagement Service of the Server and performs WsDiscovery in the local network. 5 | ### prerequisites ### 6 | * build OnvifSDK 7 | 8 | ### build ### 9 | mkdir OnvifClient-build 10 | cd OnvifClient-build 11 | cmake ../OnvifClient -DSDK="../../path/to/OnvifSDK-build" 12 | make 13 | 14 | ### run ### 15 | ./OnvifTestClient 16 | -------------------------------------------------------------------------------- /examples/OnvifServer/README: -------------------------------------------------------------------------------- 1 | 2 | === OnvifTestServer === 3 | ### desc ### 4 | It is a simple Onvif Server, which implements GetSystemDateAndTime command of the DeviceManagement Service; 5 | and performs OnvifSDK in the local network. 6 | ### prerequisites ### 7 | * build OnvifSDK 8 | 9 | ### build ### 10 | mkdir OnvifServer-build 11 | cd OnvifServer-build 12 | cmake ../OnvifServer -DSDK="../../path/to/OnvifSDK-build" 13 | make 14 | 15 | ### run ### 16 | ./OnvifTestServer 17 | 18 | -------------------------------------------------------------------------------- /OnvifSDK/include/DeviceIOClient.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICEIOCLIENT_H 2 | #define DEVICEIOCLIENT_H 3 | 4 | #include "sigrlog.h" 5 | #include "OnvifSDK.h" 6 | #include "WebDeviceIOBindingProxy.h" 7 | 8 | namespace Web { 9 | class DeviceIOClient 10 | { 11 | public: 12 | DeviceIOClient(const char * pchAdress, soap * s); 13 | ~DeviceIOClient(); 14 | 15 | int GetVideoOutputs(DevIOGetVideoOutputsResponse &); 16 | 17 | private: 18 | DeviceIOBindingProxy m_proxy; 19 | }; 20 | } // namespace Web 21 | #endif // DEVICEIOCLIENT_H 22 | -------------------------------------------------------------------------------- /OnvifSDK/source/DeviceIOClient.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "DeviceIOClient.h" 3 | 4 | namespace Web { 5 | DeviceIOClient::DeviceIOClient(const char * pchAdress, soap * s):m_proxy(s) 6 | { 7 | m_proxy.soap_endpoint = pchAdress; 8 | } 9 | 10 | DeviceIOClient::~DeviceIOClient() 11 | { 12 | 13 | } 14 | 15 | int DeviceIOClient::GetVideoOutputs(DevIOGetVideoOutputsResponse & resp) 16 | { 17 | DevIOGetVideoOutputs req(m_proxy.soap); 18 | 19 | int nRes = m_proxy.GetVideoOutputs(req.d, resp.d); 20 | 21 | CHECKRETURN(nRes, "DeviceIOClient::GetVideoOutputs"); 22 | } 23 | } // namespace Web 24 | -------------------------------------------------------------------------------- /examples/OnvifServer/OnvifTestServer.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "sigrlog.h" 4 | #include "OnvifTestServer.h" 5 | 6 | int OnvifTestServer::GetDateAndTime(DevGetSystemDateAndTimeResponse & dt) 7 | { 8 | time_t t = time(0); 9 | struct tm * now = localtime( & t ); 10 | 11 | if(now == NULL) 12 | { 13 | SIGRLOG(SIGRWARNING, "OnvifTestServer::GetDateAndTime Getting localtime failed"); 14 | return -1; 15 | } 16 | 17 | dt.SetUTCDateAndTime(now->tm_year + 1900, now->tm_mon + 1, now->tm_mday, now->tm_hour, now->tm_min, now->tm_sec); 18 | 19 | return 0; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /OnvifSDK/include/stringGenerator.h: -------------------------------------------------------------------------------- 1 | #ifndef STRINGGENERATOR_H 2 | #define STRINGGENERATOR_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "OnvifSDK.h" 10 | 11 | #define TOKEN_LEN 20 12 | 13 | static const char alphanum[] = 14 | "0123456789" 15 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 16 | "abcdefghijklmnopqrstuvwxyz"; 17 | 18 | typedef struct GeneratorInitializer_ 19 | { GeneratorInitializer_() 20 | { 21 | srand(time(0)); 22 | } 23 | } GeneratorInitializer; 24 | 25 | static int stringLength = sizeof(alphanum) - 1; 26 | 27 | #endif //STRINGGENERATOR_H 28 | -------------------------------------------------------------------------------- /OnvifSDK/include/commonTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMONTYPES_H 2 | #define COMMONTYPES_H 3 | 4 | //** for allocation of the internal objects redefine EXTRA_CONSTRUCT() 5 | #define CLASS_CTORS(gSoapPrefix, servicePrefix, classname)\ 6 | servicePrefix ## classname::servicePrefix ## classname ( _ ## gSoapPrefix ## __ ## classname * pData)\ 7 | {\ 8 | this->d = pData;\ 9 | EXTRA_CONSTRUCT()\ 10 | };\ 11 | \ 12 | servicePrefix ## classname::servicePrefix ## classname ( soap * pSoap )\ 13 | {\ 14 | this->d = soap_new__ ## gSoapPrefix ## __ ## classname (pSoap);\ 15 | EXTRA_CONSTRUCT()\ 16 | }; 17 | 18 | #endif //COMMONTYPES_H 19 | -------------------------------------------------------------------------------- /OnvifSDK/include/ReceiverClient.h: -------------------------------------------------------------------------------- 1 | #ifndef RECEIVERCLIENT_H 2 | #define RECEIVERCLIENT_H 3 | 4 | #include "sigrlog.h" 5 | #include "OnvifSDK.h" 6 | #include "WebReceiverBindingProxy.h" 7 | 8 | namespace Web { 9 | 10 | class ReceiverClient 11 | { 12 | public: 13 | ReceiverClient(const char * pchAdress, soap * s); 14 | ~ReceiverClient(); 15 | 16 | int GetReceivers( RecvGetReceiversResponse & ); 17 | int CreateReceiver( const std::string & uri, std::string & recvToken ); 18 | int SetReceiverMode( const std::string & recvToken, bool bMode ); 19 | 20 | private: 21 | ReceiverBindingProxy m_proxy; 22 | }; 23 | } // namespace Web 24 | #endif // RECEIVERCLIENT_H 25 | -------------------------------------------------------------------------------- /OnvifSDK/source/DeviceIOServiceImpl.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "sigrlog.h" 3 | #include "DeviceIOServiceImpl.h" 4 | #include "BaseServer.h" 5 | 6 | namespace Web { 7 | #warning TODO for while not supporting copy 8 | DeviceIOBindingService* DeviceIOServiceImpl::copy() 9 | { 10 | return NULL; 11 | } 12 | 13 | int DeviceIOServiceImpl::GetVideoOutputs(_tmd__GetVideoOutputs *tmd__GetVideoOutputs, _tmd__GetVideoOutputsResponse *tmd__GetVideoOutputsResponse) 14 | { 15 | DevIOGetVideoOutputsResponse resp(tmd__GetVideoOutputsResponse); 16 | 17 | int nRes = m_pBaseServer->GetVideoOutputs(resp); 18 | 19 | CHECKRETURN(nRes, "DeviceIOServiceImpl::GetVideoOutputs"); 20 | } 21 | } // namespace Web 22 | -------------------------------------------------------------------------------- /OnvifSDK/include/DisplayClient.h: -------------------------------------------------------------------------------- 1 | #ifndef DISPLAYCLIENT_H 2 | #define DISPLAYCLIENT_H 3 | 4 | #include "sigrlog.h" 5 | #include "OnvifSDK.h" 6 | #include "WebDisplayBindingProxy.h" 7 | 8 | namespace Web { 9 | 10 | class DisplayClient 11 | { 12 | public: 13 | DisplayClient(const char * pchAdress, soap * s); 14 | ~DisplayClient(); 15 | 16 | int GetLayout(DispGetLayout &, DispGetLayoutResponse &); 17 | int GetDisplayOptions(DispGetDisplayOptions &, DispGetDisplayOptionsResponse &); 18 | int SetLayout(DispSetLayout &); 19 | int CreatePaneConfiguration(DispCreatePaneConfiguration &, DispCreatePaneConfigurationResponse &); 20 | 21 | private: 22 | DisplayBindingProxy m_proxy; 23 | }; 24 | } // namespace Web 25 | #endif // DISPLAYCLIENT_H 26 | 27 | -------------------------------------------------------------------------------- /OnvifSDK/include/DeviceClient.h: -------------------------------------------------------------------------------- 1 | #ifndef deviceClient_H 2 | #define deviceClient_H 3 | 4 | #include "sigrlog.h" 5 | #include "OnvifSDK.h" 6 | #include "WebDeviceBindingProxy.h" 7 | 8 | namespace Web { 9 | class DeviceClient 10 | { 11 | public: 12 | DeviceClient(const char * pchAdress, soap * s); 13 | ~DeviceClient(); 14 | 15 | int SetDateAndTime(const DevSetSystemDateAndTime &); 16 | int GetDateAndTime(DevGetSystemDateAndTimeResponse &); 17 | //int GetDeviceInfo(DevGetDeviceInformationResponse &); 18 | //int GetCapabilities(DevGetCapabilitiesResponse &); 19 | int GetUsers(DevGetUsersResponse &); 20 | int GetServices(DevGetServicesResponse &); 21 | 22 | private: 23 | DeviceBindingProxy m_proxy; 24 | }; 25 | } // namespace Web 26 | #endif // deviceClient_H 27 | 28 | -------------------------------------------------------------------------------- /OnvifSDK/include/RecordingClient.h: -------------------------------------------------------------------------------- 1 | #ifndef RECORDINGCLIENT_H 2 | #define RECORDINGCLIENT_H 3 | 4 | #include "sigrlog.h" 5 | #include "OnvifSDK.h" 6 | #include "WebRecordingBindingProxy.h" 7 | 8 | namespace Web { 9 | class RecordingClient 10 | { 11 | public: 12 | RecordingClient(const char * pchAdress, soap * s); 13 | ~RecordingClient(); 14 | 15 | virtual int CreateRecording (RecCreateRecording &, RecCreateRecordingResponse &); 16 | virtual int CreateRecordingJob (RecCreateRecordingJob &, RecCreateRecordingJobResponse &); 17 | virtual int DeleteRecording (const std::string &); 18 | virtual int DeleteRecordingJob (const std::string &); 19 | 20 | private: 21 | RecordingBindingProxy m_proxy; 22 | }; 23 | } // namespace Web 24 | #endif // RECORDINGCLIENT_H 25 | -------------------------------------------------------------------------------- /examples/OnvifClient/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ### 2 | project(OnvifTestClient) 3 | cmake_minimum_required(VERSION 2.8) 4 | 5 | # SIGRLOG_CURRLEVEL: 6 | # level of verboseness of the logger range [0..4] 7 | add_definitions(-DSIGRLOG_CURRLEVEL=2) 8 | # SIGRLOG_OUTPUT: 9 | # destinations of the logger output 10 | # 0 - none, 1 - console only, 2 - file only, 3 - console and file 11 | add_definitions(-DSIGRLOG_OUTPUT=1) 12 | # SIGRLOG_FILENAME 13 | # output filename for logger 14 | add_definitions(-DSIGRLOG_FILENAME=\"clientLog.ini\") 15 | 16 | find_library(SDKLIB OnvifSDK ${SDK}) 17 | if( SDKLIB STREQUAL "SDKLIB-NOTFOUND" ) 18 | message(FATAL_ERROR "OnvifSDK library wasn't provided") 19 | endif() 20 | message(STATUS "OSDK Library : ${SDKLIB}") 21 | 22 | include_directories(${PROJECT_SOURCE_DIR}/../../common 23 | ${PROJECT_SOURCE_DIR}/../../OnvifSDK/include) 24 | 25 | set(${HEADERS} ${PROJECT_SOURCE_DIR}/../../OnvifSDK/include/OnvifSDK.h) 26 | 27 | set(SOURCES 28 | ${PROJECT_SOURCE_DIR}/mainClient.cpp) 29 | 30 | add_executable(OnvifTestClient ${SOURCES} ${HEADERS}) 31 | target_link_libraries(OnvifTestClient ${SDKLIB} pthread) 32 | 33 | -------------------------------------------------------------------------------- /OnvifSDK/WsDiscovery/onvifxx.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct Namespace namespaces[] = {}; 5 | 6 | 7 | Exception::Exception() 8 | { 9 | } 10 | 11 | Exception::Exception(const char * msg) : 12 | msg_(msg) 13 | { 14 | 15 | } 16 | 17 | Exception::~Exception() throw() 18 | { 19 | } 20 | 21 | std::string & Exception::message() 22 | { 23 | return msg_; 24 | } 25 | 26 | const char * Exception::what() const throw() 27 | { 28 | return msg_.c_str(); 29 | } 30 | 31 | SoapException::SoapException(soap * s) : 32 | code_(-1) 33 | { 34 | if (s != NULL) { 35 | char buf[1024]; 36 | soap_sprint_fault(s, buf, sizeof(buf)); 37 | message().assign(buf); 38 | 39 | code_ = s->errnum; 40 | } 41 | } 42 | 43 | int SoapException::code() const 44 | { 45 | return code_; 46 | } 47 | 48 | UnixException::UnixException(int code) 49 | { 50 | if (code == 0) 51 | code = errno; 52 | 53 | char buf[1024]; 54 | message().assign(strerror_r(code, buf, sizeof(buf) - 1)); 55 | 56 | code_ = code; 57 | } 58 | 59 | int UnixException::code() const 60 | { 61 | return code_; 62 | } 63 | -------------------------------------------------------------------------------- /examples/OnvifClient/mainClient.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "OnvifSDK.h" 4 | 5 | int main(const int argc, const char* argv[]) 6 | { 7 | IOnvifClient * pClient = getOnvifClient(); 8 | if(argc < 2) 9 | { 10 | printf("Input endpoint address. example:127.0.0.1:80\n"); 11 | return -1; 12 | } 13 | 14 | pClient->Init(argv[1]); 15 | soap* pSoap = pClient->GetSoap(); 16 | DevGetSystemDateAndTimeResponse r(pSoap); 17 | int iRet = pClient->GetDateAndTime(r); 18 | if(iRet != 0) 19 | { 20 | printf("GetDateAndTime failed\n"); 21 | } 22 | else 23 | { 24 | int nYear, nMonth, nDay, nHour, nMin, nSec; 25 | r.GetUTCDateAndTime(nYear, nMonth, nDay, nHour, nMin, nSec); 26 | printf("DeviceService response is:\nDate is %d:%d:%d\nTime is %d:%d:%d\n", nYear, nMonth, nDay, nHour, nMin, nSec); 27 | } 28 | 29 | sleep(30); 30 | std::vector devices = pClient->GetDiscoveredDevices(); 31 | if(devices.size() == 0) { 32 | printf("Disappointment. 0 devices were discovered\n"); 33 | } else { 34 | for(int i = 0; i < devices.size(); i++) 35 | printf("Discovered device: %s\n", devices[i].c_str()); 36 | } 37 | 38 | return 0; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /OnvifSDK/source/DisplayClient.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "DisplayClient.h" 3 | 4 | namespace Web { 5 | 6 | DisplayClient::DisplayClient(const char * pchAdress, soap * s):m_proxy(s) 7 | { 8 | m_proxy.soap_endpoint = pchAdress; 9 | } 10 | 11 | DisplayClient::~DisplayClient() 12 | { 13 | 14 | } 15 | 16 | int DisplayClient::GetLayout(DispGetLayout & req, DispGetLayoutResponse & resp) 17 | { 18 | int nRes = m_proxy.GetLayout(req.d, resp.d); 19 | 20 | CHECKRETURN(nRes, "DisplayClient::GetLayout"); 21 | } 22 | 23 | int DisplayClient::GetDisplayOptions(DispGetDisplayOptions & req, DispGetDisplayOptionsResponse & resp) 24 | { 25 | int nRes = m_proxy.GetDisplayOptions(req.d, resp.d); 26 | 27 | CHECKRETURN(nRes, "DisplayClient::GetDisplayOptions"); 28 | } 29 | 30 | int DisplayClient::SetLayout(DispSetLayout & req) 31 | { 32 | DispSetLayoutResponse resp(m_proxy.soap); 33 | 34 | int nRes = m_proxy.SetLayout(req.d, resp.d); 35 | 36 | CHECKRETURN(nRes, "DisplayClient::SetLayout"); 37 | } 38 | 39 | int DisplayClient::CreatePaneConfiguration(DispCreatePaneConfiguration & req, DispCreatePaneConfigurationResponse & resp) 40 | { 41 | int nRes = m_proxy.CreatePaneConfiguration(req.d, resp.d); 42 | 43 | CHECKRETURN(nRes, "DisplayClient::CreatePaneConfiguration"); 44 | } 45 | } // namespace Web 46 | -------------------------------------------------------------------------------- /examples/OnvifServer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ### 2 | project(OnvifTestServer) 3 | cmake_minimum_required(VERSION 2.8) 4 | 5 | # SIGRLOG_CURRLEVEL: 6 | # level of verboseness of the logger range [0..4] 7 | add_definitions(-DSIGRLOG_CURRLEVEL=2) 8 | # SIGRLOG_OUTPUT: 9 | # destinations of the logger output 10 | # 0 - none, 1 - console only, 2 - file only, 3 - console and file 11 | add_definitions(-DSIGRLOG_OUTPUT=1) 12 | # SIGRLOG_FILENAME 13 | # output filename for logger 14 | add_definitions(-DSIGRLOG_FILENAME=\"oxxServerLog.ini\") 15 | 16 | find_library(SDKLIB OnvifSDK ${SDK}) 17 | if( SDKLIB STREQUAL "SDKLIB-NOTFOUND" ) 18 | message(FATAL_ERROR "OnvifSDK library wasn't provided") 19 | endif() 20 | message(STATUS "OSDK Library : ${SDKLIB}") 21 | 22 | include_directories(${PROJECT_SOURCE_DIR}/../../common 23 | ${PROJECT_SOURCE_DIR}/../../OnvifSDK/include 24 | ${PROJECT_SOURCE_DIR}) 25 | 26 | 27 | set(HEADERS ${PROJECT_SOURCE_DIR}/../../OnvifSDK/include/OnvifSDK.h 28 | ${PROJECT_SOURCE_DIR}/../../common/sigrlog.h) 29 | 30 | set(SOURCES ${PROJECT_SOURCE_DIR}/mainServ.cpp 31 | ${PROJECT_SOURCE_DIR}/OnvifTestServer.h 32 | ${PROJECT_SOURCE_DIR}/OnvifTestServer.cpp) 33 | 34 | add_executable(OnvifTestServer ${HEADERS} ${SOURCES}) 35 | 36 | target_link_libraries(OnvifTestServer ${SDKLIB} pthread) 37 | 38 | -------------------------------------------------------------------------------- /OnvifSDK/xml/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(${CMAKE_PROJECT_NAME}_xml) 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | find_program(XSLTPROC 5 | NAMES xsltproc 6 | HINTS /usr/bin 7 | DOC "The xsltproc bin directory" 8 | ) 9 | if(NOT XSLTPROC) 10 | message(FATAL_ERROR "Could not find xsltproc") 11 | endif() 12 | 13 | file(GLOB XML_FILES *.*) 14 | 15 | 16 | foreach(XML ${XML_FILES}) 17 | get_filename_component(XML_EXT ${XML} EXT) 18 | if(XML_EXT STREQUAL ".wsdl" OR XML_EXT STREQUAL ".xsd") 19 | get_filename_component(XML_NAME ${XML} NAME) 20 | execute_process ( 21 | COMMAND ${XSLTPROC} -o ${XML_NAME} ${PROJECT_SOURCE_DIR}/patch.xslt ${PROJECT_SOURCE_DIR}/${XML_NAME} 22 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 23 | ) 24 | endif() 25 | endforeach() 26 | 27 | 28 | 29 | file(GLOB WSDL_FILES ${PROJECT_BINARY_DIR}/*.wsdl) 30 | list(REMOVE_ITEM WSDL_FILES ${PROJECT_BINARY_DIR}/bw-2.wsdl) 31 | list(REMOVE_ITEM WSDL_FILES ${PROJECT_BINARY_DIR}/rw-2.wsdl) 32 | 33 | #foreach(WSDL ${WSDL_FILES}) 34 | # get_filename_component(WSDL_NAME ${WSDL} NAME) 35 | # if(WSDL_NAME STREQUAL "bw-2.wsdl" OR WSDL_NAME STREQUAL "rw-2.wsdl") 36 | # list(REMOVE_ITEM WSDL_FILES ${WSDL}) 37 | # endif() 38 | #endforeach() 39 | 40 | set(XML_WSDL_DIR ${PROJECT_BINARY_DIR} PARENT_SCOPE) 41 | set(XML_WSDL_LIST ${WSDL_FILES} PARENT_SCOPE) 42 | 43 | add_custom_target(${PROJECT_NAME} SOURCES ${XML_FILES}) 44 | -------------------------------------------------------------------------------- /OnvifSDK/typemapWsdd.dat: -------------------------------------------------------------------------------- 1 | 2 | tds = "http://www.onvif.org/ver10/device/wsdl" 3 | tev = "http://www.onvif.org/ver10/events/wsdl" 4 | tls = "http://www.onvif.org/ver10/display/wsdl" 5 | tmd = "http://www.onvif.org/ver10/deviceIO/wsdl" 6 | timg = "http://www.onvif.org/ver20/imaging/wsdl" 7 | trt = "http://www.onvif.org/ver10/media/wsdl" 8 | tptz = "http://www.onvif.org/ver20/ptz/wsdl" 9 | trv = "http://www.onvif.org/ver10/receiver/wsdl" 10 | trc = "http://www.onvif.org/ver10/recording/wsdl" 11 | tse = "http://www.onvif.org/ver10/search/wsdl" 12 | trp = "http://www.onvif.org/ver10/replay/wsdl" 13 | tan = "http://www.onvif.org/ver20/analytics/wsdl" 14 | tad = "http://www.onvif.org/ver10/analyticsdevice/wsdl" 15 | tdn = "http://www.onvif.org/ver10/network/wsdl" 16 | tt = "http://www.onvif.org/ver10/schema" 17 | 18 | wsnt = "http://docs.oasis-open.org/wsn/b-2" 19 | wsntw = "http://docs.oasis-open.org/wsn/bw-2" 20 | wsrfbf = "http://docs.oasis-open.org/wsrf/bf-2" 21 | wsrfr = "http://docs.oasis-open.org/wsrf/r-2" 22 | wsrfrw = "http://docs.oasis-open.org/wsrf/rw-2" 23 | wstop = "http://docs.oasis-open.org/wsn/t-1" 24 | 25 | wsa = "http://schemas.xmlsoap.org/ws/2004/08/addressing" 26 | wsd = "http://schemas.xmlsoap.org/ws/2005/04/discovery" 27 | dn = "http://www.onvif.org/ver10/network/wsdl" 28 | dnrd= "http://www.onvif.org/ver10/network/wsdl/RemoteDiscoveryBinding" 29 | dndl= "http://www.onvif.org/ver10/network/wsdl/DiscoveryLookupBinding" 30 | 31 | -------------------------------------------------------------------------------- /OnvifSDK/source/ReceiverClient.cpp: -------------------------------------------------------------------------------- 1 | #include "ReceiverClient.h" 2 | 3 | namespace Web { 4 | ReceiverClient::ReceiverClient(const char * pchAdress, soap * s):m_proxy(s) 5 | { 6 | m_proxy.soap_endpoint = pchAdress; 7 | } 8 | 9 | ReceiverClient::~ReceiverClient() 10 | { 11 | 12 | } 13 | 14 | int ReceiverClient::GetReceivers(RecvGetReceiversResponse & resp) 15 | { 16 | RecvGetReceivers req(m_proxy.soap); 17 | 18 | int nRes = m_proxy.GetReceivers(req.d, resp.d); 19 | 20 | CHECKRETURN(nRes, "ReceiverClient::GetReceivers"); 21 | } 22 | 23 | int ReceiverClient::CreateReceiver(const std::string &uri, std::string & recvToken) 24 | { 25 | RecvCreateReceiver req(m_proxy.soap); 26 | RecvCreateReceiverResponse resp(m_proxy.soap); 27 | 28 | req.setUri(uri); 29 | req.setMode(0); 30 | 31 | int nRes = m_proxy.CreateReceiver(req.d, resp.d); 32 | recvToken = resp.getToken(); 33 | CHECKRETURN(nRes, "ReceiverClient::CreateReceiver"); 34 | } 35 | 36 | int ReceiverClient::SetReceiverMode(const std::string & recvToken, bool bMode) 37 | { 38 | RecvSetReceiverMode req(m_proxy.soap); 39 | RecvSetReceiverModeResponse resp(m_proxy.soap); 40 | 41 | req.setToken(recvToken); 42 | req.setMode(bMode); 43 | 44 | SIGRLOG(SIGRDEBUG2, "ReceiverClient::SetReceiverMode %s %d", req.getToken().c_str(), req.getMode()); 45 | 46 | int nRes = m_proxy.SetReceiverMode(req.d, resp.d); 47 | CHECKRETURN(nRes, "ReceiverClient::SetReceiverMode"); 48 | } 49 | } // namespace Web 50 | -------------------------------------------------------------------------------- /OnvifSDK/source/RecordingClient.cpp: -------------------------------------------------------------------------------- 1 | #include "RecordingClient.h" 2 | 3 | namespace Web { 4 | RecordingClient::RecordingClient(const char * pchAdress, soap * s):m_proxy(s) 5 | { 6 | m_proxy.soap_endpoint = pchAdress; 7 | } 8 | 9 | RecordingClient::~RecordingClient() 10 | { 11 | } 12 | 13 | int RecordingClient::CreateRecording (RecCreateRecording & req, RecCreateRecordingResponse & resp) 14 | { 15 | int iRet = m_proxy.CreateRecording(req.d, resp.d); 16 | CHECKRETURN(iRet, "RecordingClient::CreateRecording"); 17 | } 18 | 19 | int RecordingClient::CreateRecordingJob (RecCreateRecordingJob & req, RecCreateRecordingJobResponse &resp) 20 | { 21 | int iRet = m_proxy.CreateRecordingJob(req.d, resp.d); 22 | CHECKRETURN(iRet, "RecordingClient::CreateReceiverJob"); 23 | } 24 | 25 | int RecordingClient::DeleteRecording (const std::string & token) 26 | { 27 | RecDeleteRecording r (m_proxy.soap); 28 | r.setToken(token); 29 | RecDeleteRecordingResponse resp (m_proxy.soap); 30 | int iRet = m_proxy.DeleteRecording(r.d, resp.d); 31 | CHECKRETURN(iRet, "RecordingClient::DeleteRecording"); 32 | } 33 | 34 | int RecordingClient::DeleteRecordingJob (const std::string & token) 35 | { 36 | RecDeleteRecordingJob r(m_proxy.soap); 37 | r.setToken(token); 38 | 39 | RecDeleteRecordingJobResponse resp(m_proxy.soap); 40 | int iRet = m_proxy.DeleteRecordingJob(r.d, resp.d); 41 | CHECKRETURN(iRet, "RecordingClient::DeleteRecordingJob"); 42 | } 43 | } // namespace Web 44 | -------------------------------------------------------------------------------- /OnvifSDK/source/DeviceIOTypes.cpp: -------------------------------------------------------------------------------- 1 | #include "sigrlog.h" 2 | #include "OnvifSDK.h" 3 | #include "commonTypes.h" 4 | #include "WebDeviceIOBindingProxy.h" 5 | 6 | namespace Web { 7 | //////////////////////////////////////////////////////////////////////////////// 8 | //////////////////////////////////////////////////////////////////////////////// 9 | //////////////////////////////////////////////////////////////////////////////// 10 | 11 | #define EXTRA_CONSTRUCT() \ 12 | {\ 13 | } 14 | 15 | CLASS_CTORS(tmd, DevIO, GetVideoOutputs) 16 | 17 | 18 | //////////////////////////////////////////////////////////////////////////////// 19 | 20 | #define EXTRA_CONSTRUCT() \ 21 | {\ 22 | } 23 | 24 | CLASS_CTORS(tmd, DevIO, GetVideoOutputsResponse) 25 | 26 | 27 | int DevIOGetVideoOutputsResponse::SetVideoOutputs(const std::string & videoOutput) 28 | { 29 | tt__VideoOutput * vo = soap_new_tt__VideoOutput(this->d->soap, -1); 30 | 31 | vo->token = videoOutput; 32 | 33 | this->d->VideoOutputs.push_back(vo); 34 | 35 | return 0; 36 | } 37 | 38 | int DevIOGetVideoOutputsResponse::GetVideoOutputs(std::string & videoOutput) const 39 | { 40 | videoOutput = this->d->VideoOutputs[0]->token; 41 | 42 | return 0; 43 | } 44 | 45 | //////////////////////////////////////////////////////////////////////////////// 46 | //////////////////////////////////////////////////////////////////////////////// 47 | //////////////////////////////////////////////////////////////////////////////// 48 | } // namespace Web 49 | -------------------------------------------------------------------------------- /OnvifSDK/typemapWeb.dat: -------------------------------------------------------------------------------- 1 | 2 | 3 | xop = 4 | wsa5 = 5 | 6 | tds = "http://www.onvif.org/ver10/device/wsdl" 7 | tev = "http://www.onvif.org/ver10/events/wsdl" 8 | tls = "http://www.onvif.org/ver10/display/wsdl" 9 | tmd = "http://www.onvif.org/ver10/deviceIO/wsdl" 10 | timg = "http://www.onvif.org/ver20/imaging/wsdl" 11 | trt = "http://www.onvif.org/ver10/media/wsdl" 12 | tptz = "http://www.onvif.org/ver20/ptz/wsdl" 13 | trv = "http://www.onvif.org/ver10/receiver/wsdl" 14 | trc = "http://www.onvif.org/ver10/recording/wsdl" 15 | tse = "http://www.onvif.org/ver10/search/wsdl" 16 | trp = "http://www.onvif.org/ver10/replay/wsdl" 17 | tan = "http://www.onvif.org/ver20/analytics/wsdl" 18 | tad = "http://www.onvif.org/ver10/analyticsdevice/wsdl" 19 | tdn = "http://www.onvif.org/ver10/network/wsdl" 20 | tt = "http://www.onvif.org/ver10/schema" 21 | 22 | wsnt = "http://docs.oasis-open.org/wsn/b-2" 23 | wsntw = "http://docs.oasis-open.org/wsn/bw-2" 24 | wsrfbf = "http://docs.oasis-open.org/wsrf/bf-2" 25 | wsrfr = "http://docs.oasis-open.org/wsrf/r-2" 26 | wsrfrw = "http://docs.oasis-open.org/wsrf/rw-2" 27 | wstop = "http://docs.oasis-open.org/wsn/t-1" 28 | 29 | wsa = "http://schemas.xmlsoap.org/ws/2004/08/addressing" 30 | wsd = "http://schemas.xmlsoap.org/ws/2005/04/discovery" 31 | dn = "http://www.onvif.org/ver10/network/wsdl" 32 | dnrd= "http://www.onvif.org/ver10/network/wsdl/RemoteDiscoveryBinding" 33 | dndl= "http://www.onvif.org/ver10/network/wsdl/DiscoveryLookupBinding" 34 | 35 | -------------------------------------------------------------------------------- /OnvifSDK/source/ReceiverServiceImpl.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "sigrlog.h" 3 | #include "ReceiverServiceImpl.h" 4 | #include "BaseServer.h" 5 | 6 | namespace Web { 7 | #warning TODO for while not supporting copy 8 | ReceiverBindingService* ReceiverServiceImpl::copy() 9 | { 10 | return NULL; 11 | } 12 | 13 | int ReceiverServiceImpl::GetReceivers(_trv__GetReceivers *trv__GetReceivers, _trv__GetReceiversResponse *trv__GetReceiversResponse) 14 | { 15 | RecvGetReceiversResponse resp( trv__GetReceiversResponse ); 16 | 17 | int nRes = m_pBaseServer->GetReceivers(resp); 18 | 19 | CHECKRETURN(nRes, "ReceiverServiceImpl::GetReceivers"); 20 | } 21 | 22 | int ReceiverServiceImpl::CreateReceiver(_trv__CreateReceiver *trv__CreateReceiver, _trv__CreateReceiverResponse *trv__CreateReceiverResponse) 23 | { 24 | RecvCreateReceiver req(trv__CreateReceiver); 25 | RecvCreateReceiverResponse resp(trv__CreateReceiverResponse); 26 | 27 | std::string recvToken; 28 | 29 | int nRes = m_pBaseServer->CreateReceiver( req.getUri(), recvToken ); 30 | 31 | resp.setToken(recvToken); 32 | 33 | CHECKRETURN(nRes, "ReceiverServiceImpl::CreateReceiver"); 34 | } 35 | 36 | int ReceiverServiceImpl::SetReceiverMode(_trv__SetReceiverMode *trv__SetReceiverMode, _trv__SetReceiverModeResponse *trv__SetReceiverModeResponse) 37 | { 38 | RecvSetReceiverMode req(trv__SetReceiverMode); 39 | 40 | int nRes = m_pBaseServer->SetReceiverMode( req.getToken(), req.getMode() ); 41 | CHECKRETURN(nRes, "ReceiverServiceImpl::SetReceiverMode"); 42 | } 43 | } // namespace Web 44 | -------------------------------------------------------------------------------- /OnvifSDK/WsDiscovery/remotediscovery.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ONVIF_DISCOVERY_HPP 2 | #define ONVIF_DISCOVERY_HPP 3 | 4 | #include "onvifxx.hpp" 5 | 6 | static const char WSDD_MULTICAT_IP[] = "239.255.255.250"; 7 | static const int WSDD_MULTICAT_PORT = 3702; 8 | 9 | struct RemoteDiscovery 10 | { 11 | typedef struct 12 | { 13 | std::string item; 14 | std::string * matchBy; 15 | } Scopes_t; 16 | 17 | typedef struct 18 | { 19 | std::string * address; 20 | std::string * portType; 21 | 22 | struct ServiceName 23 | { 24 | std::string item; 25 | std::string * portName; 26 | } * serviceName; 27 | } EndpointReference_t; 28 | 29 | typedef struct 30 | { 31 | std::string * types; 32 | Scopes_t * scopes; 33 | } Probe_t; 34 | 35 | typedef struct 36 | { 37 | EndpointReference_t * endpoint; 38 | std::string * types; 39 | Scopes_t * scopes; 40 | std::string * xaddrs; 41 | unsigned int version; 42 | } ProbeMatch_t; 43 | 44 | typedef ProbeMatch_t Hello_t; 45 | typedef ProbeMatch_t Bye_t; 46 | typedef std::vector ProbeMatches_t; 47 | 48 | virtual void hello(const Hello_t & arg) = 0; 49 | virtual void bye(const Bye_t & arg) = 0; 50 | virtual ProbeMatches_t probe(const Probe_t & arg) = 0; 51 | //virtual void probeMatches(const ProbeMatches_t & arg, const std::string & relatesTo) = 0; 52 | 53 | static Proxy * proxy(); 54 | static Service * service(); 55 | }; 56 | 57 | #endif // ONVIF_DISCOVERY_HPP 58 | -------------------------------------------------------------------------------- /OnvifSDK/WsDiscovery/wsdd.hpp: -------------------------------------------------------------------------------- 1 | #ifndef WSDD_HPP 2 | #define WSDD_HPP 3 | 4 | #include 5 | 6 | #include "WsddLib.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class Wsdd : public IWsdd, 14 | public RemoteDiscovery 15 | { 16 | typedef Proxy Proxy_t; 17 | typedef Service Service_t; 18 | 19 | public: 20 | virtual ~Wsdd(); 21 | virtual int start(bool bIsDevice); 22 | virtual std::vector getMembers(); 23 | virtual int stop(); 24 | 25 | static Wsdd* Instance() 26 | { 27 | static Wsdd theSingleInstance; 28 | return &theSingleInstance; 29 | } 30 | 31 | private: 32 | Wsdd(); 33 | Wsdd(const Wsdd& root); 34 | Wsdd& operator=(const Wsdd&); 35 | 36 | virtual void hello(const Hello_t & arg); 37 | virtual void bye(const Bye_t & arg); 38 | virtual ProbeMatches_t probe(const Probe_t & arg); 39 | 40 | static bool isMatched(const std::string & left, const std::string & right); 41 | 42 | void runService(); 43 | static void * runServiceHelper(void * context) 44 | { 45 | ((Wsdd*)context)->runService(); 46 | } 47 | 48 | private: 49 | bool stopped_; 50 | bool bExitRequest_; 51 | bool bIsDevice_; 52 | 53 | pthread_mutex_t mutex_; 54 | pthread_t serviceThread_; 55 | 56 | std::vector scopes_; 57 | ProbeMatches_t probeMatches_; 58 | std::tr1::shared_ptr proxy_; 59 | 60 | std::vector members_; 61 | }; 62 | 63 | #endif // WSDD_HPP 64 | -------------------------------------------------------------------------------- /OnvifSDK/source/RecordingServiceImpl.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "BaseServer.h" 3 | #include "RecordingServiceImpl.h" 4 | 5 | namespace Web { 6 | int RecordingServiceImpl::CreateRecordingJob (_trc__CreateRecordingJob *trc__CreateRecordingJob, 7 | _trc__CreateRecordingJobResponse *trc__CreateRecordingJobResponse) 8 | { 9 | RecCreateRecordingJob req(trc__CreateRecordingJob); 10 | RecCreateRecordingJobResponse resp(trc__CreateRecordingJobResponse); 11 | return m_pBaseServer->CreateRecordingJob(req, resp); 12 | } 13 | 14 | int RecordingServiceImpl::DeleteRecordingJob (_trc__DeleteRecordingJob *trc__DeleteRecordingJob, 15 | _trc__DeleteRecordingJobResponse *trc__DeleteRecordingJobResponse) 16 | { 17 | RecDeleteRecordingJob r(trc__DeleteRecordingJob); 18 | return m_pBaseServer->DeleteRecordingJob(r.getToken()); 19 | } 20 | 21 | int RecordingServiceImpl::CreateRecording (_trc__CreateRecording *trc__CreateRecording, 22 | _trc__CreateRecordingResponse *trc__CreateRecordingResponse) 23 | { 24 | RecCreateRecording req(trc__CreateRecording); 25 | RecCreateRecordingResponse resp(trc__CreateRecordingResponse); 26 | return m_pBaseServer->CreateRecording(req, resp); 27 | } 28 | 29 | int RecordingServiceImpl::DeleteRecording (_trc__DeleteRecording *trc__DeleteRecording, 30 | _trc__DeleteRecordingResponse *trc__DeleteRecordingResponse) 31 | { 32 | RecDeleteRecording r(trc__DeleteRecording); 33 | return m_pBaseServer->DeleteRecording(r.getToken()); 34 | } 35 | } // namespace Web 36 | -------------------------------------------------------------------------------- /OnvifSDK/include/ReplayServiceImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef ReplayServiceImpl_H 2 | #define ReplayServiceImpl_H 3 | 4 | #include "WebReplayBindingService.h" 5 | class BaseServer; 6 | namespace Web { 7 | class ReplayServiceImpl : public ReplayBindingService 8 | { 9 | private: 10 | BaseServer * m_pBaseServer; 11 | public: 12 | ReplayServiceImpl(BaseServer * pBaseServer, struct soap * pData): 13 | m_pBaseServer(pBaseServer), 14 | ReplayBindingService(pData) 15 | { 16 | } 17 | 18 | virtual ReplayBindingService *copy() { return NULL; } 19 | 20 | /// Web service operation 'GetServiceCapabilities' (returns error code or SOAP_OK) 21 | virtual int GetServiceCapabilities(_trp__GetServiceCapabilities *trp__GetServiceCapabilities, _trp__GetServiceCapabilitiesResponse *trp__GetServiceCapabilitiesResponse) { return SOAP_OK; } 22 | 23 | /// Web service operation 'GetReplayUri' (returns error code or SOAP_OK) 24 | virtual int GetReplayUri(_trp__GetReplayUri *trp__GetReplayUri, _trp__GetReplayUriResponse *trp__GetReplayUriResponse) { return SOAP_OK; } 25 | 26 | /// Web service operation 'GetReplayConfiguration' (returns error code or SOAP_OK) 27 | virtual int GetReplayConfiguration(_trp__GetReplayConfiguration *trp__GetReplayConfiguration, _trp__GetReplayConfigurationResponse *trp__GetReplayConfigurationResponse) { return SOAP_OK; } 28 | 29 | /// Web service operation 'SetReplayConfiguration' (returns error code or SOAP_OK) 30 | virtual int SetReplayConfiguration(_trp__SetReplayConfiguration *trp__SetReplayConfiguration, _trp__SetReplayConfigurationResponse *trp__SetReplayConfigurationResponse) { return SOAP_OK; } 31 | 32 | 33 | }; 34 | } // namespace Web 35 | #endif // ReplayServiceImpl 36 | -------------------------------------------------------------------------------- /common/sigrlog.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef SIGRLOG_H 3 | #define SIGRLOG_H 4 | 5 | #include "stdio.h" 6 | 7 | //====================================================== 8 | 9 | // need to set 10 | // 11 | // SIGRLOG_CURRLEVEL [0;4] 12 | // SIGRLOG_OUTPUT [1;3] 13 | // SIGRLOG_FILENAME "filename" 14 | 15 | //====================================================== 16 | 17 | typedef enum _SigrLogLevel 18 | { 19 | SIGRCRITICAL = 0, 20 | SIGRWARNING = 1, 21 | SIGRDEBUG0 = 2, 22 | SIGRDEBUG1 = 3, 23 | SIGRDEBUG2 = 4, 24 | SIGREND 25 | } SiglLogLevel; 26 | 27 | static const char * loglevel [SIGREND] = {"CRITICAL", "WARNING", "DEBUG0","DEBUG1","DEBUG2"}; 28 | 29 | #define SIGRLOG_CONSOLE 0x01 30 | #define SIGRLOG_LOGFILE 0x02 31 | 32 | #define SIGRLOG(level, fmt...)\ 33 | do {\ 34 | if(level <= SIGRLOG_CURRLEVEL && level < SIGREND)\ 35 | {\ 36 | if(SIGRLOG_OUTPUT & SIGRLOG_CONSOLE)\ 37 | {\ 38 | printf("SIGRLOG[%s]: ", loglevel[level]);\ 39 | printf(fmt);\ 40 | printf("\n");\ 41 | }\ 42 | if(SIGRLOG_OUTPUT & SIGRLOG_LOGFILE)\ 43 | {\ 44 | FILE * fp;\ 45 | fp = fopen(SIGRLOG_FILENAME,"a+");\ 46 | if(fp)\ 47 | {\ 48 | fprintf(fp, "SIGRLOG[%s]: ", loglevel[level]);\ 49 | fprintf(fp, fmt);\ 50 | fprintf(fp, "\n");\ 51 | }\ 52 | fclose(fp);\ 53 | }\ 54 | }\ 55 | }while(0) 56 | 57 | #define CHECKRETURN(nRes, str) \ 58 | do{\ 59 | if(nRes != 0) \ 60 | {\ 61 | SIGRLOG(SIGRWARNING, "%s failed!", str);\ 62 | return -1;\ 63 | }\ 64 | else\ 65 | {\ 66 | SIGRLOG(SIGRDEBUG2, "%s suceeded!", str);\ 67 | return 0;\ 68 | }\ 69 | }while(0) 70 | 71 | 72 | #endif // SIGRLOG_H 73 | -------------------------------------------------------------------------------- /examples/OnvifServer/OnvifTestServer.h: -------------------------------------------------------------------------------- 1 | #ifndef ONVIFTESTSERVER_H 2 | #define ONVIFTESTSERVER_H 3 | 4 | #include "OnvifSDK.h" 5 | 6 | class OnvifTestServer : public IOnvif 7 | { 8 | public: 9 | //===DEV============================== 10 | virtual int GetDateAndTime( /*out*/ DevGetSystemDateAndTimeResponse & ); 11 | virtual int SetDateAndTime( DevSetSystemDateAndTime & ){ return -1; } 12 | virtual int GetUsers( /*out*/ DevGetUsersResponse & ){ return -1; } 13 | //===DEVIO============================ 14 | virtual int GetVideoOutputs( /*out*/ DevIOGetVideoOutputsResponse & ){ return -1; } 15 | //===DISP============================= 16 | virtual int GetLayout( std::string &, /*out*/ DispGetLayoutResponse & ){ return -1; } 17 | virtual int GetDisplayOptions( const std::string &, DispGetDisplayOptionsResponse & ){ return -1; } 18 | virtual int SetLayout( /*out*/ DispSetLayout &){ return -1; } 19 | virtual int CreatePaneConfiguration( DispCreatePaneConfiguration &, /*out*/ DispCreatePaneConfigurationResponse & ){ return -1; } 20 | //===RECV============================= 21 | virtual int GetReceivers( RecvGetReceiversResponse & ){ return -1; } 22 | virtual int CreateReceiver( const std::string & uri, /*out*/ std::string & recvToken ){ return -1; } 23 | virtual int SetReceiverMode( const std::string & recvToken, bool bMode ){ return -1; } 24 | //===RECORDING========================= 25 | virtual int CreateRecording (RecCreateRecording &, RecCreateRecordingResponse &){ return -1; } 26 | virtual int CreateRecordingJob (RecCreateRecordingJob &, RecCreateRecordingJobResponse &){ return -1; } 27 | virtual int DeleteRecording (const std::string &){ return -1; } 28 | virtual int DeleteRecordingJob (const std::string &){ return -1; } 29 | }; 30 | 31 | #endif // ONVIFTESTSERVER_H 32 | -------------------------------------------------------------------------------- /OnvifSDK/source/DeviceClient.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "DeviceClient.h" 3 | 4 | namespace Web { 5 | DeviceClient::DeviceClient(const char * pchAdress, soap * s):m_proxy(s) 6 | { 7 | m_proxy.soap_endpoint = pchAdress; 8 | } 9 | 10 | DeviceClient::~DeviceClient() 11 | { 12 | 13 | } 14 | 15 | int DeviceClient::GetDateAndTime(DevGetSystemDateAndTimeResponse & resp) 16 | { 17 | DevGetSystemDateAndTime req(m_proxy.soap); 18 | 19 | int nRes = m_proxy.GetSystemDateAndTime(req.d, resp.d); 20 | 21 | CHECKRETURN(nRes, "DeviceClient::GetDateAndTime"); 22 | } 23 | 24 | 25 | int DeviceClient::SetDateAndTime(const DevSetSystemDateAndTime & req) 26 | { 27 | DevSetSystemDateAndTimeResponse resp(m_proxy.soap); 28 | 29 | int nRes = m_proxy.SetSystemDateAndTime(req.d, resp.d); 30 | 31 | CHECKRETURN(nRes, "DeviceClient::SetDateAndTime"); 32 | } 33 | /* 34 | int DeviceClient::GetDeviceInfo(DevGetDeviceInformationResponse & resp) 35 | { 36 | DevGetDeviceInformation req(&m_proxy); 37 | 38 | int nRes = m_proxy.GetDeviceInformation(req.d, resp.d); 39 | 40 | CHECKRETURN(nRes, "DeviceClient::GetDeviceInfo"); 41 | } 42 | 43 | int DeviceClient::GetCapabilities(DevGetCapabilitiesResponse & resp) 44 | { 45 | DevGetCapabilities req(&m_proxy); 46 | 47 | int nRes = m_proxy.GetCapabilities(req.d, resp.d); 48 | 49 | CHECKRETURN(nRes, "DeviceClient::GetDeviceInfo"); 50 | } 51 | */ 52 | 53 | int DeviceClient::GetUsers(DevGetUsersResponse & resp) 54 | { 55 | DevGetUsers req(m_proxy.soap); 56 | 57 | int nRes = m_proxy.GetUsers(req.d, resp.d); 58 | 59 | CHECKRETURN(nRes, "DeviceClient::GetUsers"); 60 | } 61 | 62 | int DeviceClient::GetServices(DevGetServicesResponse & resp) 63 | { 64 | DevGetServices req(m_proxy.soap); 65 | int nRes = m_proxy.GetServices(req.d, resp.d); 66 | 67 | CHECKRETURN(nRes, "DeviceClient::GetServices"); 68 | } 69 | } // namespace Web 70 | -------------------------------------------------------------------------------- /OnvifSDK/xml/patch.xslt: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /OnvifSDK/source/DisplayServiceImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "sigrlog.h" 2 | #include "DisplayServiceImpl.h" 3 | #include "BaseServer.h" 4 | 5 | namespace Web { 6 | DisplayBindingService *DisplayServiceImpl::copy() 7 | { 8 | return NULL; 9 | }; 10 | 11 | int DisplayServiceImpl::GetLayout(_tls__GetLayout *tls__GetLayout, _tls__GetLayoutResponse *tls__GetLayoutResponse) 12 | { 13 | 14 | DispGetLayout req(tls__GetLayout); 15 | DispGetLayoutResponse resp(tls__GetLayoutResponse); 16 | 17 | std::string requestedLayoutToken; 18 | req.GetLayout(requestedLayoutToken); 19 | 20 | 21 | int iRet = m_pBaseServer->GetLayout(requestedLayoutToken, resp); 22 | 23 | 24 | CHECKRETURN(iRet, "DisplayServiceImpl::GetLayout"); 25 | }; 26 | 27 | int DisplayServiceImpl::GetDisplayOptions(_tls__GetDisplayOptions *tls__GetDisplayOptions, _tls__GetDisplayOptionsResponse *tls__GetDisplayOptionsResponse) 28 | { 29 | DispGetDisplayOptions req(tls__GetDisplayOptions); 30 | DispGetDisplayOptionsResponse resp(tls__GetDisplayOptionsResponse); 31 | 32 | std::string VOToken; 33 | req.GetVO(VOToken); 34 | 35 | int iRet = m_pBaseServer->GetDisplayOptions(VOToken, resp); 36 | 37 | CHECKRETURN(iRet, "DisplayServiceImpl::GetDisplayOptions"); 38 | } 39 | 40 | int DisplayServiceImpl::SetLayout(_tls__SetLayout *tls__SetLayout, _tls__SetLayoutResponse *tls__SetLayoutResponse) 41 | { 42 | DispSetLayout req(tls__SetLayout); 43 | 44 | int iRet = m_pBaseServer->SetLayout(req); 45 | 46 | CHECKRETURN(iRet, "DisplayServiceImpl::SetLayout"); 47 | } 48 | 49 | int DisplayServiceImpl::CreatePaneConfiguration(_tls__CreatePaneConfiguration *tls__CreatePaneConfiguration, _tls__CreatePaneConfigurationResponse *tls__CreatePaneConfigurationResponse) 50 | { 51 | DispCreatePaneConfiguration req(tls__CreatePaneConfiguration); 52 | DispCreatePaneConfigurationResponse resp(tls__CreatePaneConfigurationResponse); 53 | 54 | int iRet = m_pBaseServer->CreatePaneConfiguration(req, resp); 55 | 56 | // FIXME NO RESP SETTING 57 | CHECKRETURN(iRet, "DisplayServiceImpl::CreatePaneConfiguration"); 58 | } 59 | } // namespace Web 60 | -------------------------------------------------------------------------------- /OnvifSDK/include/ReceiverServiceImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef WebReceiverBindingServiceImpl_H 2 | #define WebReceiverBindingServiceImpl_H 3 | 4 | #include "WebReceiverBindingService.h" 5 | class BaseServer; 6 | 7 | namespace Web { 8 | class ReceiverServiceImpl : public ReceiverBindingService 9 | { 10 | private: 11 | BaseServer * m_pBaseServer; 12 | public: 13 | ReceiverServiceImpl(BaseServer * pBaseServer, struct soap * pData):ReceiverBindingService(pData) 14 | { 15 | m_pBaseServer = pBaseServer; 16 | }; 17 | 18 | virtual ReceiverBindingService *copy(); 19 | 20 | /// Web service operation 'GetServiceCapabilities' (returns error code or SOAP_OK) 21 | virtual int GetServiceCapabilities(_trv__GetServiceCapabilities *trv__GetServiceCapabilities, _trv__GetServiceCapabilitiesResponse *trv__GetServiceCapabilitiesResponse) {return SOAP_OK;}; 22 | 23 | /// Web service operation 'GetReceivers' (returns error code or SOAP_OK) 24 | virtual int GetReceivers(_trv__GetReceivers *trv__GetReceivers, _trv__GetReceiversResponse *trv__GetReceiversResponse); 25 | 26 | /// Web service operation 'GetReceiver' (returns error code or SOAP_OK) 27 | virtual int GetReceiver(_trv__GetReceiver *trv__GetReceiver, _trv__GetReceiverResponse *trv__GetReceiverResponse) {return SOAP_OK;}; 28 | 29 | /// Web service operation 'CreateReceiver' (returns error code or SOAP_OK) 30 | virtual int CreateReceiver(_trv__CreateReceiver *trv__CreateReceiver, _trv__CreateReceiverResponse *trv__CreateReceiverResponse); 31 | 32 | /// Web service operation 'DeleteReceiver' (returns error code or SOAP_OK) 33 | virtual int DeleteReceiver(_trv__DeleteReceiver *trv__DeleteReceiver, _trv__DeleteReceiverResponse *trv__DeleteReceiverResponse) {return SOAP_OK;}; 34 | 35 | /// Web service operation 'ConfigureReceiver' (returns error code or SOAP_OK) 36 | virtual int ConfigureReceiver(_trv__ConfigureReceiver *trv__ConfigureReceiver, _trv__ConfigureReceiverResponse *trv__ConfigureReceiverResponse) {return SOAP_OK;}; 37 | 38 | /// Web service operation 'SetReceiverMode' (returns error code or SOAP_OK) 39 | virtual int SetReceiverMode(_trv__SetReceiverMode *trv__SetReceiverMode, _trv__SetReceiverModeResponse *trv__SetReceiverModeResponse); 40 | 41 | /// Web service operation 'GetReceiverState' (returns error code or SOAP_OK) 42 | virtual int GetReceiverState(_trv__GetReceiverState *trv__GetReceiverState, _trv__GetReceiverStateResponse *trv__GetReceiverStateResponse) {return SOAP_OK;}; 43 | }; 44 | } // namespace Web 45 | #endif // WebReceiverBindingServiceImpl_H 46 | -------------------------------------------------------------------------------- /OnvifSDK/include/BaseClient.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE_CLIENT__H 2 | #define BASE_CLIENT__H 3 | 4 | #include "sigrlog.h" 5 | #include "OnvifSDK.h" 6 | #include "stringGenerator.h" 7 | 8 | #include "DeviceClient.h" 9 | #include "DeviceIOClient.h" 10 | #include "DisplayClient.h" 11 | #include "ReceiverClient.h" 12 | #include "RecordingClient.h" 13 | 14 | #include "WsddLib.h" 15 | 16 | using namespace Web; 17 | 18 | class BaseClient: IOnvifClient 19 | { 20 | public: 21 | static IOnvifClient* Instance() 22 | { 23 | static BaseClient theSingleInstance; 24 | return &theSingleInstance; 25 | } 26 | 27 | ~BaseClient(); 28 | virtual int Init(const char* pchEndpoint); 29 | virtual std::vector GetDiscoveredDevices(); 30 | virtual soap* GetSoap(); 31 | 32 | //===DEV============================== 33 | virtual int GetDateAndTime( /*out*/ DevGetSystemDateAndTimeResponse & ); 34 | virtual int SetDateAndTime( DevSetSystemDateAndTime & ); 35 | virtual int GetUsers( /*out*/ DevGetUsersResponse & ); 36 | 37 | //===DEVIO============================ 38 | virtual int GetVideoOutputs( /*out*/ DevIOGetVideoOutputsResponse & ); 39 | 40 | //===DISP============================= 41 | virtual int GetLayout( std::string &, /*out*/ DispGetLayoutResponse & ); 42 | virtual int GetDisplayOptions( const std::string &, DispGetDisplayOptionsResponse & ); 43 | virtual int SetLayout( DispSetLayout &); 44 | virtual int CreatePaneConfiguration( DispCreatePaneConfiguration &, /*out*/ DispCreatePaneConfigurationResponse & ); 45 | 46 | //===RECV============================= 47 | virtual int GetReceivers( RecvGetReceiversResponse & ); 48 | virtual int CreateReceiver( const std::string & uri, /*out*/ std::string & recvToken ); 49 | virtual int SetReceiverMode( const std::string & recvToken, bool bMode ); 50 | //===RECORDING========================= 51 | virtual int CreateRecording (RecCreateRecording &, RecCreateRecordingResponse &); 52 | virtual int CreateRecordingJob (RecCreateRecordingJob &, RecCreateRecordingJobResponse &); 53 | virtual int DeleteRecording (const std::string &); 54 | virtual int DeleteRecordingJob (const std::string &); 55 | private: 56 | BaseClient(); 57 | BaseClient(const BaseClient&); 58 | BaseClient& operator=(const BaseClient&); 59 | 60 | soap* m_pSoap; 61 | DeviceClient* m_pDevClient; 62 | DeviceIOClient* m_pDevIOClient; 63 | DisplayClient* m_pDispClient; 64 | ReceiverClient* m_pRecvClient; 65 | RecordingClient* m_pRecordingClient; 66 | IWsdd * m_pWsdd; 67 | }; 68 | 69 | #endif // BASE_CLIENT__H 70 | -------------------------------------------------------------------------------- /OnvifSDK/include/BaseServer.h: -------------------------------------------------------------------------------- 1 | #ifndef BASESERVER_H 2 | #define BASESERVER_H 3 | 4 | #include "sigrlog.h" 5 | #include "OnvifSDK.h" 6 | #include "stringGenerator.h" 7 | #include "WsddLib.h" 8 | 9 | #include "DeviceServiceImpl.h" 10 | #include "DeviceIOServiceImpl.h" 11 | #include "DisplayServiceImpl.h" 12 | #include "ReceiverServiceImpl.h" 13 | #include "ReplayServiceImpl.h" 14 | #include "RecordingServiceImpl.h" 15 | #include "SearchServiceImpl.h" 16 | 17 | using namespace Web; 18 | 19 | class BaseServer : public IOnvifServer, 20 | public IOnvif 21 | { 22 | public: 23 | static IOnvifServer* Instance() 24 | { 25 | static BaseServer theSingleInstance; 26 | return &theSingleInstance; 27 | } 28 | 29 | virtual ~BaseServer(); 30 | virtual int Init(int iServicesToHost, int port, IOnvif* pHandler); 31 | virtual int Run(); 32 | 33 | //===DEV============================== 34 | virtual int GetDateAndTime( /*out*/ DevGetSystemDateAndTimeResponse & ); 35 | virtual int SetDateAndTime( DevSetSystemDateAndTime & ); 36 | virtual int GetUsers( /*out*/ DevGetUsersResponse & ); 37 | 38 | //===DEVIO============================ 39 | virtual int GetVideoOutputs( /*out*/ DevIOGetVideoOutputsResponse & ); 40 | 41 | //===DISP============================= 42 | virtual int GetLayout( std::string &, /*out*/ DispGetLayoutResponse & ); 43 | virtual int GetDisplayOptions( const std::string &, /*out*/ DispGetDisplayOptionsResponse & ); 44 | virtual int SetLayout( DispSetLayout &); 45 | virtual int CreatePaneConfiguration( DispCreatePaneConfiguration &, /*out*/ DispCreatePaneConfigurationResponse & ); 46 | 47 | //===RECV============================= 48 | virtual int GetReceivers( RecvGetReceiversResponse & ); 49 | virtual int CreateReceiver( const std::string & uri, /*out*/ std::string & recvToken ); 50 | virtual int SetReceiverMode( const std::string & recvToken, bool bMode ); 51 | //===RECORDING========================= 52 | virtual int CreateRecording (RecCreateRecording &, RecCreateRecordingResponse &); 53 | virtual int CreateRecordingJob (RecCreateRecordingJob &, RecCreateRecordingJobResponse &); 54 | virtual int DeleteRecording (const std::string &); 55 | virtual int DeleteRecordingJob (const std::string &); 56 | 57 | private: 58 | BaseServer(); 59 | BaseServer(const BaseServer&); 60 | BaseServer& operator=(const BaseServer&); 61 | virtual int RunWsDiscovery(); 62 | 63 | bool m_bCreated; 64 | int m_iPort; 65 | struct soap * m_pSoap; 66 | DeviceServiceImpl * m_DevService; 67 | DeviceIOServiceImpl * m_DevIOService; 68 | DisplayServiceImpl * m_DispService; 69 | ReceiverServiceImpl * m_RecvService; 70 | ReplayServiceImpl * m_ReplayService; 71 | RecordingServiceImpl * m_RecordService; 72 | SearchServiceImpl * m_SearchService; 73 | IWsdd* m_pWsdd; 74 | IOnvif* m_pHandler; 75 | }; 76 | 77 | #endif // BASESERVER_H 78 | -------------------------------------------------------------------------------- /OnvifSDK/WsDiscovery/onvifxx.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ONVIFXX_H 2 | #define ONVIFXX_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define UNUSED(x) (void)x 10 | 11 | struct soap; 12 | 13 | #if __GNUC_MINOR__ < 6 14 | #define noexcept throw() 15 | 16 | const class { // this is a const object... 17 | public: 18 | template // convertible to any type 19 | operator T*() const // of null non-member 20 | { return 0; } // pointer... 21 | template // or any type of null 22 | operator T C::*() const // member pointer... 23 | { return 0; } 24 | private: 25 | void operator&() const; // whose address can't be taken 26 | } nullptr = {}; // and whose name is nullptr 27 | #endif 28 | 29 | class Exception : public std::exception 30 | { 31 | public: 32 | Exception(); 33 | Exception(const char * msg); 34 | virtual ~Exception() throw(); 35 | virtual const char * what() const throw(); 36 | 37 | protected: 38 | std::string & message(); 39 | 40 | private: 41 | std::string msg_; 42 | 43 | }; 44 | 45 | class SoapException : public Exception 46 | { 47 | public: 48 | SoapException(soap * s); 49 | 50 | int code() const; 51 | 52 | private: 53 | int code_; 54 | }; 55 | 56 | class UnixException : public Exception 57 | { 58 | public: 59 | UnixException(int code = 0); 60 | 61 | int code() const; 62 | 63 | private: 64 | int code_; 65 | }; 66 | 67 | template 68 | struct Proxy : T 69 | { 70 | virtual ~Proxy() 71 | { 72 | } 73 | }; 74 | 75 | template 76 | struct Service 77 | { 78 | virtual ~Service() {} 79 | 80 | virtual soap* getSoap() = 0; 81 | 82 | virtual int bind(T * obj, int port = 0) = 0; 83 | virtual int accept() = 0; 84 | virtual int serve() = 0; 85 | virtual void destroy() = 0; 86 | }; 87 | 88 | template 89 | struct BaseService : Service, I 90 | { 91 | T * p; 92 | 93 | BaseService() 94 | { 95 | p = NULL; 96 | } 97 | 98 | virtual int bind(T * obj, int port) 99 | { 100 | p = obj; 101 | if (port == 0) 102 | port = 80; 103 | return I::bind(NULL, port, 100); 104 | } 105 | 106 | virtual int serve() 107 | { 108 | return I::serve(); 109 | } 110 | 111 | virtual int accept() 112 | { 113 | return I::accept(); 114 | } 115 | 116 | virtual void destroy() 117 | { 118 | I::destroy(); 119 | } 120 | }; 121 | 122 | //template 123 | //class Pimpl 124 | //{ 125 | //public: 126 | // Pimpl() : p_(new T) { } 127 | // T * impl() { return p_.get(); } 128 | //private: 129 | // std::shared_ptr p_; 130 | //}; 131 | 132 | #endif //ONVIFXX_H 133 | -------------------------------------------------------------------------------- /OnvifSDK/source/DeviceServiceImpl.cpp: -------------------------------------------------------------------------------- 1 | #include "sigrlog.h" 2 | #include "DeviceServiceImpl.h" 3 | #include "BaseServer.h" 4 | 5 | namespace Web { 6 | int DeviceServiceImpl::GetSystemDateAndTime(_tds__GetSystemDateAndTime *tds__GetSystemDateAndTime, _tds__GetSystemDateAndTimeResponse *tds__GetSystemDateAndTimeResponse) 7 | { 8 | DevGetSystemDateAndTimeResponse dt(tds__GetSystemDateAndTimeResponse); 9 | 10 | int nRes = m_pBaseServer->GetDateAndTime(dt); 11 | 12 | CHECKRETURN(nRes, "DeviceServiceImpl::GetSystemDateAndTime"); 13 | }; 14 | 15 | // for while not supporting copy 16 | DeviceBindingService* DeviceServiceImpl::copy() 17 | { 18 | return NULL; 19 | }; 20 | 21 | int DeviceServiceImpl::SetSystemDateAndTime(_tds__SetSystemDateAndTime *tds__SetSystemDateAndTime, _tds__SetSystemDateAndTimeResponse *tds__SetSystemDateAndTimeResponse) 22 | { 23 | if(tds__SetSystemDateAndTime->DateTimeType != tt__SetDateTimeType__Manual) 24 | { 25 | SIGRLOG(SIGRWARNING, "DeviceServiceImpl::SetSystemDateAndTime Time is not Manual"); 26 | return SOAP_ERR; 27 | } 28 | 29 | DevSetSystemDateAndTime dt(tds__SetSystemDateAndTime); 30 | 31 | int nRes = m_pBaseServer->SetDateAndTime(dt); 32 | 33 | CHECKRETURN(nRes, "DeviceServiceImpl::SetSystemDateAndTime"); 34 | } 35 | 36 | int DeviceServiceImpl::GetCapabilities(_tds__GetCapabilities *tds__GetCapabilities, _tds__GetCapabilitiesResponse *tds__GetCapabilitiesResponse) 37 | { 38 | DevGetCapabilitiesResponse resp(tds__GetCapabilitiesResponse); 39 | 40 | resp.SetCapsDevice(OnvifDeviceServiceXAddr); 41 | 42 | return SOAP_OK; 43 | } 44 | 45 | int DeviceServiceImpl::GetDeviceInformation(_tds__GetDeviceInformation *tds__GetDeviceInformation, _tds__GetDeviceInformationResponse *tds__GetDeviceInformationResponse) 46 | { 47 | DevGetDeviceInformationResponse resp(tds__GetDeviceInformationResponse); 48 | 49 | resp.SetDeviceInfo(std::string(OnvifManufacturer), std::string(OnvifModel), 50 | std::string(OnvifFirmwareVersion), std::string(OnvifSerialNumber), std::string(OnvifHardwareId)); 51 | 52 | return SOAP_OK; 53 | } 54 | 55 | int DeviceServiceImpl::GetUsers(_tds__GetUsers *tds__GetUsers, _tds__GetUsersResponse *tds__GetUsersResponse) 56 | { 57 | DevGetUsersResponse resp(tds__GetUsersResponse); 58 | 59 | int nRes = m_pBaseServer->GetUsers(resp); 60 | 61 | CHECKRETURN(nRes, "DeviceServiceImpl::GetUsers"); 62 | } 63 | 64 | int DeviceServiceImpl::GetServices(_tds__GetServices *tds__GetServices, _tds__GetServicesResponse *tds__GetServicesResponse) 65 | { 66 | DevGetServices req(tds__GetServices); 67 | DevGetServicesResponse resp(tds__GetServicesResponse); 68 | 69 | 70 | if(req.d->IncludeCapability) 71 | SIGRLOG(SIGRWARNING, "DeviceServiceImpl::GetServices 'Including Capabilities' still not implemented"); 72 | 73 | std::string strNameSpace("dev"); 74 | std::string xaddr("192.168.10.23"); 75 | resp.AddService(strNameSpace, xaddr); 76 | 77 | 78 | return 0; 79 | } 80 | } // namespace Web 81 | -------------------------------------------------------------------------------- /OnvifSDK/include/DisplayServiceImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef WebDisplayBindingServiceImpl_H 2 | #define WebDisplayBindingServiceImpl_H 3 | 4 | #include "WebDisplayBindingService.h" 5 | class BaseServer; 6 | 7 | namespace Web { 8 | class DisplayServiceImpl : public DisplayBindingService 9 | { 10 | private: 11 | BaseServer * m_pBaseServer; 12 | public: 13 | DisplayServiceImpl(BaseServer * pBaseServer, struct soap* pData):DisplayBindingService(pData) 14 | { 15 | m_pBaseServer = pBaseServer; 16 | }; 17 | 18 | virtual DisplayBindingService * copy(); 19 | 20 | /// Web service operation 'GetServiceCapabilities' (returns error code or SOAP_OK) 21 | virtual int GetServiceCapabilities(_tls__GetServiceCapabilities *tls__GetServiceCapabilities, _tls__GetServiceCapabilitiesResponse *tls__GetServiceCapabilitiesResponse) {return SOAP_OK;}; 22 | 23 | /// Web service operation 'GetLayout' (returns error code or SOAP_OK) 24 | virtual int GetLayout(_tls__GetLayout *tls__GetLayout, _tls__GetLayoutResponse *tls__GetLayoutResponse); 25 | 26 | /// Web service operation 'SetLayout' (returns error code or SOAP_OK) 27 | virtual int SetLayout(_tls__SetLayout *tls__SetLayout, _tls__SetLayoutResponse *tls__SetLayoutResponse); 28 | 29 | /// Web service operation 'GetDisplayOptions' (returns error code or SOAP_OK) 30 | virtual int GetDisplayOptions(_tls__GetDisplayOptions *tls__GetDisplayOptions, _tls__GetDisplayOptionsResponse *tls__GetDisplayOptionsResponse); 31 | 32 | /// Web service operation 'GetPaneConfigurations' (returns error code or SOAP_OK) 33 | virtual int GetPaneConfigurations(_tls__GetPaneConfigurations *tls__GetPaneConfigurations, _tls__GetPaneConfigurationsResponse *tls__GetPaneConfigurationsResponse) {return SOAP_OK;}; 34 | 35 | /// Web service operation 'GetPaneConfiguration' (returns error code or SOAP_OK) 36 | virtual int GetPaneConfiguration(_tls__GetPaneConfiguration *tls__GetPaneConfiguration, _tls__GetPaneConfigurationResponse *tls__GetPaneConfigurationResponse) {return SOAP_OK;}; 37 | 38 | /// Web service operation 'SetPaneConfigurations' (returns error code or SOAP_OK) 39 | virtual int SetPaneConfigurations(_tls__SetPaneConfigurations *tls__SetPaneConfigurations, _tls__SetPaneConfigurationsResponse *tls__SetPaneConfigurationsResponse) {return SOAP_OK;}; 40 | 41 | /// Web service operation 'SetPaneConfiguration' (returns error code or SOAP_OK) 42 | virtual int SetPaneConfiguration(_tls__SetPaneConfiguration *tls__SetPaneConfiguration, _tls__SetPaneConfigurationResponse *tls__SetPaneConfigurationResponse) {return SOAP_OK;}; 43 | 44 | /// Web service operation 'CreatePaneConfiguration' (returns error code or SOAP_OK) 45 | virtual int CreatePaneConfiguration(_tls__CreatePaneConfiguration *tls__CreatePaneConfiguration, _tls__CreatePaneConfigurationResponse *tls__CreatePaneConfigurationResponse); 46 | 47 | /// Web service operation 'DeletePaneConfiguration' (returns error code or SOAP_OK) 48 | virtual int DeletePaneConfiguration(_tls__DeletePaneConfiguration *tls__DeletePaneConfiguration, _tls__DeletePaneConfigurationResponse *tls__DeletePaneConfigurationResponse) {return SOAP_OK;}; 49 | 50 | }; 51 | } // namespace Web 52 | #endif // WebDisplayBindingServiceImpl_H 53 | 54 | -------------------------------------------------------------------------------- /OnvifSDK/source/RecordingTypes.cpp: -------------------------------------------------------------------------------- 1 | #include "OnvifSDK.h" 2 | #include "commonTypes.h" 3 | #include "WebRecordingBindingProxy.h" 4 | 5 | namespace Web { 6 | #define EXTRA_CONSTRUCT() \ 7 | {\ 8 | if (d->RecordingConfiguration != NULL) \ 9 | return; \ 10 | d->RecordingConfiguration = soap_new_tt__RecordingConfiguration (d->soap); \ 11 | d->RecordingConfiguration->Source = soap_new_tt__RecordingSourceInformation (d->soap); \ 12 | } 13 | 14 | CLASS_CTORS(trc, Rec, CreateRecording) 15 | 16 | void 17 | RecCreateRecording::setSource (const std::string & id, const std::string & address) 18 | { 19 | d->RecordingConfiguration->Source->SourceId = id; 20 | d->RecordingConfiguration->Source->Address = address; 21 | } 22 | 23 | void 24 | RecCreateRecording::getSource (std::string & id, std::string & address) const 25 | { 26 | id = d->RecordingConfiguration->Source->SourceId; 27 | address = d->RecordingConfiguration->Source->Address; 28 | } 29 | 30 | #define EXTRA_CONSTRUCT() {} 31 | 32 | CLASS_CTORS(trc, Rec, CreateRecordingResponse) 33 | 34 | const std::string & 35 | RecCreateRecordingResponse::getToken() const { return d->RecordingToken; } 36 | 37 | void 38 | RecCreateRecordingResponse::setToken (const std::string & str) { d->RecordingToken = str; } 39 | 40 | ///////////////////////////////////////////////////////////////////////////////////// 41 | CLASS_CTORS(trc, Rec, DeleteRecording) 42 | 43 | const std::string & 44 | RecDeleteRecording::getToken() const { return d->RecordingToken; } 45 | 46 | void 47 | RecDeleteRecording::setToken (const std::string & str) { d->RecordingToken = str; } 48 | 49 | CLASS_CTORS(trc, Rec, DeleteRecordingResponse) 50 | ///////////////////////////////////////////////////////////////////////////////////// 51 | #define EXTRA_CONSTRUCT() \ 52 | {\ 53 | if (d->JobConfiguration != NULL) \ 54 | return; \ 55 | d->JobConfiguration = soap_new_tt__RecordingJobConfiguration( d->soap ); \ 56 | d->JobConfiguration->Source.push_back( soap_new_tt__RecordingJobSource( d->soap ) ); \ 57 | d->JobConfiguration->Source[0]->SourceToken = NULL; \ 58 | d->JobConfiguration->Source[0]->AutoCreateReceiver = new bool[1]; \ 59 | } 60 | 61 | CLASS_CTORS(trc, Rec, CreateRecordingJob) 62 | 63 | const std::string & 64 | RecCreateRecordingJob::getRecording() const { return d->JobConfiguration->RecordingToken; } 65 | void 66 | RecCreateRecordingJob::setRecording(const std::string & token) { d->JobConfiguration->RecordingToken = token; } 67 | bool 68 | RecCreateRecordingJob::getMode() const { return d->JobConfiguration->Mode == "Active"; } 69 | void 70 | RecCreateRecordingJob::setMode(bool b) { d->JobConfiguration->Mode = b ? "Active" : "Idle"; } 71 | 72 | #define EXTRA_CONSTRUCT() {} 73 | CLASS_CTORS(trc, Rec, CreateRecordingJobResponse) 74 | 75 | const std::string & 76 | RecCreateRecordingJobResponse::getToken() const { return d->JobToken; } 77 | void 78 | RecCreateRecordingJobResponse::setToken (const std::string & str) { d->JobToken = str; } 79 | 80 | ///////////////////////////////////////////////////////////////////////////////////// 81 | CLASS_CTORS(trc, Rec, DeleteRecordingJob) 82 | 83 | const std::string & 84 | RecDeleteRecordingJob::getToken() const { return d->JobToken; } 85 | 86 | void 87 | RecDeleteRecordingJob::setToken (const std::string & str) { d->JobToken = str; } 88 | 89 | CLASS_CTORS(trc, Rec, DeleteRecordingJobResponse) 90 | ///////////////////////////////////////////////////////////////////////////////////// 91 | } // namespace Web 92 | -------------------------------------------------------------------------------- /OnvifSDK/gen/include/duration.h: -------------------------------------------------------------------------------- 1 | /* 2 | duration.h 3 | 4 | Custom serializer for xsd:duration stored in a LONG64 with ms precision 5 | - a LONG64 int can represent 106751991167 days forward and backward 6 | - LONG64 is long long int under Unix/Linux 7 | - millisecond resolution (1/1000 sec) means 1 second = 1000 8 | - when adding to a time_t value, conversion may be needed since time_t 9 | may (or may) not have seconds resolution 10 | - durations longer than a month are always output in days, rather than 11 | months to avoid days-per-month conversion inacurracies 12 | - durations expressed in years and months are not well defined, since 13 | there is no reference starting time; the decoder assumes 30 days per 14 | month and conversion of P4M gives 120 days and therefore the duration 15 | P4M and P120D are assumed identical, while they should give different 16 | results depending on the reference starting time 17 | 18 | #import this file into your gSOAP .h file 19 | 20 | To automate the wsdl2h-mapping of xsd:dateTime to struct tm, add this 21 | line to the typemap.dat file: 22 | 23 | xsd__duration = #import "custom/duration.h" | xsd__duration 24 | 25 | The typemap.dat file is used by wsdl2h to map types (wsdl2h option -t). 26 | 27 | Compile and link your code with custom/duration.c 28 | 29 | gSOAP XML Web services tools 30 | Copyright (C) 2000-2009, Robert van Engelen, Genivia Inc., All Rights Reserved. 31 | This part of the software is released under ONE of the following licenses: 32 | GPL, the gSOAP public license, OR Genivia's license for commercial use. 33 | -------------------------------------------------------------------------------- 34 | gSOAP public license. 35 | 36 | The contents of this file are subject to the gSOAP Public License Version 1.3 37 | (the "License"); you may not use this file except in compliance with the 38 | License. You may obtain a copy of the License at 39 | http://www.cs.fsu.edu/~engelen/soaplicense.html 40 | Software distributed under the License is distributed on an "AS IS" basis, 41 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 42 | for the specific language governing rights and limitations under the License. 43 | 44 | The Initial Developer of the Original Code is Robert A. van Engelen. 45 | Copyright (C) 2000-2009, Robert van Engelen, Genivia, Inc., All Rights Reserved. 46 | -------------------------------------------------------------------------------- 47 | GPL license. 48 | 49 | This program is free software; you can redistribute it and/or modify it under 50 | the terms of the GNU General Public License as published by the Free Software 51 | Foundation; either version 2 of the License, or (at your option) any later 52 | version. 53 | 54 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 55 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 56 | PARTICULAR PURPOSE. See the GNU General Public License for more details. 57 | 58 | You should have received a copy of the GNU General Public License along with 59 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 60 | Place, Suite 330, Boston, MA 02111-1307 USA 61 | 62 | Author contact information: 63 | engelen@genivia.com / engelen@acm.org 64 | 65 | This program is released under the GPL with the additional exemption that 66 | compiling, linking, and/or using OpenSSL is allowed. 67 | -------------------------------------------------------------------------------- 68 | A commercial use license is available from Genivia, Inc., contact@genivia.com 69 | -------------------------------------------------------------------------------- 70 | */ 71 | 72 | extern typedef long long xsd__duration; /* duration in ms (1/1000 sec) */ 73 | -------------------------------------------------------------------------------- /OnvifSDK/source/ReceiverTypes.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "OnvifSDK.h" 3 | #include "commonTypes.h" 4 | #include "WebReceiverBindingProxy.h" 5 | 6 | namespace Web { 7 | #define EXTRA_CONSTRUCT() \ 8 | {\ 9 | } 10 | 11 | CLASS_CTORS(trv, Recv, GetReceivers) 12 | CLASS_CTORS(trv, Recv, GetReceiversResponse) 13 | 14 | int RecvGetReceiversResponse::SetReceivers(std::string & str) 15 | { 16 | tt__Receiver * recv = soap_new_tt__Receiver(this->d->soap, -1); 17 | 18 | recv->Token = str; 19 | 20 | this->d->Receivers.push_back(recv); 21 | 22 | return 0; 23 | } 24 | 25 | int RecvGetReceiversResponse::GetReceivers(std::string & str) const 26 | { 27 | str = this->d->Receivers[0]->Token; 28 | 29 | return 0; 30 | } 31 | 32 | //////////////////////////////////////////////////////////////////////////////// 33 | #define EXTRA_CONSTRUCT() \ 34 | {\ 35 | if(d->Configuration == NULL)\ 36 | {\ 37 | d->Configuration = soap_new_tt__ReceiverConfiguration( d->soap );\ 38 | d->Configuration->StreamSetup = soap_new_tt__StreamSetup( d->soap );\ 39 | d->Configuration->StreamSetup->Transport = soap_new_tt__Transport( d->soap );\ 40 | d->Configuration->StreamSetup->Stream = tt__StreamType__RTP_Unicast;\ 41 | d->Configuration->StreamSetup->Transport->Protocol = tt__TransportProtocol__RTSP;\ 42 | }\ 43 | } 44 | 45 | CLASS_CTORS(trv, Recv, CreateReceiver) 46 | 47 | bool RecvCreateReceiver::getMode() const 48 | { 49 | return d->Configuration->Mode == tt__ReceiverMode__AlwaysConnect; 50 | } 51 | 52 | void RecvCreateReceiver::setMode( bool bMode) 53 | { 54 | if(bMode) 55 | d->Configuration->Mode = tt__ReceiverMode__AlwaysConnect; 56 | else 57 | d->Configuration->Mode = tt__ReceiverMode__NeverConnect; 58 | } 59 | 60 | std::string RecvCreateReceiver::getUri() const 61 | { 62 | return d->Configuration->MediaUri; 63 | } 64 | void RecvCreateReceiver::setUri( const std::string & str ) 65 | { 66 | d->Configuration->MediaUri = str; 67 | } 68 | 69 | #define EXTRA_CONSTRUCT() \ 70 | {\ 71 | if(d->Receiver == NULL)\ 72 | {\ 73 | d->Receiver = soap_new_tt__Receiver( d->soap );\ 74 | d->Receiver->Configuration = soap_new_tt__ReceiverConfiguration( d->soap );\ 75 | d->Receiver->Configuration->StreamSetup = soap_new_tt__StreamSetup( d->soap );\ 76 | d->Receiver->Configuration->StreamSetup->Transport = soap_new_tt__Transport( d->soap );\ 77 | d->Receiver->Configuration->StreamSetup->Stream = tt__StreamType__RTP_Unicast;\ 78 | d->Receiver->Configuration->StreamSetup->Transport->Protocol = tt__TransportProtocol__RTSP;\ 79 | }\ 80 | } 81 | 82 | CLASS_CTORS(trv, Recv, CreateReceiverResponse) 83 | 84 | void RecvCreateReceiverResponse::setToken( const std::string & str ) 85 | { 86 | d->Receiver->Token = str; 87 | } 88 | 89 | std::string RecvCreateReceiverResponse::getToken() const 90 | { 91 | return d->Receiver->Token; 92 | } 93 | 94 | //////////////////////////////////////////////////////////////////////////////// 95 | #define EXTRA_CONSTRUCT() \ 96 | {\ 97 | } 98 | 99 | CLASS_CTORS(trv, Recv, SetReceiverMode) 100 | CLASS_CTORS(trv, Recv, SetReceiverModeResponse) 101 | 102 | bool RecvSetReceiverMode::getMode() const 103 | { 104 | return d->Mode == tt__ReceiverMode__AlwaysConnect; 105 | } 106 | 107 | std::string RecvSetReceiverMode::getToken() const 108 | { 109 | return d->ReceiverToken; 110 | } 111 | 112 | void RecvSetReceiverMode::setMode( bool bMode) 113 | { 114 | if(bMode) 115 | d->Mode = tt__ReceiverMode__AlwaysConnect; 116 | else 117 | d->Mode = tt__ReceiverMode__NeverConnect; 118 | } 119 | 120 | void RecvSetReceiverMode::setToken( const std::string & str) 121 | { 122 | d->ReceiverToken = str; 123 | } 124 | } // namespace Web 125 | -------------------------------------------------------------------------------- /OnvifSDK/WsDiscovery/wsa.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ONVIFXX_WSDD_HPP 2 | #define ONVIFXX_WSDD_HPP 3 | 4 | #if defined(SOAP_WSA_2003) 5 | # define SOAP_WSA(member) wsa3__##member 6 | # define SOAP_WSA_(prefix,member) prefix##_wsa3__##member 7 | # define SOAP_WSA__(prefix,member) prefix##wsa3__##member 8 | #elif defined(SOAP_WSA_2004) 9 | # define SOAP_WSA(member) wsa4__##member 10 | # define SOAP_WSA_(prefix,member) prefix##_wsa4__##member 11 | # define SOAP_WSA__(prefix,member) prefix##wsa4__##member 12 | #elif defined(SOAP_WSA_2005) 13 | # define SOAP_WSA(member) wsa5__##member 14 | # define SOAP_WSA_(prefix,member) prefix##_wsa5__##member 15 | # define SOAP_WSA__(prefix,member) prefix##wsa5__##member 16 | #else 17 | # define SOAP_WSA(member) wsa__##member 18 | # define SOAP_WSA_(prefix,member) prefix##_wsa__##member 19 | # define SOAP_WSA__(prefix,member) prefix##wsa__##member 20 | #endif 21 | 22 | #include 23 | #include 24 | 25 | class Wsa 26 | { 27 | public: 28 | Wsa(struct soap * soap); 29 | ~Wsa(); 30 | 31 | static uint & instanceId(); 32 | static std::string & sequenceId(); 33 | static uint & messageNumber(); 34 | 35 | std::string randUuid(); 36 | 37 | int allocHeader(); 38 | int check() const; 39 | 40 | int addFrom(const std::string & from); 41 | int addNoReply(); 42 | int addReplyTo(const std::string & replyTo); 43 | int addFaultTo(const std::string & faultTo); 44 | int addRelatesTo(const std::string & relatesTo); 45 | int addAppSequence(std::string * id = NULL); 46 | 47 | int reply(const std::string & id, const std::string & action); 48 | int request(const std::string & to, const std::string & action); 49 | 50 | 51 | template 52 | class Request : public T 53 | { 54 | public: 55 | template 56 | Request(struct soap * soap, const P & arg) 57 | { 58 | T::soap_default(soap); 59 | T::Types = arg.types; 60 | T::XAddrs = arg.xaddrs; 61 | 62 | if (arg.scopes != NULL) { 63 | T::Scopes = &scopes_; 64 | T::Scopes->soap_default(soap); 65 | T::Scopes->__item = arg.scopes->item; 66 | T::Scopes->MatchBy = arg.scopes->matchBy; 67 | } 68 | 69 | if (arg.endpoint != NULL) { 70 | T::wsa__EndpointReference = &endpoint_; 71 | T::wsa__EndpointReference->soap_default(soap); 72 | if (arg.endpoint->address != NULL) { 73 | T::wsa__EndpointReference->Address = &address_; 74 | T::wsa__EndpointReference->Address->soap_default(soap); 75 | T::wsa__EndpointReference->Address->__item = *arg.endpoint->address; 76 | } 77 | if (arg.endpoint->portType != NULL) { 78 | T::wsa__EndpointReference->PortType = &port_; 79 | T::wsa__EndpointReference->PortType->soap_default(soap); 80 | T::wsa__EndpointReference->PortType->__item = *arg.endpoint->portType; 81 | } 82 | 83 | if (arg.endpoint->serviceName != NULL) { 84 | T::wsa__EndpointReference->ServiceName = &service_; 85 | T::wsa__EndpointReference->ServiceName->soap_default(soap); 86 | T::wsa__EndpointReference->ServiceName->__item = arg.endpoint->serviceName->item; 87 | T::wsa__EndpointReference->ServiceName->PortName = arg.endpoint->serviceName->portName; 88 | } 89 | } 90 | } 91 | 92 | private: 93 | wsd__ScopesType scopes_; 94 | wsa__EndpointReferenceType endpoint_; 95 | wsa__AttributedURI address_; 96 | wsa__AttributedQName port_; 97 | wsa__ServiceNameType service_; 98 | }; 99 | 100 | private: 101 | soap * soap_; 102 | wsd__AppSequenceType sequence_; 103 | }; 104 | #endif // ONVIFXX_WSDD_HPP 105 | -------------------------------------------------------------------------------- /OnvifSDK/source/BaseClient.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "BaseClient.h" 3 | 4 | IOnvifClient* getOnvifClient() 5 | { 6 | return BaseClient::Instance(); 7 | } 8 | 9 | BaseClient::BaseClient(): 10 | m_pSoap (soap_new()), 11 | m_pWsdd (getWsdd()) 12 | { 13 | } 14 | 15 | BaseClient::~BaseClient() 16 | { 17 | if (m_pDevClient) 18 | delete m_pDevClient; 19 | if (m_pDevIOClient) 20 | delete m_pDevIOClient; 21 | if (m_pDispClient) 22 | delete m_pDispClient; 23 | if (m_pRecvClient) 24 | delete m_pRecvClient; 25 | 26 | if(m_pSoap) 27 | { 28 | soap_destroy(m_pSoap); 29 | soap_end(m_pSoap); 30 | soap_free(m_pSoap); 31 | } 32 | } 33 | 34 | soap* BaseClient::GetSoap() 35 | { 36 | return m_pSoap; 37 | } 38 | 39 | 40 | int BaseClient::Init(const char* pchEndpoint) 41 | { 42 | if(!m_pSoap || !m_pWsdd) 43 | return -1; 44 | 45 | m_pWsdd->start(false); 46 | 47 | m_pDevClient = new DeviceClient (pchEndpoint, m_pSoap); 48 | m_pDevIOClient = new DeviceIOClient (pchEndpoint, m_pSoap); 49 | m_pDispClient = new DisplayClient (pchEndpoint, m_pSoap); 50 | m_pRecvClient = new ReceiverClient (pchEndpoint, m_pSoap); 51 | m_pRecordingClient = new RecordingClient (pchEndpoint, m_pSoap); 52 | 53 | return m_pDevClient && m_pDevClient && m_pDispClient && m_pRecvClient ? 0 : -1; 54 | } 55 | 56 | std::vector BaseClient::GetDiscoveredDevices() 57 | { 58 | return m_pWsdd->getMembers(); 59 | } 60 | 61 | int BaseClient::GetDateAndTime(DevGetSystemDateAndTimeResponse & r) 62 | { 63 | return m_pDevClient->GetDateAndTime(r); 64 | } 65 | 66 | int BaseClient::SetDateAndTime( DevSetSystemDateAndTime & r) 67 | { 68 | return m_pDevClient->SetDateAndTime(r); 69 | } 70 | 71 | int BaseClient::GetUsers(DevGetUsersResponse & r) 72 | { 73 | return m_pDevClient->GetUsers(r); 74 | } 75 | 76 | //int BaseClient::GetServices(DevGetServicesResponse &r) 77 | //{ 78 | // return m_pDevClient->GetServices(r); 79 | //} 80 | 81 | int BaseClient::GetVideoOutputs(DevIOGetVideoOutputsResponse & r) 82 | { 83 | return m_pDevIOClient->GetVideoOutputs(r); 84 | } 85 | 86 | int BaseClient::GetLayout( std::string & token, DispGetLayoutResponse & resp) 87 | { 88 | DispGetLayout req(m_pSoap); 89 | req.SetLayout(token); 90 | return m_pDispClient->GetLayout(req, resp); 91 | } 92 | 93 | int BaseClient::GetDisplayOptions(const std::string & voToken, DispGetDisplayOptionsResponse & resp) 94 | { 95 | DispGetDisplayOptions req(m_pSoap); 96 | req.SetVO(voToken); 97 | return m_pDispClient->GetDisplayOptions(req, resp); 98 | } 99 | 100 | int BaseClient::SetLayout(DispSetLayout & r) 101 | { 102 | return m_pDispClient->SetLayout(r); 103 | } 104 | 105 | int BaseClient::CreatePaneConfiguration(DispCreatePaneConfiguration & req, DispCreatePaneConfigurationResponse & resp) 106 | { 107 | return m_pDispClient->CreatePaneConfiguration(req, resp); 108 | } 109 | 110 | int BaseClient::GetReceivers( RecvGetReceiversResponse & r) 111 | { 112 | return m_pRecvClient->GetReceivers(r); 113 | } 114 | 115 | int BaseClient::CreateReceiver(const std::string & uri, std::string & recvToken ) 116 | { 117 | return m_pRecvClient->CreateReceiver( uri, recvToken); 118 | } 119 | 120 | int BaseClient::SetReceiverMode( const std::string & recvToken, bool bMode ) 121 | { 122 | return m_pRecvClient->SetReceiverMode(recvToken, bMode); 123 | } 124 | 125 | int BaseClient::CreateRecording (RecCreateRecording & req, RecCreateRecordingResponse & resp) 126 | { 127 | return m_pRecordingClient->CreateRecording(req, resp); 128 | } 129 | 130 | int BaseClient::CreateRecordingJob (RecCreateRecordingJob & req, RecCreateRecordingJobResponse & resp) 131 | { 132 | return m_pRecordingClient->CreateRecordingJob(req, resp); 133 | } 134 | 135 | int BaseClient::DeleteRecording (const std::string &s) 136 | { 137 | return m_pRecordingClient->DeleteRecording(s); 138 | } 139 | 140 | int BaseClient::DeleteRecordingJob (const std::string &s) 141 | { 142 | return m_pRecordingClient->DeleteRecordingJob(s); 143 | } 144 | -------------------------------------------------------------------------------- /OnvifSDK/cmake/FindGSOAP.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # This module detects if gsoap is installed and determines where the 3 | # include files and libraries are. 4 | # 5 | # This code sets the following variables: 6 | # 7 | # GSOAP_IMPORT_DIR = full path to the gsoap import directory 8 | # GSOAP_LIBRARIES = full path to the gsoap libraries 9 | # GSOAP_SSL_LIBRARIES = full path to the gsoap ssl libraries 10 | # GSOAP_INCLUDE_DIR = include dir to be used when using the gsoap library 11 | # GSOAP_WSDL2H = wsdl2h binary 12 | # GSOAP_SOAPCPP2 = soapcpp2 binary 13 | # GSOAP_FOUND = set to true if gsoap was found successfully 14 | # 15 | # GSOAP_ROOT 16 | # setting this enables search for gsoap libraries / headers in this location 17 | 18 | # ----------------------------------------------------- 19 | # GSOAP Import Directories 20 | # ----------------------------------------------------- 21 | find_path(GSOAP_IMPORT_DIR 22 | NAMES wsa.h 23 | PATHS ${GSOAP_ROOT}/import ${GSOAP_ROOT}/share/gsoap/import 24 | ) 25 | 26 | # ----------------------------------------------------- 27 | # GSOAP Libraries 28 | # ----------------------------------------------------- 29 | find_library(GSOAP_LIBRARIES 30 | NAMES gsoap++ 31 | HINTS ${GSOAP_ROOT}/lib ${GSOAP_ROOT}/lib64 32 | ${GSOAP_ROOT}/lib32 33 | DOC "The main gsoap library" 34 | ) 35 | find_library(GSOAP_SSL_LIBRARIES 36 | NAMES gsoapssl++ 37 | HINTS ${GSOAP_ROOT}/lib ${GSOAP_ROOT}/lib64 38 | ${GSOAP_ROOT}/lib32 39 | DOC "The ssl gsoap library" 40 | ) 41 | 42 | # ----------------------------------------------------- 43 | # GSOAP Include Directories 44 | # ----------------------------------------------------- 45 | find_path(GSOAP_INCLUDE_DIR 46 | NAMES stdsoap2.h 47 | HINTS ${GSOAP_ROOT} ${GSOAP_ROOT}/include ${GSOAP_ROOT}/include/* 48 | DOC "The gsoap include directory" 49 | ) 50 | 51 | # ----------------------------------------------------- 52 | # GSOAP Binaries 53 | # ---------------------------------------------------- 54 | if(NOT GSOAP_TOOL_DIR) 55 | set(GSOAP_TOOL_DIR GSOAP_ROOT) 56 | endif() 57 | 58 | find_program(GSOAP_WSDL2H 59 | NAMES wsdl2h 60 | HINTS ${GSOAP_TOOL_DIR}/bin 61 | DOC "The gsoap bin directory" 62 | ) 63 | find_program(GSOAP_SOAPCPP2 64 | NAMES soapcpp2 65 | HINTS ${GSOAP_TOOL_DIR}/bin 66 | DOC "The gsoap bin directory" 67 | ) 68 | # ----------------------------------------------------- 69 | # GSOAP version 70 | # try to determine the flagfor the 2.7.6 compatiblity, break with 2.7.13 and re-break with 2.7.16 71 | # ---------------------------------------------------- 72 | 73 | execute_process(COMMAND ${GSOAP_SOAPCPP2} "-v" OUTPUT_VARIABLE GSOAP_STRING_VERSION ERROR_VARIABLE GSOAP_STRING_VERSION ) 74 | string(REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" GSOAP_VERSION ${GSOAP_STRING_VERSION}) 75 | # ----------------------------------------------------- 76 | # GSOAP_276_COMPAT_FLAGS and GSOAPVERSION 77 | # try to determine the flagfor the 2.7.6 compatiblity, break with 2.7.13 and re-break with 2.7.16 78 | # ---------------------------------------------------- 79 | if( "${GSOAP_VERSION}" VERSION_LESS "2.7.6") 80 | set(GSOAP_276_COMPAT_FLAGS "") 81 | elseif ( "${GSOAP_VERSION}" VERSION_LESS "2.7.14") 82 | set(GSOAP_276_COMPAT_FLAGS "-z") 83 | else ( "${GSOAP_VERSION}" VERSION_LESS "2.7.14") 84 | set(GSOAP_276_COMPAT_FLAGS "-z1 -z2") 85 | endif ( "${GSOAP_VERSION}" VERSION_LESS "2.7.6") 86 | 87 | # ----------------------------------------------------- 88 | # handle the QUIETLY and REQUIRED arguments and set GSOAP_FOUND to TRUE if 89 | # all listed variables are TRUE 90 | # ----------------------------------------------------- 91 | include(FindPackageHandleStandardArgs) 92 | find_package_handle_standard_args(gsoap DEFAULT_MSG GSOAP_LIBRARIES 93 | GSOAP_INCLUDE_DIR GSOAP_WSDL2H GSOAP_SOAPCPP2) 94 | mark_as_advanced(GSOAP_INCLUDE_DIR GSOAP_LIBRARIES GSOAP_WSDL2H GSOAP_SOAPCPP2) 95 | 96 | 97 | if(GSOAP_FOUND AND GSOAP_FIND_REQUIRED AND GSOAP_FIND_VERSION AND ${GSOAP_VERSION} VERSION_LESS ${GSOAP_FIND_VERSION}) 98 | message(SEND_ERROR "Found GSOAP version ${GSOAP_VERSION} less then required ${GSOAP_FIND_VERSION}.") 99 | endif() 100 | -------------------------------------------------------------------------------- /OnvifSDK/include/SearchServiceImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef SearchServiceImpl_H 2 | #define SearchServiceImpl_H 3 | 4 | #include "WebSearchBindingService.h" 5 | class BaseServer; 6 | namespace Web { 7 | class SearchServiceImpl : public SearchBindingService 8 | { 9 | private: 10 | BaseServer * m_pBaseServer; 11 | public: 12 | SearchServiceImpl(BaseServer * pBaseServer, struct soap * pData): 13 | m_pBaseServer(pBaseServer), 14 | SearchBindingService(pData) 15 | { 16 | } 17 | 18 | virtual SearchBindingService *copy() { return SOAP_OK; } 19 | 20 | /// Web service operation 'GetServiceCapabilities' (returns error code or SOAP_OK) 21 | virtual int GetServiceCapabilities(_tse__GetServiceCapabilities *tse__GetServiceCapabilities, _tse__GetServiceCapabilitiesResponse *tse__GetServiceCapabilitiesResponse) { return SOAP_OK; } 22 | 23 | /// Web service operation 'GetRecordingSummary' (returns error code or SOAP_OK) 24 | virtual int GetRecordingSummary(_tse__GetRecordingSummary *tse__GetRecordingSummary, _tse__GetRecordingSummaryResponse *tse__GetRecordingSummaryResponse) { return SOAP_OK; } 25 | 26 | /// Web service operation 'GetRecordingInformation' (returns error code or SOAP_OK) 27 | virtual int GetRecordingInformation(_tse__GetRecordingInformation *tse__GetRecordingInformation, _tse__GetRecordingInformationResponse *tse__GetRecordingInformationResponse) { return SOAP_OK; } 28 | 29 | /// Web service operation 'GetMediaAttributes' (returns error code or SOAP_OK) 30 | virtual int GetMediaAttributes(_tse__GetMediaAttributes *tse__GetMediaAttributes, _tse__GetMediaAttributesResponse *tse__GetMediaAttributesResponse) { return SOAP_OK; } 31 | 32 | /// Web service operation 'FindRecordings' (returns error code or SOAP_OK) 33 | virtual int FindRecordings(_tse__FindRecordings *tse__FindRecordings, _tse__FindRecordingsResponse *tse__FindRecordingsResponse) { return SOAP_OK; } 34 | 35 | /// Web service operation 'GetRecordingSearchResults' (returns error code or SOAP_OK) 36 | virtual int GetRecordingSearchResults(_tse__GetRecordingSearchResults *tse__GetRecordingSearchResults, _tse__GetRecordingSearchResultsResponse *tse__GetRecordingSearchResultsResponse) { return SOAP_OK; } 37 | 38 | /// Web service operation 'FindEvents' (returns error code or SOAP_OK) 39 | virtual int FindEvents(_tse__FindEvents *tse__FindEvents, _tse__FindEventsResponse *tse__FindEventsResponse) { return SOAP_OK; } 40 | 41 | /// Web service operation 'GetEventSearchResults' (returns error code or SOAP_OK) 42 | virtual int GetEventSearchResults(_tse__GetEventSearchResults *tse__GetEventSearchResults, _tse__GetEventSearchResultsResponse *tse__GetEventSearchResultsResponse) { return SOAP_OK; } 43 | 44 | /// Web service operation 'FindPTZPosition' (returns error code or SOAP_OK) 45 | virtual int FindPTZPosition(_tse__FindPTZPosition *tse__FindPTZPosition, _tse__FindPTZPositionResponse *tse__FindPTZPositionResponse) { return SOAP_OK; } 46 | 47 | /// Web service operation 'GetPTZPositionSearchResults' (returns error code or SOAP_OK) 48 | virtual int GetPTZPositionSearchResults(_tse__GetPTZPositionSearchResults *tse__GetPTZPositionSearchResults, _tse__GetPTZPositionSearchResultsResponse *tse__GetPTZPositionSearchResultsResponse) { return SOAP_OK; } 49 | 50 | /// Web service operation 'GetSearchState' (returns error code or SOAP_OK) 51 | virtual int GetSearchState(_tse__GetSearchState *tse__GetSearchState, _tse__GetSearchStateResponse *tse__GetSearchStateResponse) { return SOAP_OK; } 52 | 53 | /// Web service operation 'EndSearch' (returns error code or SOAP_OK) 54 | virtual int EndSearch(_tse__EndSearch *tse__EndSearch, _tse__EndSearchResponse *tse__EndSearchResponse) { return SOAP_OK; } 55 | 56 | /// Web service operation 'FindMetadata' (returns error code or SOAP_OK) 57 | virtual int FindMetadata(_tse__FindMetadata *tse__FindMetadata, _tse__FindMetadataResponse *tse__FindMetadataResponse) { return SOAP_OK; } 58 | 59 | /// Web service operation 'GetMetadataSearchResults' (returns error code or SOAP_OK) 60 | virtual int GetMetadataSearchResults(_tse__GetMetadataSearchResults *tse__GetMetadataSearchResults, _tse__GetMetadataSearchResultsResponse *tse__GetMetadataSearchResultsResponse) { return SOAP_OK; } 61 | }; 62 | } // namespace Web 63 | #endif // SearchServiceImpl 64 | -------------------------------------------------------------------------------- /OnvifSDK/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ### 2 | project(OnvifSDK) 3 | cmake_minimum_required(VERSION 2.8) 4 | 5 | # SIGRLOG_CURRLEVEL: 6 | # level of verboseness of the logger range [0..4] 7 | add_definitions(-DSIGRLOG_CURRLEVEL=4) 8 | # SIGRLOG_OUTPUT: 9 | # destinations of the logger output 10 | # 0 - none, 1 - console only, 2 - file only, 3 - console and file 11 | add_definitions(-DSIGRLOG_OUTPUT=1) 12 | # SIGRLOG_FILENAME 13 | # output filename for logger 14 | add_definitions(-DSIGRLOG_FILENAME=\"oxxServerLog.ini\") 15 | 16 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) 17 | 18 | find_package(GSOAP 2.8.15 REQUIRED) 19 | message(STATUS "The GSOAP version: ${GSOAP_VERSION}") 20 | message(STATUS "The GSOAP include directory: ${GSOAP_INCLUDE_DIR}") 21 | message(STATUS "The GSOAP libraries: ${GSOAP_LIBRARIES}") 22 | message(STATUS "The GSOAP import directory: ${GSOAP_IMPORT_DIR}") 23 | 24 | if( GSOAP_IMPORT_DIR STREQUAL "GSOAP_IMPORT_DIR-NOTFOUND" ) 25 | set(GSOAP_IMPORT_DIR "/usr/local/share/gsoap/import") 26 | endif() 27 | 28 | add_definitions(-DWITH_PURE_VIRTUAL) 29 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") 30 | 31 | ### generate stubs 32 | set(OSDK_GEN_SOURCE_DIR ${PROJECT_BINARY_DIR}/src) 33 | add_subdirectory(xml) 34 | 35 | if(NOT IS_DIRECTORY ${OSDK_GEN_SOURCE_DIR}) 36 | file(MAKE_DIRECTORY ${OSDK_GEN_SOURCE_DIR}) 37 | 38 | execute_process( 39 | COMMAND ${GSOAP_WSDL2H} -jgxP -oweb.h -t${PROJECT_SOURCE_DIR}/typemapWeb.dat 40 | ${XML_WSDL_DIR}/devicemgmt.wsdl ${XML_WSDL_DIR}/deviceio.wsdl 41 | ${XML_WSDL_DIR}/display.wsdl ${XML_WSDL_DIR}/recording.wsdl 42 | ${XML_WSDL_DIR}/replay.wsdl ${XML_WSDL_DIR}/search.wsdl 43 | ${XML_WSDL_DIR}/receiver.wsdl 44 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 45 | ) 46 | ### remove optional fault element 47 | execute_process( 48 | COMMAND sed "s/struct\\sSOAP_ENV__Fault/\\/\\/struct SOAP_ENV__Fault/" web.h 49 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 50 | OUTPUT_FILE web1.h 51 | ) 52 | 53 | execute_process( 54 | COMMAND ${GSOAP_WSDL2H} -gxP -ord.h -t${PROJECT_SOURCE_DIR}/typemapWsdd.dat 55 | ${XML_WSDL_DIR}/remotediscovery.wsdl 56 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 57 | ) 58 | 59 | execute_process( 60 | COMMAND ln -s ${GSOAP_IMPORT_DIR}/stlvector.h stlvector.h 61 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 62 | ) 63 | 64 | execute_process( 65 | COMMAND ln -s ${GSOAP_IMPORT_DIR}/soap12.h soap12.h 66 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 67 | ) 68 | 69 | file(APPEND ${PROJECT_BINARY_DIR}/rd.h 70 | "struct SOAP_ENV__Header {\n" 71 | "std::string wsa__MessageID;\n" 72 | "wsa__Relationship *wsa__RelatesTo;\n" 73 | "wsa__EndpointReferenceType *wsa__From;\n" 74 | "wsa__EndpointReferenceType *wsa__ReplyTo;\n" 75 | "wsa__EndpointReferenceType *wsa__FaultTo;\n" 76 | "std::string wsa__To;\n" 77 | "std::string wsa__Action;\n" 78 | "wsd__AppSequenceType *wsd__AppSequence;\n" 79 | "};" 80 | ) 81 | 82 | execute_process( 83 | COMMAND ${GSOAP_SOAPCPP2} -abjnxLw web1.h -dsrc -qWeb -I${GSOAP_IMPORT_DIR} -I${GSOAP_IMPORT_DIR}/.. 84 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 85 | ) 86 | execute_process( 87 | COMMAND ${GSOAP_SOAPCPP2} -abjnxLw rd.h -dsrc -pWsdd -I${GSOAP_IMPORT_DIR} -I${GSOAP_IMPORT_DIR}/.. 88 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 89 | ) 90 | 91 | aux_source_directory(${OSDK_GEN_SOURCE_DIR} OSDK_GEN_FILES) 92 | endif() 93 | 94 | # list project files 95 | include_directories(${PROJECT_SOURCE_DIR}/../common 96 | ${PROJECT_SOURCE_DIR}/gen/include 97 | ${PROJECT_SOURCE_DIR}/include 98 | ${PROJECT_SOURCE_DIR}/WsDiscovery 99 | ${OSDK_GEN_SOURCE_DIR}) 100 | 101 | set(HEADERS 102 | ${PROJECT_SOURCE_DIR}/../common/sigrlog.h 103 | ${PROJECT_SOURCE_DIR}/gen/include/stdsoap2.h 104 | ${PROJECT_SOURCE_DIR}/include/stringGenerator.h 105 | ${PROJECT_SOURCE_DIR}/include/BaseServer.h 106 | ${PROJECT_SOURCE_DIR}/include/BaseClient.h 107 | ${PROJECT_SOURCE_DIR}/include/OnvifSDK.h 108 | ${PROJECT_SOURCE_DIR}/../WsDiscovery/WsddLib.h) 109 | 110 | set(SOURCES 111 | ${PROJECT_SOURCE_DIR}/gen/source/stdsoap2.cpp 112 | ${PROJECT_SOURCE_DIR}/source/BaseServer.cpp 113 | ${PROJECT_SOURCE_DIR}/source/BaseClient.cpp) 114 | 115 | file(GLOB WSD_FILES ${PROJECT_SOURCE_DIR}/WsDiscovery/*) 116 | 117 | file(GLOB OSDK_HEADERS ${PROJECT_SOURCE_DIR}/include/*.h) 118 | file(GLOB OSDK_SOURCES ${PROJECT_SOURCE_DIR}/source/*.cpp) 119 | 120 | add_library(OnvifSDK STATIC ${SOURCES} ${HEADERS} 121 | ${OSDK_GEN_FILES} 122 | ${WSD_FILES} 123 | ${OSDK_HEADERS} 124 | ${OSDK_SOURCES}) 125 | 126 | target_link_libraries(OnvifSDK pthread) 127 | -------------------------------------------------------------------------------- /OnvifSDK/include/RecordingServiceImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef RecordingServiceImpl_H 2 | #define RecordingServiceImpl_H 3 | 4 | #include "WebRecordingBindingService.h" 5 | class BaseServer; 6 | namespace Web { 7 | class RecordingServiceImpl : public RecordingBindingService 8 | { 9 | private: 10 | BaseServer * m_pBaseServer; 11 | public: 12 | RecordingServiceImpl(BaseServer * pBaseServer, struct soap * pData): 13 | m_pBaseServer(pBaseServer), 14 | RecordingBindingService(pData) 15 | { 16 | } 17 | 18 | virtual RecordingBindingService *copy() { return NULL; } 19 | 20 | /// Web service operation 'GetServiceCapabilities' (returns error code or SOAP_OK) 21 | virtual int GetServiceCapabilities(_trc__GetServiceCapabilities *trc__GetServiceCapabilities, _trc__GetServiceCapabilitiesResponse *trc__GetServiceCapabilitiesResponse) { return SOAP_OK; } 22 | 23 | /// Web service operation 'CreateRecording' (returns error code or SOAP_OK) 24 | virtual int CreateRecording(_trc__CreateRecording *trc__CreateRecording, _trc__CreateRecordingResponse *trc__CreateRecordingResponse); 25 | 26 | /// Web service operation 'DeleteRecording' (returns error code or SOAP_OK) 27 | virtual int DeleteRecording(_trc__DeleteRecording *trc__DeleteRecording, _trc__DeleteRecordingResponse *trc__DeleteRecordingResponse); 28 | 29 | /// Web service operation 'GetRecordings' (returns error code or SOAP_OK) 30 | virtual int GetRecordings(_trc__GetRecordings *trc__GetRecordings, _trc__GetRecordingsResponse *trc__GetRecordingsResponse) { return SOAP_OK; } 31 | 32 | /// Web service operation 'SetRecordingConfiguration' (returns error code or SOAP_OK) 33 | virtual int SetRecordingConfiguration(_trc__SetRecordingConfiguration *trc__SetRecordingConfiguration, _trc__SetRecordingConfigurationResponse *trc__SetRecordingConfigurationResponse) { return SOAP_OK; } 34 | 35 | /// Web service operation 'GetRecordingConfiguration' (returns error code or SOAP_OK) 36 | virtual int GetRecordingConfiguration(_trc__GetRecordingConfiguration *trc__GetRecordingConfiguration, _trc__GetRecordingConfigurationResponse *trc__GetRecordingConfigurationResponse) { return SOAP_OK; } 37 | 38 | /// Web service operation 'GetRecordingOptions' (returns error code or SOAP_OK) 39 | virtual int GetRecordingOptions(_trc__GetRecordingOptions *trc__GetRecordingOptions, _trc__GetRecordingOptionsResponse *trc__GetRecordingOptionsResponse) { return SOAP_OK; } 40 | 41 | /// Web service operation 'CreateTrack' (returns error code or SOAP_OK) 42 | virtual int CreateTrack(_trc__CreateTrack *trc__CreateTrack, _trc__CreateTrackResponse *trc__CreateTrackResponse) { return SOAP_OK; } 43 | 44 | /// Web service operation 'DeleteTrack' (returns error code or SOAP_OK) 45 | virtual int DeleteTrack(_trc__DeleteTrack *trc__DeleteTrack, _trc__DeleteTrackResponse *trc__DeleteTrackResponse) { return SOAP_OK; } 46 | 47 | /// Web service operation 'GetTrackConfiguration' (returns error code or SOAP_OK) 48 | virtual int GetTrackConfiguration(_trc__GetTrackConfiguration *trc__GetTrackConfiguration, _trc__GetTrackConfigurationResponse *trc__GetTrackConfigurationResponse) { return SOAP_OK; } 49 | 50 | /// Web service operation 'SetTrackConfiguration' (returns error code or SOAP_OK) 51 | virtual int SetTrackConfiguration(_trc__SetTrackConfiguration *trc__SetTrackConfiguration, _trc__SetTrackConfigurationResponse *trc__SetTrackConfigurationResponse) { return SOAP_OK; } 52 | 53 | /// Web service operation 'CreateRecordingJob' (returns error code or SOAP_OK) 54 | virtual int CreateRecordingJob(_trc__CreateRecordingJob *trc__CreateRecordingJob, _trc__CreateRecordingJobResponse *trc__CreateRecordingJobResponse); 55 | 56 | /// Web service operation 'DeleteRecordingJob' (returns error code or SOAP_OK) 57 | virtual int DeleteRecordingJob(_trc__DeleteRecordingJob *trc__DeleteRecordingJob, _trc__DeleteRecordingJobResponse *trc__DeleteRecordingJobResponse); 58 | 59 | /// Web service operation 'GetRecordingJobs' (returns error code or SOAP_OK) 60 | virtual int GetRecordingJobs(_trc__GetRecordingJobs *trc__GetRecordingJobs, _trc__GetRecordingJobsResponse *trc__GetRecordingJobsResponse) { return SOAP_OK; } 61 | 62 | /// Web service operation 'SetRecordingJobConfiguration' (returns error code or SOAP_OK) 63 | virtual int SetRecordingJobConfiguration(_trc__SetRecordingJobConfiguration *trc__SetRecordingJobConfiguration, _trc__SetRecordingJobConfigurationResponse *trc__SetRecordingJobConfigurationResponse) { return SOAP_OK; } 64 | 65 | /// Web service operation 'GetRecordingJobConfiguration' (returns error code or SOAP_OK) 66 | virtual int GetRecordingJobConfiguration(_trc__GetRecordingJobConfiguration *trc__GetRecordingJobConfiguration, _trc__GetRecordingJobConfigurationResponse *trc__GetRecordingJobConfigurationResponse) { return SOAP_OK; } 67 | 68 | /// Web service operation 'SetRecordingJobMode' (returns error code or SOAP_OK) 69 | virtual int SetRecordingJobMode(_trc__SetRecordingJobMode *trc__SetRecordingJobMode, _trc__SetRecordingJobModeResponse *trc__SetRecordingJobModeResponse) { return SOAP_OK; } 70 | 71 | /// Web service operation 'GetRecordingJobState' (returns error code or SOAP_OK) 72 | virtual int GetRecordingJobState(_trc__GetRecordingJobState *trc__GetRecordingJobState, _trc__GetRecordingJobStateResponse *trc__GetRecordingJobStateResponse) { return SOAP_OK; } 73 | 74 | 75 | }; 76 | } // namespace Web 77 | #endif // RecordingServiceImpl_H 78 | -------------------------------------------------------------------------------- /OnvifSDK/xml/bf-2.xsd: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 26 | 30 | 31 | 33 | 34 | 35 | Get access to the xml: attribute groups for xml:lang as declared on 'schema' 36 | and 'documentation' below 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 48 | 50 | 52 | 54 | 55 | 56 | 57 | 59 | 60 | 61 | 62 | 63 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /OnvifSDK/xml/remotediscovery.wsdl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /OnvifSDK/source/BaseServer.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "BaseServer.h" 3 | 4 | using namespace Web; 5 | 6 | static GeneratorInitializer generatorInitializer; 7 | 8 | std::string GenerateToken() 9 | { 10 | std::string str; 11 | 12 | for(unsigned int i = 0; i < TOKEN_LEN; ++i) 13 | str += alphanum[rand() % stringLength]; 14 | 15 | return str; 16 | }; 17 | 18 | IOnvifServer* getOnvifServer() 19 | { 20 | return BaseServer::Instance(); 21 | } 22 | 23 | BaseServer::BaseServer(): 24 | m_pWsdd(NULL), 25 | m_pSoap(soap_new()) 26 | { 27 | } 28 | 29 | int BaseServer::Init(int iServicesToHost, int iPort, IOnvif *pHandler) 30 | { 31 | m_pHandler = pHandler; 32 | m_iPort = iPort; 33 | m_DevService = (iServicesToHost & DEV_S) ? new DeviceServiceImpl(this, m_pSoap) : NULL; 34 | m_DevIOService = (iServicesToHost & DEVIO_S) ? new DeviceIOServiceImpl(this, m_pSoap) : NULL; 35 | m_DispService = (iServicesToHost & DISP_S) ? new DisplayServiceImpl(this, m_pSoap) : NULL; 36 | m_RecvService = (iServicesToHost & RECV_S) ? new ReceiverServiceImpl(this, m_pSoap) : NULL; 37 | m_ReplayService = (iServicesToHost & REPLAY_S) ? new ReplayServiceImpl(this, m_pSoap) : NULL; 38 | m_RecordService = (iServicesToHost & RECORD_S) ? new RecordingServiceImpl(this, m_pSoap): NULL; 39 | m_SearchService = (iServicesToHost & SEARCH_S) ? new SearchServiceImpl(this, m_pSoap) : NULL; 40 | 41 | int iRet = RunWsDiscovery(); 42 | if(iRet != 0) 43 | SIGRLOG (SIGRWARNING, "BaseServer::Run RunWsDiscovery failed"); 44 | 45 | m_bCreated = m_pSoap && m_DevService && m_pHandler && (iRet == 0); 46 | return m_bCreated ? 0 : -1; 47 | } 48 | 49 | BaseServer::~BaseServer() 50 | { 51 | if(m_pWsdd) 52 | m_pWsdd->stop(); 53 | 54 | if(m_RecvService) 55 | delete m_RecvService; 56 | if(m_DispService) 57 | delete m_DispService; 58 | if(m_DevIOService) 59 | delete m_DevIOService; 60 | if(m_DevService) 61 | delete m_DevService; 62 | if(m_ReplayService) 63 | delete m_ReplayService; 64 | if(m_RecordService) 65 | delete m_RecordService; 66 | if(m_SearchService) 67 | delete m_SearchService; 68 | 69 | if(m_pSoap) 70 | { 71 | soap_destroy(m_pSoap); 72 | soap_end(m_pSoap); 73 | soap_free(m_pSoap); 74 | } 75 | } 76 | 77 | int BaseServer::Run() 78 | { 79 | if(!m_bCreated) 80 | { 81 | SIGRLOG(SIGRCRITICAL, "BaseServer::Run Services were not created"); 82 | return -1; 83 | } 84 | 85 | int iRet = soap_bind(m_pSoap, NULL, m_iPort, 100); 86 | 87 | if (iRet == SOAP_INVALID_SOCKET) 88 | { 89 | SIGRLOG(SIGRCRITICAL, "BaseServer::Run Binding on %d port failed", m_iPort); 90 | return -1; 91 | } 92 | 93 | while(1) 94 | { 95 | iRet = soap_accept(m_pSoap); 96 | if (iRet == SOAP_INVALID_SOCKET) 97 | { 98 | SIGRLOG(SIGRCRITICAL, "BaseServer::Run accepting failed"); 99 | return -1; 100 | } 101 | 102 | if (soap_begin_serve(m_pSoap) != SOAP_OK) 103 | SIGRLOG(SIGRWARNING, "BaseServer::Run serve failed"); 104 | 105 | if (m_DevService) 106 | iRet = m_DevService->dispatch(); 107 | 108 | if (iRet == SOAP_OK) 109 | continue; 110 | 111 | if (m_DevIOService) 112 | iRet = m_DevIOService->dispatch(); 113 | 114 | if (iRet == SOAP_OK) 115 | continue; 116 | 117 | if (m_DispService) 118 | iRet = m_DispService->dispatch(); 119 | 120 | if (iRet == SOAP_OK) 121 | continue; 122 | 123 | if (m_RecvService) 124 | iRet = m_RecvService->dispatch(); 125 | 126 | if (iRet == SOAP_OK) 127 | continue; 128 | 129 | if (m_ReplayService) 130 | iRet = m_ReplayService->dispatch(); 131 | 132 | if (iRet == SOAP_OK) 133 | continue; 134 | 135 | if (m_RecordService) 136 | iRet = m_RecordService->dispatch(); 137 | 138 | if (iRet == SOAP_OK) 139 | continue; 140 | 141 | if (m_SearchService) 142 | iRet = m_SearchService->dispatch(); 143 | 144 | if(iRet != SOAP_OK) 145 | SIGRLOG(SIGRWARNING, "BaseServer::Run SOAP_Error= %d", iRet); 146 | } 147 | 148 | return 0; 149 | } 150 | 151 | int BaseServer::RunWsDiscovery() 152 | { 153 | m_pWsdd = getWsdd(); 154 | 155 | if(!m_pWsdd) 156 | return -1; 157 | int iRet = m_pWsdd->start(true); 158 | return iRet; 159 | } 160 | 161 | int BaseServer::GetDateAndTime( DevGetSystemDateAndTimeResponse & r) 162 | { 163 | return m_pHandler->GetDateAndTime(r); 164 | } 165 | 166 | int BaseServer::SetDateAndTime( DevSetSystemDateAndTime & r) 167 | { 168 | return m_pHandler->SetDateAndTime(r); 169 | } 170 | 171 | int BaseServer::GetUsers( /*out*/ DevGetUsersResponse & r) 172 | { 173 | return m_pHandler->GetUsers(r); 174 | } 175 | 176 | //===DEVIO============================ 177 | int BaseServer::GetVideoOutputs( /*out*/ DevIOGetVideoOutputsResponse & r) 178 | { 179 | return m_pHandler->GetVideoOutputs(r); 180 | } 181 | 182 | //===DISP============================= 183 | int BaseServer::GetLayout( std::string & token, /*out*/ DispGetLayoutResponse & resp) 184 | { 185 | return m_pHandler->GetLayout(token, resp); 186 | } 187 | 188 | int BaseServer::GetDisplayOptions( const std::string & token, DispGetDisplayOptionsResponse & resp) 189 | { 190 | return m_pHandler->GetDisplayOptions(token, resp); 191 | } 192 | 193 | int BaseServer::SetLayout(DispSetLayout &r) 194 | { 195 | return m_pHandler->SetLayout(r); 196 | } 197 | 198 | int BaseServer::CreatePaneConfiguration( DispCreatePaneConfiguration & req, /*out*/ DispCreatePaneConfigurationResponse & resp) 199 | { 200 | return m_pHandler->CreatePaneConfiguration(req, resp); 201 | } 202 | 203 | //===RECV============================= 204 | int BaseServer::GetReceivers( RecvGetReceiversResponse & r) 205 | { 206 | return m_pHandler->GetReceivers(r); 207 | } 208 | 209 | int BaseServer::CreateReceiver( const std::string & uri, /*out*/ std::string & recvToken ) 210 | { 211 | return m_pHandler->CreateReceiver(uri, recvToken); 212 | } 213 | 214 | int BaseServer::SetReceiverMode( const std::string & recvToken, bool bMode ) 215 | { 216 | return m_pHandler->SetReceiverMode(recvToken, bMode); 217 | } 218 | //===RECORDING========================= 219 | int BaseServer::CreateRecording (RecCreateRecording & req, RecCreateRecordingResponse & resp) 220 | { 221 | return m_pHandler->CreateRecording(req, resp); 222 | } 223 | 224 | int BaseServer::CreateRecordingJob (RecCreateRecordingJob & req, RecCreateRecordingJobResponse & resp) 225 | { 226 | return m_pHandler->CreateRecordingJob(req, resp); 227 | } 228 | 229 | int BaseServer::DeleteRecording (const std::string & str) 230 | { 231 | return m_pHandler->DeleteRecording(str); 232 | } 233 | 234 | int BaseServer::DeleteRecordingJob (const std::string &str) 235 | { 236 | return m_pHandler->DeleteRecordingJob(str); 237 | } 238 | -------------------------------------------------------------------------------- /OnvifSDK/WsDiscovery/wsdd.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "wsdd.hpp" 3 | #include "sigrlog.h" 4 | 5 | Wsdd::Wsdd() : 6 | stopped_(false), 7 | bExitRequest_(false) 8 | { 9 | SIGRLOG (SIGRDEBUG2, "start" ); 10 | scopes_.push_back("onvif://www.onvif.org/type/NetworkVideoTransmitter"); 11 | scopes_.push_back("onvif://www.onvif.org/type/video_encoder"); 12 | scopes_.push_back("onvif://www.onvif.org/type/audio_encoder"); 13 | scopes_.push_back("onvif://www.onvif.org/type/ptz"); 14 | scopes_.push_back("onvif://www.onvif.org/name/OnvifxxExample"); 15 | scopes_.push_back("onvif://www.onvif.org/location/Anywhere"); 16 | scopes_.push_back("onvif://www.onvif.org/hardware/OnvifxxEngine"); 17 | } 18 | 19 | Wsdd::~Wsdd() 20 | { 21 | } 22 | 23 | int Wsdd::start(bool bIsDevice) 24 | { 25 | bIsDevice_ = bIsDevice; 26 | mutex_ = PTHREAD_MUTEX_INITIALIZER; 27 | int iRet = pthread_create(&serviceThread_, NULL, &Wsdd::runServiceHelper, this); 28 | return iRet; 29 | } 30 | 31 | std::vector Wsdd::getMembers() 32 | { 33 | pthread_mutex_lock(&mutex_); 34 | std::vector v = members_; 35 | pthread_mutex_unlock(&mutex_); 36 | return v; 37 | } 38 | 39 | int Wsdd::stop() 40 | { 41 | pthread_mutex_lock(&mutex_); 42 | bExitRequest_ = true; 43 | pthread_mutex_unlock(&mutex_); 44 | pthread_join(serviceThread_, NULL); 45 | return 0; 46 | } 47 | 48 | void Wsdd::hello(const Hello_t & arg) 49 | { 50 | SIGRLOG( SIGRDEBUG2, "hello ( %s, %s, %s)", 51 | (arg.xaddrs != NULL ? arg.xaddrs->c_str() : ""), 52 | (arg.types != NULL ? arg.types->c_str() : ""), 53 | (arg.scopes != NULL ? arg.scopes->item.c_str() : "")); 54 | if(arg.xaddrs != NULL && !arg.xaddrs->empty()) 55 | { 56 | if (std::find(members_.begin(), members_.end(), *arg.xaddrs) == members_.end()) 57 | members_.push_back(arg.xaddrs->c_str()); 58 | } 59 | } 60 | 61 | void Wsdd::bye(const Bye_t & arg) 62 | { 63 | SIGRLOG( SIGRDEBUG2, "bye ( %s, %s, %s)", 64 | (arg.xaddrs != NULL ? arg.xaddrs->c_str() : ""), 65 | (arg.types != NULL ? arg.types->c_str() : ""), 66 | (arg.scopes != NULL ? arg.scopes->item.c_str() : "")); 67 | } 68 | 69 | Wsdd::ProbeMatches_t Wsdd::probe(const Probe_t & arg) 70 | { 71 | SIGRLOG( SIGRDEBUG2, "probe ( %s, %s)", 72 | (arg.types != NULL ? arg.types->c_str() : ""), 73 | (arg.scopes != NULL ? arg.scopes->item.c_str() : "")); 74 | 75 | bool matched = true; 76 | if (arg.types != NULL && probeMatches_.back().types != NULL) { 77 | std::string types = *arg.types; 78 | while (true) { 79 | std::size_t pos1 = types.rfind(':'); 80 | if (pos1 == std::string::npos) 81 | break; 82 | 83 | std::size_t pos2 = types.rfind(' ', pos1); 84 | if (pos2 == std::string::npos) 85 | pos2 = 0; 86 | else 87 | ++pos2; 88 | 89 | types.erase(pos2, pos1 - pos2 + 1); 90 | } 91 | 92 | matched = isMatched(types, *probeMatches_.back().types); 93 | } 94 | 95 | if (matched && arg.scopes != NULL && probeMatches_.back().scopes != NULL) 96 | matched = isMatched(arg.scopes->item, probeMatches_.back().scopes->item); 97 | 98 | return matched ? probeMatches_ : Wsdd::ProbeMatches_t(); 99 | } 100 | 101 | std::vector &split(const std::string &s, char delim, std::vector &elems) { 102 | std::stringstream ss(s); 103 | std::string item; 104 | while (std::getline(ss, item, delim)) { 105 | elems.push_back(item); 106 | } 107 | return elems; 108 | } 109 | 110 | std::vector split(const std::string &s, char delim) { 111 | std::vector elems; 112 | split(s, delim, elems); 113 | return elems; 114 | } 115 | 116 | bool Wsdd::isMatched(const std::string & left, const std::string & right) 117 | { 118 | std::vector l; 119 | std::vector r; 120 | 121 | l = split(left, ' '); 122 | r = split(right, ' '); 123 | 124 | return std::find_first_of(l.begin(), l.end(), r.begin(), r.end()) != l.end(); 125 | } 126 | 127 | template 128 | std::string vector_join( const std::vector& v, const std::string& token ){ 129 | std::ostringstream result; 130 | for (typename std::vector::const_iterator i = v.begin(); i != v.end(); i++){ 131 | if (i != v.begin()) result << token; 132 | result << *i; 133 | } 134 | return result.str(); 135 | } 136 | 137 | void Wsdd::runService() 138 | { 139 | try { 140 | std::string address = "urn:uuid:05f1b46c-f29a-46f7-9140-e4bc00c8cea6"; 141 | std::string xaddrs = "http://127.0.0.1/onvif/services"; 142 | std::string types = "dn:NetworkVideoTransmitter"; 143 | 144 | Scopes_t scopes = Scopes_t(); 145 | scopes.item = vector_join(scopes_, " "); 146 | EndpointReference_t endpoint = EndpointReference_t(); 147 | endpoint.address = &address; 148 | 149 | probeMatches_.resize(1); 150 | probeMatches_.back().endpoint = &endpoint; 151 | probeMatches_.back().scopes = &scopes; 152 | probeMatches_.back().types = &types; 153 | probeMatches_.back().xaddrs = &xaddrs; 154 | probeMatches_.back().version = 1; 155 | 156 | if(bIsDevice_) 157 | { 158 | SIGRLOG( SIGRDEBUG2, "Sending hello" ); 159 | proxy_.reset(RemoteDiscovery::proxy()); 160 | proxy_->hello(probeMatches_.back()); 161 | } 162 | 163 | 164 | SIGRLOG( SIGRDEBUG2, "Starting the service loop" ); 165 | std::tr1::shared_ptr service(RemoteDiscovery::service()); 166 | service->bind(this); 167 | 168 | while (true) { 169 | 170 | pthread_mutex_lock(&mutex_); 171 | if(bExitRequest_) 172 | { 173 | service->destroy(); 174 | bExitRequest_ = false; 175 | break; 176 | } 177 | pthread_mutex_unlock(&mutex_); 178 | 179 | 180 | SIGRLOG( SIGRDEBUG2, "Accept" ); 181 | if (service->accept() == -1) { 182 | SIGRLOG( SIGRWARNING, "Accept failed" ); 183 | continue; 184 | } 185 | 186 | SIGRLOG( SIGRDEBUG2, "Serve" ); 187 | int err = service->serve(); 188 | if (err != 0) { 189 | if (err != -1) { 190 | SIGRLOG( SIGRWARNING, "Serve failed :%s", SoapException(service->getSoap()).what() ); 191 | } 192 | continue; 193 | } 194 | 195 | SIGRLOG( SIGRDEBUG2, "Clear"); 196 | service->destroy(); 197 | } 198 | 199 | if(bIsDevice_) 200 | { 201 | service.reset(); 202 | proxy_.reset(RemoteDiscovery::proxy()); 203 | proxy_->bye(probeMatches_.back()); 204 | } 205 | 206 | } catch (std::exception & ex) { 207 | SIGRLOG( SIGRWARNING, "%s", ex.what() ); 208 | 209 | } 210 | 211 | SIGRLOG( SIGRDEBUG0, "The service loop stopped" ); 212 | } 213 | -------------------------------------------------------------------------------- /OnvifSDK/gen/source/duration.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | duration.c 3 | 4 | Custom serializer for xsd:duration stored in a LONG64 with ms precision 5 | - the LONG64 int can represent 106751991167 days forward and backward 6 | - LONG64 is long long int under Unix/Linux 7 | - millisecond resolution (1/1000 sec) means 1 second = 1000 8 | - when adding to a time_t value, conversion may be needed since time_t 9 | may (or may) not have seconds resolution 10 | - durations longer than a month are always output in days, rather than 11 | months to avoid days-per-month conversion 12 | - durations expressed in years and months are not well defined, since 13 | there is no reference starting time; the decoder assumes 30 days per 14 | month and conversion of P4M gives 120 days and therefore the duration 15 | P4M and P120D are assumed identical, while they may yield different 16 | result depending on the reference starting time 17 | 18 | Compile this file and link it with your code. 19 | 20 | gSOAP XML Web services tools 21 | Copyright (C) 2000-2009, Robert van Engelen, Genivia Inc., All Rights Reserved. 22 | This part of the software is released under ONE of the following licenses: 23 | GPL, the gSOAP public license, OR Genivia's license for commercial use. 24 | -------------------------------------------------------------------------------- 25 | gSOAP public license. 26 | 27 | The contents of this file are subject to the gSOAP Public License Version 1.3 28 | (the "License"); you may not use this file except in compliance with the 29 | License. You may obtain a copy of the License at 30 | http://www.cs.fsu.edu/~engelen/soaplicense.html 31 | Software distributed under the License is distributed on an "AS IS" basis, 32 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 33 | for the specific language governing rights and limitations under the License. 34 | 35 | The Initial Developer of the Original Code is Robert A. van Engelen. 36 | Copyright (C) 2000-2009, Robert van Engelen, Genivia, Inc., All Rights Reserved. 37 | -------------------------------------------------------------------------------- 38 | GPL license. 39 | 40 | This program is free software; you can redistribute it and/or modify it under 41 | the terms of the GNU General Public License as published by the Free Software 42 | Foundation; either version 2 of the License, or (at your option) any later 43 | version. 44 | 45 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 46 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 47 | PARTICULAR PURPOSE. See the GNU General Public License for more details. 48 | 49 | You should have received a copy of the GNU General Public License along with 50 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple 51 | Place, Suite 330, Boston, MA 02111-1307 USA 52 | 53 | Author contact information: 54 | engelen@genivia.com / engelen@acm.org 55 | 56 | This program is released under the GPL with the additional exemption that 57 | compiling, linking, and/or using OpenSSL is allowed. 58 | -------------------------------------------------------------------------------- 59 | A commercial use license is available from Genivia, Inc., contact@genivia.com 60 | -------------------------------------------------------------------------------- 61 | */ 62 | 63 | /* soapH.h generated by soapcpp2 from .h file containing #import "duration.h":*/ 64 | #include "soapH.h" 65 | 66 | void soap_default_xsd__duration(struct soap *soap, LONG64 *a) 67 | { (void)soap; /* appease -Wall -Werror */ 68 | *a = 0; 69 | } 70 | 71 | const char *soap_xsd__duration2s(struct soap *soap, LONG64 a) 72 | { LONG64 d; 73 | int k, h, m, s, f; 74 | if (a < 0) 75 | { strcpy(soap->tmpbuf, "-P"); 76 | k = 2; 77 | a = -a; 78 | } 79 | else 80 | { strcpy(soap->tmpbuf, "P"); 81 | k = 1; 82 | } 83 | f = a % 1000; 84 | a /= 1000; 85 | s = a % 60; 86 | a /= 60; 87 | m = a % 60; 88 | a /= 60; 89 | h = a % 24; 90 | d = a / 24; 91 | if (d) 92 | sprintf(soap->tmpbuf + k, SOAP_LONG_FORMAT"D", d); 93 | if (h || m || s || f) 94 | { if (d) 95 | k = strlen(soap->tmpbuf); 96 | if (f) 97 | sprintf(soap->tmpbuf + k, "T%dH%dM%d.%03dS", h, m, s, f); 98 | else 99 | sprintf(soap->tmpbuf + k, "T%dH%dM%dS", h, m, s); 100 | } 101 | else if (!d) 102 | strcpy(soap->tmpbuf + k, "T0S"); 103 | return soap->tmpbuf; 104 | } 105 | 106 | int soap_out_xsd__duration(struct soap *soap, const char *tag, int id, const LONG64 *a, const char *type) 107 | { if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_xsd__duration), type) 108 | || soap_string_out(soap, soap_xsd__duration2s(soap, *a), 0)) 109 | return soap->error; 110 | return soap_element_end_out(soap, tag); 111 | } 112 | 113 | int soap_s2xsd__duration(struct soap *soap, const char *s, LONG64 *a) 114 | { LONG64 sign = 1, Y = 0, M = 0, D = 0, H = 0, N = 0, S = 0; 115 | float f = 0; 116 | *a = 0; 117 | if (s) 118 | { if (*s == '-') 119 | { sign = -1; 120 | s++; 121 | } 122 | if (*s++ != 'P') 123 | return soap->error = SOAP_TYPE; 124 | /* date part */ 125 | while (s && *s) 126 | { LONG64 n; 127 | char k; 128 | if (*s == 'T') 129 | { s++; 130 | break; 131 | } 132 | if (sscanf(s, SOAP_LONG_FORMAT"%c", &n, &k) != 2) 133 | return soap->error = SOAP_TYPE; 134 | s = strchr(s, k); 135 | if (!s) 136 | return soap->error = SOAP_TYPE; 137 | switch (k) 138 | { case 'Y': 139 | Y = n; 140 | break; 141 | case 'M': 142 | M = n; 143 | break; 144 | case 'D': 145 | D = n; 146 | break; 147 | default: 148 | return soap->error = SOAP_TYPE; 149 | } 150 | s++; 151 | } 152 | /* time part */ 153 | while (s && *s) 154 | { LONG64 n; 155 | char k; 156 | if (sscanf(s, SOAP_LONG_FORMAT"%c", &n, &k) != 2) 157 | return soap->error = SOAP_TYPE; 158 | s = strchr(s, k); 159 | if (!s) 160 | return soap->error = SOAP_TYPE; 161 | switch (k) 162 | { case 'H': 163 | H = n; 164 | break; 165 | case 'M': 166 | N = n; 167 | break; 168 | case '.': 169 | S = n; 170 | if (sscanf(s, "%g", &f) != 1) 171 | return soap->error = SOAP_TYPE; 172 | s = NULL; 173 | continue; 174 | case 'S': 175 | S = n; 176 | break; 177 | default: 178 | return soap->error = SOAP_TYPE; 179 | } 180 | s++; 181 | } 182 | /* convert Y-M-D H:N:S.f to signed long long int */ 183 | *a = sign * ((((((((((((Y * 12) + M) * 30) + D) * 24) + H) * 60) + N) * 60) + S) * 1000) + (long)(1000.0 * f)); 184 | } 185 | return soap->error; 186 | } 187 | 188 | LONG64 *soap_in_xsd__duration(struct soap *soap, const char *tag, LONG64 *a, const char *type) 189 | { if (soap_element_begin_in(soap, tag, 0, NULL)) 190 | return NULL; 191 | if (*soap->type 192 | && soap_match_tag(soap, soap->type, type) 193 | && soap_match_tag(soap, soap->type, ":duration")) 194 | { soap->error = SOAP_TYPE; 195 | soap_revert(soap); 196 | return NULL; 197 | } 198 | a = (LONG64*)soap_id_enter(soap, soap->id, a, SOAP_TYPE_xsd__duration, sizeof(LONG64), 0, NULL, NULL, NULL); 199 | if (*soap->href) 200 | a = (LONG64*)soap_id_forward(soap, soap->href, a, 0, SOAP_TYPE_xsd__duration, 0, sizeof(LONG64), 0, NULL); 201 | else if (a) 202 | { if (soap_s2xsd__duration(soap, soap_value(soap), a)) 203 | return NULL; 204 | } 205 | if (soap->body && soap_element_end_in(soap, tag)) 206 | return NULL; 207 | return a; 208 | } 209 | -------------------------------------------------------------------------------- /OnvifSDK/xml/addressing.xsd: -------------------------------------------------------------------------------- 1 | 2 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | If "Policy" elements from namespace "http://schemas.xmlsoap.org/ws/2002/12/policy#policy" are used, they must appear first (before any extensibility elements). 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /OnvifSDK/include/DeviceIOServiceImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef WebDeviceIOBindingServiceImpl_H 2 | #define WebDeviceIOBindingServiceImpl_H 3 | 4 | #include "WebDeviceIOBindingService.h" 5 | class BaseServer; 6 | 7 | namespace Web { 8 | class DeviceIOServiceImpl : public DeviceIOBindingService 9 | { 10 | private: 11 | BaseServer * m_pBaseServer; 12 | public: 13 | DeviceIOServiceImpl(BaseServer * pBaseServer, struct soap * pData):DeviceIOBindingService(pData) 14 | { 15 | m_pBaseServer = pBaseServer; 16 | }; 17 | 18 | virtual DeviceIOBindingService* copy(); 19 | 20 | /// Web service operation 'GetServiceCapabilities' (returns error code or SOAP_OK) 21 | virtual int GetServiceCapabilities(_tmd__GetServiceCapabilities *tmd__GetServiceCapabilities, _tmd__GetServiceCapabilitiesResponse *tmd__GetServiceCapabilitiesResponse) {return SOAP_OK;}; 22 | 23 | /// Web service operation 'GetRelayOutputOptions' (returns error code or SOAP_OK) 24 | virtual int GetRelayOutputOptions(_tmd__GetRelayOutputOptions *tmd__GetRelayOutputOptions, _tmd__GetRelayOutputOptionsResponse *tmd__GetRelayOutputOptionsResponse) {return SOAP_OK;}; 25 | 26 | /// Web service operation 'GetAudioSources' (returns error code or SOAP_OK) 27 | virtual int GetAudioSources(_trt__GetAudioSources *trt__GetAudioSources, _trt__GetAudioSourcesResponse *trt__GetAudioSourcesResponse) {return SOAP_OK;}; 28 | 29 | /// Web service operation 'GetAudioOutputs' (returns error code or SOAP_OK) 30 | virtual int GetAudioOutputs(_trt__GetAudioOutputs *trt__GetAudioOutputs, _trt__GetAudioOutputsResponse *trt__GetAudioOutputsResponse) {return SOAP_OK;}; 31 | 32 | /// Web service operation 'GetVideoSources' (returns error code or SOAP_OK) 33 | virtual int GetVideoSources(_trt__GetVideoSources *trt__GetVideoSources, _trt__GetVideoSourcesResponse *trt__GetVideoSourcesResponse) {return SOAP_OK;}; 34 | 35 | /// Web service operation 'GetVideoOutputs' (returns error code or SOAP_OK) 36 | virtual int GetVideoOutputs(_tmd__GetVideoOutputs *tmd__GetVideoOutputs, _tmd__GetVideoOutputsResponse *tmd__GetVideoOutputsResponse); 37 | 38 | /// Web service operation 'GetVideoSourceConfiguration' (returns error code or SOAP_OK) 39 | virtual int GetVideoSourceConfiguration(_tmd__GetVideoSourceConfiguration *tmd__GetVideoSourceConfiguration, _tmd__GetVideoSourceConfigurationResponse *tmd__GetVideoSourceConfigurationResponse) {return SOAP_OK;}; 40 | 41 | /// Web service operation 'GetVideoOutputConfiguration' (returns error code or SOAP_OK) 42 | virtual int GetVideoOutputConfiguration(_tmd__GetVideoOutputConfiguration *tmd__GetVideoOutputConfiguration, _tmd__GetVideoOutputConfigurationResponse *tmd__GetVideoOutputConfigurationResponse) {return SOAP_OK;}; 43 | 44 | /// Web service operation 'GetAudioSourceConfiguration' (returns error code or SOAP_OK) 45 | virtual int GetAudioSourceConfiguration(_tmd__GetAudioSourceConfiguration *tmd__GetAudioSourceConfiguration, _tmd__GetAudioSourceConfigurationResponse *tmd__GetAudioSourceConfigurationResponse) {return SOAP_OK;}; 46 | 47 | /// Web service operation 'GetAudioOutputConfiguration' (returns error code or SOAP_OK) 48 | virtual int GetAudioOutputConfiguration(_tmd__GetAudioOutputConfiguration *tmd__GetAudioOutputConfiguration, _tmd__GetAudioOutputConfigurationResponse *tmd__GetAudioOutputConfigurationResponse) {return SOAP_OK;}; 49 | 50 | /// Web service operation 'SetVideoSourceConfiguration' (returns error code or SOAP_OK) 51 | virtual int SetVideoSourceConfiguration(_tmd__SetVideoSourceConfiguration *tmd__SetVideoSourceConfiguration, _tmd__SetVideoSourceConfigurationResponse *tmd__SetVideoSourceConfigurationResponse) {return SOAP_OK;}; 52 | 53 | /// Web service operation 'SetVideoOutputConfiguration' (returns error code or SOAP_OK) 54 | virtual int SetVideoOutputConfiguration(_tmd__SetVideoOutputConfiguration *tmd__SetVideoOutputConfiguration, _tmd__SetVideoOutputConfigurationResponse *tmd__SetVideoOutputConfigurationResponse) {return SOAP_OK;}; 55 | 56 | /// Web service operation 'SetAudioSourceConfiguration' (returns error code or SOAP_OK) 57 | virtual int SetAudioSourceConfiguration(_tmd__SetAudioSourceConfiguration *tmd__SetAudioSourceConfiguration, _tmd__SetAudioSourceConfigurationResponse *tmd__SetAudioSourceConfigurationResponse) {return SOAP_OK;}; 58 | 59 | /// Web service operation 'SetAudioOutputConfiguration' (returns error code or SOAP_OK) 60 | virtual int SetAudioOutputConfiguration(_tmd__SetAudioOutputConfiguration *tmd__SetAudioOutputConfiguration, _tmd__SetAudioOutputConfigurationResponse *tmd__SetAudioOutputConfigurationResponse) {return SOAP_OK;}; 61 | 62 | /// Web service operation 'GetVideoSourceConfigurationOptions' (returns error code or SOAP_OK) 63 | virtual int GetVideoSourceConfigurationOptions(_tmd__GetVideoSourceConfigurationOptions *tmd__GetVideoSourceConfigurationOptions, _tmd__GetVideoSourceConfigurationOptionsResponse *tmd__GetVideoSourceConfigurationOptionsResponse) {return SOAP_OK;}; 64 | 65 | /// Web service operation 'GetVideoOutputConfigurationOptions' (returns error code or SOAP_OK) 66 | virtual int GetVideoOutputConfigurationOptions(_tmd__GetVideoOutputConfigurationOptions *tmd__GetVideoOutputConfigurationOptions, _tmd__GetVideoOutputConfigurationOptionsResponse *tmd__GetVideoOutputConfigurationOptionsResponse) {return SOAP_OK;}; 67 | 68 | /// Web service operation 'GetAudioSourceConfigurationOptions' (returns error code or SOAP_OK) 69 | virtual int GetAudioSourceConfigurationOptions(_tmd__GetAudioSourceConfigurationOptions *tmd__GetAudioSourceConfigurationOptions, _tmd__GetAudioSourceConfigurationOptionsResponse *tmd__GetAudioSourceConfigurationOptionsResponse) {return SOAP_OK;}; 70 | 71 | /// Web service operation 'GetAudioOutputConfigurationOptions' (returns error code or SOAP_OK) 72 | virtual int GetAudioOutputConfigurationOptions(_tmd__GetAudioOutputConfigurationOptions *tmd__GetAudioOutputConfigurationOptions, _tmd__GetAudioOutputConfigurationOptionsResponse *tmd__GetAudioOutputConfigurationOptionsResponse) {return SOAP_OK;}; 73 | 74 | /// Web service operation 'GetRelayOutputs' (returns error code or SOAP_OK) 75 | virtual int GetRelayOutputs(_tds__GetRelayOutputs *tds__GetRelayOutputs, _tds__GetRelayOutputsResponse *tds__GetRelayOutputsResponse) {return SOAP_OK;}; 76 | 77 | /// Web service operation 'SetRelayOutputSettings' (returns error code or SOAP_OK) 78 | virtual int SetRelayOutputSettings(_tmd__SetRelayOutputSettings *tmd__SetRelayOutputSettings, _tmd__SetRelayOutputSettingsResponse *tmd__SetRelayOutputSettingsResponse) {return SOAP_OK;}; 79 | 80 | /// Web service operation 'SetRelayOutputState' (returns error code or SOAP_OK) 81 | virtual int SetRelayOutputState(_tds__SetRelayOutputState *tds__SetRelayOutputState, _tds__SetRelayOutputStateResponse *tds__SetRelayOutputStateResponse) {return SOAP_OK;}; 82 | 83 | /// Web service operation 'GetDigitalInputs' (returns error code or SOAP_OK) 84 | virtual int GetDigitalInputs(_tmd__GetDigitalInputs *tmd__GetDigitalInputs, _tmd__GetDigitalInputsResponse *tmd__GetDigitalInputsResponse) {return SOAP_OK;}; 85 | 86 | /// Web service operation 'GetSerialPorts' (returns error code or SOAP_OK) 87 | virtual int GetSerialPorts(_tmd__GetSerialPorts *tmd__GetSerialPorts, _tmd__GetSerialPortsResponse *tmd__GetSerialPortsResponse) {return SOAP_OK;}; 88 | 89 | /// Web service operation 'GetSerialPortConfiguration' (returns error code or SOAP_OK) 90 | virtual int GetSerialPortConfiguration(_tmd__GetSerialPortConfiguration *tmd__GetSerialPortConfiguration, _tmd__GetSerialPortConfigurationResponse *tmd__GetSerialPortConfigurationResponse) {return SOAP_OK;}; 91 | 92 | /// Web service operation 'SetSerialPortConfiguration' (returns error code or SOAP_OK) 93 | virtual int SetSerialPortConfiguration(_tmd__SetSerialPortConfiguration *tmd__SetSerialPortConfiguration, _tmd__SetSerialPortConfigurationResponse *tmd__SetSerialPortConfigurationResponse) {return SOAP_OK;}; 94 | 95 | /// Web service operation 'GetSerialPortConfigurationOptions' (returns error code or SOAP_OK) 96 | virtual int GetSerialPortConfigurationOptions(_tmd__GetSerialPortConfigurationOptions *tmd__GetSerialPortConfigurationOptions, _tmd__GetSerialPortConfigurationOptionsResponse *tmd__GetSerialPortConfigurationOptionsResponse) {return SOAP_OK;}; 97 | 98 | /// Web service operation 'SendReceiveSerialCommand' (returns error code or SOAP_OK) 99 | virtual int SendReceiveSerialCommand(_tmd__SendReceiveSerialCommand *tmd__SendReceiveSerialCommand, _tmd__SendReceiveSerialCommandResponse *tmd__SendReceiveSerialCommandResponse) {return SOAP_OK;}; 100 | }; 101 | }; // namespace Web 102 | #endif // WebDeviceIOBindingServiceImpl_H 103 | -------------------------------------------------------------------------------- /OnvifSDK/xml/t-1.xsd: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 35 | 36 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 67 | 68 | 69 | 71 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 97 | 99 | 100 | 101 | 102 | 103 | 104 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | TopicPathExpression ::= TopicPath ( '|' TopicPath )* 143 | TopicPath ::= RootTopic ChildTopicExpression* 144 | RootTopic ::= NamespacePrefix? ('//')? (NCName | '*') 145 | NamespacePrefix ::= NCName ':' 146 | ChildTopicExpression ::= '/' '/'? (QName | NCName | '*'| '.') 147 | 148 | 149 | 150 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | The pattern allows strings matching the following EBNF: 161 | ConcreteTopicPath ::= RootTopic ChildTopic* 162 | RootTopic ::= QName 163 | ChildTopic ::= '/' (QName | NCName) 164 | 165 | 166 | 167 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | The pattern allows strings matching the following EBNF: 178 | RootTopic ::= QName 179 | 180 | 181 | 182 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /OnvifSDK/source/DeviceTypes.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "OnvifSDK.h" 3 | #include "commonTypes.h" 4 | #include "WebDeviceBindingProxy.h" 5 | 6 | namespace Web { 7 | //////////////////////////////////////////////////////////////////////////////// 8 | //////////////////////////////////////////////////////////////////////////////// 9 | //////////////////////////////////////////////////////////////////////////////// 10 | 11 | #define EXTRA_CONSTRUCT() \ 12 | {\ 13 | if(this->d->UTCDateTime == 0) this->d->UTCDateTime = soap_new_tt__DateTime(this->d->soap, -1);\ 14 | if(this->d->UTCDateTime->Time == 0) this->d->UTCDateTime->Time = soap_new_tt__Time(this->d->soap, -1);\ 15 | if(this->d->UTCDateTime->Date == 0) this->d->UTCDateTime->Date = soap_new_tt__Date(this->d->soap, -1);\ 16 | } 17 | 18 | CLASS_CTORS(tds, Dev, SetSystemDateAndTime) 19 | 20 | 21 | int DevSetSystemDateAndTime::SetUTCDateAndTime(int year, int month, int day, int hour, int min, int sec) 22 | { 23 | this->d->UTCDateTime->Date->Year = year; 24 | this->d->UTCDateTime->Date->Month = month; 25 | this->d->UTCDateTime->Date->Day = day; 26 | 27 | this->d->UTCDateTime->Time->Hour = hour; 28 | this->d->UTCDateTime->Time->Minute = min; 29 | this->d->UTCDateTime->Time->Second = sec; 30 | 31 | this->d->DateTimeType = tt__SetDateTimeType__Manual; 32 | 33 | return 0; 34 | } 35 | 36 | int DevSetSystemDateAndTime::GetUTCDateAndTime(int & year, int & month, int & day, int & hour, int & min, int & sec) const 37 | { 38 | year = this->d->UTCDateTime->Date->Year; 39 | month = this->d->UTCDateTime->Date->Month; 40 | day = this->d->UTCDateTime->Date->Day; 41 | 42 | hour = this->d->UTCDateTime->Time->Hour; 43 | min = this->d->UTCDateTime->Time->Minute; 44 | sec = this->d->UTCDateTime->Time->Second; 45 | 46 | return 0; 47 | } 48 | 49 | //////////////////////////////////////////////////////////////////////////////// 50 | 51 | #define EXTRA_CONSTRUCT() \ 52 | {\ 53 | } 54 | 55 | CLASS_CTORS(tds, Dev, SetSystemDateAndTimeResponse) 56 | 57 | 58 | //////////////////////////////////////////////////////////////////////////////// 59 | //////////////////////////////////////////////////////////////////////////////// 60 | //////////////////////////////////////////////////////////////////////////////// 61 | 62 | #define EXTRA_CONSTRUCT() \ 63 | {\ 64 | } 65 | 66 | CLASS_CTORS(tds, Dev, GetSystemDateAndTime) 67 | 68 | 69 | //////////////////////////////////////////////////////////////////////////////// 70 | 71 | #define EXTRA_CONSTRUCT() \ 72 | {\ 73 | if(this->d->SystemDateAndTime == 0) this->d->SystemDateAndTime = soap_new_tt__SystemDateTime(this->d->soap, -1);\ 74 | if(this->d->SystemDateAndTime->UTCDateTime == 0) this->d->SystemDateAndTime->UTCDateTime = soap_new_tt__DateTime(this->d->soap, -1);\ 75 | if(this->d->SystemDateAndTime->UTCDateTime->Time == 0) this->d->SystemDateAndTime->UTCDateTime->Time = soap_new_tt__Time(this->d->soap, -1);\ 76 | if(this->d->SystemDateAndTime->UTCDateTime->Date == 0) this->d->SystemDateAndTime->UTCDateTime->Date = soap_new_tt__Date(this->d->soap, -1);\ 77 | } 78 | 79 | CLASS_CTORS(tds, Dev, GetSystemDateAndTimeResponse) 80 | 81 | 82 | int DevGetSystemDateAndTimeResponse::SetUTCDateAndTime(int year, int month, int day, int hour, int min, int sec) 83 | { 84 | this->d->SystemDateAndTime->UTCDateTime->Date->Year = year; 85 | this->d->SystemDateAndTime->UTCDateTime->Date->Month = month; 86 | this->d->SystemDateAndTime->UTCDateTime->Date->Day = day; 87 | 88 | this->d->SystemDateAndTime->UTCDateTime->Time->Hour = hour; 89 | this->d->SystemDateAndTime->UTCDateTime->Time->Minute = min; 90 | this->d->SystemDateAndTime->UTCDateTime->Time->Second = sec; 91 | 92 | return 0; 93 | } 94 | 95 | int DevGetSystemDateAndTimeResponse::GetUTCDateAndTime(int & year, int & month, int & day, int & hour, int & min, int & sec) const 96 | { 97 | year = this->d->SystemDateAndTime->UTCDateTime->Date->Year; 98 | month = this->d->SystemDateAndTime->UTCDateTime->Date->Month; 99 | day = this->d->SystemDateAndTime->UTCDateTime->Date->Day; 100 | 101 | hour = this->d->SystemDateAndTime->UTCDateTime->Time->Hour; 102 | min = this->d->SystemDateAndTime->UTCDateTime->Time->Minute; 103 | sec = this->d->SystemDateAndTime->UTCDateTime->Time->Second; 104 | 105 | return 0; 106 | } 107 | 108 | //////////////////////////////////////////////////////////////////////////////// 109 | //////////////////////////////////////////////////////////////////////////////// 110 | //////////////////////////////////////////////////////////////////////////////// 111 | 112 | #define EXTRA_CONSTRUCT() \ 113 | {\ 114 | } 115 | 116 | CLASS_CTORS(tds, Dev, GetUsers) 117 | 118 | 119 | //////////////////////////////////////////////////////////////////////////////// 120 | 121 | #define EXTRA_CONSTRUCT() \ 122 | {\ 123 | } 124 | 125 | CLASS_CTORS(tds, Dev, GetUsersResponse) 126 | 127 | 128 | int DevGetUsersResponse::AddUser(std::vector user) 129 | { 130 | tt__User * pUser = soap_new_tt__User(this->d->soap,-1); 131 | pUser->Password = soap_new_std__string(this->d->soap,-1); 132 | 133 | pUser->Username = user[0]; 134 | *(pUser->Password) = user[1]; 135 | pUser->UserLevel = user[2] == "Administrator" ? tt__UserLevel__Administrator : 136 | user[2] == "Operator" ? tt__UserLevel__Operator : 137 | user[2] == "User" ? tt__UserLevel__User : 138 | user[2] == "Anonymous" ? tt__UserLevel__Anonymous : tt__UserLevel__Extended; 139 | 140 | this->d->User.push_back(pUser); 141 | 142 | return 0; 143 | } 144 | 145 | int DevGetUsersResponse::GetUsers(std::vector & users) const 146 | { 147 | for(size_t i = 0; i < this->d->User.size(); ++i) 148 | { 149 | users.push_back(this->d->User[i]->Username); 150 | users.push_back(*(this->d->User[i]->Password)); 151 | 152 | std::string strUserLevel = tt__UserLevel__Administrator ? "Administrator" : 153 | tt__UserLevel__Operator ? "Operator" : 154 | tt__UserLevel__User ? "User" : 155 | tt__UserLevel__Anonymous ? "Anonymous" : "Extended"; 156 | 157 | 158 | users.push_back(strUserLevel); 159 | } 160 | 161 | return 0; 162 | } 163 | 164 | //////////////////////////////////////////////////////////////////////////////// 165 | //////////////////////////////////////////////////////////////////////////////// 166 | //////////////////////////////////////////////////////////////////////////////// 167 | 168 | #define EXTRA_CONSTRUCT() \ 169 | {\ 170 | } 171 | 172 | CLASS_CTORS(tds, Dev, GetDeviceInformation) 173 | 174 | 175 | //////////////////////////////////////////////////////////////////////////////// 176 | 177 | #define EXTRA_CONSTRUCT() \ 178 | {\ 179 | } 180 | 181 | CLASS_CTORS(tds, Dev, GetDeviceInformationResponse) 182 | 183 | 184 | int DevGetDeviceInformationResponse::SetDeviceInfo(std::string strManufacturer, std::string strModel, 185 | std::string strFirmwareVersion, std::string strSerialNumber, std::string strHardwareId) 186 | { 187 | this->d->Manufacturer = strManufacturer; 188 | this->d->Model = strModel; 189 | this->d->FirmwareVersion = strFirmwareVersion; 190 | this->d->SerialNumber = strSerialNumber; 191 | this->d->HardwareId = strHardwareId; 192 | 193 | return 0; 194 | } 195 | 196 | int DevGetDeviceInformationResponse::GetDeviceInfo(std::string & strManufacturer, std::string & strModel, 197 | std::string & strFirmwareVersion, std::string & strSerialNumber, std::string & strHardwareId) const 198 | { 199 | strManufacturer = this->d->Manufacturer; 200 | strModel = this->d->Model; 201 | strFirmwareVersion = this->d->FirmwareVersion; 202 | strSerialNumber = this->d->SerialNumber; 203 | strHardwareId = this->d->HardwareId; 204 | 205 | return 0; 206 | } 207 | 208 | //////////////////////////////////////////////////////////////////////////////// 209 | //////////////////////////////////////////////////////////////////////////////// 210 | //////////////////////////////////////////////////////////////////////////////// 211 | 212 | #define EXTRA_CONSTRUCT() \ 213 | {\ 214 | } 215 | 216 | CLASS_CTORS(tds, Dev, GetCapabilities) 217 | 218 | 219 | //////////////////////////////////////////////////////////////////////////////// 220 | 221 | #define EXTRA_CONSTRUCT() \ 222 | {\ 223 | this->d->Capabilities = soap_new_tt__Capabilities(this->d->soap,-1);\ 224 | this->d->Capabilities->Device = soap_new_tt__DeviceCapabilities(this->d->soap,-1);\ 225 | } 226 | 227 | CLASS_CTORS(tds, Dev, GetCapabilitiesResponse) 228 | 229 | 230 | int DevGetCapabilitiesResponse::SetCapsDevice(std::string xaddr) 231 | { 232 | this->d->Capabilities->Device->XAddr = xaddr; 233 | 234 | return 0; 235 | } 236 | 237 | int DevGetCapabilitiesResponse::GetCapsDevice(std::string & xaddr) const 238 | { 239 | xaddr = this->d->Capabilities->Device->XAddr; 240 | 241 | return 0; 242 | } 243 | 244 | //////////////////////////////////////////////////////////////////////////////// 245 | //////////////////////////////////////////////////////////////////////////////// 246 | //////////////////////////////////////////////////////////////////////////////// 247 | 248 | #define EXTRA_CONSTRUCT() \ 249 | {\ 250 | } 251 | 252 | CLASS_CTORS(tds, Dev, GetServices) 253 | 254 | 255 | //////////////////////////////////////////////////////////////////////////////// 256 | 257 | #define EXTRA_CONSTRUCT() \ 258 | {\ 259 | } 260 | 261 | CLASS_CTORS(tds, Dev, GetServicesResponse) 262 | 263 | 264 | int DevGetServicesResponse::AddService(std::string & nameSpace, std::string & xaddr) 265 | { 266 | tds__Service * pServiceEntry = soap_new_tds__Service(this->d->soap); 267 | pServiceEntry->Namespace = nameSpace; 268 | pServiceEntry->XAddr = xaddr; 269 | this->d->Service.push_back(pServiceEntry); 270 | } 271 | 272 | //////////////////////////////////////////////////////////////////////////////// 273 | //////////////////////////////////////////////////////////////////////////////// 274 | //////////////////////////////////////////////////////////////////////////////// 275 | } // namespace Web 276 | -------------------------------------------------------------------------------- /OnvifSDK/source/DisplayTypes.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "sigrlog.h" 3 | #include "OnvifSDK.h" 4 | #include "commonTypes.h" 5 | #include "WebDisplayBindingProxy.h" 6 | 7 | namespace Web { 8 | //////////////////////////////////////////////////////////////////////////////// 9 | //////////////////////////////////////////////////////////////////////////////// 10 | //////////////////////////////////////////////////////////////////////////////// 11 | 12 | #define EXTRA_CONSTRUCT() \ 13 | {\ 14 | } 15 | 16 | CLASS_CTORS(tls, Disp, GetLayout) 17 | 18 | int DispGetLayout::SetLayout(const std::string & str) 19 | { 20 | this->d->VideoOutput = str; 21 | return 0; 22 | } 23 | 24 | int DispGetLayout::GetLayout(std::string & str) const 25 | { 26 | str = this->d->VideoOutput; 27 | return 0; 28 | } 29 | 30 | //////////////////////////////////////////////////////////////////////////////// 31 | #define EXTRA_CONSTRUCT() \ 32 | {\ 33 | if(this->d->Layout == 0) this->d->Layout = soap_new_tt__Layout(this->d->soap);\ 34 | } 35 | 36 | CLASS_CTORS(tls, Disp, GetLayoutResponse) 37 | 38 | int DispGetLayoutResponse::SetLayout(const std::string & str) 39 | { 40 | tt__PaneLayout * paneLayout = soap_new_tt__PaneLayout(this->d->soap); 41 | 42 | paneLayout->Pane = str.c_str(); 43 | paneLayout->Area = soap_new_tt__Rectangle(this->d->soap); 44 | paneLayout->Area->bottom = new float(0.0f); 45 | paneLayout->Area->top = new float(0.0f); 46 | paneLayout->Area->left = new float(1.0f); 47 | paneLayout->Area->right = new float(1.0f); 48 | 49 | this->d->Layout->PaneLayout.push_back(paneLayout); 50 | 51 | return 0; 52 | } 53 | 54 | int DispGetLayoutResponse::GetLayout(std::string & str) const 55 | { 56 | str = this->d->Layout->PaneLayout[0]->Pane; 57 | return 0; 58 | } 59 | 60 | //////////////////////////////////////////////////////////////////////////////// 61 | //////////////////////////////////////////////////////////////////////////////// 62 | //////////////////////////////////////////////////////////////////////////////// 63 | 64 | #define EXTRA_CONSTRUCT() \ 65 | {\ 66 | } 67 | 68 | CLASS_CTORS(tls, Disp, GetDisplayOptions) 69 | 70 | 71 | int DispGetDisplayOptions::GetVO(std::string & str) const 72 | { 73 | str = d->VideoOutput; 74 | return 0; 75 | } 76 | 77 | 78 | int DispGetDisplayOptions::SetVO(const std::string & str) 79 | { 80 | d->VideoOutput = str; 81 | return 0; 82 | } 83 | 84 | 85 | //////////////////////////////////////////////////////////////////////////////// 86 | 87 | #define EXTRA_CONSTRUCT() \ 88 | {\ 89 | if(this->d->LayoutOptions == 0) this->d->LayoutOptions = soap_new_tt__LayoutOptions(this->d->soap);\ 90 | if(this->d->CodingCapabilities == 0) this->d->CodingCapabilities = soap_new_tt__CodingCapabilities(this->d->soap);\ 91 | } 92 | 93 | CLASS_CTORS(tls, Disp, GetDisplayOptionsResponse) 94 | 95 | inline tt__Rectangle * makeSoapRectangle(soap * s, float bottom, float top, float left, float right) __attribute__((always_inline)); 96 | 97 | inline tt__Rectangle * makeSoapRectangle(soap * s, float bottom, float top, float left, float right) 98 | { 99 | float * pbot = new float(bottom); 100 | float * ptop = new float(top); 101 | float * pleft = new float(left); 102 | float * pright = new float(right); 103 | 104 | return soap_new_set_tt__Rectangle(s, pbot, ptop, pright, pleft); 105 | } 106 | 107 | int DispGetDisplayOptionsResponse::Set4FixedLayouts(const float flayout1[1*4], const float flayout4[4*4], const float flayout9[9*4], const float flayout16[16*4]) 108 | { 109 | // bottom = -1.0 110 | // top = 1.0 111 | // left = -1.0 112 | // tight = 1.0 113 | 114 | // panes counted from left to right from top to bottom 115 | 116 | // 1 pane layout 117 | tt__PaneLayoutOptions * layout1 = soap_new_tt__PaneLayoutOptions(d->soap, -1); 118 | 119 | layout1->Area.push_back(makeSoapRectangle(d->soap, flayout1[0], flayout1[1], flayout1[2], flayout1[3])); 120 | 121 | d->LayoutOptions->PaneLayoutOptions.push_back(layout1); 122 | 123 | // 4 pane layout 124 | tt__PaneLayoutOptions * layout4 = soap_new_tt__PaneLayoutOptions(d->soap, -1); 125 | 126 | for(int i = 0; i < 4; i++) 127 | { 128 | layout4->Area.push_back(makeSoapRectangle(d->soap, flayout4[i*4+0], flayout4[i*4+1], flayout4[i*4+2], flayout4[i*4+3])); 129 | } 130 | 131 | d->LayoutOptions->PaneLayoutOptions.push_back(layout4); 132 | 133 | // 9 pane layout 134 | tt__PaneLayoutOptions * layout9 = soap_new_tt__PaneLayoutOptions(d->soap, -1); 135 | 136 | for(int i = 0; i < 9; i++) 137 | { 138 | layout9->Area.push_back(makeSoapRectangle(d->soap, flayout9[i*4+0], flayout9[i*4+1], flayout9[i*4+2], flayout9[i*4+3])); 139 | } 140 | 141 | d->LayoutOptions->PaneLayoutOptions.push_back(layout9); 142 | 143 | // 16 pane layout 144 | tt__PaneLayoutOptions * layout16 = soap_new_tt__PaneLayoutOptions(d->soap, -1); 145 | 146 | for(int i = 0; i < 16; i++) 147 | { 148 | layout16->Area.push_back(makeSoapRectangle(d->soap, flayout16[i*4+0], flayout16[i*4+1], flayout16[i*4+2], flayout16[i*4+3])); 149 | } 150 | 151 | d->LayoutOptions->PaneLayoutOptions.push_back(layout16); 152 | } 153 | 154 | int DispGetDisplayOptionsResponse::GetLayoutOptions(std::vector< std::vector > & layoutOptions) const 155 | { 156 | for(size_t i = 0; i < d->LayoutOptions->PaneLayoutOptions.size(); ++i) 157 | { 158 | std::vector area; 159 | for(size_t j = 0; j < d->LayoutOptions->PaneLayoutOptions[i]->Area.size(); j++) 160 | { 161 | DispRectangle rect; 162 | rect.bot = *d->LayoutOptions->PaneLayoutOptions[i]->Area[j]->bottom; 163 | rect.top = *d->LayoutOptions->PaneLayoutOptions[i]->Area[j]->top; 164 | rect.left = *d->LayoutOptions->PaneLayoutOptions[i]->Area[j]->left; 165 | rect.right = *d->LayoutOptions->PaneLayoutOptions[i]->Area[j]->right; 166 | area.push_back(rect); 167 | } 168 | layoutOptions.push_back(area); 169 | } 170 | 171 | 172 | return 0; 173 | } 174 | 175 | //////////////////////////////////////////////////////////////////////////////// 176 | //////////////////////////////////////////////////////////////////////////////// 177 | //////////////////////////////////////////////////////////////////////////////// 178 | 179 | #define EXTRA_CONSTRUCT() \ 180 | {\ 181 | if(this->d->Layout == 0) this->d->Layout = soap_new_tt__Layout(this->d->soap);\ 182 | } 183 | 184 | CLASS_CTORS(tls, Disp, SetLayout) 185 | 186 | int DispSetLayout::GetVO(std::string & vo) 187 | { 188 | vo = d->VideoOutput; 189 | 190 | return 0; 191 | } 192 | 193 | int DispSetLayout::GetLayout(std::vector > & panelayouts) 194 | { 195 | for(size_t i = 0; i < d->Layout->PaneLayout.size(); ++i) 196 | { 197 | std::string token = d->Layout->PaneLayout[i]->Pane; 198 | DispRectangle rect; 199 | rect.bot = *d->Layout->PaneLayout[i]->Area->bottom; 200 | rect.top = *d->Layout->PaneLayout[i]->Area->top; 201 | rect.left = *d->Layout->PaneLayout[i]->Area->left; 202 | rect.right = *d->Layout->PaneLayout[i]->Area->right; 203 | 204 | panelayouts.push_back(std::pair(token, rect)); 205 | } 206 | 207 | return 0; 208 | } 209 | 210 | int DispSetLayout::SetVO(const std::string & vo) 211 | { 212 | d->VideoOutput = vo; 213 | 214 | return 0; 215 | } 216 | 217 | int DispSetLayout::SetLayout(const std::vector< std::pair > & panelayouts) 218 | { 219 | std::vector< std::pair >::const_iterator itr; 220 | 221 | for(itr = panelayouts.begin(); itr != panelayouts.end(); ++itr) 222 | { 223 | tt__PaneLayout * pl = soap_new_tt__PaneLayout(d->soap, -1); 224 | 225 | pl->Area = makeSoapRectangle(d->soap, (*itr).second.bot, (*itr).second.top, (*itr).second.left, (*itr).second.right); 226 | pl->Pane = (*itr).first; 227 | 228 | d->Layout->PaneLayout.push_back(pl); 229 | } 230 | 231 | return 0; 232 | } 233 | 234 | //////////////////////////////////////////////////////////////////////////////// 235 | 236 | #define EXTRA_CONSTRUCT() \ 237 | {\ 238 | } 239 | 240 | CLASS_CTORS(tls, Disp, SetLayoutResponse) 241 | 242 | //////////////////////////////////////////////////////////////////////////////// 243 | //////////////////////////////////////////////////////////////////////////////// 244 | //////////////////////////////////////////////////////////////////////////////// 245 | 246 | #define EXTRA_CONSTRUCT() \ 247 | {\ 248 | } 249 | 250 | CLASS_CTORS(tls, Disp, CreatePaneConfiguration) 251 | 252 | int DispCreatePaneConfiguration::GetPaneConfig(std::string & videoOutput, std::string & paneToken, std::string & receiverToken) const 253 | { 254 | videoOutput = d->VideoOutput; 255 | paneToken = d->PaneConfiguration->Token; 256 | receiverToken = *d->PaneConfiguration->ReceiverToken; 257 | 258 | return 0; 259 | } 260 | 261 | int DispCreatePaneConfiguration::SetPaneConfig(const std::string & videoOutput, const std::string & paneToken, const std::string & receiverToken) 262 | { 263 | d->PaneConfiguration = soap_new_tt__PaneConfiguration(d->soap, -1); 264 | d->PaneConfiguration->ReceiverToken = soap_new_std__string(d->soap, -1); 265 | 266 | d->VideoOutput = videoOutput; 267 | d->PaneConfiguration->Token = paneToken; 268 | *d->PaneConfiguration->ReceiverToken = receiverToken; 269 | 270 | return 0; 271 | } 272 | 273 | //////////////////////////////////////////////////////////////////////////////// 274 | 275 | #define EXTRA_CONSTRUCT() \ 276 | {\ 277 | } 278 | 279 | CLASS_CTORS(tls, Disp, CreatePaneConfigurationResponse) 280 | 281 | int DispCreatePaneConfigurationResponse::SetPaneConfigToken(const std::string & paneConfigToken) 282 | { 283 | d->PaneToken = paneConfigToken; 284 | 285 | return 0; 286 | } 287 | 288 | int DispCreatePaneConfigurationResponse::GetPaneConfigToken(std::string & paneConfigToken) const 289 | { 290 | paneConfigToken = d->PaneToken; 291 | 292 | return 0; 293 | } 294 | } // namespace Web 295 | -------------------------------------------------------------------------------- /OnvifSDK/WsDiscovery/wsa.cpp: -------------------------------------------------------------------------------- 1 | #include "wsa.hpp" 2 | //#include 3 | 4 | namespace { 5 | /** Anonymous Reply/To endpoint address */ 6 | static const std::string ANONYMOUS_URI = "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous"; 7 | /** Specifies no Reply endpoint address (no reply) */ 8 | static const std::string NONE_URI = "addressing/none not supported"; 9 | static const std::string FAULT_ACTION = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault"; 10 | 11 | int wsaError(soap * s, wsa__FaultSubcodeValues fault) 12 | { 13 | const char * code = soap_wsa__FaultSubcodeValues2s(s, fault); 14 | switch (fault) { 15 | case wsa__FaultSubcodeValues__wsa__InvalidMessageInformationHeader: 16 | return soap_sender_fault_subcode(s, code, "A message information header is not valid and the message cannot be processed. The validity failure can be either structural or semantic, e.g. a [destination] that is not a URI or a [relationship] to a [message id] that was never issued.", "Invalid header"); 17 | case wsa__FaultSubcodeValues__wsa__MessageInformationHeaderRequired: 18 | return soap_sender_fault_subcode(s, code, "A required message information header, To, MessageID, or Action, is not present.", "Missing Header QName"); 19 | case wsa__FaultSubcodeValues__wsa__DestinationUnreachable: 20 | return soap_sender_fault_subcode(s, code, "No route can be determined to reach the destination role defined by the WS-Addressing To.", NULL); 21 | case wsa__FaultSubcodeValues__wsa__ActionNotSupported: 22 | return soap_sender_fault_subcode(s, code, "The [action] cannot be processed at the receiver.", s->action); 23 | case wsa__FaultSubcodeValues__wsa__EndpointUnavailable: 24 | return soap_sender_fault(s, code, "The endpoint is unable to process the message at this time."); 25 | default: 26 | break; 27 | } 28 | 29 | return SOAP_FAULT; 30 | } 31 | 32 | }; 33 | 34 | 35 | Wsa::Wsa(struct soap * soap) : 36 | soap_(soap) 37 | { 38 | sequence_.soap_default(soap); 39 | } 40 | 41 | Wsa::~Wsa() 42 | { 43 | soap_destroy(soap_); 44 | soap_end(soap_); 45 | } 46 | 47 | uint & Wsa::instanceId() 48 | { 49 | static uint rv = time(NULL); 50 | return rv; 51 | } 52 | 53 | std::string & Wsa::sequenceId() 54 | { 55 | static std::string rv; 56 | return rv; 57 | } 58 | 59 | uint & Wsa::messageNumber() 60 | { 61 | static uint rv = 0; 62 | ++rv; 63 | return rv; 64 | } 65 | 66 | std::string Wsa::randUuid() 67 | { 68 | char rv[48]; 69 | int r1, r2, r3, r4; 70 | #ifdef WITH_OPENSSL 71 | r1 = soap_random; 72 | r2 = soap_random; 73 | #else 74 | static int k = 0xFACEB00B; 75 | int lo = k % 127773; 76 | int hi = k / 127773; 77 | # ifdef HAVE_GETTIMEOFDAY 78 | struct timeval tv; 79 | gettimeofday(&tv, NULL); 80 | r1 = 10000000 * tv.tv_sec + tv.tv_usec; 81 | #else 82 | r1 = (int)time(NULL); 83 | # endif 84 | k = 16807 * lo - 2836 * hi; 85 | if (k <= 0) 86 | k += 0x7FFFFFFF; 87 | r2 = k; 88 | k &= 0x8FFFFFFF; 89 | r2 += *(int*)soap_->buf; 90 | #endif 91 | r3 = soap_random; 92 | r4 = soap_random; 93 | sprintf(rv, "uuid:%8.8x-%4.4hx-4%3.3hx-%4.4hx-%4.4hx%8.8x", 94 | r1, (short)(r2 >> 16), (short)r2 >> 4, 95 | ((short)(r3 >> 16) & 0x3FFF) | 0x8000, (short)r3, r4); 96 | 97 | return rv; 98 | } 99 | 100 | int Wsa::allocHeader() 101 | { 102 | soap_header(soap_); 103 | if (soap_->header != NULL) 104 | return SOAP_OK; 105 | 106 | return (soap_->error = SOAP_EOM); 107 | } 108 | 109 | int Wsa::check() const 110 | { 111 | if (soap_->header == NULL || soap_->header->SOAP_WSA(Action).empty()) 112 | return wsaError(soap_, wsa__FaultSubcodeValues__wsa__MessageInformationHeaderRequired); 113 | 114 | return SOAP_OK; 115 | } 116 | 117 | int Wsa::addFrom(const std::string & from) 118 | { 119 | if (soap_->header == NULL) 120 | return SOAP_ERR; 121 | 122 | soap_->header->SOAP_WSA(From) = new wsa__EndpointReferenceType; 123 | soap_->header->SOAP_WSA(From)->soap_default(soap_); 124 | soap_->header->SOAP_WSA(From)->Address->__item = from; 125 | return SOAP_OK; 126 | } 127 | 128 | int Wsa::addNoReply() 129 | { 130 | return addReplyTo(NONE_URI); 131 | } 132 | 133 | int Wsa::addReplyTo(const std::string & replyTo) 134 | { 135 | if (soap_->header == NULL) 136 | return SOAP_ERR; 137 | 138 | if (!replyTo.empty()) { 139 | soap_->header->SOAP_WSA(ReplyTo) = new wsa__EndpointReferenceType; 140 | soap_->header->SOAP_WSA(ReplyTo)->soap_default(soap_); 141 | soap_->header->SOAP_WSA(ReplyTo)->Address->__item = replyTo; 142 | } 143 | 144 | return SOAP_OK; 145 | } 146 | 147 | int Wsa::addFaultTo(const std::string & faultTo) 148 | { 149 | if (soap_->header == NULL) 150 | return SOAP_ERR; 151 | 152 | if (!faultTo.empty()) { 153 | soap_->header->SOAP_WSA(FaultTo) = new wsa__EndpointReferenceType; 154 | soap_->header->SOAP_WSA(FaultTo)->soap_default(soap_); 155 | soap_->header->SOAP_WSA(FaultTo)->Address->__item = faultTo; 156 | } 157 | 158 | return SOAP_OK; 159 | } 160 | 161 | int Wsa::addRelatesTo(const std::string & relatesTo) 162 | { 163 | if (soap_->header == NULL) 164 | return SOAP_ERR; 165 | 166 | if (!relatesTo.empty()) { 167 | soap_->header->SOAP_WSA(RelatesTo) = new wsa__Relationship; 168 | soap_->header->SOAP_WSA(RelatesTo)->soap_default(soap_); 169 | soap_->header->SOAP_WSA(RelatesTo)->__item = relatesTo; 170 | } 171 | 172 | return SOAP_OK; 173 | } 174 | 175 | int Wsa::addAppSequence(std::string * id) 176 | { 177 | sequence_.SequenceId = id; 178 | sequence_.InstanceId = instanceId(); 179 | sequence_.MessageNumber = messageNumber(); 180 | soap_->header->wsd__AppSequence = &sequence_; 181 | } 182 | 183 | 184 | int Wsa::reply(const std::string & id, const std::string & action) 185 | { 186 | // struct SOAP_ENV__Header * oldheader = soap_->header; 187 | // soap_->header = NULL; 188 | 189 | // /* if endpoint address for reply is 'none' return immediately */ 190 | // if (oldheader != NULL && oldheader->SOAP_WSA(ReplyTo) && oldheader->SOAP_WSA(ReplyTo)->Address 191 | // && !strcmp(oldheader->SOAP_WSA(ReplyTo)->Address, NONE_URI)) 192 | // { 193 | // return soap_send_empty_response(soap_, SOAP_OK); 194 | // } 195 | 196 | // /* allocate a new header */ 197 | // if (alloHeader() != 0) 198 | // return soap_->error; 199 | 200 | // struct SOAP_ENV__Header * newheader = soap_->header; 201 | // if (oldheader != NULL) 202 | // *newheader = *oldheader; 203 | 204 | // newheader->SOAP_WSA(MessageID) = id; 205 | // newheader->SOAP_WSA(Action) = action; 206 | // newheader->SOAP_WSA(RelatesTo) = NULL; 207 | // newheader->SOAP_WSA(From) = NULL; 208 | // newheader->SOAP_WSA(To) = NULL; 209 | // newheader->SOAP_WSA(ReplyTo) = NULL; 210 | // newheader->SOAP_WSA(FaultTo) = NULL; 211 | 212 | 213 | // if (oldheader && oldheader->SOAP_WSA(MessageID)) { 214 | // newheader->SOAP_WSA(RelatesTo) = (SOAP_WSA_(,RelatesTo)*)soap_malloc(soap, sizeof(SOAP_WSA_(,RelatesTo))); 215 | // SOAP_WSA_(soap_default_,RelatesTo)(soap, newheader->SOAP_WSA(RelatesTo)); 216 | // newheader->SOAP_WSA(RelatesTo)->__item = oldheader->SOAP_WSA(MessageID); 217 | // } 218 | 219 | // if (oldheader && oldheader->SOAP_WSA(ReplyTo) && oldheader->SOAP_WSA(ReplyTo)->Address && strcmp(oldheader->SOAP_WSA(ReplyTo)->Address, soap_wsa_anonymousURI)) { 220 | // newheader->SOAP_WSA(To) = oldheader->SOAP_WSA(ReplyTo)->Address; 221 | // /* (re)connect to ReplyTo endpoint if From != ReplyTo */ 222 | // if (!oldheader->SOAP_WSA(From) || !oldheader->SOAP_WSA(From)->Address || strcmp(oldheader->SOAP_WSA(From)->Address, oldheader->SOAP_WSA(ReplyTo)->Address)) { 223 | // struct soap *reply_soap = soap_copy(soap); 224 | // if (reply_soap) { 225 | // soap_copy_stream(reply_soap, soap); 226 | // soap_clr_omode(reply_soap, SOAP_ENC_MIME | SOAP_ENC_DIME | SOAP_ENC_MTOM); 227 | // soap_free_stream(soap); /* prevents close in soap_connect() below */ 228 | // newheader->SOAP_WSA(FaultTo) = oldheader->SOAP_WSA(FaultTo); 229 | // soap->header = newheader; 230 | // if (soap_connect(soap, newheader->SOAP_WSA(To), newheader->SOAP_WSA(Action))) { 231 | // int err; 232 | // soap_copy_stream(soap, reply_soap); 233 | //#if defined(SOAP_WSA_2005) 234 | // err = soap_wsa_error(soap, SOAP_WSA(DestinationUnreachable), newheader->SOAP_WSA(To)); 235 | //#elif defined(SOAP_WSA_2003) 236 | // err = soap_wsa_error(soap, "WS-Addessing destination unreachable"); 237 | //#else 238 | // err = soap_wsa_error(soap, SOAP_WSA(DestinationUnreachable)); 239 | //#endif 240 | // soap_free_stream(reply_soap); 241 | // soap_end(reply_soap); 242 | // soap_free(reply_soap); 243 | // soap->header = NULL; 244 | // return err; 245 | // } 246 | // if (soap_valid_socket(reply_soap->socket)) { 247 | // soap_send_empty_response(reply_soap, SOAP_OK); /* HTTP ACCEPTED */ 248 | // soap_closesock(reply_soap); 249 | // } 250 | // soap_free_stream(reply_soap); 251 | // soap_end(reply_soap); 252 | // soap_free(reply_soap); 253 | // data->fresponse = soap->fresponse; 254 | // soap->fresponse = soap_wsa_response; /* response will be a POST */ 255 | // } 256 | // } 257 | // } else if (oldheader && oldheader->SOAP_WSA(From)) 258 | // newheader->SOAP_WSA(To) = oldheader->SOAP_WSA(From)->Address; 259 | // else 260 | // newheader->SOAP_WSA(To) = (char*)soap_wsa_anonymousURI; 261 | 262 | // soap->header = newheader; 263 | // soap->action = newheader->SOAP_WSA(Action); 264 | 265 | return SOAP_OK; 266 | } 267 | 268 | 269 | int Wsa::request(const std::string & to, const std::string & action) 270 | { 271 | if (allocHeader() != 0) 272 | return soap_->error; 273 | soap_->header->SOAP_WSA(MessageID) = randUuid(); 274 | soap_->header->SOAP_WSA(To) = to.empty() ? ANONYMOUS_URI : to; 275 | soap_->header->SOAP_WSA(Action) = action; 276 | soap_->header->SOAP_WSA(RelatesTo) = NULL; 277 | soap_->header->SOAP_WSA(From) = NULL; 278 | soap_->header->SOAP_WSA(ReplyTo) = NULL; 279 | soap_->header->SOAP_WSA(FaultTo) = NULL; 280 | return check(); 281 | } 282 | -------------------------------------------------------------------------------- /OnvifSDK/xml/replay.wsdl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | The capabilities for the replay service is returned in the Capabilities element. 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | Indicator that the Device supports reverse playback as defined in the ONVIF Streaming Specification. 41 | 42 | 43 | 44 | 45 | The list contains two elements defining the minimum and maximum valid values supported as session timeout in seconds. 46 | 47 | 48 | 49 | 50 | Indicates support for RTP/RTSP/TCP. 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | Specifies the connection parameters to be used for the stream. The URI that is returned may depend on these parameters. 63 | 64 | 65 | 66 | 67 | The identifier of the recording to be streamed. 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | The URI to which the client should connect in order to stream the recording. 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Description of the new replay configuration parameters. 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | The current replay configuration parameters. 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | Returns the capabilities of the replay service. The result is returned in a typed answer. 147 | 148 | 149 | 150 | 151 | 152 | Requests a URI that can be used to initiate playback of a recorded stream 153 | using RTSP as the control protocol. The URI is valid only as it is 154 | specified in the response. 155 | This operation is mandatory. 156 | 157 | 158 | 159 | 160 | 161 | 162 | Returns the current configuration of the replay service. 163 | This operation is mandatory. 164 | 165 | 166 | 167 | 168 | 169 | 170 | Changes the current configuration of the replay service. 171 | This operation is mandatory. 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | -------------------------------------------------------------------------------- /OnvifSDK/xml/ws-discovery.xsd: -------------------------------------------------------------------------------- 1 | 2 | 53 | 60 | 61 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 129 | 130 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 170 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 263 | 264 | 267 | 268 | 269 | 270 | 271 | 272 | -------------------------------------------------------------------------------- /OnvifSDK/include/OnvifSDK.h: -------------------------------------------------------------------------------- 1 | #ifndef ONVIF_SDK__H 2 | #define ONVIF_SDK__H 3 | 4 | #include 5 | #include 6 | 7 | #define CLASS_DEFINITION_BEGIN(gSoapPrefix, servicePrefix, classname) \ 8 | class _ ## gSoapPrefix ## __ ## classname; \ 9 | class servicePrefix ## classname \ 10 | { \ 11 | public: \ 12 | servicePrefix ## classname ( soap * ); \ 13 | servicePrefix ## classname ( _ ## gSoapPrefix ## __ ## classname * ); \ 14 | _ ## gSoapPrefix ## __ ## classname * d; 15 | 16 | #define CLASS_DEFINITION_END() \ 17 | }; 18 | 19 | class soap; 20 | 21 | namespace Web { 22 | ///////////////////////////////////////////////////////////////////////////////////// 23 | // DeviceMgmt /////////////////////////////////////////////////////////////////////// 24 | ///////////////////////////////////////////////////////////////////////////////////// 25 | CLASS_DEFINITION_BEGIN(tds, Dev, SetSystemDateAndTime) 26 | int GetUTCDateAndTime(int & year, int & month, int & day, int & hour, int & min, int & sec) const; 27 | int SetUTCDateAndTime(int year, int month, int day, int hour, int min, int sec); 28 | CLASS_DEFINITION_END() 29 | 30 | CLASS_DEFINITION_BEGIN(tds, Dev, SetSystemDateAndTimeResponse) 31 | CLASS_DEFINITION_END() 32 | 33 | 34 | ///////////////////////////////////////////////////////////////////////////////////// 35 | 36 | CLASS_DEFINITION_BEGIN(tds, Dev, GetSystemDateAndTime) 37 | CLASS_DEFINITION_END() 38 | 39 | CLASS_DEFINITION_BEGIN(tds, Dev, GetSystemDateAndTimeResponse) 40 | int SetUTCDateAndTime(int year, int month, int day, int hour, int min, int sec); 41 | int GetUTCDateAndTime(int & year, int & month, int & day, int & hour, int & min, int & sec) const; 42 | CLASS_DEFINITION_END() 43 | 44 | 45 | ///////////////////////////////////////////////////////////////////////////////////// 46 | 47 | CLASS_DEFINITION_BEGIN(tds, Dev, GetUsers) 48 | CLASS_DEFINITION_END() 49 | 50 | 51 | CLASS_DEFINITION_BEGIN(tds, Dev, GetUsersResponse) 52 | int AddUser(std::vector user); 53 | int GetUsers(std::vector & users) const; 54 | CLASS_DEFINITION_END() 55 | 56 | 57 | ///////////////////////////////////////////////////////////////////////////////////// 58 | 59 | CLASS_DEFINITION_BEGIN(tds, Dev, GetDeviceInformation) 60 | CLASS_DEFINITION_END() 61 | 62 | CLASS_DEFINITION_BEGIN(tds, Dev, GetDeviceInformationResponse) 63 | int SetDeviceInfo(std::string strManufacturer, std::string strModel, 64 | std::string strFirmwareVersion, std::string strSerialNumber, 65 | std::string strHardwareId); 66 | int GetDeviceInfo(std::string & strManufacturer, std::string & strModel, 67 | std::string & strFirmwareVersion, std::string & strSerialNumber, 68 | std::string & strHardwareId) const; 69 | CLASS_DEFINITION_END() 70 | 71 | ///////////////////////////////////////////////////////////////////////////////////// 72 | 73 | CLASS_DEFINITION_BEGIN(tds, Dev, GetCapabilities) 74 | CLASS_DEFINITION_END() 75 | 76 | CLASS_DEFINITION_BEGIN(tds, Dev, GetCapabilitiesResponse) 77 | int SetCapsDevice(std::string xaddr); 78 | int GetCapsDevice(std::string & xaddr) const; 79 | CLASS_DEFINITION_END() 80 | 81 | ///////////////////////////////////////////////////////////////////////////////////// 82 | 83 | CLASS_DEFINITION_BEGIN(tds, Dev, GetServices) 84 | CLASS_DEFINITION_END() 85 | 86 | CLASS_DEFINITION_BEGIN(tds, Dev, GetServicesResponse) 87 | int AddService(std::string & nameSpace, std::string & xaddr); 88 | CLASS_DEFINITION_END() 89 | 90 | ///////////////////////////////////////////////////////////////////////////////////// 91 | // DeviceIO ///////////////////////////////////////////////////////////////////////// 92 | ///////////////////////////////////////////////////////////////////////////////////// 93 | 94 | CLASS_DEFINITION_BEGIN(tmd, DevIO, GetVideoOutputs) 95 | CLASS_DEFINITION_END() 96 | 97 | 98 | CLASS_DEFINITION_BEGIN(tmd, DevIO, GetVideoOutputsResponse) 99 | int SetVideoOutputs(const std::string & videoOutput); 100 | int GetVideoOutputs(std::string & videoOutput) const; 101 | CLASS_DEFINITION_END() 102 | 103 | ///////////////////////////////////////////////////////////////////////////////////// 104 | // Display ////////////////////////////////////////////////////////////////////////// 105 | ///////////////////////////////////////////////////////////////////////////////////// 106 | 107 | struct DispRectangle 108 | { 109 | float bot; 110 | float top; 111 | float left; 112 | float right; 113 | }; 114 | 115 | CLASS_DEFINITION_BEGIN(tls, Disp, GetLayout) 116 | int GetLayout(std::string & str) const; 117 | int SetLayout(const std::string & str); 118 | CLASS_DEFINITION_END() 119 | 120 | CLASS_DEFINITION_BEGIN(tls, Disp, GetLayoutResponse) 121 | int SetLayout(const std::string & str); 122 | int GetLayout(std::string & str) const; 123 | CLASS_DEFINITION_END() 124 | 125 | ///////////////////////////////////////////////////////////////////////////////////// 126 | 127 | CLASS_DEFINITION_BEGIN(tls, Disp, GetDisplayOptions) 128 | int GetVO(std::string & str) const; 129 | int SetVO(const std::string & str); 130 | CLASS_DEFINITION_END() 131 | 132 | CLASS_DEFINITION_BEGIN(tls, Disp, GetDisplayOptionsResponse) 133 | int Set4FixedLayouts(const float flayout1[1*4], const float flayout4[4*4], 134 | const float flayout9[9*4], const float flayout16[16*4]); 135 | int GetLayoutOptions(std::vector< std::vector > & layoutOptions) const; 136 | CLASS_DEFINITION_END() 137 | 138 | ///////////////////////////////////////////////////////////////////////////////////// 139 | 140 | CLASS_DEFINITION_BEGIN(tls, Disp, SetLayout) 141 | int GetVO(std::string & vo); 142 | int GetLayout(std::vector > & panelayouts); 143 | int SetVO(const std::string & vo); 144 | int SetLayout(const std::vector< std::pair > & panelayouts); 145 | CLASS_DEFINITION_END() 146 | 147 | CLASS_DEFINITION_BEGIN(tls, Disp, SetLayoutResponse) 148 | CLASS_DEFINITION_END() 149 | 150 | ///////////////////////////////////////////////////////////////////////////////////// 151 | 152 | CLASS_DEFINITION_BEGIN(tls, Disp, CreatePaneConfiguration) 153 | int GetPaneConfig(std::string & videoOutput, 154 | std::string & paneToken, 155 | std::string & receiverToken) const; 156 | int SetPaneConfig(const std::string & videoOutput, 157 | const std::string & paneToken, 158 | const std::string & receiverToken); 159 | CLASS_DEFINITION_END() 160 | 161 | CLASS_DEFINITION_BEGIN(tls, Disp, CreatePaneConfigurationResponse) 162 | int SetPaneConfigToken(const std::string & paneConfigToken); 163 | int GetPaneConfigToken(std::string & paneConfigToken) const; 164 | CLASS_DEFINITION_END() 165 | 166 | ///////////////////////////////////////////////////////////////////////////////////// 167 | // Receiver ///////////////////////////////////////////////////////////////////////// 168 | ///////////////////////////////////////////////////////////////////////////////////// 169 | 170 | CLASS_DEFINITION_BEGIN(trv, Recv, GetReceivers) 171 | CLASS_DEFINITION_END() 172 | 173 | CLASS_DEFINITION_BEGIN(trv, Recv, GetReceiversResponse) 174 | int SetReceivers(std::string & str); 175 | int GetReceivers(std::string & str) const; 176 | CLASS_DEFINITION_END() 177 | ///////////////////////////////////////////////////////////////////////////////////// 178 | CLASS_DEFINITION_BEGIN(trv, Recv, CreateReceiver) 179 | bool getMode() const; 180 | void setMode( const bool ); 181 | std::string getUri() const; 182 | void setUri( const std::string & ); 183 | CLASS_DEFINITION_END() 184 | 185 | CLASS_DEFINITION_BEGIN(trv, Recv, CreateReceiverResponse) 186 | void setToken( const std::string & str ); 187 | std::string getToken() const; 188 | CLASS_DEFINITION_END() 189 | 190 | ///////////////////////////////////////////////////////////////////////////////////// 191 | 192 | CLASS_DEFINITION_BEGIN(trv, Recv, SetReceiverMode) 193 | bool getMode() const; 194 | void setMode( bool ); 195 | std::string getToken() const; 196 | void setToken( const std::string & ); 197 | CLASS_DEFINITION_END() 198 | 199 | CLASS_DEFINITION_BEGIN(trv, Recv, SetReceiverModeResponse) 200 | CLASS_DEFINITION_END() 201 | 202 | ///////////////////////////////////////////////////////////////////////////////////// 203 | // RecordingControl ///////////////////////////////////////////////////////////////// 204 | ///////////////////////////////////////////////////////////////////////////////////// 205 | CLASS_DEFINITION_BEGIN(trc, Rec, CreateRecording) 206 | void setSource (const std::string & id, const std::string & address); 207 | void getSource (std::string & id, std::string & address) const; 208 | CLASS_DEFINITION_END() 209 | 210 | CLASS_DEFINITION_BEGIN(trc, Rec, CreateRecordingResponse) 211 | const std::string & getToken() const; 212 | void setToken(const std::string &); 213 | CLASS_DEFINITION_END() 214 | 215 | ///////////////////////////////////////////////////////////////////////////////////// 216 | CLASS_DEFINITION_BEGIN(trc, Rec, DeleteRecording) 217 | const std::string & getToken() const; 218 | void setToken(const std::string &); 219 | CLASS_DEFINITION_END() 220 | 221 | CLASS_DEFINITION_BEGIN(trc, Rec, DeleteRecordingResponse) 222 | CLASS_DEFINITION_END() 223 | 224 | ///////////////////////////////////////////////////////////////////////////////////// 225 | CLASS_DEFINITION_BEGIN(trc, Rec, CreateRecordingJob) 226 | const std::string & getRecording() const; 227 | void setRecording(const std::string &); 228 | bool getMode() const; 229 | void setMode(bool); 230 | CLASS_DEFINITION_END() 231 | 232 | CLASS_DEFINITION_BEGIN(trc, Rec, CreateRecordingJobResponse) 233 | const std::string & getToken() const; 234 | void setToken(const std::string &); 235 | CLASS_DEFINITION_END() 236 | 237 | ///////////////////////////////////////////////////////////////////////////////////// 238 | CLASS_DEFINITION_BEGIN(trc, Rec, DeleteRecordingJob) 239 | const std::string & getToken() const; 240 | void setToken(const std::string &); 241 | CLASS_DEFINITION_END() 242 | 243 | CLASS_DEFINITION_BEGIN(trc, Rec, DeleteRecordingJobResponse) 244 | CLASS_DEFINITION_END() 245 | 246 | ///////////////////////////////////////////////////////////////////////////////////// 247 | } // namespace Web 248 | 249 | using namespace Web; 250 | class IOnvif 251 | { 252 | public: 253 | 254 | //===DEV============================== 255 | virtual int GetDateAndTime( /*out*/ DevGetSystemDateAndTimeResponse & ) = 0; 256 | virtual int SetDateAndTime( DevSetSystemDateAndTime & ) = 0; 257 | virtual int GetUsers( /*out*/ DevGetUsersResponse & ) = 0; 258 | 259 | //===DEVIO============================ 260 | virtual int GetVideoOutputs( /*out*/ DevIOGetVideoOutputsResponse & ) = 0; 261 | 262 | //===DISP============================= 263 | virtual int GetLayout( std::string &, /*out*/ DispGetLayoutResponse & ) = 0; 264 | virtual int GetDisplayOptions( const std::string &, DispGetDisplayOptionsResponse & ) = 0; 265 | virtual int SetLayout( DispSetLayout &) = 0; 266 | virtual int CreatePaneConfiguration( DispCreatePaneConfiguration &, /*out*/ DispCreatePaneConfigurationResponse & ) = 0; 267 | 268 | //===RECV============================= 269 | virtual int GetReceivers( RecvGetReceiversResponse & ) = 0; 270 | virtual int CreateReceiver( const std::string & uri, /*out*/ std::string & recvToken ) = 0; 271 | virtual int SetReceiverMode( const std::string & recvToken, bool bMode ) = 0; 272 | //===RECORDING========================= 273 | virtual int CreateRecording (RecCreateRecording &, RecCreateRecordingResponse &) = 0; 274 | virtual int CreateRecordingJob (RecCreateRecordingJob &, RecCreateRecordingJobResponse &) = 0; 275 | virtual int DeleteRecording (const std::string &) = 0; 276 | virtual int DeleteRecordingJob (const std::string &) = 0; 277 | }; 278 | 279 | typedef enum _Services 280 | { 281 | DEV_S = 2, 282 | DEVIO_S = 4, 283 | DISP_S = 8, 284 | RECV_S = 16, 285 | REPLAY_S = 32, 286 | RECORD_S = 64, 287 | SEARCH_S = 128 288 | } Services; 289 | 290 | class IOnvifServer 291 | { 292 | public: 293 | virtual int Init(int iServicesToHost, int port, IOnvif* pHandler) = 0; 294 | virtual int Run() = 0; 295 | }; 296 | 297 | IOnvifServer* getOnvifServer(); 298 | 299 | class IOnvifClient : public IOnvif 300 | { 301 | public: 302 | virtual int Init(const char* pchEndpoint) = 0; 303 | virtual std::vector GetDiscoveredDevices() = 0; 304 | virtual soap* GetSoap() = 0; 305 | }; 306 | 307 | IOnvifClient* getOnvifClient(); 308 | 309 | std::string GenerateToken(); 310 | 311 | #endif // ONVIF_SDK__H 312 | --------------------------------------------------------------------------------