ReactOS  0.4.13-dev-479-gec9c8fd
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 
29 extern HRESULT WINAPI QUARTZ_DllCanUnloadNow(void) DECLSPEC_HIDDEN;
30 extern BOOL WINAPI QUARTZ_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
31 
32 static LONG server_locks = 0;
33 
34 /* For the moment, do nothing here. */
35 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
36 {
37  return QUARTZ_DllMain( hInstDLL, fdwReason, lpv );
38 }
39 
40 static HRESULT SeekingPassThru_create(IUnknown *pUnkOuter, LPVOID *ppObj)
41 {
42  return PosPassThru_Construct(pUnkOuter,ppObj); /* from strmbase */
43 }
44 
45 /******************************************************************************
46  * DirectShow ClassFactory
47  */
48 typedef 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 
65 static const struct object_creation_info object_creation[] =
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 {
126  HRESULT hres;
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 
154 static const IClassFactoryVtbl DSCF_Vtbl =
155 {
157  DSCF_AddRef,
158  DSCF_Release,
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 
222 static 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 }
229 };
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  */
279 const 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 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
HRESULT AVISplitter_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: avisplit.c:1430
HRESULT WAVEParser_create(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
Definition: waveparser.c:419
#define HRESULT
Definition: msvc.h:9
HRESULT VideoRenderer_create(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
LONG WINAPI AmpFactorToDB(LONG ampfactor)
Definition: main.c:289
static const IClassFactoryVtbl DSCF_Vtbl
Definition: main.c:154
DWORD WINAPI AMGetErrorTextA(HRESULT hr, LPSTR buffer, DWORD maxlen)
Definition: main.c:307
#define REFIID
Definition: guiddef.h:113
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
HRESULT AsyncReader_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: filesource.c:420
static HRESULT WINAPI DSCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
Definition: main.c:89
#define WideCharToMultiByte
Definition: compat.h:101
HRESULT FilterGraphNoThread_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: filtergraph.c:5766
HRESULT hr
Definition: shlfolder.c:183
#define error(str)
Definition: mkdosfs.c:1605
HRESULT DSoundRender_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: dsoundrender.c:618
WINE_DEFAULT_DEBUG_CHANNEL(wmic)
REFIID riid
Definition: precomp.h:44
const char * qzdebugstr_guid(const GUID *id)
Definition: main.c:279
#define REFCLSID
Definition: guiddef.h:112
#define CP_ACP
Definition: compat.h:99
static HRESULT SeekingPassThru_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: main.c:40
HRESULT VMR9Impl_create(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
Definition: vmr9.c:2451
#define WARN(fmt,...)
Definition: debug.h:111
#define CALLBACK
Definition: compat.h:27
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT AVIDec_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: avidec.c:395
GLuint buffer
Definition: glext.h:5915
const char * name
Definition: main.c:224
char * LPSTR
Definition: xmlstorage.h:182
const CLSID * clsid
Definition: main.c:70
Definition: send.c:47
static ULONG WINAPI DSCF_AddRef(IClassFactory *iface)
Definition: main.c:104
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
struct tagIClassFactoryImpl IClassFactoryImpl
HRESULT(* pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: main.c:71
HRESULT ACMWrapper_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: acmwrapper.c:380
HRESULT WINAPI QUARTZ_DllGetClassObject(REFCLSID, REFIID, LPVOID *)
Definition: main.c:28
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
HRESULT __RPC_STUB ICaptureGraphBuilder_FindInterface_Stub(ICaptureGraphBuilder *This, const GUID *pCategory, IBaseFilter *pf, REFIID riid, IUnknown **ppint)
Definition: main.c:244
static HRESULT WINAPI DSCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: main.c:122
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: main.c:440
static LPUNKNOWN
Definition: ndr_ole.c:49
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110
#define S_FALSE
Definition: winerror.h:2357
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
smooth NULL
Definition: ftsmooth.c:416
static const struct object_creation_info object_creation[]
Definition: main.c:65
#define __RPC_STUB
Definition: rpc.h:66
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
HRESULT WINAPI PosPassThru_Construct(IUnknown *pUnkOuter, LPVOID *ppPassThru)
Definition: pospass.c:249
HRESULT FilterMapper_create(IUnknown *pUnkOuter, LPVOID *ppObj)
HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: filtergraph.c:5689
HRESULT FilterMapper2_create(IUnknown *pUnkOuter, LPVOID *ppObj)
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
HRESULT MPEGSplitter_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: mpegsplit.c:871
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
HRESULT VideoRendererDefault_create(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT QUARTZ_CreateSystemClock(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
Definition: systemclock.c:377
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: main.c:54
static HRESULT WINAPI DSCF_LockServer(IClassFactory *iface, BOOL dolock)
Definition: main.c:143
static LONG server_locks
Definition: ole_server.c:61
REFCLSID clsid
Definition: msctf.c:84
HRESULT VMR7Impl_create(IUnknown *pUnkOuter, LPVOID *ppv) DECLSPEC_HIDDEN
Definition: vmr9.c:2446
#define InterlockedDecrement
Definition: armddk.h:52
const GUID riid
Definition: main.c:223
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
DWORD WINAPI AMGetErrorTextW(HRESULT hr, LPWSTR buffer, DWORD maxlen)
Definition: main.c:323
#define lstrcpyW
Definition: compat.h:406
HRESULT NullRenderer_create(IUnknown *pUnkOuter, void **ppv)
Definition: nullrenderer.c:225
HRESULT WINAPI DllCanUnloadNow(void)
Definition: main.c:204
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
HRESULT CALLBACK ICaptureGraphBuilder_FindInterface_Proxy(ICaptureGraphBuilder *This, const GUID *pCategory, IBaseFilter *pf, REFIID riid, void **ppint)
Definition: main.c:234
GLuint res
Definition: glext.h:9613
static const struct @250 InterfaceDesc[]
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static ULONG WINAPI DSCF_Release(IClassFactory *iface)
Definition: main.c:110
const GUID IID_IClassFactory
HRESULT __RPC_STUB ICaptureGraphBuilder2_FindInterface_Stub(ICaptureGraphBuilder2 *This, const GUID *pCategory, const GUID *pType, IBaseFilter *pf, REFIID riid, IUnknown **ppint)
Definition: main.c:264
IClassFactory IClassFactory_iface
Definition: main.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:406
static const WCHAR errorW[]
Definition: htmlevent.c:61
#define SUCCEEDED(hr)
Definition: intsafe.h:57
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: main.c:166
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
Definition: main.c:26
#define MAX_ERROR_TEXT_LEN
Definition: errors.h:29
LONG WINAPI DBToAmpFactor(LONG db)
Definition: main.c:295