winctrl.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. //------------------------------------------------------------------------------
  2. // File: WinCtrl.h
  3. //
  4. // Desc: DirectShow base classes - defines classes for video control
  5. // interfaces.
  6. //
  7. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
  8. //------------------------------------------------------------------------------
  9. #ifndef __WINCTRL__
  10. #define __WINCTRL__
  11. #define ABSOL(x) (x < 0 ? -x : x)
  12. #define NEGAT(x) (x > 0 ? -x : x)
  13. // Helper
  14. BOOL WINAPI PossiblyEatMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  15. class CBaseControlWindow : public CBaseVideoWindow, public CBaseWindow
  16. {
  17. protected:
  18. CBaseFilter *m_pFilter; // Pointer to owning media filter
  19. CBasePin *m_pPin; // Controls media types for connection
  20. CCritSec *m_pInterfaceLock; // Externally defined critical section
  21. COLORREF m_BorderColour; // Current window border colour
  22. BOOL m_bAutoShow; // What happens when the state changes
  23. HWND m_hwndOwner; // Owner window that we optionally have
  24. HWND m_hwndDrain; // HWND to post any messages received
  25. BOOL m_bCursorHidden; // Should we hide the window cursor
  26. public:
  27. // Internal methods for other objects to get information out
  28. HRESULT DoSetWindowStyle(long Style,long WindowLong);
  29. HRESULT DoGetWindowStyle(__out long *pStyle,long WindowLong);
  30. BOOL IsAutoShowEnabled() {
  31. return m_bAutoShow;
  32. };
  33. COLORREF GetBorderColour() {
  34. return m_BorderColour;
  35. };
  36. HWND GetOwnerWindow() {
  37. return m_hwndOwner;
  38. };
  39. BOOL IsCursorHidden() {
  40. return m_bCursorHidden;
  41. };
  42. inline BOOL PossiblyEatMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) {
  43. return ::PossiblyEatMessage(m_hwndDrain, uMsg, wParam, lParam);
  44. }
  45. // Derived classes must call this to set the pin the filter is using
  46. // We don't have the pin passed in to the constructor (as we do with
  47. // the CBaseFilter object) because filters typically create the
  48. // pins dynamically when requested in CBaseFilter::GetPin. This can
  49. // not be called from our constructor because is is a virtual method
  50. void SetControlWindowPin(CBasePin *pPin) {
  51. m_pPin = pPin;
  52. }
  53. public:
  54. CBaseControlWindow(__inout CBaseFilter *pFilter, // Owning media filter
  55. __in CCritSec *pInterfaceLock, // Locking object
  56. __in_opt LPCTSTR pName, // Object description
  57. __inout_opt LPUNKNOWN pUnk, // Normal COM ownership
  58. __inout HRESULT *phr); // OLE return code
  59. // These are the properties we support
  60. STDMETHODIMP put_Caption(__in BSTR strCaption);
  61. STDMETHODIMP get_Caption(__out BSTR *pstrCaption);
  62. STDMETHODIMP put_AutoShow(long AutoShow);
  63. STDMETHODIMP get_AutoShow(__out long *AutoShow);
  64. STDMETHODIMP put_WindowStyle(long WindowStyle);
  65. STDMETHODIMP get_WindowStyle(__out long *pWindowStyle);
  66. STDMETHODIMP put_WindowStyleEx(long WindowStyleEx);
  67. STDMETHODIMP get_WindowStyleEx(__out long *pWindowStyleEx);
  68. STDMETHODIMP put_WindowState(long WindowState);
  69. STDMETHODIMP get_WindowState(__out long *pWindowState);
  70. STDMETHODIMP put_BackgroundPalette(long BackgroundPalette);
  71. STDMETHODIMP get_BackgroundPalette(__out long *pBackgroundPalette);
  72. STDMETHODIMP put_Visible(long Visible);
  73. STDMETHODIMP get_Visible(__out long *pVisible);
  74. STDMETHODIMP put_Left(long Left);
  75. STDMETHODIMP get_Left(__out long *pLeft);
  76. STDMETHODIMP put_Width(long Width);
  77. STDMETHODIMP get_Width(__out long *pWidth);
  78. STDMETHODIMP put_Top(long Top);
  79. STDMETHODIMP get_Top(__out long *pTop);
  80. STDMETHODIMP put_Height(long Height);
  81. STDMETHODIMP get_Height(__out long *pHeight);
  82. STDMETHODIMP put_Owner(OAHWND Owner);
  83. STDMETHODIMP get_Owner(__out OAHWND *Owner);
  84. STDMETHODIMP put_MessageDrain(OAHWND Drain);
  85. STDMETHODIMP get_MessageDrain(__out OAHWND *Drain);
  86. STDMETHODIMP get_BorderColor(__out long *Color);
  87. STDMETHODIMP put_BorderColor(long Color);
  88. STDMETHODIMP get_FullScreenMode(__out long *FullScreenMode);
  89. STDMETHODIMP put_FullScreenMode(long FullScreenMode);
  90. // And these are the methods
  91. STDMETHODIMP SetWindowForeground(long Focus);
  92. STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd,long uMsg,LONG_PTR wParam,LONG_PTR lParam);
  93. STDMETHODIMP GetMinIdealImageSize(__out long *pWidth,__out long *pHeight);
  94. STDMETHODIMP GetMaxIdealImageSize(__out long *pWidth,__out long *pHeight);
  95. STDMETHODIMP SetWindowPosition(long Left,long Top,long Width,long Height);
  96. STDMETHODIMP GetWindowPosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight);
  97. STDMETHODIMP GetRestorePosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight);
  98. STDMETHODIMP HideCursor(long HideCursor);
  99. STDMETHODIMP IsCursorHidden(__out long *CursorHidden);
  100. };
  101. // This class implements the IBasicVideo interface
  102. class CBaseControlVideo : public CBaseBasicVideo
  103. {
  104. protected:
  105. CBaseFilter *m_pFilter; // Pointer to owning media filter
  106. CBasePin *m_pPin; // Controls media types for connection
  107. CCritSec *m_pInterfaceLock; // Externally defined critical section
  108. public:
  109. // Derived classes must provide these for the implementation
  110. virtual HRESULT IsDefaultTargetRect() PURE;
  111. virtual HRESULT SetDefaultTargetRect() PURE;
  112. virtual HRESULT SetTargetRect(RECT *pTargetRect) PURE;
  113. virtual HRESULT GetTargetRect(RECT *pTargetRect) PURE;
  114. virtual HRESULT IsDefaultSourceRect() PURE;
  115. virtual HRESULT SetDefaultSourceRect() PURE;
  116. virtual HRESULT SetSourceRect(RECT *pSourceRect) PURE;
  117. virtual HRESULT GetSourceRect(RECT *pSourceRect) PURE;
  118. virtual HRESULT GetStaticImage(__inout long *pBufferSize,__out_bcount_part(*pBufferSize, *pBufferSize) long *pDIBImage) PURE;
  119. // Derived classes must override this to return a VIDEOINFO representing
  120. // the video format. We cannot call IPin ConnectionMediaType to get this
  121. // format because various filters dynamically change the type when using
  122. // DirectDraw such that the format shows the position of the logical
  123. // bitmap in a frame buffer surface, so the size might be returned as
  124. // 1024x768 pixels instead of 320x240 which is the real video dimensions
  125. __out virtual VIDEOINFOHEADER *GetVideoFormat() PURE;
  126. // Helper functions for creating memory renderings of a DIB image
  127. HRESULT GetImageSize(__in VIDEOINFOHEADER *pVideoInfo,
  128. __out LONG *pBufferSize,
  129. __in RECT *pSourceRect);
  130. HRESULT CopyImage(IMediaSample *pMediaSample,
  131. __in VIDEOINFOHEADER *pVideoInfo,
  132. __inout LONG *pBufferSize,
  133. __out_bcount_part(*pBufferSize, *pBufferSize) BYTE *pVideoImage,
  134. __in RECT *pSourceRect);
  135. // Override this if you want notifying when the rectangles change
  136. virtual HRESULT OnUpdateRectangles() {
  137. return NOERROR;
  138. };
  139. virtual HRESULT OnVideoSizeChange();
  140. // Derived classes must call this to set the pin the filter is using
  141. // We don't have the pin passed in to the constructor (as we do with
  142. // the CBaseFilter object) because filters typically create the
  143. // pins dynamically when requested in CBaseFilter::GetPin. This can
  144. // not be called from our constructor because is is a virtual method
  145. void SetControlVideoPin(__inout CBasePin *pPin) {
  146. m_pPin = pPin;
  147. }
  148. // Helper methods for checking rectangles
  149. virtual HRESULT CheckSourceRect(__in RECT *pSourceRect);
  150. virtual HRESULT CheckTargetRect(__in RECT *pTargetRect);
  151. public:
  152. CBaseControlVideo(__inout CBaseFilter *pFilter, // Owning media filter
  153. __in CCritSec *pInterfaceLock, // Serialise interface
  154. __in_opt LPCTSTR pName, // Object description
  155. __inout_opt LPUNKNOWN pUnk, // Normal COM ownership
  156. __inout HRESULT *phr); // OLE return code
  157. // These are the properties we support
  158. STDMETHODIMP get_AvgTimePerFrame(__out REFTIME *pAvgTimePerFrame);
  159. STDMETHODIMP get_BitRate(__out long *pBitRate);
  160. STDMETHODIMP get_BitErrorRate(__out long *pBitErrorRate);
  161. STDMETHODIMP get_VideoWidth(__out long *pVideoWidth);
  162. STDMETHODIMP get_VideoHeight(__out long *pVideoHeight);
  163. STDMETHODIMP put_SourceLeft(long SourceLeft);
  164. STDMETHODIMP get_SourceLeft(__out long *pSourceLeft);
  165. STDMETHODIMP put_SourceWidth(long SourceWidth);
  166. STDMETHODIMP get_SourceWidth(__out long *pSourceWidth);
  167. STDMETHODIMP put_SourceTop(long SourceTop);
  168. STDMETHODIMP get_SourceTop(__out long *pSourceTop);
  169. STDMETHODIMP put_SourceHeight(long SourceHeight);
  170. STDMETHODIMP get_SourceHeight(__out long *pSourceHeight);
  171. STDMETHODIMP put_DestinationLeft(long DestinationLeft);
  172. STDMETHODIMP get_DestinationLeft(__out long *pDestinationLeft);
  173. STDMETHODIMP put_DestinationWidth(long DestinationWidth);
  174. STDMETHODIMP get_DestinationWidth(__out long *pDestinationWidth);
  175. STDMETHODIMP put_DestinationTop(long DestinationTop);
  176. STDMETHODIMP get_DestinationTop(__out long *pDestinationTop);
  177. STDMETHODIMP put_DestinationHeight(long DestinationHeight);
  178. STDMETHODIMP get_DestinationHeight(__out long *pDestinationHeight);
  179. // And these are the methods
  180. STDMETHODIMP GetVideoSize(__out long *pWidth,__out long *pHeight);
  181. STDMETHODIMP SetSourcePosition(long Left,long Top,long Width,long Height);
  182. STDMETHODIMP GetSourcePosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight);
  183. STDMETHODIMP GetVideoPaletteEntries(long StartIndex,long Entries,__out long *pRetrieved,__out_ecount_part(Entries, *pRetrieved) long *pPalette);
  184. STDMETHODIMP SetDefaultSourcePosition();
  185. STDMETHODIMP IsUsingDefaultSource();
  186. STDMETHODIMP SetDestinationPosition(long Left,long Top,long Width,long Height);
  187. STDMETHODIMP GetDestinationPosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight);
  188. STDMETHODIMP SetDefaultDestinationPosition();
  189. STDMETHODIMP IsUsingDefaultDestination();
  190. STDMETHODIMP GetCurrentImage(__inout long *pBufferSize,__out_bcount_part(*pBufferSize, *pBufferSize) long *pVideoImage);
  191. };
  192. #endif // __WINCTRL__