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.

66 lines
1.7 KiB

7 years ago
​
​
7 years ago
6 years ago
7 years ago
​
7 years ago
​
​
7 years ago
​
​
​
7 years ago
​
​
​
​
7 years ago
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
  1. #include "rgooseIPCamera.h"
  2. #define LOG( X ) m_pLog->Log( "ARGUS_IPCAM", this, X )
  3. #define LOG_ERROR( X ) m_pLog->Log( "ARGUS_IPCAM", this, _LOG_ERROR, X )
  4. ARGUS_IPCAM::ARGUS_IPCAM( uint32_t id ): ARGUS_Camera( id ), basicThread(){
  5. m_pLog = basicLogCollection::getInstance();
  6. m_pOnVif = NULL;
  7. m_pPosition = NULL;
  8. m_bOnline = false;
  9. };
  10. ARGUS_IPCAM::~ARGUS_IPCAM(){
  11. waitThreadEnd( true );
  12. if(m_pOnVif != NULL) delete(m_pOnVif);
  13. };
  14. bool ARGUS_IPCAM::create( CSTR ip, CSTR username, CSTR password ){
  15. m_pOnVif = new pOnvif();
  16. if(m_pOnVif != NULL) {
  17. m_pOnVif->setIPAddress( ip );
  18. m_pOnVif->setUsername( username );
  19. m_pOnVif->setPassword( password );
  20. if( m_pOnVif->create() ){
  21. videoSourceProfile *tPtr;
  22. tPtr = m_pOnVif->getProfiles()->at(0);
  23. sprintf( m_pProfileToken, "%s", tPtr->profiletoken );
  24. LOG( m_pProfileToken );
  25. sprintf( m_pDevToken, "%s", tPtr->sourcetoken );
  26. LOG( m_pDevToken );
  27. return basicThread::init();
  28. };
  29. };
  30. return false;
  31. };
  32. void ARGUS_IPCAM::m_fThreadProc( void ){
  33. pid_t pid = gettid();
  34. char pidBuf[16];
  35. sprintf(pidBuf,"pid:%d", pid);
  36. LOG(pidBuf);
  37. m_bThreadStatus = TH_WORKING;
  38. float Direction = 1.f;
  39. while( m_bThreadStatus < TH_ENDED ){
  40. m_tTimeTSeconds = time( NULL );
  41. if( ( m_tTimeTSeconds % 30 ) == 0 ) {
  42. m_pOnVif->ptz_AbsoluteMove( m_pProfileToken, 0, -1, 0 );
  43. SLEEP(1000);
  44. }
  45. if( ( ( m_tTimeTSeconds - 15 ) % 30 ) == 0 ) {
  46. m_pOnVif->ptz_AbsoluteMove( m_pProfileToken, Direction, -1, 0 );
  47. Direction *= -1.f;
  48. SLEEP(1000);
  49. }
  50. SLEEP( 100 );
  51. };
  52. };
  53. void ARGUS_IPCAM::dispatchEvent( basicEvent *Evt ){
  54. if( m_bOnline ) {
  55. LOG("EVENT!");
  56. };
  57. };
  58. #undef LOG
  59. #undef LOG_ERROR