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.

229 lines
9.9 KiB

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