Old fashion design for PC-104
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.

152 lines
3.2 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: VideoCamera.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of VideoCamera.cpp
  13. //----------------------------------------------------------------------------
  14. // VideoCamera.cpp: implementation of the CVideoCamera class.
  15. //
  16. //////////////////////////////////////////////////////////////////////
  17. #include "stdafx.h"
  18. #include "VideoCamera.h"
  19. #include "VideoCaptureSource.h"
  20. #include "..\..\LgLib\Version.h"
  21. #ifdef _DEBUG
  22. #undef THIS_FILE
  23. static char THIS_FILE[]=__FILE__;
  24. #define new DEBUG_NEW
  25. #endif
  26. //////////////////////////////////////////////////////////////////////
  27. // Construction/Destruction
  28. //////////////////////////////////////////////////////////////////////
  29. CVideoCamera::CVideoCamera()
  30. {
  31. CVideoDevice::SetIOCount( 0, 1 );
  32. m_pWaitPin = NULL;
  33. m_nType = VC_FIX;
  34. m_bLock = FALSE;
  35. m_pVideoCaptureSource = NULL;
  36. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVideoCamera::CVideoCamera") );
  37. }
  38. CVideoCamera::~CVideoCamera()
  39. {
  40. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVideoCamera::~CVideoCamera") );
  41. }
  42. BOOL CVideoCamera::Connect( CVideoPin *pPin, BOOL bAutoConnect, BOOL bAutoDisconnect, DWORD dwTimeLimit )
  43. {
  44. CVideoPin *pOPin = GetOutput(0);
  45. if( pOPin )
  46. {
  47. // automatic connection
  48. if( bAutoConnect )
  49. {
  50. m_pWaitPin = pPin;
  51. m_dwWaitTime = ::GetTickCount();
  52. m_bAutoDisconnect = bAutoDisconnect;
  53. m_dwTimeLimit = dwTimeLimit;
  54. }
  55. else
  56. {
  57. m_pWaitPin = NULL;
  58. }
  59. // search for video line conections path
  60. if( !pOPin->IsLocked() )
  61. {
  62. if( !pOPin->WayLock( pPin ) )
  63. {
  64. return FALSE;
  65. }
  66. }
  67. // test all video line conections (video switchers)
  68. if( pOPin->WayCheck() )
  69. return TRUE;
  70. }
  71. return FALSE;
  72. }
  73. BOOL CVideoCamera::Disconnect()
  74. {
  75. CVideoPin *pOPin = GetOutput(0);
  76. if( pOPin )
  77. {
  78. // disable automatic connection
  79. m_pWaitPin = NULL;
  80. // nothing connected, nothing so to disconnect
  81. if( !pOPin->IsLocked() )
  82. return TRUE;
  83. // release line owning
  84. pOPin->WayUnlock();
  85. return TRUE;
  86. }
  87. return FALSE;
  88. }
  89. void CVideoCamera::CheckState()
  90. {
  91. if( m_pWaitPin )
  92. {
  93. CVideoPin *pOPin = GetOutput(0);
  94. if( ( pOPin->IsLocked() || pOPin->WayLock( m_pWaitPin ) ) &&
  95. pOPin->WayCheck() )
  96. {
  97. // automatic disconnection immediatlly after connection
  98. if( m_bAutoDisconnect )
  99. {
  100. Disconnect();
  101. }
  102. m_pWaitPin = NULL;
  103. }
  104. else
  105. if( ::GetTickCount() - m_dwWaitTime > m_dwTimeLimit )
  106. {
  107. // connection time expaired
  108. Disconnect();
  109. m_pWaitPin = NULL;
  110. }
  111. }
  112. }
  113. BOOL CVideoCamera::AssignCaptureSource( CVideoCaptureSource *pVideoCaptureSource )
  114. {
  115. if( m_pVideoCaptureSource != pVideoCaptureSource )
  116. {
  117. if( m_pVideoCaptureSource )
  118. m_pVideoCaptureSource->AssignVideoCamera( NULL );
  119. m_pVideoCaptureSource = pVideoCaptureSource;
  120. if( m_pVideoCaptureSource )
  121. m_pVideoCaptureSource->AssignVideoCamera( this );
  122. }
  123. return TRUE;
  124. }