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.

91 lines
1.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
  1. #include "onvifDeviceNode.h"
  2. #define LOG(X) m_pLog->Log("onvifDeviceNode", this, X)
  3. #define LOG_ERROR(X) m_pLog->Log("onvifDeviceNode", this, _LOG_ERROR, X)
  4. onvifDeviceNode::onvifDeviceNode(CSTR URL)
  5. {
  6. m_pLog = basicLogCollection::getInstance();
  7. strncpy(m_pDeviceManagementURL, URL, 256);
  8. if (strlen(m_pDeviceManagementURL))
  9. {
  10. CSTR tVal = (CSTR) malloc(strlen(m_pDeviceManagementURL));
  11. strcpy(tVal, m_pDeviceManagementURL);
  12. m_pTransport = new clientPort(tVal);
  13. if (m_pTransport != NULL)
  14. {
  15. m_pProtocol = new protocolONVIF(m_pTransport);
  16. if (m_pProtocol != NULL)
  17. {
  18. enquireDevice();
  19. }
  20. else
  21. {
  22. delete(m_pTransport);
  23. };
  24. };
  25. }
  26. else
  27. {
  28. LOG_ERROR("Provided URL is Invalid!");
  29. m_pTransport = NULL;
  30. m_pProtocol = NULL;
  31. };
  32. }
  33. onvifDeviceNode::~onvifDeviceNode()
  34. {
  35. if (m_pProtocol != NULL)
  36. {
  37. delete(m_pProtocol);
  38. }
  39. if (m_pTransport != NULL)
  40. {
  41. delete(m_pTransport);
  42. }
  43. }
  44. bool onvifDeviceNode::enquireDevice(void)
  45. {
  46. if (m_pProtocol->GetProfiles(m_pDeviceManagementURL))
  47. {
  48. LOG("Profiles Loaded.");
  49. // LOG(m_pProtocol->GetStreamURI(m_pDeviceManagementURL, 0));
  50. return true;
  51. }
  52. else
  53. {
  54. LOG_ERROR("Error get OnVif Profiles.");
  55. };
  56. return false;
  57. }
  58. CSTR onvifDeviceNode::getStreamURI(int P)
  59. {
  60. if (m_pProtocol != NULL)
  61. {
  62. return m_pProtocol->GetStreamURI(m_pDeviceManagementURL, P);
  63. };
  64. return NULL;
  65. }
  66. int onvifDeviceNode::getProfilesCount(void)
  67. {
  68. if (m_pProtocol != NULL)
  69. {
  70. return m_pProtocol->GetAccessProfiles()->size();
  71. };
  72. return 0;
  73. }
  74. vectorProfileOnvif * onvifDeviceNode::getProfilesVector(void)
  75. {
  76. if (m_pProtocol != NULL)
  77. {
  78. return m_pProtocol->GetAccessProfiles();
  79. };
  80. return NULL;
  81. }
  82. #undef LOG
  83. #undef LOG_ERROR