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

138 lines
4.6 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __PROTOCOL_ONVIF_HEADER__
  2. #define __PROTOCOL_ONVIF_HEADER__
  3. #include "protocolHTTP.h"
  4. #include "xmlParser.h"
  5. #include "../../components/base/basicMutex.h"
  6. #define ONE_WAY_TEMPLATE "<operation name=\�%s\�><input message=\�%s:%s\� /></operation>"
  7. /*
  8. device.GetSystemDateAndTime
  9. <? xml version = "1.0" encoding = "UTF-8" ?>
  10. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
  11. <SOAP-ENV:Body>
  12. <tds:GetSystemDateAndTime/>
  13. </SOAP-ENV:Body>
  14. </SOAP-ENV:Envelope>
  15. GetDeviceInformation
  16. <?xml version="1.0" encoding="UTF-8"?>
  17. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
  18. xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
  19. <SOAP-ENV:Body>
  20. <tds:GetDeviceInformation/>
  21. </SOAP-ENV:Body>
  22. </SOAP-ENV:Envelope>
  23. device.GetCapabilities
  24. <?xml version="1.0" encoding="UTF-8"?>
  25. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
  26. xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
  27. <SOAP-ENV:Body>
  28. <tds:GetCapabilities>
  29. <tds:Category>All</tds:Category>
  30. </tds:GetCapabilities>
  31. </SOAP-ENV:Body>
  32. </SOAP-ENV:Envelope>
  33. */
  34. //GetProfiles
  35. #define ONVIF_GetProfiles "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:trt=\"http://www.onvif.org/ver10/media/wsdl\"><soap:Body><trt:GetProfiles/></soap:Body></soap:Envelope>"
  36. //GetStreamURI
  37. //#define ONVIF_GetStreamURI "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:trt=\"http://www.onvif.org/ver10/media/wsdl\" xmlns:tt=\"http://www.onvif.org/ver10/schema\"><soap:Body><trt:GetStreamUri><trt:StreamSetup><tt:Stream>RTP-Unicast</tt:Stream><tt:Transport><tt:Protocol>UDP</tt:Protocol></Transport></trt:StreamSetup><trt:ProfileToken>%s</trt:ProfileToken></trt:GetStreamUri></soap:Body></soap:Envelope>"
  38. #define ONVIF_GetStreamURI "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:trt=\"http://www.onvif.org/ver10/media/wsdl\" xmlns:tt=\"http://www.onvif.org/ver10/schema\"><soap:Body><trt:GetStreamUri><trt:ProfileToken>%s</trt:ProfileToken></trt:GetStreamUri></soap:Body></soap:Envelope>"
  39. /*
  40. GetVideoSourceConfigurations
  41. <?xml version="1.0" encoding="utf-8"?>
  42. <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
  43. xmlns:trt="http://www.onvif.org/ver10/media/wsdl">
  44. <soap:Body>
  45. <trt:GetVideoSourceConfigurations />
  46. </soap:Body>
  47. </soap:Envelope>
  48. ContinuousMove
  49. <?xml version="1.0" encoding="utf-8"?>
  50. <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
  51. xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"
  52. xmlns:tt="http://www.onvif.org/ver10/schema">
  53. <soap:Body>
  54. <tptz:ContinuousMove>
  55. <tptz:ProfileToken>Profile1</tptz:ProfileToken>
  56. <tptz:Velocity>
  57. <tt:PanTilt x="1" y="1"/>
  58. <tt:Zoom x="1"/>
  59. </tptz:Velocity>
  60. </tptz:ContinuousMove>
  61. </soap:Body>
  62. </soap:Envelope>
  63. Stop
  64. <?xml version="1.0" encoding="utf-8"?>
  65. <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
  66. xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl">
  67. <soap:Body>
  68. <tptz:Stop>
  69. <tptz:ProfileToken>Profile1</tptz:ProfileToken>
  70. <tptz:PanTilt>true</tptz:PanTilt>
  71. <tptz:Zoom>true</tptz:Zoom>
  72. </tptz:Stop>
  73. </soap:Body>
  74. </soap:Envelope>
  75. */
  76. #define ONVIF_REQUEST_TIMEOUT_TIME 10 // in Milliseconds
  77. #define ONVIF_REQUEST_TIMEOUT_COUNT 1000 // 10 sec
  78. typedef struct S_PROFILE_ONVIF {
  79. CSTR pToken;
  80. CSTR pNcode;
  81. CSTR pName;
  82. int nWidth;
  83. int nHeight;
  84. int nFramerate;
  85. int nBitrate;
  86. } profileONVIF;
  87. typedef std::vector<profileONVIF *> vectorProfileOnvif;
  88. /**
  89. * TODO: Add class description
  90. *
  91. * @author gagua
  92. */
  93. class protocolONVIF : public protocolHTTP {
  94. private:
  95. CSTR buildOneWayRequest(CSTR OPName, CSTR Prefix);
  96. bool m_bRequestIsActive;
  97. basicMutex *m_pRequestMutex;//???
  98. bool m_bProtoIsBusy;
  99. int m_nRequestTimeOut;
  100. CSTR m_pStreamURI;
  101. vectorProfileOnvif m_vProfiles;
  102. protected:
  103. basicTransport *m_oDataTransport;
  104. //virtual bool packetHandler(unsigned char *Buffer, size_t BufferSize);
  105. virtual bool packetHandler(protocolPackage *Package);
  106. public:
  107. // Constructor
  108. protocolONVIF();
  109. //ToDo: change Serial to BaseClass of some kind of socket
  110. protocolONVIF( basicTransport *SocketTransport );
  111. // Destructor
  112. virtual ~protocolONVIF();
  113. virtual bool init(){ return true; };
  114. bool GetProfiles(CSTR URL);
  115. CSTR GetStreamURI(CSTR URL, int profileID);
  116. vectorProfileOnvif *GetAccessProfiles(void){ return &m_vProfiles; };
  117. };
  118. #endif