Get rid of the no longer used ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
[wine/multimedia.git] / dlls / quartz / main.c
blob773d547444f741ec7a28872fd0c2e40ea77d45fb
1 /* DirectShow Base Functions (QUARTZ.DLL)
3 * Copyright 2002 Lionel Ulmer
5 * This file contains the (internal) driver registration functions,
6 * driver enumeration APIs and DirectDraw creation functions.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "config.h"
24 #include "wine/debug.h"
26 #include "quartz_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
30 static DWORD dll_ref = 0;
32 /* For the moment, do nothing here. */
33 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
35 switch(fdwReason) {
36 case DLL_PROCESS_ATTACH:
37 DisableThreadLibraryCalls(hInstDLL);
38 break;
39 case DLL_PROCESS_DETACH:
40 break;
42 return TRUE;
45 /******************************************************************************
46 * DirectShow ClassFactory
48 typedef struct {
49 IClassFactory ITF_IClassFactory;
51 DWORD ref;
52 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
53 } IClassFactoryImpl;
55 struct object_creation_info
57 const CLSID *clsid;
58 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
61 static const struct object_creation_info object_creation[] =
63 { &CLSID_FilterGraph, FILTERGRAPH_create },
64 { &CLSID_FilterMapper, FilterMapper2_create },
65 { &CLSID_FilterMapper2, FilterMapper2_create },
66 { &CLSID_AsyncReader, AsyncReader_create },
67 { &CLSID_MemoryAllocator, StdMemAllocator_create },
68 { &CLSID_AviSplitter, AVISplitter_create },
70 { &CLSID_SystemClock, &QUARTZ_CreateSystemClock }
73 static HRESULT WINAPI
74 DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
76 ICOM_THIS(IClassFactoryImpl,iface);
78 if (IsEqualGUID(riid, &IID_IUnknown)
79 || IsEqualGUID(riid, &IID_IClassFactory))
81 IClassFactory_AddRef(iface);
82 *ppobj = This;
83 return S_OK;
86 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
87 return E_NOINTERFACE;
90 static ULONG WINAPI DSCF_AddRef(LPCLASSFACTORY iface) {
91 ICOM_THIS(IClassFactoryImpl,iface);
92 return ++(This->ref);
95 static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface) {
96 ICOM_THIS(IClassFactoryImpl,iface);
98 ULONG ref = --This->ref;
100 if (ref == 0)
101 HeapFree(GetProcessHeap(), 0, This);
103 return ref;
107 static HRESULT WINAPI DSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
108 REFIID riid, LPVOID *ppobj) {
109 ICOM_THIS(IClassFactoryImpl,iface);
110 HRESULT hres;
111 LPUNKNOWN punk;
113 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
115 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
116 if (FAILED(hres)) {
117 *ppobj = NULL;
118 return hres;
120 hres = IUnknown_QueryInterface(punk, riid, ppobj);
121 if (FAILED(hres)) {
122 *ppobj = NULL;
123 return hres;
125 IUnknown_Release(punk);
126 return hres;
129 static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
130 ICOM_THIS(IClassFactoryImpl,iface);
131 FIXME("(%p)->(%d),stub!\n",This,dolock);
132 return S_OK;
135 static IClassFactoryVtbl DSCF_Vtbl =
137 DSCF_QueryInterface,
138 DSCF_AddRef,
139 DSCF_Release,
140 DSCF_CreateInstance,
141 DSCF_LockServer
144 /*******************************************************************************
145 * DllGetClassObject [QUARTZ.@]
146 * Retrieves class object from a DLL object
148 * NOTES
149 * Docs say returns STDAPI
151 * PARAMS
152 * rclsid [I] CLSID for the class object
153 * riid [I] Reference to identifier of interface for class object
154 * ppv [O] Address of variable to receive interface pointer for riid
156 * RETURNS
157 * Success: S_OK
158 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
159 * E_UNEXPECTED
161 DWORD WINAPI QUARTZ_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
163 int i;
164 IClassFactoryImpl *factory;
166 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
168 if ( !IsEqualGUID( &IID_IClassFactory, riid )
169 && ! IsEqualGUID( &IID_IUnknown, riid) )
170 return E_NOINTERFACE;
172 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
174 if (IsEqualGUID(object_creation[i].clsid, rclsid))
175 break;
178 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
180 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
181 return CLASS_E_CLASSNOTAVAILABLE;
184 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
185 if (factory == NULL) return E_OUTOFMEMORY;
187 factory->ITF_IClassFactory.lpVtbl = &DSCF_Vtbl;
188 factory->ref = 1;
190 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
192 *ppv = &(factory->ITF_IClassFactory);
193 return S_OK;
196 /***********************************************************************
197 * DllCanUnloadNow (QUARTZ.@)
199 HRESULT WINAPI QUARTZ_DllCanUnloadNow()
201 return dll_ref != 0 ? S_FALSE : S_OK;
205 static struct {
206 const GUID riid;
207 const char *name;
208 } InterfaceDesc[] =
210 #define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
211 { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } , #name },
212 #include "uuids.h"
213 { { 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} }, NULL }
216 /***********************************************************************
217 * qzdebugstr_guid (internal)
219 * Gives a text version of DirectShow GUIDs
221 const char * qzdebugstr_guid( const GUID * id )
223 int i;
224 char * name = NULL;
226 for (i=0;InterfaceDesc[i].name && !name;i++) {
227 if (IsEqualGUID(&InterfaceDesc[i].riid, id)) return InterfaceDesc[i].name;
229 return debugstr_guid(id);
232 /***********************************************************************
233 * qzdebugstr_State (internal)
235 * Gives a text version of the FILTER_STATE enumeration
237 const char * qzdebugstr_State(FILTER_STATE state)
239 switch (state)
241 case State_Stopped:
242 return "State_Stopped";
243 case State_Running:
244 return "State_Running";
245 case State_Paused:
246 return "State_Paused";
247 default:
248 return "State_Unknown";