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.

726 lines
16 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: 15/08/2001
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: DSVideoProcessor.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of DSVideoProcessor.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "DSVideoProcessor.h"
  16. #include "DSConfiguration.h"
  17. CDSVideoProcessor::CDSVideoProcessor()
  18. {
  19. m_pVideoWindow = NULL;
  20. m_pAMCrossbar = NULL;
  21. m_pAMVideoProcAmp = NULL;
  22. m_pSampleGrabber = NULL;
  23. m_pSampleGrabberCB = NULL;
  24. m_pVideoHeader = NULL;
  25. m_pInputPin = NULL;
  26. m_nInputPinCount = 0;
  27. m_nOutputPin = -1;
  28. m_nVideoType = VT_NONE_VIDEO;
  29. m_ppPseudoVideoWnd = NULL;
  30. m_pbPseudoVideoWnd = NULL;
  31. m_nPseudoVideoWnd = 0;
  32. m_nPseudoCaptureLoop = 0;
  33. m_nPseudoLastInput = -1;
  34. m_dwPseudoLastTime = 0;
  35. m_pAMAnalogVideoDecoder = NULL;
  36. m_hEventVideoSample = NULL;
  37. ::CoInitialize( NULL );
  38. }
  39. CDSVideoProcessor::~CDSVideoProcessor()
  40. {
  41. Destroy();
  42. ::CoUninitialize();
  43. }
  44. BOOL CDSVideoProcessor::Create( CDSConfiguration* pDirectShow )
  45. {
  46. Destroy();
  47. if( !pDirectShow )
  48. return FALSE;
  49. IAMCrossbar *pCrossbar = pDirectShow->GetCrossbar();
  50. if( !pCrossbar )
  51. return FALSE;
  52. HRESULT hr = pCrossbar->QueryInterface( IID_IAMCrossbar, (void**)&m_pAMCrossbar );
  53. if( FAILED( hr ) )
  54. return FALSE;
  55. IBaseFilter *pBaseFilter = NULL;
  56. hr = m_pAMCrossbar->QueryInterface( IID_IBaseFilter, (void**)&pBaseFilter );
  57. if( FAILED( hr ) )
  58. return FALSE;
  59. FindMembers( pBaseFilter );
  60. pBaseFilter->Release();
  61. InitSwitch();
  62. if( !m_pSampleGrabber )
  63. return FALSE;
  64. if( m_pVideoWindow )
  65. {
  66. m_pVideoWindow->put_Visible( OAFALSE );
  67. m_pVideoWindow->put_AutoShow( OAFALSE );
  68. }
  69. if( m_pAMVideoProcAmp )
  70. {
  71. m_pAMVideoProcAmp->Set( VideoProcAmp_Saturation, 0, 0 );
  72. }
  73. m_hEventVideoSample = ::CreateEvent( NULL, FALSE, FALSE, NULL );
  74. if( !m_hEventVideoSample )
  75. return FALSE;
  76. m_pSampleGrabberCB = new CDSSampleGrabberCB( this );
  77. if( !m_pSampleGrabberCB )
  78. return FALSE;
  79. hr = m_pSampleGrabber->SetOneShot(FALSE);
  80. if( FAILED( hr ) )
  81. return FALSE;
  82. hr = m_pSampleGrabber->SetBufferSamples(FALSE);
  83. if( FAILED( hr ) )
  84. return FALSE;
  85. hr = m_pSampleGrabber->SetCallback( m_pSampleGrabberCB, 1 );
  86. if( FAILED( hr ) )
  87. return FALSE;
  88. AM_MEDIA_TYPE mt;
  89. if( FAILED( m_pSampleGrabber->GetConnectedMediaType(&mt) ) )
  90. return FALSE;
  91. if( mt.formattype != FORMAT_VideoInfo )
  92. return FALSE;
  93. m_pVideoHeader = (VIDEOINFOHEADER*)mt.pbFormat;
  94. if( !m_pVideoHeader )
  95. return FALSE;
  96. return Start( FALSE );
  97. }
  98. void CDSVideoProcessor::FindMembers( IBaseFilter *pMemberFilter )
  99. {
  100. IEnumPins *pEnumPins = NULL;
  101. HRESULT hr = pMemberFilter->EnumPins( &pEnumPins );
  102. if( FAILED(hr) )
  103. return;
  104. IPin *pPinOut = NULL;
  105. while( pEnumPins->Next( 1, &pPinOut, NULL ) == S_OK )
  106. {
  107. PIN_INFO PinInfo;
  108. hr = pPinOut->QueryPinInfo( &PinInfo );
  109. if( FAILED( hr ) )
  110. {
  111. pPinOut->Release();
  112. pPinOut = NULL;
  113. continue;
  114. }
  115. if( PinInfo.dir == PINDIR_INPUT )
  116. {
  117. pPinOut->Release();
  118. pPinOut = NULL;
  119. continue;
  120. }
  121. IPin *pPinIn = NULL;
  122. hr = pPinOut->ConnectedTo( &pPinIn );
  123. if( FAILED( hr ) )
  124. {
  125. pPinOut->Release();
  126. pPinOut = NULL;
  127. continue;
  128. }
  129. hr = pPinIn->QueryPinInfo( &PinInfo );
  130. if( FAILED( hr ) )
  131. {
  132. pPinOut->Release();
  133. pPinOut = NULL;
  134. pPinIn->Release();
  135. continue;
  136. }
  137. if( !m_pVideoWindow )
  138. PinInfo.pFilter->QueryInterface( IID_IVideoWindow, (void**)&m_pVideoWindow );
  139. if( !m_pAMVideoProcAmp )
  140. PinInfo.pFilter->QueryInterface( IID_IAMVideoProcAmp, (void**)&m_pAMVideoProcAmp );
  141. if( !m_pSampleGrabber )
  142. PinInfo.pFilter->QueryInterface( IID_ISampleGrabber, (void**)&m_pSampleGrabber );
  143. if( !m_pAMAnalogVideoDecoder )
  144. PinInfo.pFilter->QueryInterface( IID_IAMAnalogVideoDecoder, (void**)&m_pAMAnalogVideoDecoder );
  145. FindMembers( PinInfo.pFilter );
  146. PinInfo.pFilter->Release();
  147. pPinOut->Release();
  148. pPinIn->Release();
  149. }
  150. pEnumPins->Release();
  151. }
  152. void CDSVideoProcessor::Destroy()
  153. {
  154. TRACE( "INFO: CDSVideoProcessor::Destroy\n" );
  155. Stop( TRUE );
  156. if( m_pSampleGrabber )
  157. {
  158. m_pSampleGrabber->SetCallback( NULL, 1 );
  159. m_pSampleGrabber->Release();
  160. m_pSampleGrabber = NULL;
  161. }
  162. // m_pSampleGrabberCB = NULL;
  163. if( m_pAMCrossbar )
  164. {
  165. m_pAMCrossbar->Release();
  166. m_pAMCrossbar = NULL;
  167. }
  168. if( m_pVideoWindow )
  169. {
  170. m_pVideoWindow->Release();
  171. m_pVideoWindow = NULL;
  172. }
  173. if( m_pAMVideoProcAmp )
  174. {
  175. m_pAMVideoProcAmp->Release();
  176. m_pAMVideoProcAmp = NULL;
  177. }
  178. if( m_pSampleGrabberCB )
  179. {
  180. m_pSampleGrabberCB->Release();
  181. m_pSampleGrabberCB = NULL;
  182. }
  183. m_pVideoHeader = NULL;
  184. if( m_pInputPin )
  185. {
  186. delete [] m_pInputPin;
  187. m_pInputPin = NULL;
  188. }
  189. m_nInputPinCount = 0;
  190. m_nOutputPin = -1;
  191. m_nPseudoLastInput = -1;
  192. if( m_ppPseudoVideoWnd )
  193. {
  194. delete [] m_ppPseudoVideoWnd;
  195. m_ppPseudoVideoWnd = NULL;
  196. }
  197. m_nPseudoVideoWnd = 0;
  198. if( m_pAMAnalogVideoDecoder )
  199. {
  200. m_pAMAnalogVideoDecoder->Release();
  201. m_pAMAnalogVideoDecoder = NULL;
  202. }
  203. if( m_hEventVideoSample )
  204. {
  205. ::CloseHandle( m_hEventVideoSample );
  206. m_hEventVideoSample = NULL;
  207. }
  208. if( m_pbPseudoVideoWnd )
  209. {
  210. delete [] m_pbPseudoVideoWnd;
  211. m_pbPseudoVideoWnd = NULL;
  212. }
  213. }
  214. BOOL CDSVideoProcessor::SwitchVideo( int nInputPin )
  215. {
  216. if( m_nVideoType != VT_LIVE_VIDEO )
  217. return FALSE;
  218. if( m_nInputPinCount > nInputPin )
  219. {
  220. HRESULT hr = m_pAMCrossbar->Route( m_nOutputPin, m_pInputPin[ nInputPin ] );
  221. if( FAILED( hr ) )
  222. return FALSE;
  223. }
  224. return TRUE;
  225. }
  226. BOOL CDSVideoProcessor::GetDirectInput( PLONG pInput )
  227. {
  228. if( !m_pAMVideoProcAmp )
  229. return FALSE;
  230. LONG lData = 0;
  231. return SUCCEEDED( m_pAMVideoProcAmp->Get( VideoProcAmp_Gamma, pInput, &lData ) );
  232. }
  233. BOOL CDSVideoProcessor::SetDirectOutput( LONG nIndex, BOOL bOn )
  234. {
  235. if( !m_pAMVideoProcAmp )
  236. return FALSE;
  237. LONG lData = 0;
  238. return SUCCEEDED( m_pAMVideoProcAmp->Set( bOn ? VideoProcAmp_Sharpness : VideoProcAmp_Gamma, nIndex, lData ) );
  239. }
  240. BOOL CDSVideoProcessor::Capture( LPBITMAPINFO pBitmapInfo, LPBYTE pBytes )
  241. {
  242. if( !pBytes )
  243. return FALSE;
  244. LPBYTE pSrcBuffer = NULL;
  245. LONG nLength = 0;
  246. if( !m_pSampleGrabberCB->LockBuffer( &pSrcBuffer, &nLength ) )
  247. return FALSE;
  248. ::CopyMemory( pBytes, pSrcBuffer, nLength );
  249. m_pSampleGrabberCB->UnlockBuffer();
  250. return TRUE;
  251. }
  252. HBITMAP CDSVideoProcessor::CaptureDIB()
  253. {
  254. if( !m_pVideoHeader )
  255. return NULL;
  256. if( !m_pSampleGrabberCB )
  257. return NULL;
  258. LPBYTE pDstBuffer = NULL;
  259. HBITMAP hBitmap = ::CreateDIBSection( 0, (LPBITMAPINFO)&m_pVideoHeader->bmiHeader, DIB_RGB_COLORS, (void**)&pDstBuffer, NULL, 0UL );
  260. if( !hBitmap )
  261. return NULL;
  262. LPBYTE pSrcBuffer = NULL;
  263. LONG nLength = 0;
  264. if( !m_pSampleGrabberCB->LockBuffer( &pSrcBuffer, &nLength ) )
  265. {
  266. DeleteObject( hBitmap );
  267. return NULL;
  268. }
  269. ::CopyMemory( pDstBuffer, pSrcBuffer, nLength );
  270. m_pSampleGrabberCB->UnlockBuffer();
  271. return hBitmap;
  272. }
  273. BOOL CDSVideoProcessor::InitSwitch()
  274. {
  275. if( !m_pAMCrossbar )
  276. return FALSE;
  277. long OutputPinCount;
  278. long InputPinCount;
  279. HRESULT hr = m_pAMCrossbar->get_PinCounts( &OutputPinCount, &InputPinCount );
  280. if( FAILED( hr ) )
  281. return FALSE;
  282. for( long i = 0; i < OutputPinCount && m_nOutputPin < 0; i++ )
  283. {
  284. long PinIndexRelated;
  285. long PhysicalType;
  286. HRESULT hr = m_pAMCrossbar->get_CrossbarPinInfo( FALSE, i, &PinIndexRelated, &PhysicalType );
  287. if( FAILED( hr ) )
  288. return FALSE;
  289. switch( PhysicalType )
  290. {
  291. case PhysConn_Video_Tuner:
  292. case PhysConn_Video_Composite:
  293. case PhysConn_Video_SVideo:
  294. case PhysConn_Video_RGB:
  295. case PhysConn_Video_YRYBY:
  296. case PhysConn_Video_SerialDigital:
  297. case PhysConn_Video_ParallelDigital:
  298. case PhysConn_Video_SCSI:
  299. case PhysConn_Video_AUX:
  300. case PhysConn_Video_1394:
  301. case PhysConn_Video_USB:
  302. case PhysConn_Video_VideoDecoder:
  303. case PhysConn_Video_VideoEncoder:
  304. case PhysConn_Video_SCART:
  305. m_nOutputPin = i;
  306. break;
  307. }
  308. }
  309. PLONG pInputPin = new LONG[ InputPinCount ];
  310. if( !pInputPin )
  311. return FALSE;
  312. long nInput = 0;
  313. for( i = 0; i < InputPinCount; i++ )
  314. {
  315. long PinIndexRelated = 0;
  316. long PhysicalType = -1;
  317. HRESULT hr = m_pAMCrossbar->get_CrossbarPinInfo( TRUE, i, &PinIndexRelated, &PhysicalType );
  318. if( FAILED( hr ) )
  319. {
  320. delete [] pInputPin;
  321. return FALSE;
  322. }
  323. switch( PhysicalType )
  324. {
  325. case PhysConn_Video_Tuner:
  326. case PhysConn_Video_Composite:
  327. case PhysConn_Video_SVideo:
  328. case PhysConn_Video_RGB:
  329. case PhysConn_Video_YRYBY:
  330. case PhysConn_Video_SerialDigital:
  331. case PhysConn_Video_ParallelDigital:
  332. case PhysConn_Video_SCSI:
  333. case PhysConn_Video_AUX:
  334. case PhysConn_Video_1394:
  335. case PhysConn_Video_USB:
  336. case PhysConn_Video_VideoDecoder:
  337. case PhysConn_Video_VideoEncoder:
  338. case PhysConn_Video_SCART:
  339. pInputPin[ nInput++ ] = i;
  340. break;
  341. }
  342. }
  343. m_nInputPinCount = nInput;
  344. m_pInputPin = new LONG[ m_nInputPinCount ];
  345. if( !m_pInputPin )
  346. {
  347. delete [] pInputPin;
  348. return FALSE;
  349. }
  350. ::CopyMemory( m_pInputPin, pInputPin, sizeof(LONG) * m_nInputPinCount );
  351. delete [] pInputPin;
  352. m_ppPseudoVideoWnd = new CDDVideoWnd* [ m_nInputPinCount ];
  353. if( !m_ppPseudoVideoWnd )
  354. return FALSE;
  355. m_pbPseudoVideoWnd = new BOOL[ m_nInputPinCount ];
  356. if( !m_pbPseudoVideoWnd )
  357. return FALSE;
  358. ::ZeroMemory( m_pbPseudoVideoWnd, sizeof(BOOL) * m_nInputPinCount );
  359. ::ZeroMemory( m_ppPseudoVideoWnd, sizeof(CDDVideoWnd*) * m_nInputPinCount );
  360. m_nPseudoVideoWnd = 0;
  361. return TRUE;
  362. }
  363. BOOL CDSVideoProcessor::ConnectVideoWnd( IVideoWindow** ppVideoWindow )
  364. {
  365. if( m_nVideoType != VT_NONE_VIDEO )
  366. return FALSE;
  367. if( !ppVideoWindow )
  368. return FALSE;
  369. if( !m_pVideoWindow )
  370. {
  371. *ppVideoWindow = NULL;
  372. return FALSE;
  373. }
  374. HRESULT hr = m_pVideoWindow->QueryInterface( IID_IVideoWindow, (void**)ppVideoWindow );
  375. if( FAILED( hr ) )
  376. {
  377. *ppVideoWindow = NULL;
  378. return FALSE;
  379. }
  380. m_nVideoType = VT_LIVE_VIDEO;
  381. return TRUE;
  382. }
  383. BOOL CDSVideoProcessor::ConnectVideoWnd( CDDVideoWnd *pVideoWnd, int nInput )
  384. {
  385. if( m_nVideoType != VT_NONE_VIDEO && m_nVideoType != VT_MULTIPLEX_VIDEO )
  386. return FALSE;
  387. if( !m_ppPseudoVideoWnd )
  388. return FALSE;
  389. if( nInput >= m_nInputPinCount )
  390. return FALSE;
  391. if( nInput > 0 )
  392. {
  393. if( m_ppPseudoVideoWnd[ nInput ] )
  394. return FALSE;
  395. m_ppPseudoVideoWnd[ nInput ] = pVideoWnd;
  396. m_ppPseudoVideoWnd[ nInput ]->SetImageFormat( (LPBITMAPINFO)&m_pVideoHeader->bmiHeader, sizeof(BITMAPINFO) );
  397. m_nVideoType = VT_MULTIPLEX_VIDEO;
  398. return TRUE;
  399. }
  400. for( nInput = 0; nInput < m_nInputPinCount; nInput++ )
  401. {
  402. if( !m_ppPseudoVideoWnd[ nInput ] )
  403. {
  404. m_ppPseudoVideoWnd[ nInput ] = pVideoWnd;
  405. m_ppPseudoVideoWnd[ nInput ]->SetImageFormat( (LPBITMAPINFO)&m_pVideoHeader->bmiHeader, sizeof(BITMAPINFO) );
  406. m_nVideoType = VT_MULTIPLEX_VIDEO;
  407. return TRUE;
  408. }
  409. }
  410. return FALSE;
  411. }
  412. void CDSVideoProcessor::ActivateWnd( LONG nIndex )
  413. {
  414. if( nIndex < 0 && nIndex >= m_nInputPinCount )
  415. return;
  416. if( !m_pbPseudoVideoWnd )
  417. return;
  418. m_pbPseudoVideoWnd[ nIndex ] = TRUE;
  419. }
  420. DWORD CDSVideoProcessor::ThreadProc()
  421. {
  422. HANDLE pEvent[] = { CThread::GetThreadStopEvent(), m_hEventVideoSample };
  423. BOOL bRun = TRUE;
  424. while( bRun )
  425. {
  426. switch( WaitForMultipleObjects( 2, pEvent, FALSE, INFINITE ) )
  427. {
  428. case WAIT_OBJECT_0:
  429. bRun = FALSE;
  430. continue;
  431. case WAIT_OBJECT_0+1:
  432. // Sleep(100);
  433. ProcessVideoSample();
  434. break;
  435. default:
  436. ASSERT( NULL );
  437. bRun = FALSE;
  438. continue;
  439. }
  440. }
  441. return 0UL;
  442. }
  443. void CDSVideoProcessor::ProcessVideoSample()
  444. {
  445. // TRACE( "INFO: CDSVideoProcessor::ProcessVideoSample\n" );
  446. __try
  447. {
  448. if( m_nVideoType != VT_MULTIPLEX_VIDEO )
  449. return;
  450. if( !m_pAMCrossbar )
  451. return;
  452. if( m_nPseudoCaptureLoop % 2 == 0 )
  453. // if( (GetTickCount() - m_dwPseudoLastTime) > 100UL )
  454. {
  455. m_dwPseudoLastTime = GetTickCount();
  456. if( m_pbPseudoVideoWnd[ m_nPseudoVideoWnd ] &&
  457. m_ppPseudoVideoWnd[ m_nPseudoVideoWnd ] &&
  458. m_ppPseudoVideoWnd[ m_nPseudoVideoWnd ]->GetSafeHwnd() )
  459. {
  460. LPBITMAPINFO pBitmapInfo = NULL;
  461. LPBYTE pBytes = NULL;
  462. if( m_ppPseudoVideoWnd[ m_nPseudoVideoWnd ]->GetImageInfo( &pBitmapInfo, &pBytes ) )
  463. {
  464. if( Capture( pBitmapInfo, pBytes ) )
  465. m_ppPseudoVideoWnd[ m_nPseudoVideoWnd ]->PostMessage( WM_UPDATE_BITMAP );
  466. m_ppPseudoVideoWnd[ m_nPseudoVideoWnd ]->ReleaseImageInfo();
  467. }
  468. }
  469. for( int i = 0; i < m_nInputPinCount; i++ )
  470. {
  471. m_nPseudoVideoWnd = (m_nPseudoVideoWnd + 1) % m_nInputPinCount;
  472. if( m_pbPseudoVideoWnd[ m_nPseudoVideoWnd ] &&
  473. m_ppPseudoVideoWnd[ m_nPseudoVideoWnd ] )
  474. {
  475. if( m_nPseudoLastInput != m_pInputPin[ m_nPseudoVideoWnd ] )
  476. {
  477. m_nPseudoLastInput = m_pInputPin[ m_nPseudoVideoWnd ];
  478. m_pAMCrossbar->Route( m_nOutputPin, m_pInputPin[ m_nPseudoVideoWnd ] );
  479. TRACE( "-----Route %d <-> %d\n", m_nOutputPin, m_pInputPin[ m_nPseudoVideoWnd ] );
  480. }
  481. break;
  482. }
  483. }
  484. }
  485. m_nPseudoCaptureLoop++;
  486. }
  487. __except( 1 )
  488. {
  489. }
  490. }
  491. void CDSVideoProcessor::OnVideoSample()
  492. {
  493. // return; // NOTE TEST ONLY
  494. if( m_hEventVideoSample )
  495. ::SetEvent( m_hEventVideoSample );
  496. }
  497. BOOL CDSVideoProcessor::SetVideoStandart( long lVideoStandard )
  498. {
  499. if( !m_pAMAnalogVideoDecoder )
  500. return FALSE;
  501. return SUCCEEDED( m_pAMAnalogVideoDecoder->put_TVFormat( lVideoStandard ) );
  502. }
  503. /*
  504. BOOL CDSVideoProcessor::DrawText( LPCTSTR pText, LPBITMAPINFO pBitmapInfo, LPBYTE pBytes, COLORREF cColor )
  505. {
  506. if( !pText || !pBitmapInfo || !pBytes )
  507. return FALSE;
  508. if( pBitmapInfo->bmiHeader.biBitCount % 8 != 0 )
  509. return FALSE;
  510. int nStrPixelSize = _tcslen( pText ) * m_SymbolData.GetWidth();
  511. int nStrShift = ( pBitmapInfo->bmiHeader.biWidth - nStrPixelSize ) >> 1;
  512. int nCharRowBegin = ( m_SymbolData.GetHeigth() - 1 ) * m_SymbolData.GetWidth();
  513. PBYTE pPixel08Ptr;
  514. PWORD pPixel16Ptr;
  515. RGBTRIPLE* pPixel24Ptr;
  516. BYTE color08;
  517. WORD color16;
  518. RGBTRIPLE color24;
  519. int x, y;
  520. switch( pBitmapInfo->bmiHeader.biBitCount )
  521. {
  522. case 8:
  523. color08 = (BYTE)cColor;
  524. pPixel08Ptr = (PBYTE)pBytes;
  525. pPixel08Ptr += nStrShift;
  526. for( y = 0; y < m_SymbolData.GetHeigth(); y++ )
  527. {
  528. int nChar = 0;
  529. int nCharColumn = 0;
  530. for( x = 0; x < nStrPixelSize; x++ )
  531. {
  532. if( *( m_SymbolData.Get( pText[ nChar ] ) + nCharRowBegin + nCharColumn ) )
  533. pPixel08Ptr[ x ] = color08;
  534. if( ++nCharColumn == m_SymbolData.GetWidth() )
  535. {
  536. nCharColumn = 0;
  537. nChar++;
  538. }
  539. }
  540. pPixel08Ptr += pBitmapInfo->bmiHeader.biWidth;
  541. nCharRowBegin -= m_SymbolData.GetWidth();
  542. }
  543. break;
  544. case 16:
  545. color16 = ( ( GetRValue( cColor ) >> 3 ) << 11 ) |
  546. ( ( GetGValue( cColor ) >> 2 ) << 5 ) |
  547. ( ( GetBValue( cColor ) >> 3 ) << 0 );
  548. pPixel16Ptr = (PWORD)pBytes;
  549. pPixel16Ptr += nStrShift;
  550. for( y = 0; y < m_SymbolData.GetHeigth(); y++ )
  551. {
  552. int nChar = 0;
  553. int nCharColumn = 0;
  554. for( x = 0; x < nStrPixelSize; x++ )
  555. {
  556. if( *( m_SymbolData.Get( pText[ nChar ] ) + nCharRowBegin + nCharColumn ) )
  557. pPixel16Ptr[ x ] = color16;
  558. if( ++nCharColumn == m_SymbolData.GetWidth() )
  559. {
  560. nCharColumn = 0;
  561. nChar++;
  562. }
  563. }
  564. pPixel16Ptr += pBitmapInfo->bmiHeader.biWidth;
  565. nCharRowBegin -= m_SymbolData.GetWidth();
  566. }
  567. break;
  568. case 24:
  569. color24.rgbtRed = GetRValue( cColor );
  570. color24.rgbtGreen = GetGValue( cColor );
  571. color24.rgbtBlue = GetBValue( cColor );
  572. pPixel24Ptr = (RGBTRIPLE*)pBytes;
  573. pPixel24Ptr += nStrShift;
  574. for( y = 0; y < m_SymbolData.GetHeigth(); y++ )
  575. {
  576. int nChar = 0;
  577. int nCharColumn = 0;
  578. for( x = 0; x < nStrPixelSize; x++ )
  579. {
  580. if( *( m_SymbolData.Get( pText[ nChar ] ) + nCharRowBegin + nCharColumn ) )
  581. pPixel24Ptr[ x ] = color24;
  582. if( ++nCharColumn == m_SymbolData.GetWidth() )
  583. {
  584. nCharColumn = 0;
  585. nChar++;
  586. }
  587. }
  588. pPixel24Ptr += pBitmapInfo->bmiHeader.biWidth;
  589. nCharRowBegin -= m_SymbolData.GetWidth();
  590. }
  591. break;
  592. }
  593. return TRUE;
  594. }
  595. */