Leaked source code of windows server 2003
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.

880 lines
29 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: VMRenderer.h
  3. *
  4. *
  5. *
  6. *
  7. * Created: Tue 02/15/2000
  8. * Author: Stephen Estrop [StEstrop]
  9. *
  10. * Copyright (c) 2000 Microsoft Corporation
  11. \**************************************************************************/
  12. #include "VMRuuids.h"
  13. #include "alloclib.h"
  14. #include "CVMRMediaSample.h"
  15. #include "vmrwinctrl.h"
  16. #include "vmrwindow.h"
  17. #include "vmrp.h"
  18. #include "ddva.h"
  19. #include "videoacc.h"
  20. class CVMRInputPin;
  21. class CVMRFilter;
  22. class CVMRAllocator;
  23. class CVMRRendererMacroVision;
  24. class CVMRDeinterlaceContainer;
  25. extern const AMOVIESETUP_FILTER sudVMRFilter;
  26. class CVMRDeinterlaceContainer {
  27. public:
  28. CVMRDeinterlaceContainer(LPDIRECTDRAW7 pDD, HRESULT* phr);
  29. ~CVMRDeinterlaceContainer();
  30. HRESULT QueryAvailableModes(
  31. LPDXVA_VideoDesc lpVideoDescription,
  32. LPDWORD lpdwNumModesSupported,
  33. LPGUID pGuidsDeinterlaceModes
  34. );
  35. HRESULT QueryModeCaps(
  36. LPGUID pGuidDeinterlaceMode,
  37. LPDXVA_VideoDesc lpVideoDescription,
  38. LPDXVA_DeinterlaceCaps lpDeinterlaceCaps
  39. );
  40. private:
  41. IDDVideoAcceleratorContainer* m_pIDDVAContainer;
  42. IDirectDrawVideoAccelerator* m_pIDDVideoAccelerator;
  43. };
  44. //
  45. // Combination of all the VP_TV_XXX flags (w/o _WIN_VGA) gives 0x7FFF
  46. //
  47. #define ValidTVStandard(dw) (dw & 0x7FFF)
  48. //
  49. // MacroVision implementation wrapped in a class for Video Renderer
  50. //
  51. class CVMRRendererMacroVision {
  52. public:
  53. CVMRRendererMacroVision(void) ;
  54. ~CVMRRendererMacroVision(void) ;
  55. BOOL SetMacroVision(HMONITOR hMon, DWORD dwCPBits) ;
  56. BOOL StopMacroVision();
  57. HMONITOR GetCPHMonitor(void) { return m_hMon; };
  58. private:
  59. DWORD m_dwCPKey;
  60. HMONITOR m_hMon;
  61. };
  62. /* -------------------------------------------------------------------------
  63. ** Dedicated Mixer Pin allocator class
  64. ** -------------------------------------------------------------------------
  65. */
  66. class CVMRPinAllocator :
  67. public CBaseAllocator
  68. {
  69. friend class CVMRFilter;
  70. friend class CVMRInputPin;
  71. public:
  72. CVMRPinAllocator(CVMRInputPin* pPin, CCritSec *pLock, HRESULT *phr);
  73. // Overriden to delegate reference counts to the pin
  74. STDMETHODIMP_(ULONG) NonDelegatingAddRef();
  75. STDMETHODIMP_(ULONG) NonDelegatingRelease();
  76. STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,VOID **ppv);
  77. STDMETHODIMP SetProperties(
  78. ALLOCATOR_PROPERTIES* pRequest, ALLOCATOR_PROPERTIES* pActual);
  79. STDMETHODIMP GetBuffer(
  80. IMediaSample **ppSample, REFERENCE_TIME *pStartTime,
  81. REFERENCE_TIME *pEndTime, DWORD dwFlags);
  82. STDMETHODIMP ReleaseBuffer(IMediaSample *pMediaSample);
  83. // Check all samples are returned
  84. BOOL CanFree() const
  85. {
  86. return m_lFree.GetCount() == m_lAllocated;
  87. }
  88. private:
  89. void Free();
  90. HRESULT Alloc();
  91. private:
  92. CVMRInputPin* m_pPin;
  93. CCritSec* m_pInterfaceLock;
  94. };
  95. //
  96. // these values are used to do sanity checking mostly
  97. //
  98. #define MAX_COMPRESSED_TYPES 10
  99. #define MAX_COMPRESSED_BUFFERS 20
  100. typedef struct _tag_SURFACE_INFO {
  101. LPDIRECTDRAWSURFACE7 pSurface;
  102. union {
  103. LPVOID pBuffer; // NULL if not locked
  104. DWORD_PTR InUse;
  105. };
  106. } SURFACE_INFO, *LPSURFACE_INFO;
  107. typedef struct _tag_COMP_SURFACE_INFO {
  108. DWORD dwAllocated;
  109. LPSURFACE_INFO pSurfInfo;
  110. } COMP_SURFACE_INFO, *LPCOMP_SURFACE_INFO;
  111. enum {
  112. AM_VIDEOACCELERATOR = 0x01,
  113. AM_IMEMINPUTPIN = 0x02
  114. };
  115. /* -------------------------------------------------------------------------
  116. ** New Renderer's input pin
  117. ** -------------------------------------------------------------------------
  118. */
  119. class CVMRInputPin :
  120. public CBaseInputPin,
  121. public IPinConnection,
  122. public IAMVideoAccelerator,
  123. public IVMRVideoStreamControl
  124. {
  125. public:
  126. DECLARE_IUNKNOWN
  127. CVMRInputPin(DWORD dwID, CVMRFilter* pRenderer,
  128. CCritSec *pLock, HRESULT *phr, LPCWSTR Name);
  129. virtual ~CVMRInputPin();
  130. // Overriden to delegate reference counts to the filter
  131. STDMETHODIMP_(ULONG) NonDelegatingAddRef();
  132. STDMETHODIMP_(ULONG) NonDelegatingRelease();
  133. STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,VOID **ppv);
  134. // IPinConnection
  135. //
  136. // This interface is implemented to allow the VMR to support dynamice
  137. // pin reconnections.
  138. //
  139. STDMETHODIMP DynamicQueryAccept(const AM_MEDIA_TYPE *pmt);
  140. STDMETHODIMP NotifyEndOfStream(HANDLE hNotifyEvent);
  141. STDMETHODIMP IsEndPin();
  142. STDMETHODIMP DynamicDisconnect();
  143. // IOverlay
  144. //
  145. // This interface is only added to support old applications that want to
  146. // know the VMR's window handle. This interface is only obtainable when
  147. // the VMR is in Window'ed mode. New applications should be written to the
  148. // WindowLess mode and therefore already know the window handle of the
  149. // playback window (because they created the thing!).
  150. //
  151. // The VMR will not allow upstream filters to connect using this interface,
  152. // that is the VMR should only expose the interface after a connection
  153. // (via IMemInputPin or IAMVideoAccelerator) has been made. Note that
  154. // this interface is implemented as a nested class, this is so that we
  155. // we can have "proper" Set/GetColorKey functions on the IVMRPinConfig
  156. // interface that don't clash with the functions of the same name in this
  157. // interface.
  158. //
  159. class CIIOverlay : public IOverlay {
  160. LONG m_cRef;
  161. CVMRInputPin* m_pObj;
  162. public:
  163. CIIOverlay(CVMRInputPin* pObj) :
  164. m_cRef(0), m_pObj(pObj) {}
  165. STDMETHODIMP_(ULONG) AddRef()
  166. {
  167. return (ULONG)++m_cRef;
  168. }
  169. STDMETHODIMP_(ULONG) Release()
  170. {
  171. return (ULONG)--m_cRef;
  172. }
  173. STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
  174. {
  175. return m_pObj->QueryInterface(riid, ppv);
  176. }
  177. STDMETHODIMP GetPalette(DWORD *, PALETTEENTRY**) { return E_NOTIMPL;}
  178. STDMETHODIMP SetPalette(DWORD, PALETTEENTRY*) { return E_NOTIMPL;}
  179. STDMETHODIMP GetDefaultColorKey(COLORKEY*) { return E_NOTIMPL;}
  180. STDMETHODIMP GetColorKey(COLORKEY*) { return E_NOTIMPL;}
  181. STDMETHODIMP SetColorKey(COLORKEY*) { return E_NOTIMPL;}
  182. STDMETHODIMP GetWindowHandle(HWND* pHwnd) {
  183. return m_pObj->GetWindowHandle(pHwnd);
  184. }
  185. STDMETHODIMP GetClipList(RECT*, RECT*, RGNDATA**) { return E_NOTIMPL;}
  186. STDMETHODIMP GetVideoPosition(RECT*, RECT*) { return E_NOTIMPL;}
  187. STDMETHODIMP Advise(IOverlayNotify*, DWORD) { return E_NOTIMPL;}
  188. STDMETHODIMP Unadvise() { return E_NOTIMPL;}
  189. };
  190. // IAMVideoAccelerator
  191. STDMETHODIMP GetVideoAcceleratorGUIDs(
  192. LPDWORD pdwNumGuidsSupported,
  193. LPGUID pGuidsSupported
  194. );
  195. STDMETHODIMP GetUncompFormatsSupported(
  196. const GUID* pGuid,
  197. LPDWORD pdwNumFormatsSupported,
  198. LPDDPIXELFORMAT pFormatsSupported
  199. );
  200. STDMETHODIMP GetInternalMemInfo(
  201. const GUID* pGuid,
  202. const AMVAUncompDataInfo* pamvaUncompDataInfo,
  203. LPAMVAInternalMemInfo pamvaInternalMemInfo
  204. );
  205. STDMETHODIMP GetCompBufferInfo(
  206. const GUID* pGuid,
  207. const AMVAUncompDataInfo* pamvaUncompDataInfo,
  208. LPDWORD pdwNumTypesCompBuffers,
  209. LPAMVACompBufferInfo pamvaCCompBufferInfo
  210. );
  211. STDMETHODIMP GetInternalCompBufferInfo(
  212. LPDWORD pdwNumTypesCompBuffers,
  213. LPAMVACompBufferInfo pamvaCCompBufferInfo
  214. );
  215. STDMETHODIMP BeginFrame(
  216. const AMVABeginFrameInfo* pamvaBeginFrameInfo
  217. );
  218. STDMETHODIMP EndFrame(
  219. const AMVAEndFrameInfo* pEndFrameInfo
  220. );
  221. STDMETHODIMP GetBuffer(
  222. DWORD dwTypeIndex,
  223. DWORD dwBufferIndex,
  224. BOOL bReadOnly,
  225. LPVOID* ppBuffer,
  226. LPLONG lpStride
  227. );
  228. STDMETHODIMP ReleaseBuffer(
  229. DWORD dwTypeIndex,
  230. DWORD dwBufferIndex
  231. );
  232. STDMETHODIMP Execute(
  233. DWORD dwFunction,
  234. LPVOID lpPrivateInputData,
  235. DWORD cbPrivateInputData,
  236. LPVOID lpPrivateOutputData,
  237. DWORD cbPrivateOutputData,
  238. DWORD dwNumBuffers,
  239. const AMVABUFFERINFO *pAMVABufferInfo
  240. );
  241. STDMETHODIMP QueryRenderStatus(
  242. DWORD dwTypeIndex,
  243. DWORD dwBufferIndex,
  244. DWORD dwFlags
  245. );
  246. STDMETHODIMP DisplayFrame(
  247. DWORD dwFlipToIndex,
  248. IMediaSample *pMediaSample
  249. );
  250. // Override ReceiveConnection to allow format changes while running
  251. STDMETHODIMP ReceiveConnection(IPin * pConnector, const AM_MEDIA_TYPE *pmt);
  252. STDMETHODIMP Disconnect();
  253. // connection related functions
  254. HRESULT BreakConnect();
  255. HRESULT CompleteConnect(IPin *pReceivePin);
  256. HRESULT SetMediaType(const CMediaType *pmt);
  257. HRESULT CheckMediaType(const CMediaType* mtOut);
  258. HRESULT DynamicCheckMediaType(const CMediaType* pmt);
  259. HRESULT CheckInterlaceFlags(DWORD dwInterlaceFlags);
  260. HRESULT OnAlloc(
  261. CVMRMediaSample **ppSampleList,
  262. LONG lSampleCount);
  263. HRESULT OnSetProperties(
  264. ALLOCATOR_PROPERTIES* pReq, ALLOCATOR_PROPERTIES* pAct);
  265. HRESULT AllocateSurfaceWorker(
  266. SURFACE_INFO* lplpDDSurf,
  267. DDSURFACEDESC2* lpddsd,
  268. DWORD* lpdwBuffCount,
  269. bool fInterlaced
  270. );
  271. HRESULT AllocateSurface(
  272. const AM_MEDIA_TYPE* cmt,
  273. SURFACE_INFO** lplpDDSurfInfo,
  274. DWORD* lpdwBackBuffer,
  275. DWORD* lpdwSurfFlags,
  276. DWORD Pool,
  277. AM_MEDIA_TYPE** ppmt);
  278. HRESULT OnGetBuffer(
  279. IMediaSample *pSamp,REFERENCE_TIME *pSTime,
  280. REFERENCE_TIME *pETime,DWORD dwFlags);
  281. // allocator control
  282. STDMETHODIMP GetAllocator(IMemAllocator **ppAllocator);
  283. STDMETHODIMP NotifyAllocator(IMemAllocator *pAllocator,BOOL bReadOnly);
  284. // streaming functions
  285. HRESULT Active();
  286. HRESULT Inactive();
  287. STDMETHODIMP BeginFlush();
  288. STDMETHODIMP EndFlush();
  289. STDMETHODIMP Receive(IMediaSample *pMediaSample);
  290. STDMETHODIMP EndOfStream();
  291. // IVMRVideoStreamControl
  292. // - uses p_Mixer & dwPin ID to map to the corresponding SetStreamXXX call
  293. STDMETHODIMP SetColorKey(DDCOLORKEY* Clr);
  294. STDMETHODIMP GetColorKey(DDCOLORKEY* pClr);
  295. STDMETHODIMP SetStreamActiveState(BOOL fActive);
  296. STDMETHODIMP GetStreamActiveState(BOOL* lpfActive);
  297. HRESULT GetWindowHandle(HWND* pHwnd);
  298. DWORD GetPinID() {
  299. return m_dwPinID;
  300. }
  301. private:
  302. friend class CVMRPinAllocator;
  303. friend class CVMRFilter;
  304. friend class CIIOverlay;
  305. void DoQualityMessage();
  306. HRESULT TryDynamicReconfiguration(IPin* pConnector,const AM_MEDIA_TYPE *pmt);
  307. HRESULT DynamicReconfigureMEM(IPin* pConnector,const AM_MEDIA_TYPE *pmt);
  308. HRESULT DynamicReconfigureDVA(IPin* pConnector,const AM_MEDIA_TYPE *pmt);
  309. //
  310. // Helper functions for the IAMVideoAccelerator connection protocol
  311. //
  312. SURFACE_INFO* SurfaceInfoFromTypeAndIndex(DWORD dwTypeIdx, DWORD dwBuffIdx);
  313. HRESULT CheckValidMCConnection();
  314. void FlipDVASurface(DWORD dwFlipToIndex,DWORD dwFlipFromIndex);
  315. HRESULT VABreakConnect();
  316. HRESULT VACompleteConnect(IPin *pReceivePin,const CMediaType *pMediaType);
  317. HRESULT CreateVideoAcceleratorObject();
  318. HRESULT InitializeUncompDataInfo(BITMAPINFOHEADER *pbmiHeader);
  319. BOOL IsSuitableVideoAcceleratorGuid(const GUID * pGuid);
  320. HRESULT AllocateVACompSurfaces(LPDIRECTDRAW7 pDDraw, BITMAPINFOHEADER *pbmiHdr);
  321. HRESULT AllocateMCUncompSurfaces(const CMediaType *pMediaType,
  322. LPDIRECTDRAW7 pDDraw, BITMAPINFOHEADER *pbmiHdr);
  323. //
  324. // motion comp related variables
  325. //
  326. HANDLE m_hDXVAEvent;
  327. BOOL m_bVideoAcceleratorSupported;
  328. DWORD m_dwBackBufferCount;
  329. GUID m_mcGuid;
  330. DDVAUncompDataInfo m_ddUncompDataInfo;
  331. DDVAInternalMemInfo m_ddvaInternalMemInfo;
  332. DWORD m_dwCompSurfTypes;
  333. LPCOMP_SURFACE_INFO m_pCompSurfInfo;
  334. IDDVideoAcceleratorContainer* m_pIDDVAContainer;
  335. IDirectDrawVideoAccelerator* m_pIDDVideoAccelerator;
  336. IAMVideoAcceleratorNotify* m_pIVANotify;
  337. //
  338. // DShow filter related variables
  339. //
  340. CVMRFilter* m_pRenderer;
  341. CCritSec* m_pInterfaceLock;
  342. CVMRPinAllocator m_PinAllocator;
  343. CMediaType m_mtNew;
  344. LONG m_lSampleSize;
  345. enum {DELTA_DECODE_CHECKED = 0x01, DELTA_DECODE_MODE_SET = 0x02};
  346. DWORD m_dwDeltaDecode;
  347. BOOL m_fInDFC;
  348. bool m_bDynamicFormatNeeded;
  349. bool m_bActive;
  350. DWORD m_dwPinID;
  351. LPDIRECTDRAWSURFACE7 m_pDDS;
  352. CIIOverlay m_pIOverlay;
  353. DWORD m_RenderTransport;
  354. //
  355. // De-interlace variables, only relevant in mixing mode.
  356. //
  357. DXVA_DeinterlaceCaps m_DeinterlaceCaps;
  358. GUID m_DeinterlaceGUID;
  359. BOOL m_DeinterlaceUserGUIDSet;
  360. GUID m_DeinterlaceUserGUID;
  361. // array of DDraw surfaces in allocation order, if pBuffer is non-NULL
  362. // then the surface is in use, the array is m_dwNumSamples big.
  363. SURFACE_INFO* m_pVidSurfs;
  364. // array of video samples in temporal order, the array
  365. // is only allocated when we are de-interlacing, the array
  366. // is m_dwNumHistorySamples big.
  367. DXVA_VideoSample* m_pVidHistorySamps;
  368. DWORD m_dwNumSamples;
  369. DWORD m_dwNumHistorySamples;
  370. BOOL m_InterlacedStream;
  371. REFERENCE_TIME m_SamplePeriod;
  372. DWORD m_SampleCount;
  373. CCritSec m_DeinterlaceLock;
  374. HRESULT GetStreamInterlaceProperties(
  375. const AM_MEDIA_TYPE *pMT,
  376. BOOL* lpIsInterlaced,
  377. GUID* lpDeintGuid,
  378. DXVA_DeinterlaceCaps* pCaps);
  379. void ReleaseAllocatedSurfaces() {
  380. if (m_pVidSurfs) {
  381. //
  382. // delete the surfaces in reverse order.
  383. //
  384. DWORD dwNumSamples = m_dwNumSamples - 1;
  385. for (DWORD i = 0; i < m_dwNumSamples; i++) {
  386. RELEASE(m_pVidSurfs[dwNumSamples - i].pSurface);
  387. }
  388. m_dwNumSamples = 0;
  389. delete [] m_pVidSurfs;
  390. m_pVidSurfs = NULL;
  391. }
  392. if (m_pVidHistorySamps) {
  393. m_dwNumHistorySamples = 0;
  394. delete [] m_pVidHistorySamps;
  395. m_pVidHistorySamps = NULL;
  396. }
  397. }
  398. BOOL m_FrontBufferStale;
  399. void FrontBufferStale(BOOL bStale) {
  400. if (bStale) {
  401. m_dwDeltaDecode = 0;
  402. }
  403. m_FrontBufferStale = bStale;
  404. }
  405. BOOL IsFrontBufferStale() {
  406. return m_FrontBufferStale;
  407. }
  408. BOOL m_bConnected;
  409. void CompletelyConnected(BOOL bConnected) {
  410. m_bConnected = bConnected;
  411. }
  412. BOOL IsCompletelyConnected() {
  413. return m_bConnected;
  414. }
  415. //
  416. // IPinConnection stuff
  417. //
  418. HANDLE m_hEndOfStream;
  419. };
  420. /* -------------------------------------------------------------------------
  421. ** New Renderer's filter
  422. ** -------------------------------------------------------------------------
  423. */
  424. class CVMRFilter :
  425. public CBaseFilter,
  426. public CPersistStream,
  427. public IQualProp,
  428. public IQualityControl,
  429. public IAMFilterMiscFlags,
  430. public IKsPropertySet,
  431. public IVMRWindowlessControl,
  432. public IVMRMixerControl,
  433. public IVMRFilterConfig,
  434. public IVMRFilterConfigInternal,
  435. public IVMRMonitorConfig,
  436. public IVMRMixerBitmap,
  437. public IVMRDeinterlaceControl,
  438. public ISpecifyPropertyPages
  439. {
  440. public:
  441. DECLARE_IUNKNOWN
  442. STDMETHODIMP NonDelegatingQueryInterface(REFIID, void**);
  443. static CUnknown *CreateInstance(LPUNKNOWN, HRESULT *);
  444. static CUnknown *CreateInstance2(LPUNKNOWN, HRESULT *);
  445. static void InitClass(BOOL bLoading, const CLSID *clsid);
  446. int NumInputPinsConnected() const;
  447. CVMRFilter(TCHAR *pName, LPUNKNOWN pUnk, HRESULT *phr, BOOL fDefault);
  448. virtual ~CVMRFilter();
  449. void VMRCleanUp();
  450. CBasePin *GetPin(int n);
  451. int GetPinCount();
  452. // Override the filter and pin interface functions
  453. STDMETHODIMP JoinFilterGraph(IFilterGraph *pGraph,LPCWSTR pName);
  454. STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
  455. STDMETHODIMP Stop();
  456. STDMETHODIMP Pause();
  457. STDMETHODIMP Run(REFERENCE_TIME StartTime);
  458. STDMETHODIMP GetState(DWORD dwMSecs,FILTER_STATE *State);
  459. HRESULT Receive(DWORD dwPinID, IMediaSample *pMediaSample);
  460. // called when the filter changes state
  461. HRESULT Active(DWORD dwPinID);
  462. HRESULT Inactive(DWORD dwPinID);
  463. HRESULT BeginFlush(DWORD dwPinID);
  464. HRESULT EndFlush(DWORD dwPinID);
  465. HRESULT EndOfStream(DWORD dwPinID);
  466. HRESULT CompleteConnect(DWORD dwPinID, const CMediaType& cmt);
  467. HRESULT RuntimeAbortPlayback(HRESULT hr);
  468. // deal with connections
  469. HRESULT BreakConnect(DWORD dwPinID);
  470. HRESULT CheckMediaType(const CMediaType *);
  471. HRESULT SetMediaType(const CMediaType *pmt);
  472. HRESULT OnSetProperties(CVMRInputPin* pReceivePin);
  473. // IQualProp property page support
  474. STDMETHODIMP get_FramesDroppedInRenderer(int *cFramesDropped);
  475. STDMETHODIMP get_FramesDrawn(int *pcFramesDrawn);
  476. STDMETHODIMP get_AvgFrameRate(int *piAvgFrameRate);
  477. STDMETHODIMP get_Jitter(int *piJitter);
  478. STDMETHODIMP get_AvgSyncOffset(int *piAvg);
  479. STDMETHODIMP get_DevSyncOffset(int *piDev);
  480. // IQualityControl methods - Notify allows audio-video throttling
  481. STDMETHODIMP SetSink( IQualityControl * piqc);
  482. STDMETHODIMP Notify( IBaseFilter * pSelf, Quality q);
  483. // IAMFilterMiscFlags
  484. STDMETHODIMP_(ULONG) GetMiscFlags(void)
  485. {
  486. return AM_FILTER_MISC_FLAGS_IS_RENDERER;
  487. }
  488. // IVMRWindowlessControl
  489. STDMETHODIMP GetNativeVideoSize(LONG* lWidth, LONG* lHeight,
  490. LONG* lARWidth, LONG* lARHeight);
  491. STDMETHODIMP GetMinIdealVideoSize(LONG* lWidth, LONG* lHeight);
  492. STDMETHODIMP GetMaxIdealVideoSize(LONG* lWidth, LONG* lHeight);
  493. STDMETHODIMP SetVideoPosition(const LPRECT lpSRCRect,
  494. const LPRECT lpDSTRect);
  495. STDMETHODIMP GetVideoPosition(LPRECT lpSRCRect,LPRECT lpDSTRect);
  496. STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode);
  497. STDMETHODIMP SetAspectRatioMode(DWORD AspectRatioMode);
  498. STDMETHODIMP SetVideoClippingWindow(HWND hwnd);
  499. STDMETHODIMP RepaintVideo(HWND hwnd, HDC hdc);
  500. STDMETHODIMP DisplayModeChanged();
  501. STDMETHODIMP GetCurrentImage(BYTE** lpDib);
  502. STDMETHODIMP SetBorderColor(COLORREF Clr);
  503. STDMETHODIMP GetBorderColor(COLORREF* lpClr);
  504. STDMETHODIMP SetColorKey(COLORREF Clr);
  505. STDMETHODIMP GetColorKey(COLORREF* lpClr);
  506. // IVMRMixerControl
  507. STDMETHODIMP SetAlpha(DWORD dwID, float Alpha);
  508. STDMETHODIMP GetAlpha(DWORD dwID, float* Alpha);
  509. STDMETHODIMP SetZOrder(DWORD dwID, DWORD zOrder);
  510. STDMETHODIMP GetZOrder(DWORD dwID, DWORD* zOrder);
  511. STDMETHODIMP SetOutputRect(DWORD dwID, const NORMALIZEDRECT *pRect);
  512. STDMETHODIMP GetOutputRect(DWORD dwID, NORMALIZEDRECT *pRect);
  513. STDMETHODIMP SetBackgroundClr(COLORREF clrBkg);
  514. STDMETHODIMP GetBackgroundClr(COLORREF* lpClrBkg);
  515. STDMETHODIMP SetMixingPrefs(DWORD dwRenderFlags);
  516. STDMETHODIMP GetMixingPrefs(DWORD* pdwRenderFlags);
  517. // IVMRDeinterlaceControl
  518. STDMETHODIMP GetNumberOfDeinterlaceModes(VMRVideoDesc* lpVideoDesc,
  519. LPDWORD lpdwNumDeinterlaceModes,
  520. LPGUID lpDeinterlaceModes);
  521. STDMETHODIMP GetDeinterlaceModeCaps(LPGUID lpDeinterlaceMode,
  522. VMRVideoDesc* lpVideoDesc,
  523. VMRDeinterlaceCaps* lpDeinterlaceCaps);
  524. STDMETHODIMP GetDeinterlaceMode(DWORD dwStreamID,
  525. LPGUID lpDeinterlaceMode);
  526. STDMETHODIMP SetDeinterlaceMode(DWORD dwStreamID,
  527. LPGUID lpDeinterlaceMode);
  528. STDMETHODIMP GetDeinterlacePrefs(LPDWORD lpdwDeinterlacePrefs);
  529. STDMETHODIMP SetDeinterlacePrefs(DWORD dwDeinterlacePrefs);
  530. STDMETHODIMP GetActualDeinterlaceMode(DWORD dwStreamID,
  531. LPGUID lpDeinterlaceMode);
  532. //
  533. // IKsPropertySet interface methods
  534. //
  535. STDMETHODIMP Set(REFGUID guidPropSet, DWORD PropID, LPVOID pInstanceData,
  536. DWORD cbInstanceData, LPVOID pPropData, DWORD cbPropData);
  537. STDMETHODIMP Get(REFGUID guidPropSet, DWORD PropID, LPVOID pInstanceData,
  538. DWORD cbInstanceData, LPVOID pPropData, DWORD cbPropData,
  539. DWORD *pcbReturned);
  540. STDMETHODIMP QuerySupported(REFGUID guidPropSet, DWORD PropID, DWORD *pTypeSupport);
  541. // IVMRSurfaceAllocatorNotify
  542. class CIVMRSurfaceAllocatorNotify : public IVMRSurfaceAllocatorNotify {
  543. LONG m_cRef;
  544. CVMRFilter* m_pObj;
  545. public:
  546. CIVMRSurfaceAllocatorNotify(CVMRFilter* pObj) :
  547. m_cRef(0), m_pObj(pObj) {}
  548. ~CIVMRSurfaceAllocatorNotify();
  549. STDMETHODIMP_(ULONG) AddRef()
  550. {
  551. return InterlockedIncrement(&m_cRef);
  552. }
  553. STDMETHODIMP_(ULONG) Release()
  554. {
  555. return InterlockedDecrement(&m_cRef);
  556. }
  557. STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
  558. {
  559. return m_pObj->QueryInterface(riid, ppv);
  560. }
  561. STDMETHODIMP AdviseSurfaceAllocator(
  562. DWORD_PTR dwUserID,
  563. IVMRSurfaceAllocator* lpIVRMSurfaceAllocator
  564. );
  565. STDMETHODIMP SetDDrawDevice(LPDIRECTDRAW7 lpDDrawDevice, HMONITOR hMon);
  566. STDMETHODIMP ChangeDDrawDevice(LPDIRECTDRAW7 lpDDrawDevice, HMONITOR hMon);
  567. STDMETHODIMP RestoreDDrawSurfaces();
  568. STDMETHODIMP NotifyEvent(LONG EventCode, LONG_PTR lp1, LONG_PTR lp2);
  569. STDMETHODIMP SetBorderColor(COLORREF clr);
  570. };
  571. // IVMRImagePresenter
  572. class CIVMRImagePresenter : public IVMRImagePresenter {
  573. LONG m_cRef;
  574. CVMRFilter* m_pObj;
  575. public:
  576. CIVMRImagePresenter(CVMRFilter* pObj) :
  577. m_cRef(0), m_pObj(pObj) {}
  578. STDMETHODIMP_(ULONG) AddRef()
  579. {
  580. return (ULONG)++m_cRef;
  581. }
  582. STDMETHODIMP_(ULONG) Release()
  583. {
  584. return (ULONG)--m_cRef;
  585. }
  586. STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
  587. {
  588. return m_pObj->QueryInterface(riid, ppv);
  589. }
  590. STDMETHODIMP StartPresenting(DWORD_PTR dwUserID);
  591. STDMETHODIMP StopPresenting(DWORD_PTR dwUserID);
  592. STDMETHODIMP PresentImage(
  593. DWORD_PTR dwUserID,
  594. VMRPRESENTATIONINFO* lpPresInfo
  595. );
  596. };
  597. // IImageSyncNotifyEvent
  598. class CIImageSyncNotifyEvent : public IImageSyncNotifyEvent {
  599. LONG m_cRef;
  600. CVMRFilter* m_pObj;
  601. public:
  602. CIImageSyncNotifyEvent(CVMRFilter* pObj) :
  603. m_cRef(0), m_pObj(pObj) {}
  604. STDMETHODIMP_(ULONG) AddRef()
  605. {
  606. return (ULONG)++m_cRef;
  607. }
  608. STDMETHODIMP_(ULONG) Release()
  609. {
  610. return (ULONG)--m_cRef;
  611. }
  612. STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
  613. {
  614. return m_pObj->QueryInterface(riid, ppv);
  615. }
  616. STDMETHODIMP NotifyEvent(long EventCode, LONG_PTR lp1, LONG_PTR lp2);
  617. };
  618. // CPersistStream
  619. HRESULT WriteToStream(IStream *pStream);
  620. HRESULT ReadFromStream(IStream *pStream);
  621. int SizeMax();
  622. STDMETHODIMP GetClassID(CLSID *pClsid);
  623. // IVMRFilterConfig
  624. STDMETHODIMP SetImageCompositor(IVMRImageCompositor* lpVMRImgCompositor);
  625. STDMETHODIMP SetNumberOfStreams(DWORD dwMaxStreams);
  626. STDMETHODIMP GetNumberOfStreams(DWORD* lpdwMaxStreams);
  627. STDMETHODIMP SetRenderingPrefs(DWORD dwRenderFlags);
  628. STDMETHODIMP GetRenderingPrefs(DWORD* pdwRenderFlags);
  629. STDMETHODIMP SetRenderingMode(DWORD Mode);
  630. STDMETHODIMP GetRenderingMode(DWORD* pMode);
  631. // IVMRFilterConfigInternal
  632. STDMETHODIMP GetAspectRatioModePrivate(DWORD* lpAspectRatioMode);
  633. STDMETHODIMP SetAspectRatioModePrivate(DWORD AspectRatioMode);
  634. // IVMRMonitorConfig ... proxied to To the app-presenter if it supports it
  635. STDMETHODIMP SetMonitor( const VMRGUID *pGUID );
  636. STDMETHODIMP GetMonitor( VMRGUID *pGUID );
  637. STDMETHODIMP SetDefaultMonitor( const VMRGUID *pGUID );
  638. STDMETHODIMP GetDefaultMonitor( VMRGUID *pGUID );
  639. STDMETHODIMP GetAvailableMonitors( VMRMONITORINFO* pInfo, DWORD dwMaxInfoArraySize,
  640. DWORD* pdwNumDevices );
  641. // IVMRMixerBitmap
  642. STDMETHODIMP SetAlphaBitmap( const VMRALPHABITMAP *pBmpParms );
  643. STDMETHODIMP UpdateAlphaBitmapParameters( PVMRALPHABITMAP pBmpParms );
  644. STDMETHODIMP GetAlphaBitmapParameters( PVMRALPHABITMAP pBmpParms );
  645. // ISpecifyPropertyPages
  646. STDMETHODIMP GetPages(CAUUID *pPages);
  647. // helper for the window manager
  648. IVMRWindowlessControl* GetWLControl() {
  649. return m_lpWLControl;
  650. }
  651. HRESULT SetAbortSignal(BOOL fAbort) {
  652. return m_lpISControl->SetAbortSignal(fAbort);
  653. }
  654. private:
  655. friend class CVMRInputPin;
  656. friend class CIVMRWindowlessControl;
  657. friend class CIVMRSurfaceAllocatorNotify;
  658. friend class CIVMRImagePresenter;
  659. friend class CIImageSyncNotifyEvent;
  660. CVMRInputPin* m_pInputPins[MAX_MIXER_PINS];
  661. CCritSec m_InterfaceLock;// Critical section for interfaces
  662. CCritSec m_RendererLock; // Controls access to internals
  663. IVMRWindowlessControl* m_lpWLControl;
  664. IVMRSurfaceAllocator* m_lpRLNotify;
  665. IVMRImagePresenter* m_lpPresenter;
  666. IVMRImagePresenterConfig* m_pPresenterConfig;
  667. IVMRMonitorConfig* m_pPresenterMonitorConfig;
  668. IVMRMixerControlInternal* m_lpMixControl;
  669. IVMRMixerBitmap* m_lpMixBitmap;
  670. IVMRMixerStream* m_lpMixStream;
  671. IImageSyncControl* m_lpISControl;
  672. IImageSync* m_lpIS;
  673. IQualProp* m_lpISQualProp;
  674. DWORD_PTR m_dwUserID;
  675. DWORD m_VMRMode;
  676. BOOL m_VMRCreateAsDefaultRenderer;
  677. BOOL m_VMRModePassThru;
  678. BOOL m_bModeChangeAllowed;
  679. BOOL m_fInputPinCountSet;
  680. DWORD m_dwNumPins;
  681. CVMRRendererMacroVision m_MacroVision;
  682. HMONITOR m_hMonitor;
  683. LPDIRECTDRAW7 m_lpDirectDraw;
  684. DDCAPS_DX7 m_ddHWCaps;
  685. HRESULT m_hrSurfaceFlipped;
  686. HRESULT m_hr3D;
  687. DWORD m_ARMode;
  688. BOOL m_bARModeDefaultSet;
  689. DWORD m_TexCaps;
  690. DDPIXELFORMAT m_ddpfMonitor;
  691. DWORD m_dwDisplayChangeMask;
  692. DWORD m_dwEndOfStreamMask;
  693. DWORD m_dwRenderPrefs;
  694. CRendererPosPassThru* m_pPosition; // Support IMediaSeeking
  695. CVMRVideoWindow* m_pVideoWindow;
  696. CVMRDeinterlaceContainer* m_pDeinterlace;
  697. DWORD m_dwDeinterlacePrefs;
  698. CIVMRSurfaceAllocatorNotify m_pIVMRSurfaceAllocatorNotify;
  699. CIVMRImagePresenter m_pIVMRImagePresenter;
  700. CIImageSyncNotifyEvent m_pIImageSyncNotifyEvent;
  701. HRESULT ValidateIVRWindowlessControlState();
  702. HRESULT GetMediaPositionInterface(REFIID riid, void** ppv);
  703. HRESULT CreateDefaultAllocatorPresenter();
  704. HRESULT SetDDrawDeviceWorker(LPDIRECTDRAW7 lpDDrawDevice, HMONITOR hMon);
  705. HRESULT CreateExtraInputPins(DWORD dwNumPins);
  706. void DestroyExtraInputPins();
  707. HRESULT CreateInputPin();
  708. HRESULT ImageSyncInit();
  709. HRESULT MixerInit(DWORD dwNumStreams);
  710. void AutoShowWindow();
  711. BOOL ModeChangeAllowed();
  712. void SetVMRMode(DWORD mode);
  713. BOOL IsVPMConnectedToUs();
  714. };