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.

156 lines
4.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __PROTOCOL_ONVIF_HEADER__
  2. #define __PROTOCOL_ONVIF_HEADER__
  3. #include "../../components/base/basicMutex.h"
  4. #include "protocolHTTP.h"
  5. #include "xmlParser.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\"
  38. // 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>"
  39. #define ONVIF_GetStreamURI \
  40. "<?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\" " \
  41. "xmlns:tt=\"http://www.onvif.org/ver10/schema\"><soap:Body><trt:GetStreamUri><trt:ProfileToken>%s</trt:ProfileToken></trt:GetStreamUri></soap:Body></soap:Envelope>"
  42. /*
  43. GetVideoSourceConfigurations
  44. <?xml version="1.0" encoding="utf-8"?>
  45. <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
  46. xmlns:trt="http://www.onvif.org/ver10/media/wsdl">
  47. <soap:Body>
  48. <trt:GetVideoSourceConfigurations />
  49. </soap:Body>
  50. </soap:Envelope>
  51. ContinuousMove
  52. <?xml version="1.0" encoding="utf-8"?>
  53. <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
  54. xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"
  55. xmlns:tt="http://www.onvif.org/ver10/schema">
  56. <soap:Body>
  57. <tptz:ContinuousMove>
  58. <tptz:ProfileToken>Profile1</tptz:ProfileToken>
  59. <tptz:Velocity>
  60. <tt:PanTilt x="1" y="1"/>
  61. <tt:Zoom x="1"/>
  62. </tptz:Velocity>
  63. </tptz:ContinuousMove>
  64. </soap:Body>
  65. </soap:Envelope>
  66. Stop
  67. <?xml version="1.0" encoding="utf-8"?>
  68. <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
  69. xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl">
  70. <soap:Body>
  71. <tptz:Stop>
  72. <tptz:ProfileToken>Profile1</tptz:ProfileToken>
  73. <tptz:PanTilt>true</tptz:PanTilt>
  74. <tptz:Zoom>true</tptz:Zoom>
  75. </tptz:Stop>
  76. </soap:Body>
  77. </soap:Envelope>
  78. */
  79. #define ONVIF_REQUEST_TIMEOUT_TIME 10 // in Milliseconds
  80. #define ONVIF_REQUEST_TIMEOUT_COUNT 1000 // 10 sec
  81. typedef struct S_PROFILE_ONVIF
  82. {
  83. CSTR pToken;
  84. CSTR pNcode;
  85. CSTR pName;
  86. int nWidth;
  87. int nHeight;
  88. int nFramerate;
  89. int nBitrate;
  90. } profileONVIF;
  91. typedef std::vector<profileONVIF *> vectorProfileOnvif;
  92. /**
  93. * TODO: Add class description
  94. *
  95. * @author gagua
  96. */
  97. class protocolONVIF : public protocolHTTP
  98. {
  99. private:
  100. CSTR buildOneWayRequest(CSTR OPName, CSTR Prefix);
  101. bool m_bRequestIsActive;
  102. basicMutex * m_pRequestMutex; //???
  103. bool m_bProtoIsBusy;
  104. int m_nRequestTimeOut;
  105. CSTR m_pStreamURI;
  106. vectorProfileOnvif m_vProfiles;
  107. protected:
  108. basicTransport * m_oDataTransport;
  109. // virtual bool packetHandler(unsigned char *Buffer, size_t BufferSize);
  110. virtual bool packetHandler(protocolPackage * Package);
  111. public:
  112. // Constructor
  113. protocolONVIF();
  114. // ToDo: change Serial to BaseClass of some kind of socket
  115. protocolONVIF(basicTransport * SocketTransport);
  116. // Destructor
  117. virtual ~protocolONVIF();
  118. virtual bool init()
  119. {
  120. return true;
  121. }
  122. bool GetProfiles(CSTR URL);
  123. CSTR GetStreamURI(CSTR URL, int profileID);
  124. vectorProfileOnvif * GetAccessProfiles(void)
  125. {
  126. return &m_vProfiles;
  127. }
  128. };
  129. #endif