ReactOS 0.4.16-dev-297-gc569aee
main.c
Go to the documentation of this file.
1/* DirectShow Base Functions (QUARTZ.DLL)
2 *
3 * Copyright 2002 Lionel Ulmer
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include "config.h"
21#include "wine/debug.h"
22
23#include "quartz_private.h"
24#include "wine/unicode.h"
25
27
29extern HRESULT WINAPI QUARTZ_DllCanUnloadNow(void) DECLSPEC_HIDDEN;
30extern BOOL WINAPI QUARTZ_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
31
32static LONG server_locks = 0;
33
34/* For the moment, do nothing here. */
35BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
36{
37 return QUARTZ_DllMain( hInstDLL, fdwReason, lpv );
38}
39
41{
42 return PosPassThru_Construct(pUnkOuter,ppObj); /* from strmbase */
43}
44
45/******************************************************************************
46 * DirectShow ClassFactory
47 */
48typedef struct {
49 IClassFactory IClassFactory_iface;
50 LONG ref;
51 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
53
55{
56 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
57}
58
60{
61 const CLSID *clsid;
62 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
63};
64
66{
67 { &CLSID_SeekingPassThru, SeekingPassThru_create },
68 { &CLSID_FilterGraph, FilterGraph_create },
69 { &CLSID_FilterGraphNoThread, FilterGraphNoThread_create },
70 { &CLSID_FilterMapper, FilterMapper_create },
71 { &CLSID_FilterMapper2, FilterMapper2_create },
72 { &CLSID_AsyncReader, AsyncReader_create },
73 { &CLSID_MemoryAllocator, StdMemAllocator_create },
74 { &CLSID_AviSplitter, AVISplitter_create },
75 { &CLSID_MPEG1Splitter, MPEGSplitter_create },
76 { &CLSID_VideoRenderer, VideoRenderer_create },
77 { &CLSID_NullRenderer, NullRenderer_create },
78 { &CLSID_VideoMixingRenderer, VMR7Impl_create },
79 { &CLSID_VideoMixingRenderer9, VMR9Impl_create },
80 { &CLSID_VideoRendererDefault, VideoRendererDefault_create },
81 { &CLSID_DSoundRender, DSoundRender_create },
82 { &CLSID_AudioRender, DSoundRender_create },
83 { &CLSID_AVIDec, AVIDec_create },
84 { &CLSID_SystemClock, QUARTZ_CreateSystemClock },
85 { &CLSID_ACMWrapper, ACMWrapper_create },
86 { &CLSID_WAVEParser, WAVEParser_create }
87};
88
90{
93 {
94 IClassFactory_AddRef(iface);
95 *ppobj = iface;
96 return S_OK;
97 }
98
99 *ppobj = NULL;
100 WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
101 return E_NOINTERFACE;
102}
103
105{
107 return InterlockedIncrement(&This->ref);
108}
109
111{
114
115 if (ref == 0)
117
118 return ref;
119}
120
121
123 REFIID riid, void **ppobj)
124{
127 LPUNKNOWN punk;
128
129 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
130
131 *ppobj = NULL;
132 if(pOuter && !IsEqualGUID(&IID_IUnknown, riid))
133 return E_NOINTERFACE;
134
135 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
136 if (SUCCEEDED(hres)) {
137 hres = IUnknown_QueryInterface(punk, riid, ppobj);
138 IUnknown_Release(punk);
139 }
140 return hres;
141}
142
144{
146 FIXME("(%p)->(%d),stub!\n",This,dolock);
147 if(dolock)
149 else
151 return S_OK;
152}
153
154static const IClassFactoryVtbl DSCF_Vtbl =
155{
161};
162
163/*******************************************************************************
164 * DllGetClassObject [QUARTZ.@]
165 * Retrieves class object from a DLL object
166 *
167 * NOTES
168 * Docs say returns STDAPI
169 *
170 * PARAMS
171 * rclsid [I] CLSID for the class object
172 * riid [I] Reference to identifier of interface for class object
173 * ppv [O] Address of variable to receive interface pointer for riid
174 *
175 * RETURNS
176 * Success: S_OK
177 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
178 * E_UNEXPECTED
179 */
181{
182 unsigned int i;
183
184 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
185
187 {
188 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
189 {
190 if (IsEqualGUID(object_creation[i].clsid, rclsid))
191 {
193 if (factory == NULL) return E_OUTOFMEMORY;
194
196 factory->ref = 1;
197
198 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
199
201 return S_OK;
202 }
203 }
204 }
205 return QUARTZ_DllGetClassObject( rclsid, riid, ppv );
206}
207
208/***********************************************************************
209 * DllCanUnloadNow (QUARTZ.@)
210 */
212{
213 if(server_locks == 0 && QUARTZ_DllCanUnloadNow() == S_OK)
214 return S_OK;
215 return S_FALSE;
216}
217
218
219#define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
220 { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } , #name },
221
222static const struct {
223 const GUID riid;
224 const char *name;
225} InterfaceDesc[] =
226{
227#include "uuids.h"
228 { { 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} }, NULL }
230
231/***********************************************************************
232 * proxies
233 */
235 const GUID *pCategory,
236 IBaseFilter *pf,
237 REFIID riid,
238 void **ppint )
239{
240 return ICaptureGraphBuilder_RemoteFindInterface_Proxy( This, pCategory, pf,
241 riid, (IUnknown **)ppint );
242}
243
245 const GUID *pCategory,
246 IBaseFilter *pf,
247 REFIID riid,
248 IUnknown **ppint )
249{
250 return ICaptureGraphBuilder_FindInterface( This, pCategory, pf, riid, (void **)ppint );
251}
252
254 const GUID *pCategory,
255 const GUID *pType,
256 IBaseFilter *pf,
257 REFIID riid,
258 void **ppint )
259{
260 return ICaptureGraphBuilder2_RemoteFindInterface_Proxy( This, pCategory, pType,
261 pf, riid, (IUnknown **)ppint );
262}
263
265 const GUID *pCategory,
266 const GUID *pType,
267 IBaseFilter *pf,
268 REFIID riid,
269 IUnknown **ppint )
270{
271 return ICaptureGraphBuilder2_FindInterface( This, pCategory, pType, pf, riid, (void **)ppint );
272}
273
274/***********************************************************************
275 * qzdebugstr_guid (internal)
276 *
277 * Gives a text version of DirectShow GUIDs
278 */
279const char * qzdebugstr_guid( const GUID * id )
280{
281 int i;
282
283 for (i=0; InterfaceDesc[i].name; i++)
284 if (IsEqualGUID(&InterfaceDesc[i].riid, id)) return InterfaceDesc[i].name;
285
286 return debugstr_guid(id);
287}
288
290{
291 FIXME("(%d) Stub!\n", ampfactor);
292 return 0;
293}
294
296{
297 FIXME("(%d) Stub!\n", db);
298 /* Avoid divide by zero (probably during range computation) in Windows Media Player 6.4 */
299 if (db < -1000)
300 return 0;
301 return 100;
302}
303
304/***********************************************************************
305 * AMGetErrorTextA (QUARTZ.@)
306 */
308{
309 DWORD res;
311
312 TRACE("(%x,%p,%d)\n", hr, buffer, maxlen);
313 if (!buffer)
314 return 0;
315
316 res = AMGetErrorTextW(hr, errorW, sizeof(errorW)/sizeof(*errorW));
317 return WideCharToMultiByte(CP_ACP, 0, errorW, res, buffer, maxlen, 0, 0);
318}
319
320/***********************************************************************
321 * AMGetErrorTextW (QUARTZ.@)
322 */
324{
325 unsigned int len;
326 static const WCHAR format[] = {'E','r','r','o','r',':',' ','0','x','%','l','x',0};
328
329 FIXME("(%x,%p,%d) stub\n", hr, buffer, maxlen);
330
331 if (!buffer) return 0;
333 if ((len = strlenW(error)) >= maxlen) return 0;
335 return len;
336}
HRESULT ACMWrapper_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: acmwrapper.c:380
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
HRESULT AVIDec_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: avidec.c:395
HRESULT AVISplitter_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: avisplit.c:1430
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
Definition: main.c:26
static const struct object_creation_info object_creation[]
Definition: main.c:74
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: main.c:166
static const IClassFactoryVtbl DSCF_Vtbl
Definition: main.c:140
HRESULT WINAPI DllCanUnloadNow(void)
Definition: main.c:204
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: main.c:63
static ULONG WINAPI DSCF_AddRef(IClassFactory *iface)
Definition: main.c:81
static ULONG WINAPI DSCF_Release(IClassFactory *iface)
Definition: main.c:87
static HRESULT WINAPI DSCF_LockServer(IClassFactory *iface, BOOL dolock)
Definition: main.c:119
static HRESULT WINAPI DSCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
Definition: main.c:66
static HRESULT WINAPI DSCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: main.c:98
HRESULT DSoundRender_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: dsoundrender.c:618
HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: filtergraph.c:5689
HRESULT FilterGraphNoThread_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: filtergraph.c:5766
HRESULT FilterMapper2_create(IUnknown *pUnkOuter, LPVOID *ppObj)
HRESULT FilterMapper_create(IUnknown *pUnkOuter, LPVOID *ppObj)
static const struct @259 InterfaceDesc[]
HRESULT __RPC_STUB ICaptureGraphBuilder_FindInterface_Stub(ICaptureGraphBuilder *This, const GUID *pCategory, IBaseFilter *pf, REFIID riid, IUnknown **ppint)
Definition: main.c:244
const char * qzdebugstr_guid(const GUID *id)
Definition: main.c:279
HRESULT WINAPI QUARTZ_DllGetClassObject(REFCLSID, REFIID, LPVOID *)
Definition: main.c:28
DWORD WINAPI AMGetErrorTextA(HRESULT hr, LPSTR buffer, DWORD maxlen)
Definition: main.c:307
DWORD WINAPI AMGetErrorTextW(HRESULT hr, LPWSTR buffer, DWORD maxlen)
Definition: main.c:323
HRESULT __RPC_STUB ICaptureGraphBuilder2_FindInterface_Stub(ICaptureGraphBuilder2 *This, const GUID *pCategory, const GUID *pType, IBaseFilter *pf, REFIID riid, IUnknown **ppint)
Definition: main.c:264
HRESULT CALLBACK ICaptureGraphBuilder_FindInterface_Proxy(ICaptureGraphBuilder *This, const GUID *pCategory, IBaseFilter *pf, REFIID riid, void **ppint)
Definition: main.c:234
LONG WINAPI AmpFactorToDB(LONG ampfactor)
Definition: main.c:289
static HRESULT SeekingPassThru_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: main.c:40
LONG WINAPI DBToAmpFactor(LONG db)
Definition: main.c:295
HRESULT CALLBACK ICaptureGraphBuilder2_FindInterface_Proxy(ICaptureGraphBuilder2 *This, const GUID *pCategory, const GUID *pType, IBaseFilter *pf, REFIID riid, void **ppint)
Definition: main.c:253
HRESULT StdMemAllocator_create(LPUNKNOWN lpUnkOuter, LPVOID *ppv)
Definition: memallocator.c:898
HRESULT MPEGSplitter_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: mpegsplit.c:871
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
#define CP_ACP
Definition: compat.h:109
#define CALLBACK
Definition: compat.h:35
#define lstrcpyW
Definition: compat.h:749
#define WideCharToMultiByte
Definition: compat.h:111
#define MAX_ERROR_TEXT_LEN
Definition: errors.h:29
HRESULT AsyncReader_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: filesource.c:420
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const WCHAR errorW[]
Definition: htmlevent.c:61
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_guid
Definition: kernel32.h:35
#define error(str)
Definition: mkdosfs.c:1605
HRESULT hres
Definition: protocol.c:465
REFCLSID clsid
Definition: msctf.c:82
static LPUNKNOWN
Definition: ndr_ole.c:49
HRESULT NullRenderer_create(IUnknown *pUnkOuter, void **ppv)
Definition: nullrenderer.c:225
static LONG server_locks
Definition: ole_server.c:61
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
HRESULT VMR9Impl_create(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
Definition: vmr9.c:2451
HRESULT WAVEParser_create(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
Definition: waveparser.c:419
HRESULT VideoRenderer_create(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
HRESULT QUARTZ_CreateSystemClock(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
Definition: systemclock.c:377
HRESULT VideoRendererDefault_create(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
HRESULT VMR7Impl_create(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
Definition: vmr9.c:2446
#define strlenW(s)
Definition: unicode.h:34
#define __RPC_STUB
Definition: rpc.h:66
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI PosPassThru_Construct(IUnknown *pUnkOuter, LPVOID *ppPassThru)
Definition: pospass.c:249
Definition: main.c:439
IClassFactory IClassFactory_iface
Definition: main.c:440
Definition: format.c:58
Definition: name.c:39
const CLSID * clsid
Definition: main.c:70
HRESULT(* pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: main.c:71
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184