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.

155 lines
3.9 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "objectCamera_VISCA_PTZ.h"
  2. #define LOG( X ) m_pLog->Log( "objectCamera_VISCA_PTZ", this, X )
  3. #define LOG_ERROR( X ) m_pLog->Log( "objectCamera_VISCA_PTZ", this, _LOG_ERROR, X )
  4. objectCamera_VISCA_PTZ::objectCamera_VISCA_PTZ(config_setting_t *Settings) :basicCameraPTZ(Settings){
  5. m_pLog = basicLogCollection::getInstance();
  6. m_pProtocol = NULL;
  7. m_pTransport = NULL;
  8. m_sSourcePort = -1;
  9. m_eControllProtocolType = PTZ_PROTO_VISCA;
  10. };
  11. objectCamera_VISCA_PTZ::~objectCamera_VISCA_PTZ(){
  12. // Delete Video Source
  13. if( m_pVideoSource != NULL ){
  14. delete( (videoAVLIBSource*) m_pVideoSource );
  15. };
  16. if( m_pProtocol != NULL ){
  17. delete( m_pProtocol );
  18. };
  19. if( m_pTransport != NULL ){
  20. delete( m_pTransport );
  21. };
  22. };
  23. bool objectCamera_VISCA_PTZ::create(void){
  24. config_setting_t *pSetting;
  25. if( m_pSettings == NULL ) return false;
  26. /* Load Srom Settings */
  27. if( !basicCameraPTZ::create() ) return false;
  28. pSetting = config_setting_get_member(m_pSettings, "COM_PORT");
  29. if( pSetting == NULL ) return false;
  30. m_sSourcePort = config_setting_get_int(pSetting);
  31. if( m_sSourcePort < 0 ) return false;
  32. char cPortStr[8];
  33. sprintf(cPortStr, "com%d", m_sSourcePort);
  34. m_pTransport = new serialPort( cPortStr, 9600 );
  35. if (m_pTransport != NULL){
  36. m_pProtocol = new protocolPTZ_VISCA(m_pTransport);
  37. m_pProtocol->init();
  38. };
  39. //init video
  40. videoAVLIBSource *tSource;
  41. tSource = new videoAVLIBSource();
  42. if (tSource->open((CSTR)m_sCameraInfo.m_pSourcePath, false, 25, m_sCameraInfo.m_iSourcePort, m_sCameraInfo.m_iWidth, m_sCameraInfo.m_iHeight)){
  43. //tNode->setTimeLapse(3000);
  44. tSource->attachDestination(m_pVideoNode);
  45. tSource->setStreaming(true);
  46. m_pVideoSource = (basicMediaSource *)tSource;
  47. } else {
  48. delete tSource;
  49. return false;
  50. };
  51. return true;
  52. };
  53. /* ���� ������� 500 .... 10.
  54. 7:30 mispar tik 123760118
  55. */
  56. bool objectCamera_VISCA_PTZ::create(mediaSourceInfo *SI){
  57. config_setting_t *pSetting;
  58. if (m_pSettings == NULL) return false;
  59. if (SI == NULL) return false;
  60. if (!basicCameraPTZ::create(SI)) return false;
  61. pSetting = config_setting_get_member(m_pSettings, "COM_PORT");
  62. m_sSourcePort = SI->comTransportType;
  63. if (pSetting == NULL){
  64. pSetting = config_setting_add(m_pSettings, "COM_PORT", CONFIG_TYPE_INT);
  65. };
  66. config_setting_set_int(pSetting, m_sSourcePort);
  67. basicSettingsProvider::getInstance()->compromise();
  68. return create();
  69. };
  70. void objectCamera_VISCA_PTZ::dispatch(basicEvent *Evt){
  71. if( Evt->m_eClass == EVT_CLASS_SENSOR ) {
  72. switch (Evt->m_eType){
  73. case EVT_ALARM:
  74. // Basic Camera Reaction
  75. break;
  76. default:
  77. break;
  78. };
  79. } else
  80. if (Evt->m_eClass == EVT_CLASS_IMAGE){
  81. switch (Evt->m_eType){
  82. case EVT_COMMAND:
  83. basicCameraCommand *pData;
  84. pData = (basicCameraCommand *)Evt->m_pEvtData;
  85. // Basic Camera Commands
  86. switch( pData->m_cCode ){
  87. case CMD_CAMERA_INIT:
  88. m_pProtocol->init();
  89. break;
  90. case CMD_CAMERA_SET_PTZ:
  91. //m_pProtocol->goAbsolute( cP, cT, cZ );
  92. break;
  93. default:
  94. break;
  95. };
  96. break;
  97. default:
  98. break;
  99. };
  100. };
  101. };
  102. void objectCamera_VISCA_PTZ::cmdBeginPanLeft(void){
  103. m_pProtocol->goLeft();
  104. };
  105. void objectCamera_VISCA_PTZ::cmdBeginPanRight(void){
  106. m_pProtocol->goRight();
  107. };
  108. void objectCamera_VISCA_PTZ::cmdEndManualPan(void){
  109. m_pProtocol->goStop();
  110. };
  111. void objectCamera_VISCA_PTZ::cmdBeginTiltUp(void){
  112. m_pProtocol->goUp();
  113. };
  114. void objectCamera_VISCA_PTZ::cmdBeginTiltDown(void){
  115. m_pProtocol->goDown();
  116. };
  117. void objectCamera_VISCA_PTZ::cmdEndManualTilt(void){
  118. m_pProtocol->goStop();
  119. };
  120. void objectCamera_VISCA_PTZ::cmdBeginZoomWide(void){
  121. m_pProtocol->startZoomWide();
  122. };
  123. void objectCamera_VISCA_PTZ::cmdBeginZoomTele(void){
  124. m_pProtocol->startZoomTele();
  125. };
  126. void objectCamera_VISCA_PTZ::cmdEndManualZoom(void){
  127. m_pProtocol->stopZoom();
  128. };
  129. #undef LOG
  130. #undef LOG_ERROR