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.

137 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: VideoCaptureDevice.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of VideoCaptureDevice.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "VideoCaptureDevice.h"
  16. #include "..\..\LgLib\Version.h"
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[]=__FILE__;
  20. #define new DEBUG_NEW
  21. #endif
  22. CVideoCaptureDevice::CVideoCaptureDevice()
  23. {
  24. m_ppVideoCaptureSource = NULL;
  25. m_nVideoStandard = 0;
  26. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVideoCaptureDevice::CVideoCaptureDevice") );
  27. }
  28. CVideoCaptureDevice::~CVideoCaptureDevice()
  29. {
  30. Destroy();
  31. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CVideoCaptureDevice::~CVideoCaptureDevice") );
  32. }
  33. void CVideoCaptureDevice::Destroy()
  34. {
  35. if( m_ppVideoCaptureSource )
  36. {
  37. delete [] m_ppVideoCaptureSource;
  38. m_ppVideoCaptureSource = NULL;
  39. }
  40. CVideoDevice::Destroy();
  41. }
  42. BOOL CVideoCaptureDevice::AssignCaptureSource( int nInput, CVideoCaptureSource *pVideoCaptureSource )
  43. {
  44. if( nInput >= GetInputCount() || pVideoCaptureSource == NULL )
  45. return FALSE;
  46. if( !m_ppVideoCaptureSource )
  47. return FALSE;
  48. // if already assigned
  49. if( m_ppVideoCaptureSource[nInput] )
  50. return FALSE;
  51. m_ppVideoCaptureSource[nInput] = pVideoCaptureSource;
  52. return TRUE;
  53. }
  54. void CVideoCaptureDevice::SetIOCount( int nInput, int nOutput )
  55. {
  56. CVideoDevice::SetIOCount( nInput, nOutput );
  57. m_ppVideoCaptureSource = new CVideoCaptureSource*[ nInput ];
  58. if( !m_ppVideoCaptureSource )
  59. return;
  60. for( int i = 0; i < nInput; i++ )
  61. m_ppVideoCaptureSource[i] = NULL;
  62. }
  63. BOOL CVideoCaptureDevice::Capture( int nInput, LPBITMAPINFO *pBitmapInfo, LPBYTE *ppBytes, HBITMAP *pBitmap, DWORD dwPreviewTime )
  64. {
  65. if( nInput >= GetInputCount() )
  66. return NULL;
  67. if( !m_ppVideoCaptureSource )
  68. return NULL;
  69. // if was not assigned
  70. if( !m_ppVideoCaptureSource[nInput] )
  71. return NULL;
  72. return m_ppVideoCaptureSource[nInput]->Capture( pBitmapInfo, ppBytes, pBitmap, dwPreviewTime );
  73. }
  74. int CVideoCaptureDevice::GetAvailiblePin( CVideoPin *pOutputPin, int nSearchFrom )
  75. {
  76. if( !pOutputPin )
  77. return NULL;
  78. nSearchFrom = ( nSearchFrom < 0 ) ? 0 : nSearchFrom + 1;
  79. int nAvaliblePin = -1;
  80. int nMinWeight = INT_MAX;
  81. for( int i = nSearchFrom; i < GetInputCount(); i++ )
  82. {
  83. CVideoPin *pInputPin = GetInput(i);
  84. ASSERT( pInputPin );
  85. int nWeight = pInputPin->TestConnection( pOutputPin );
  86. if( nMinWeight > nWeight )
  87. {
  88. nMinWeight = nWeight;
  89. nAvaliblePin = i;
  90. }
  91. }
  92. return nAvaliblePin;
  93. }
  94. BOOL CVideoCaptureDevice::AssignVideoCamera( int nInput, CVideoCamera *pVideoCamera )
  95. {
  96. if( nInput >= GetInputCount() || pVideoCamera == NULL )
  97. return FALSE;
  98. if( !m_ppVideoCaptureSource )
  99. return FALSE;
  100. if( !m_ppVideoCaptureSource[ nInput ] )
  101. return FALSE;
  102. // assign video camera to video source
  103. m_ppVideoCaptureSource[ nInput ]->AssignVideoCamera( pVideoCamera );
  104. return TRUE;
  105. }