Debian Codegraph @

sys/directshow/strmbase/baseclasses/winctrl.h

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