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.

193 lines
4.1 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 24/03/2000
  5. // Last modification: 02/06/2001
  6. // Project Intruder Position Indicator
  7. // SUBSYSTEM: Video Camera Showing Window
  8. // FILE: VideoDirectShow.h
  9. // AUTHOR: Chizhevskiy Sergey
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file for class CVideoDirectShow
  13. //----------------------------------------------------------------------------
  14. #ifndef __VIDEO__DIRECT__SHOW__H__INCLUDED__
  15. #define __VIDEO__DIRECT__SHOW__H__INCLUDED__
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. #include "ICaptureDIB.h"
  20. #ifndef _AFXDLL
  21. class CRect : public RECT
  22. {
  23. public:
  24. CRect() { left = right = top = bottom = 0; }
  25. CRect( LONG l, LONG t, LONG r, LONG b ) { left = l; right = r; top = t; bottom = b; }
  26. CRect( CRect* rect ) { left = rect->left; right = rect->right; top = rect->top; bottom = rect->bottom; }
  27. };
  28. #define POSITION void*
  29. template <class TYPE, class ARG_TYPE>
  30. class CList
  31. {
  32. public:
  33. CList()
  34. {
  35. m_pFirst = NULL;
  36. m_pLast = NULL;
  37. m_nCount = 0;
  38. }
  39. ~CList()
  40. {
  41. RemoveAll();
  42. }
  43. private:
  44. typedef struct tagNODE
  45. {
  46. tagNODE *pNext;
  47. tagNODE *pPrev;
  48. ARG_TYPE data;
  49. }NODE, *PNODE;
  50. public:
  51. POSITION AddTail( ARG_TYPE newElement )
  52. {
  53. PNODE pNewNode = new NODE;
  54. if( !pNewNode )
  55. return NULL;
  56. pNewNode->pNext = NULL;
  57. pNewNode->pPrev = m_pLast;
  58. pNewNode->data = newElement;
  59. if( m_pLast )
  60. m_pLast->pNext = pNewNode;
  61. m_pLast = pNewNode;
  62. if( !m_pFirst )
  63. m_pFirst = m_pLast;
  64. m_nCount++;
  65. return (POSITION)m_pLast;
  66. }
  67. void RemoveAll()
  68. {
  69. PNODE pNode = m_pFirst;
  70. while( pNode )
  71. {
  72. PNODE pDelNode = pNode;
  73. pNode = pNode->pNext;
  74. delete pDelNode;
  75. }
  76. m_pFirst = NULL;
  77. m_pLast = NULL;
  78. m_nCount = 0;
  79. }
  80. POSITION Find( ARG_TYPE searchValue, POSITION startAfter = NULL ) const
  81. {
  82. PNODE pNode = (PNODE) ( startAfter ? startAfter : m_pFirst );
  83. while( pNode )
  84. {
  85. if( pNode->data == searchValue )
  86. return pNode;
  87. pNode = pNode->pNext;
  88. }
  89. return (POSITION) NULL;
  90. }
  91. POSITION GetHeadPosition() const
  92. {
  93. return (POSITION)m_pFirst;
  94. }
  95. TYPE& GetNext( POSITION& rPosition )
  96. {
  97. PNODE pNode = (PNODE)rPosition;
  98. rPosition = pNode->pNext;
  99. return pNode->data;
  100. }
  101. private:
  102. NODE *m_pFirst;
  103. NODE *m_pLast;
  104. int m_nCount;
  105. };
  106. #endif // CList
  107. class CVideoDirectShow
  108. {
  109. public:
  110. CVideoDirectShow();
  111. virtual ~CVideoDirectShow();
  112. public:
  113. void ShowWindow( int n, int nShow );
  114. void SetWindowPosition( int n, int x, int y, int cx, int cy );
  115. BOOL SetupDialog( HWND hWnd, int n );
  116. BOOL Create( LPCTSTR pFileName );
  117. BOOL ConnectWnd( int n, HWND hWnd, int x, int y, int cx, int cy );
  118. BOOL Capture( int n, LPBITMAPINFO pBmi, LPBYTE pByte );
  119. private:
  120. IGraphBuilder *m_pGraph;
  121. IMediaControl *m_pMediaControl;
  122. private:
  123. BOOL FindVideos();
  124. BOOL SetupFilters();
  125. private:
  126. friend static INT_PTR CALLBACK DialogProcSetup( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  127. {
  128. if( uMsg == WM_INITDIALOG )
  129. ::SetWindowLong( hWnd, GWL_USERDATA, lParam );
  130. CVideoDirectShow *pThis = (CVideoDirectShow*) ::GetWindowLong( hWnd, GWL_USERDATA );
  131. if( pThis )
  132. return pThis->DialogProc( hWnd, uMsg, wParam, lParam );
  133. return FALSE;
  134. }
  135. BOOL DialogProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  136. private:
  137. struct PROPERTY
  138. {
  139. ISpecifyPropertyPages *pSpecify;
  140. IUnknown *pUnknown;
  141. WCHAR pName[MAX_FILTER_NAME];
  142. };
  143. typedef CList<PROPERTY,PROPERTY> CSpecifyList;
  144. typedef CList<CLSID, CLSID> CGuidList;
  145. private:
  146. ICaptureDIB *FindCaptureDIB( IBaseFilter* pFilter, CGuidList &list );
  147. void EnumFilters( IBaseFilter* pFilter, CGuidList &gList, CSpecifyList &sList );
  148. bool IsCompatible( IBaseFilter *pFilter, REFIID IID );
  149. private:
  150. private:
  151. CSpecifyList m_SpecifyList;
  152. private:
  153. HWND m_phWnd[10];
  154. IVideoWindow *m_ppVideoWindow[10];
  155. ICaptureDIB *m_ppCaptureDIB[10];
  156. int m_nCount;
  157. };
  158. #endif