ntoskrnl.exe: Add KeQueryActiveProcessorCountEx() function.
[wine.git] / dlls / qedit / main.c
blobf4d1bbb0613890ed60d6935da4edd281d760aedd
1 /* DirectShow Editing Services (qedit.dll)
3 * Copyright 2008 Google (Lei Zhang)
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.
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.
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
20 #include "qedit_private.h"
21 #include "rpcproxy.h"
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(qedit);
26 static HINSTANCE instance;
28 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
30 switch(fdwReason) {
31 case DLL_PROCESS_ATTACH:
32 instance = hInstDLL;
33 DisableThreadLibraryCalls(hInstDLL);
34 break;
36 return TRUE;
39 /******************************************************************************
40 * DirectShow ClassFactory
42 typedef struct {
43 IClassFactory IClassFactory_iface;
44 LONG ref;
45 HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
46 } IClassFactoryImpl;
48 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
50 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
53 struct object_creation_info
55 const CLSID *clsid;
56 HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
59 static const struct object_creation_info object_creation[] =
61 {&CLSID_AMTimeline, timeline_create},
62 {&CLSID_MediaDet, media_detector_create},
63 {&CLSID_NullRenderer, null_renderer_create},
64 {&CLSID_SampleGrabber, sample_grabber_create},
67 static HRESULT WINAPI DSCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
69 if (IsEqualGUID(riid, &IID_IUnknown)
70 || IsEqualGUID(riid, &IID_IClassFactory))
72 IClassFactory_AddRef(iface);
73 *ppobj = iface;
74 return S_OK;
77 *ppobj = NULL;
78 WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
79 return E_NOINTERFACE;
82 static ULONG WINAPI DSCF_AddRef(IClassFactory *iface)
84 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
85 return InterlockedIncrement(&This->ref);
88 static ULONG WINAPI DSCF_Release(IClassFactory *iface)
90 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
91 ULONG ref = InterlockedDecrement(&This->ref);
93 if (ref == 0)
94 CoTaskMemFree(This);
96 return ref;
99 static HRESULT WINAPI DSCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid,
100 void **ppobj)
102 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
103 HRESULT hres;
104 LPUNKNOWN punk;
106 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
108 *ppobj = NULL;
109 if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
110 return E_NOINTERFACE;
112 hres = This->create_instance(pOuter, &punk);
113 if (SUCCEEDED(hres)) {
114 hres = IUnknown_QueryInterface(punk, riid, ppobj);
115 IUnknown_Release(punk);
117 return hres;
120 static HRESULT WINAPI DSCF_LockServer(IClassFactory *iface, BOOL dolock)
122 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
123 FIXME("(%p)->(%d),stub!\n",This,dolock);
124 return S_OK;
127 static const IClassFactoryVtbl DSCF_Vtbl =
129 DSCF_QueryInterface,
130 DSCF_AddRef,
131 DSCF_Release,
132 DSCF_CreateInstance,
133 DSCF_LockServer
137 /***********************************************************************
138 * DllCanUnloadNow (QEDIT.@)
140 HRESULT WINAPI DllCanUnloadNow(void)
142 return S_FALSE;
145 /*******************************************************************************
146 * DllGetClassObject [QEDIT.@]
147 * Retrieves class object from a DLL object
149 * PARAMS
150 * rclsid [I] CLSID for the class object
151 * riid [I] Reference to identifier of interface for class object
152 * ppv [O] Address of variable to receive interface pointer for riid
154 * RETURNS
155 * Success: S_OK
156 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
157 * E_UNEXPECTED, E_NOINTERFACE
160 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
162 unsigned int i;
163 IClassFactoryImpl *factory;
165 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
167 if ( !IsEqualGUID( &IID_IClassFactory, riid )
168 && ! IsEqualGUID( &IID_IUnknown, riid) )
169 return E_NOINTERFACE;
171 for (i = 0; i < ARRAY_SIZE(object_creation); i++)
173 if (IsEqualGUID(object_creation[i].clsid, rclsid))
174 break;
177 if (i == ARRAY_SIZE(object_creation))
179 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
180 return CLASS_E_CLASSNOTAVAILABLE;
183 factory = CoTaskMemAlloc(sizeof(*factory));
184 if (factory == NULL) return E_OUTOFMEMORY;
186 factory->IClassFactory_iface.lpVtbl = &DSCF_Vtbl;
187 factory->ref = 1;
189 factory->create_instance = object_creation[i].create_instance;
191 *ppv = &factory->IClassFactory_iface;
192 return S_OK;
195 static const REGPINTYPES reg_null_mt = {&GUID_NULL, &GUID_NULL};
197 static const REGFILTERPINS2 reg_sample_grabber_pins[2] =
200 .cInstances = 1,
201 .nMediaTypes = 1,
202 .lpMediaType = &reg_null_mt,
205 .dwFlags = REG_PINFLAG_B_OUTPUT,
206 .cInstances = 1,
207 .nMediaTypes = 1,
208 .lpMediaType = &reg_null_mt,
212 static const REGFILTER2 reg_sample_grabber =
214 .dwVersion = 2,
215 .dwMerit = MERIT_DO_NOT_USE,
216 .u.s2.cPins2 = 2,
217 .u.s2.rgPins2 = reg_sample_grabber_pins,
220 static const REGFILTERPINS2 reg_null_renderer_pins[1] =
223 .dwFlags = REG_PINFLAG_B_OUTPUT,
224 .cInstances = 1,
225 .nMediaTypes = 1,
226 .lpMediaType = &reg_null_mt,
230 static const REGFILTER2 reg_null_renderer =
232 .dwVersion = 2,
233 .dwMerit = MERIT_DO_NOT_USE,
234 .u.s2.cPins2 = 1,
235 .u.s2.rgPins2 = reg_null_renderer_pins,
238 /***********************************************************************
239 * DllRegisterServer (QEDIT.@)
241 HRESULT WINAPI DllRegisterServer(void)
243 IFilterMapper2 *mapper;
244 HRESULT hr;
246 if (FAILED(hr = __wine_register_resources( instance )))
247 return hr;
249 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
250 &IID_IFilterMapper2, (void **)&mapper)))
251 return hr;
253 IFilterMapper2_RegisterFilter(mapper, &CLSID_SampleGrabber, L"SampleGrabber",
254 NULL, NULL, NULL, &reg_sample_grabber);
255 IFilterMapper2_RegisterFilter(mapper, &CLSID_NullRenderer, L"Null Renderer",
256 NULL, NULL, NULL, &reg_null_renderer);
258 IFilterMapper2_Release(mapper);
259 return S_OK;
262 /***********************************************************************
263 * DllUnregisterServer (QEDIT.@)
265 HRESULT WINAPI DllUnregisterServer(void)
267 IFilterMapper2 *mapper;
268 HRESULT hr;
270 if (FAILED(hr = __wine_unregister_resources( instance )))
271 return hr;
273 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
274 &IID_IFilterMapper2, (void **)&mapper)))
275 return hr;
277 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_SampleGrabber);
278 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_NullRenderer);
280 IFilterMapper2_Release(mapper);
281 return S_OK;