1 //------------------------------------------------------------------------------
4 // Desc: DirectShow base classes.
6 // Copyright (c) 1992-2002 Microsoft Corporation. All rights reserved.
7 //------------------------------------------------------------------------------
13 // These help with property page implementations. The first can be used to
14 // load any string from a resource file. The buffer to load into is passed
15 // as an input parameter. The same buffer is the return value if the string
16 // was found otherwise it returns TEXT(""). The GetDialogSize is passed the
17 // resource ID of a dialog box and returns the size of it in screen pixels
19 #define STR_MAX_LENGTH 256
20 TCHAR
* WINAPI
StringFromResource(TCHAR
*pBuffer
, int iResourceID
);
23 #define WideStringFromResource StringFromResource
24 char* WINAPI
StringFromResource(char*pBuffer
, int iResourceID
);
26 WCHAR
* WINAPI
WideStringFromResource(WCHAR
*pBuffer
, int iResourceID
);
30 BOOL WINAPI
GetDialogSize(int iResourceID
, // Dialog box resource identifier
31 DLGPROC pDlgProc
, // Pointer to dialog procedure
32 LPARAM lParam
, // Any user data wanted in pDlgProc
33 SIZE
*pResult
); // Returns the size of dialog box
35 // Class that aggregates an IDirectDraw interface
37 class CAggDirectDraw
: public IDirectDraw
, public CUnknown
41 LPDIRECTDRAW m_pDirectDraw
;
46 STDMETHODIMP
NonDelegatingQueryInterface(REFIID riid
,void **ppv
);
48 // Constructor and destructor
50 CAggDirectDraw(TCHAR
*pName
,LPUNKNOWN pUnk
) :
52 m_pDirectDraw(NULL
) { };
54 virtual CAggDirectDraw::~CAggDirectDraw() { };
56 // Set the object we should be aggregating
57 void SetDirectDraw(LPDIRECTDRAW pDirectDraw
) {
58 m_pDirectDraw
= pDirectDraw
;
61 // IDirectDraw methods
63 STDMETHODIMP
Compact();
64 STDMETHODIMP
CreateClipper(DWORD dwFlags
,LPDIRECTDRAWCLIPPER
*lplpDDClipper
,IUnknown
*pUnkOuter
);
65 STDMETHODIMP
CreatePalette(DWORD dwFlags
,LPPALETTEENTRY lpColorTable
,LPDIRECTDRAWPALETTE
*lplpDDPalette
,IUnknown
*pUnkOuter
);
66 STDMETHODIMP
CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc
,LPDIRECTDRAWSURFACE
*lplpDDSurface
,IUnknown
*pUnkOuter
);
67 STDMETHODIMP
DuplicateSurface(LPDIRECTDRAWSURFACE lpDDSurface
,LPDIRECTDRAWSURFACE
*lplpDupDDSurface
);
68 STDMETHODIMP
EnumDisplayModes(DWORD dwSurfaceDescCount
,LPDDSURFACEDESC lplpDDSurfaceDescList
,LPVOID lpContext
,LPDDENUMMODESCALLBACK lpEnumCallback
);
69 STDMETHODIMP
EnumSurfaces(DWORD dwFlags
,LPDDSURFACEDESC lpDDSD
,LPVOID lpContext
,LPDDENUMSURFACESCALLBACK lpEnumCallback
);
70 STDMETHODIMP
FlipToGDISurface();
71 STDMETHODIMP
GetCaps(LPDDCAPS lpDDDriverCaps
,LPDDCAPS lpDDHELCaps
);
72 STDMETHODIMP
GetDisplayMode(LPDDSURFACEDESC lpDDSurfaceDesc
);
73 STDMETHODIMP
GetFourCCCodes(LPDWORD lpNumCodes
,LPDWORD lpCodes
);
74 STDMETHODIMP
GetGDISurface(LPDIRECTDRAWSURFACE
*lplpGDIDDSurface
);
75 STDMETHODIMP
GetMonitorFrequency(LPDWORD lpdwFrequency
);
76 STDMETHODIMP
GetScanLine(LPDWORD lpdwScanLine
);
77 STDMETHODIMP
GetVerticalBlankStatus(LPBOOL lpblsInVB
);
78 STDMETHODIMP
Initialize(GUID
*lpGUID
);
79 STDMETHODIMP
RestoreDisplayMode();
80 STDMETHODIMP
SetCooperativeLevel(HWND hWnd
,DWORD dwFlags
);
81 STDMETHODIMP
SetDisplayMode(DWORD dwWidth
,DWORD dwHeight
,DWORD dwBpp
);
82 STDMETHODIMP
WaitForVerticalBlank(DWORD dwFlags
,HANDLE hEvent
);
86 // Class that aggregates an IDirectDrawSurface interface
88 class CAggDrawSurface
: public IDirectDrawSurface
, public CUnknown
92 LPDIRECTDRAWSURFACE m_pDirectDrawSurface
;
97 STDMETHODIMP
NonDelegatingQueryInterface(REFIID riid
,void **ppv
);
99 // Constructor and destructor
101 CAggDrawSurface(TCHAR
*pName
,LPUNKNOWN pUnk
) :
102 CUnknown(pName
,pUnk
),
103 m_pDirectDrawSurface(NULL
) { };
105 virtual ~CAggDrawSurface() { };
107 // Set the object we should be aggregating
108 void SetDirectDrawSurface(LPDIRECTDRAWSURFACE pDirectDrawSurface
) {
109 m_pDirectDrawSurface
= pDirectDrawSurface
;
112 // IDirectDrawSurface methods
114 STDMETHODIMP
AddAttachedSurface(LPDIRECTDRAWSURFACE lpDDSAttachedSurface
);
115 STDMETHODIMP
AddOverlayDirtyRect(LPRECT lpRect
);
116 STDMETHODIMP
Blt(LPRECT lpDestRect
,LPDIRECTDRAWSURFACE lpDDSrcSurface
,LPRECT lpSrcRect
,DWORD dwFlags
,LPDDBLTFX lpDDBltFx
);
117 STDMETHODIMP
BltBatch(LPDDBLTBATCH lpDDBltBatch
,DWORD dwCount
,DWORD dwFlags
);
118 STDMETHODIMP
BltFast(DWORD dwX
,DWORD dwY
,LPDIRECTDRAWSURFACE lpDDSrcSurface
,LPRECT lpSrcRect
,DWORD dwTrans
);
119 STDMETHODIMP
DeleteAttachedSurface(DWORD dwFlags
,LPDIRECTDRAWSURFACE lpDDSAttachedSurface
);
120 STDMETHODIMP
EnumAttachedSurfaces(LPVOID lpContext
,LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback
);
121 STDMETHODIMP
EnumOverlayZOrders(DWORD dwFlags
,LPVOID lpContext
,LPDDENUMSURFACESCALLBACK lpfnCallback
);
122 STDMETHODIMP
Flip(LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride
,DWORD dwFlags
);
123 STDMETHODIMP
GetAttachedSurface(LPDDSCAPS lpDDSCaps
,LPDIRECTDRAWSURFACE
*lplpDDAttachedSurface
);
124 STDMETHODIMP
GetBltStatus(DWORD dwFlags
);
125 STDMETHODIMP
GetCaps(LPDDSCAPS lpDDSCaps
);
126 STDMETHODIMP
GetClipper(LPDIRECTDRAWCLIPPER
*lplpDDClipper
);
127 STDMETHODIMP
GetColorKey(DWORD dwFlags
,LPDDCOLORKEY lpDDColorKey
);
128 STDMETHODIMP
GetDC(HDC
*lphDC
);
129 STDMETHODIMP
GetFlipStatus(DWORD dwFlags
);
130 STDMETHODIMP
GetOverlayPosition(LPLONG lpdwX
,LPLONG lpdwY
);
131 STDMETHODIMP
GetPalette(LPDIRECTDRAWPALETTE
*lplpDDPalette
);
132 STDMETHODIMP
GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat
);
133 STDMETHODIMP
GetSurfaceDesc(LPDDSURFACEDESC lpDDSurfaceDesc
);
134 STDMETHODIMP
Initialize(LPDIRECTDRAW lpDD
,LPDDSURFACEDESC lpDDSurfaceDesc
);
135 STDMETHODIMP
IsLost();
136 STDMETHODIMP
Lock(LPRECT lpDestRect
,LPDDSURFACEDESC lpDDSurfaceDesc
,DWORD dwFlags
,HANDLE hEvent
);
137 STDMETHODIMP
ReleaseDC(HDC hDC
);
138 STDMETHODIMP
Restore();
139 STDMETHODIMP
SetClipper(LPDIRECTDRAWCLIPPER lpDDClipper
);
140 STDMETHODIMP
SetColorKey(DWORD dwFlags
,LPDDCOLORKEY lpDDColorKey
);
141 STDMETHODIMP
SetOverlayPosition(LONG dwX
,LONG dwY
);
142 STDMETHODIMP
SetPalette(LPDIRECTDRAWPALETTE lpDDPalette
);
143 STDMETHODIMP
Unlock(LPVOID lpSurfaceData
);
144 STDMETHODIMP
UpdateOverlay(LPRECT lpSrcRect
,LPDIRECTDRAWSURFACE lpDDDestSurface
,LPRECT lpDestRect
,DWORD dwFlags
,LPDDOVERLAYFX lpDDOverlayFX
);
145 STDMETHODIMP
UpdateOverlayDisplay(DWORD dwFlags
);
146 STDMETHODIMP
UpdateOverlayZOrder(DWORD dwFlags
,LPDIRECTDRAWSURFACE lpDDSReference
);
150 // DirectShow must work on multiple platforms. In particular, it also runs on
151 // Windows NT 3.51 which does not have DirectDraw capabilities. The filters
152 // cannot therefore link statically to the DirectDraw library. To make their
153 // lives that little bit easier we provide this class that manages loading
154 // and unloading the library and creating the initial IDirectDraw interface
156 typedef DWORD (WINAPI
*PGETFILEVERSIONINFOSIZE
)(LPTSTR
,LPDWORD
);
157 typedef BOOL (WINAPI
*PGETFILEVERSIONINFO
)(LPTSTR
,DWORD
,DWORD
,LPVOID
);
158 typedef BOOL (WINAPI
*PVERQUERYVALUE
)(LPVOID
,LPTSTR
,LPVOID
,PUINT
);
160 class CLoadDirectDraw
162 LPDIRECTDRAW m_pDirectDraw
; // The DirectDraw driver instance
163 HINSTANCE m_hDirectDraw
; // Handle to the loaded library
170 HRESULT
LoadDirectDraw(LPSTR szDevice
);
171 void ReleaseDirectDraw();
172 HRESULT
IsDirectDrawLoaded();
173 LPDIRECTDRAW
GetDirectDraw();
174 BOOL
IsDirectDrawVersion1();
177 #endif // __VIDEOCTL__