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.

67 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. m_pLog = basicLogCollection::getInstance();
  6. strncpy(m_pDeviceManagementURL, URL, 256);
  7. if (strlen(m_pDeviceManagementURL)){
  8. CSTR tVal = (CSTR)malloc(strlen(m_pDeviceManagementURL));
  9. strcpy(tVal, m_pDeviceManagementURL);
  10. m_pTransport = new clientPort(tVal);
  11. if (m_pTransport != NULL){
  12. m_pProtocol = new protocolONVIF(m_pTransport);
  13. if (m_pProtocol != NULL){
  14. enquireDevice();
  15. } else {
  16. delete(m_pTransport);
  17. };
  18. };
  19. } else {
  20. LOG_ERROR("Provided URL is Invalid!");
  21. m_pTransport = NULL;
  22. m_pProtocol = NULL;
  23. };
  24. };
  25. onvifDeviceNode::~onvifDeviceNode(){
  26. if (m_pProtocol != NULL)delete(m_pProtocol);
  27. if (m_pTransport != NULL)delete(m_pTransport);
  28. };
  29. bool onvifDeviceNode::enquireDevice(void){
  30. if (m_pProtocol->GetProfiles(m_pDeviceManagementURL)){
  31. LOG("Profiles Loaded.");
  32. //LOG(m_pProtocol->GetStreamURI(m_pDeviceManagementURL, 0));
  33. return true;
  34. } else {
  35. LOG_ERROR("Error get OnVif Profiles.");
  36. };
  37. return false;
  38. };
  39. CSTR onvifDeviceNode::getStreamURI(int P){
  40. if (m_pProtocol != NULL){
  41. return m_pProtocol->GetStreamURI(m_pDeviceManagementURL, P );
  42. };
  43. return NULL;
  44. };
  45. int onvifDeviceNode::getProfilesCount(void){
  46. if (m_pProtocol != NULL){
  47. return m_pProtocol->GetAccessProfiles()->size();
  48. };
  49. return 0;
  50. };
  51. vectorProfileOnvif *onvifDeviceNode::getProfilesVector(void){
  52. if (m_pProtocol != NULL){
  53. return m_pProtocol->GetAccessProfiles();
  54. };
  55. return NULL;
  56. };
  57. #undef LOG
  58. #undef LOG_ERROR