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.

603 lines
15 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: 07/12/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: DirectShowStreamVideo.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of DirectShowStreamVideo.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "..\Version.h"
  16. #include "DirectShowStreamVideo.h"
  17. #include "DirectShowSampleGrabberCB.h"
  18. #include "DirectShowVideo.h"
  19. CDirectShowStreamVideo::CDirectShowStreamVideo()
  20. {
  21. m_pVideoWindow = NULL;
  22. m_pAMVideoProcAmp = NULL;
  23. m_pAMAnalogVideoDecoder = NULL;
  24. m_pAMCrossbar = NULL;
  25. m_pInputPin = NULL;
  26. m_pCaptureFilter = NULL;
  27. m_nInputPinCount = 0;
  28. m_nOutputPin = -1;
  29. m_nDirectShowVideoSwitch = 0;
  30. m_nDirectShowVideoSource = -1;
  31. m_nDirectShowVideoFrame = 0;
  32. m_nDirectShowVideoStandard = AnalogVideo_None;
  33. m_nVideoFPS = 3;
  34. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDirectShowStreamVideo::CDirectShowStreamVideo" );
  35. }
  36. CDirectShowStreamVideo::~CDirectShowStreamVideo()
  37. {
  38. Destroy();
  39. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CDirectShowStreamVideo::~CDirectShowStreamVideo" );
  40. }
  41. BOOL CDirectShowStreamVideo::Create( IBaseFilter *pSourceFilter, IBaseFilter *pCaptureFilter )
  42. {
  43. Destroy();
  44. if( !pCaptureFilter || FAILED( pCaptureFilter->QueryInterface( IID_IBaseFilter, (void**)&m_pCaptureFilter ) ) )
  45. m_pCaptureFilter = NULL;
  46. // make copy of crossbar if exist
  47. if( FAILED( pSourceFilter->QueryInterface( IID_IAMCrossbar, (void**)&m_pAMCrossbar ) ) )
  48. m_pAMCrossbar = NULL;
  49. IBaseFilter *pMemberFilter = NULL;
  50. if( FAILED(pSourceFilter->QueryInterface( IID_IBaseFilter, (void**)&pMemberFilter ) ) )
  51. return FALSE;
  52. // search for video window
  53. m_pVideoWindow = (IVideoWindow*)FindInterface( pMemberFilter, IID_IVideoWindow );
  54. if( m_pVideoWindow )
  55. {
  56. // hide video window
  57. m_pVideoWindow->put_Visible( OAFALSE );
  58. m_pVideoWindow->put_AutoShow( OAFALSE );
  59. }
  60. // search for analog video amplifier
  61. m_pAMVideoProcAmp = (IAMVideoProcAmp*)FindInterface( pMemberFilter, IID_IAMVideoProcAmp );
  62. if( m_pAMVideoProcAmp && 0 )
  63. {
  64. // make gray-scale video
  65. SetVideoSaturation( 0 );
  66. // set contrast
  67. SetVideoContrast( 50 );
  68. // set brightness
  69. SetVideoBrightness( 50 );
  70. }
  71. // search for analog video decoder
  72. m_pAMAnalogVideoDecoder = (IAMAnalogVideoDecoder*)FindInterface( pMemberFilter, IID_IAMAnalogVideoDecoder );
  73. // search for sample grabber
  74. ISampleGrabber *pSampleGrabber = (ISampleGrabber*)FindInterface( pMemberFilter, IID_ISampleGrabber );
  75. if( !pSampleGrabber )
  76. {
  77. pMemberFilter->Release();
  78. return FALSE;
  79. }
  80. if( !CDirectShowStream::Create( pSampleGrabber ) )
  81. {
  82. pSampleGrabber->Release();
  83. pMemberFilter->Release();
  84. return FALSE;
  85. }
  86. pSampleGrabber->Release();
  87. pMemberFilter->Release();
  88. // prepare swiching
  89. if( m_pAMCrossbar )
  90. {
  91. if( !InitSwitcher() )
  92. return FALSE;
  93. }
  94. else
  95. {
  96. m_nInputPinCount = 1;
  97. m_pInputPin = new LONG[m_nInputPinCount];
  98. if( !m_pInputPin )
  99. {
  100. m_nInputPinCount = 0;
  101. return FALSE;
  102. }
  103. m_pInputPin[0] = 0;
  104. m_nOutputPin = 0;
  105. }
  106. #ifdef __INCLUDE__VIDEO__MEDIA__SERVER__
  107. m_MediaServer.Create( m_pBitmapInfoHeader );
  108. #endif // __INCLUDE__VIDEO__MEDIA__SERVER__
  109. return TRUE;
  110. }
  111. void CDirectShowStreamVideo::Destroy()
  112. {
  113. CDirectShowStream::Destroy();
  114. #ifdef __INCLUDE__VIDEO__MEDIA__SERVER__
  115. m_MediaServer.Destroy();
  116. #endif // __INCLUDE__VIDEO__MEDIA__SERVER__
  117. if( m_pAMCrossbar )
  118. {
  119. m_pAMCrossbar->Release();
  120. m_pAMCrossbar = NULL;
  121. }
  122. if( m_pVideoWindow )
  123. {
  124. m_pVideoWindow->Release();
  125. m_pVideoWindow = NULL;
  126. }
  127. if( m_pAMVideoProcAmp )
  128. {
  129. m_pAMVideoProcAmp->Release();
  130. m_pAMVideoProcAmp = NULL;
  131. }
  132. if( m_pAMAnalogVideoDecoder )
  133. {
  134. m_pAMAnalogVideoDecoder->Release();
  135. m_pAMAnalogVideoDecoder = NULL;
  136. }
  137. if( m_pInputPin )
  138. {
  139. delete [] m_pInputPin;
  140. m_pInputPin = NULL;
  141. }
  142. if( m_pCaptureFilter )
  143. {
  144. m_pCaptureFilter->Release();
  145. m_pCaptureFilter = NULL;
  146. }
  147. m_nInputPinCount = 0;
  148. m_nOutputPin = -1;
  149. m_nDirectShowVideoSwitch = 0;
  150. m_nDirectShowVideoSource = -1;
  151. m_nDirectShowVideoFrame = 0;
  152. }
  153. BOOL CDirectShowStreamVideo::SetVideoStandart( long lVideoStandard )
  154. {
  155. if( !m_pAMAnalogVideoDecoder )
  156. return FALSE;
  157. if( FAILED( m_pAMAnalogVideoDecoder->put_TVFormat( lVideoStandard ) ) )
  158. return FALSE;
  159. m_nDirectShowVideoStandard = lVideoStandard;
  160. return TRUE;
  161. }
  162. BOOL CDirectShowStreamVideo::SetVideoFPS( INT nFPS )
  163. {
  164. m_nVideoFPS = nFPS;
  165. return TRUE;
  166. }
  167. BOOL CDirectShowStreamVideo::IsSwitchable()
  168. {
  169. return m_pAMCrossbar != NULL;
  170. }
  171. INT CDirectShowStreamVideo::GetVideoSourceCount()
  172. {
  173. return m_nInputPinCount;
  174. }
  175. BOOL CDirectShowStreamVideo::SetVideoSource( INT nSource )
  176. {
  177. if( !m_pAMCrossbar && !nSource )
  178. return TRUE;
  179. if( nSource < 0 || nSource >= m_nInputPinCount || !m_pAMCrossbar )
  180. return FALSE;
  181. if( m_nOutputPin == -1 )
  182. return FALSE;
  183. if( !m_pAMCrossbar )
  184. return FALSE;
  185. if( FAILED( m_pAMCrossbar->Route( m_nOutputPin, m_pInputPin[ nSource ] ) ) )
  186. return FALSE;
  187. m_nDirectShowVideoSource = nSource;
  188. return TRUE;
  189. }
  190. PVOID CDirectShowStreamVideo::FindInterface( IBaseFilter *pFilter, REFIID iid )
  191. {
  192. if( !pFilter )
  193. return NULL;
  194. IEnumPins *pEnumPins = NULL;
  195. HRESULT hr = pFilter->EnumPins( &pEnumPins );
  196. if( FAILED(hr) )
  197. return NULL;
  198. PVOID pInterface = NULL;
  199. while( !pInterface )
  200. {
  201. IPin *pPinOut = NULL;
  202. // get next pin
  203. if( pEnumPins->Next( 1, &pPinOut, NULL ) != S_OK )
  204. break;
  205. // get pin information
  206. PIN_INFO PinInfo;
  207. hr = pPinOut->QueryPinInfo( &PinInfo );
  208. if( FAILED( hr ) )
  209. {
  210. pPinOut->Release();
  211. continue;
  212. }
  213. if( PinInfo.pFilter )
  214. PinInfo.pFilter->Release();
  215. // check direction
  216. if( PinInfo.dir == PINDIR_INPUT )
  217. {
  218. pPinOut->Release();
  219. continue;
  220. }
  221. // get pin connected to this pin
  222. IPin *pPinIn = NULL;
  223. hr = pPinOut->ConnectedTo( &pPinIn );
  224. if( FAILED( hr ) )
  225. {
  226. pPinOut->Release();
  227. continue;
  228. }
  229. hr = pPinIn->QueryPinInfo( &PinInfo );
  230. if( FAILED( hr ) )
  231. {
  232. pPinOut->Release();
  233. pPinIn->Release();
  234. continue;
  235. }
  236. /*
  237. TCHAR pName[MAX_PATH];
  238. ::WideCharToMultiByte( CP_ACP, 0, PinInfo.achName, -1, pName, MAX_PATH, 0, 0 );
  239. FILTER_INFO fi;
  240. PinInfo.pFilter->QueryFilterInfo( &fi );
  241. ::WideCharToMultiByte( CP_ACP, 0, fi.achName, -1, pName, MAX_PATH, 0, 0 );
  242. if( fi.pGraph )
  243. fi.pGraph->Release();
  244. */
  245. if( (!PinInfo.pFilter) || FAILED( PinInfo.pFilter->QueryInterface( iid, &pInterface ) ) )
  246. pInterface = FindInterface( PinInfo.pFilter, iid );
  247. if( PinInfo.pFilter )
  248. PinInfo.pFilter->Release();
  249. pPinOut->Release();
  250. pPinIn->Release();
  251. }
  252. pEnumPins->Release();
  253. return pInterface;
  254. }
  255. BOOL CDirectShowStreamVideo::InitSwitcher()
  256. {
  257. if( !m_pAMCrossbar )
  258. return FALSE;
  259. long OutputPinCount;
  260. long InputPinCount;
  261. HRESULT hr = m_pAMCrossbar->get_PinCounts( &OutputPinCount, &InputPinCount );
  262. if( FAILED( hr ) )
  263. return FALSE;
  264. for( long i = 0; i < OutputPinCount && m_nOutputPin < 0; i++ )
  265. {
  266. long PinIndexRelated;
  267. long PhysicalType;
  268. HRESULT hr = m_pAMCrossbar->get_CrossbarPinInfo( FALSE, i, &PinIndexRelated, &PhysicalType );
  269. if( FAILED( hr ) )
  270. return FALSE;
  271. switch( PhysicalType )
  272. {
  273. case PhysConn_Video_Tuner:
  274. case PhysConn_Video_Composite:
  275. case PhysConn_Video_SVideo:
  276. case PhysConn_Video_RGB:
  277. case PhysConn_Video_YRYBY:
  278. case PhysConn_Video_SerialDigital:
  279. case PhysConn_Video_ParallelDigital:
  280. case PhysConn_Video_SCSI:
  281. case PhysConn_Video_AUX:
  282. case PhysConn_Video_1394:
  283. case PhysConn_Video_USB:
  284. case PhysConn_Video_VideoDecoder:
  285. case PhysConn_Video_VideoEncoder:
  286. case PhysConn_Video_SCART:
  287. m_nOutputPin = i;
  288. break;
  289. }
  290. }
  291. PLONG pInputPin = new LONG[ InputPinCount ];
  292. if( !pInputPin )
  293. return FALSE;
  294. long nInput = 0;
  295. for( i = 0; i < InputPinCount; i++ )
  296. {
  297. long PinIndexRelated = 0;
  298. long PhysicalType = -1;
  299. HRESULT hr = m_pAMCrossbar->get_CrossbarPinInfo( TRUE, i, &PinIndexRelated, &PhysicalType );
  300. if( FAILED( hr ) )
  301. {
  302. delete [] pInputPin;
  303. return FALSE;
  304. }
  305. switch( PhysicalType )
  306. {
  307. case PhysConn_Video_Tuner:
  308. case PhysConn_Video_Composite:
  309. case PhysConn_Video_SVideo:
  310. case PhysConn_Video_RGB:
  311. case PhysConn_Video_YRYBY:
  312. case PhysConn_Video_SerialDigital:
  313. case PhysConn_Video_ParallelDigital:
  314. case PhysConn_Video_SCSI:
  315. case PhysConn_Video_AUX:
  316. case PhysConn_Video_1394:
  317. case PhysConn_Video_USB:
  318. case PhysConn_Video_VideoDecoder:
  319. case PhysConn_Video_VideoEncoder:
  320. case PhysConn_Video_SCART:
  321. pInputPin[ nInput++ ] = i;
  322. break;
  323. }
  324. }
  325. m_nInputPinCount = nInput;
  326. m_pInputPin = new LONG[ m_nInputPinCount ];
  327. if( !m_pInputPin )
  328. {
  329. delete [] pInputPin;
  330. return FALSE;
  331. }
  332. ::CopyMemory( m_pInputPin, pInputPin, sizeof(LONG) * m_nInputPinCount );
  333. delete [] pInputPin;
  334. return TRUE;
  335. }
  336. void CDirectShowStreamVideo::OnVideoSample( double SampleTime, BYTE *pBuffer, long BufferLen )
  337. {
  338. if( !m_pBitmapInfoHeader || !pBuffer )
  339. return;
  340. #ifdef __INCLUDE__VIDEO__MEDIA__SERVER__
  341. QWORD qTime = 10000i64 * (QWORD)GetTickCount();
  342. if( !m_MediaServer.WriteSample( qTime, pBuffer, BufferLen ) )
  343. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CDirectShowStreamVideo::OnVideoSample"), _T("m_MediaServer.WriteSample failed") );
  344. #endif
  345. // protect
  346. CLgLocker Lock( &CLgLinkP<CDirectShowStream,CDirectShowVideo>::GetLock() );
  347. // make reference
  348. CLgArray< CLgLink<CDirectShowVideo,CDirectShowStream>* >& arrVideo = *this;
  349. if( arrVideo.GetCount() )
  350. {
  351. // determine number of visible windows
  352. INT nVisibleCount = 0;
  353. for( INT i = 0; i < arrVideo.GetCount(); i++ )
  354. {
  355. CDirectShowVideo *pDirectShowVideo = *arrVideo[i];
  356. if( pDirectShowVideo->IsVideoShow() )
  357. nVisibleCount ++;
  358. }
  359. // no visible windows
  360. if( !nVisibleCount )
  361. return;
  362. // take every second frame
  363. if( ++m_nDirectShowVideoFrame >= m_nVideoFPS || nVisibleCount == 1 )
  364. {
  365. // update current input
  366. if( m_nDirectShowVideoSwitch < arrVideo.GetCount() )
  367. {
  368. // update image
  369. CDirectShowVideo *pDirectShowVideo = *arrVideo[ m_nDirectShowVideoSwitch ];
  370. pDirectShowVideo->UpdateVideo( m_pBitmapInfoHeader, pBuffer, SampleTime );
  371. }
  372. // get next input
  373. for( INT i = 0; i < arrVideo.GetCount(); i++ )
  374. {
  375. // take next window
  376. m_nDirectShowVideoSwitch = (m_nDirectShowVideoSwitch + 1) % arrVideo.GetCount();
  377. CDirectShowVideo *pDirectShowVideo = *arrVideo[ m_nDirectShowVideoSwitch ];
  378. // if new source differs from old source then switch
  379. if( m_nDirectShowVideoSource != pDirectShowVideo->GetVideoInput() && pDirectShowVideo->IsVideoShow() )
  380. {
  381. // check video standard
  382. if( m_nDirectShowVideoStandard != pDirectShowVideo->GetVideoStandard() &&
  383. pDirectShowVideo->GetVideoStandard() != AnalogVideo_None )
  384. {
  385. // switch video standard
  386. SetVideoStandart( pDirectShowVideo->GetVideoStandard() );
  387. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CDirectShowStreamVideo::OnVideoSample", "video standard switched to %d", m_nDirectShowVideoStandard );
  388. }
  389. // switch video source
  390. SetVideoSource( pDirectShowVideo->GetVideoInput() );
  391. LGLOG( LOG_LEVEL_REALTIME, LOG_TYPE_INFO, this, "CDirectShowStreamVideo::OnVideoSample", "video input switched to %d", m_nDirectShowVideoSource );
  392. break;
  393. }
  394. }
  395. // reset frame counter
  396. m_nDirectShowVideoFrame = 0;
  397. }
  398. }
  399. }
  400. BOOL CDirectShowStreamVideo::SetVideoContrast(double dPercent)
  401. {
  402. if( !m_pAMVideoProcAmp )
  403. return FALSE;
  404. // get limits
  405. LONG nMin = 0;
  406. LONG nMax = 0;
  407. LONG nSteppingDelta = 0;
  408. LONG nDefault = 0;
  409. LONG nCapsFlags = 0;
  410. HRESULT hr = m_pAMVideoProcAmp->GetRange( VideoProcAmp_Contrast, &nMin, &nMax, &nSteppingDelta, &nDefault, &nCapsFlags );
  411. if( FAILED(hr) )
  412. return FALSE;
  413. // prepare new value
  414. LONG nContrast = (LONG)( nMin + ( nMax - nMin ) * dPercent / 100.0 );
  415. // check bounds
  416. if( nContrast > nMax ) nContrast = nMax;
  417. if( nContrast < nMin ) nContrast = nMin;
  418. // make contrast
  419. hr = m_pAMVideoProcAmp->Set( VideoProcAmp_Contrast, nContrast, VideoProcAmp_Flags_Manual );
  420. return SUCCEEDED(hr);
  421. }
  422. BOOL CDirectShowStreamVideo::SetVideoBrightness( double dPercent )
  423. {
  424. if( !m_pAMVideoProcAmp )
  425. return FALSE;
  426. // get limits
  427. LONG nMin = 0;
  428. LONG nMax = 0;
  429. LONG nSteppingDelta = 0;
  430. LONG nDefault = 0;
  431. LONG nCapsFlags = 0;
  432. HRESULT hr = m_pAMVideoProcAmp->GetRange( VideoProcAmp_Brightness, &nMin, &nMax, &nSteppingDelta, &nDefault, &nCapsFlags );
  433. if( FAILED(hr) )
  434. return FALSE;
  435. // prepare new value
  436. LONG nBrightness = (LONG)( nMin + ( nMax - nMin ) * dPercent / 100.0 );
  437. // check bounds
  438. if( nBrightness > nMax ) nBrightness = nMax;
  439. if( nBrightness < nMin ) nBrightness = nMin;
  440. // make bright
  441. hr = m_pAMVideoProcAmp->Set( VideoProcAmp_Brightness, nBrightness, VideoProcAmp_Flags_Manual );
  442. return SUCCEEDED(hr);
  443. }
  444. BOOL CDirectShowStreamVideo::SetVideoSaturation( double dPercent )
  445. {
  446. if( !m_pAMVideoProcAmp )
  447. return FALSE;
  448. // get limits
  449. LONG nMin = 0;
  450. LONG nMax = 0;
  451. LONG nSteppingDelta = 0;
  452. LONG nDefault = 0;
  453. LONG nCapsFlags = 0;
  454. HRESULT hr = m_pAMVideoProcAmp->GetRange( VideoProcAmp_Saturation, &nMin, &nMax, &nSteppingDelta, &nDefault, &nCapsFlags );
  455. if( FAILED(hr) )
  456. return FALSE;
  457. // prepare new value
  458. LONG nSaturation = (LONG)( nMin + ( nMax - nMin ) * dPercent / 100.0 );
  459. // check bounds
  460. if( nSaturation > nMax ) nSaturation = nMax;
  461. if( nSaturation < nMin ) nSaturation = nMin;
  462. // make bright
  463. hr = m_pAMVideoProcAmp->Set( VideoProcAmp_Saturation, nSaturation, VideoProcAmp_Flags_Manual );
  464. return SUCCEEDED(hr);
  465. }
  466. BOOL CDirectShowStreamVideo::ShowPropertyPage( HWND hParentWnd )
  467. {
  468. IBaseFilter *pFilter = m_pCaptureFilter;
  469. /* Obtain the filter's IBaseFilter interface. (Not shown) */
  470. ISpecifyPropertyPages *pProp;
  471. HRESULT hr = pFilter->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pProp);
  472. if (SUCCEEDED(hr))
  473. {
  474. // Get the filter's name and IUnknown pointer.
  475. FILTER_INFO FilterInfo;
  476. pFilter->QueryFilterInfo(&FilterInfo);
  477. IUnknown *pFilterUnk;
  478. pFilter->QueryInterface(IID_IUnknown, (void **)&pFilterUnk);
  479. // Show the page.
  480. CAUUID caGUID;
  481. pProp->GetPages(&caGUID);
  482. pProp->Release();
  483. OleCreatePropertyFrame(
  484. hParentWnd, // Parent window
  485. 0, 0, // (Reserved)
  486. FilterInfo.achName, // Caption for the dialog box
  487. 1, // Number of objects (just the filter)
  488. &pFilterUnk, // Array of object pointers.
  489. caGUID.cElems, // Number of property pages
  490. caGUID.pElems, // Array of property page CLSIDs
  491. 0, // Locale identifier
  492. 0, NULL // Reserved
  493. );
  494. // Clean up.
  495. pFilterUnk->Release();
  496. FilterInfo.pGraph->Release();
  497. CoTaskMemFree(caGUID.pElems);
  498. }
  499. return TRUE;
  500. }