wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / qedit / main.c
blob158fb4bc0b8a3406e851687078bf4004dd8b855d
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 #define WINE_NO_NAMELESS_EXTENSION
22 #include "qedit_private.h"
23 #include "rpcproxy.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(qedit);
28 static HINSTANCE qedit_instance;
30 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
32 if (reason == DLL_PROCESS_ATTACH)
34 qedit_instance = instance;
35 DisableThreadLibraryCalls(instance);
37 else if (reason == DLL_PROCESS_DETACH && !reserved)
39 strmbase_release_typelibs();
41 return TRUE;
44 /******************************************************************************
45 * DirectShow ClassFactory
47 typedef struct {
48 IClassFactory IClassFactory_iface;
49 LONG ref;
50 HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
51 } IClassFactoryImpl;
53 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
55 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
58 struct object_creation_info
60 const CLSID *clsid;
61 HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
64 static const struct object_creation_info object_creation[] =
66 {&CLSID_AMTimeline, timeline_create},
67 {&CLSID_MediaDet, media_detector_create},
68 {&CLSID_NullRenderer, null_renderer_create},
69 {&CLSID_SampleGrabber, sample_grabber_create},
72 static HRESULT WINAPI DSCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
74 if (IsEqualGUID(riid, &IID_IUnknown)
75 || IsEqualGUID(riid, &IID_IClassFactory))
77 IClassFactory_AddRef(iface);
78 *ppobj = iface;
79 return S_OK;
82 *ppobj = NULL;
83 WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
84 return E_NOINTERFACE;
87 static ULONG WINAPI DSCF_AddRef(IClassFactory *iface)
89 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
90 return InterlockedIncrement(&This->ref);
93 static ULONG WINAPI DSCF_Release(IClassFactory *iface)
95 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
96 ULONG ref = InterlockedDecrement(&This->ref);
98 if (ref == 0)
99 CoTaskMemFree(This);
101 return ref;
104 static HRESULT WINAPI DSCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid,
105 void **ppobj)
107 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
108 HRESULT hres;
109 LPUNKNOWN punk;
111 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
113 *ppobj = NULL;
114 if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
115 return E_NOINTERFACE;
117 hres = This->create_instance(pOuter, &punk);
118 if (SUCCEEDED(hres)) {
119 hres = IUnknown_QueryInterface(punk, riid, ppobj);
120 IUnknown_Release(punk);
122 return hres;
125 static HRESULT WINAPI DSCF_LockServer(IClassFactory *iface, BOOL dolock)
127 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
128 FIXME("(%p)->(%d),stub!\n",This,dolock);
129 return S_OK;
132 static const IClassFactoryVtbl DSCF_Vtbl =
134 DSCF_QueryInterface,
135 DSCF_AddRef,
136 DSCF_Release,
137 DSCF_CreateInstance,
138 DSCF_LockServer
142 /***********************************************************************
143 * DllCanUnloadNow (QEDIT.@)
145 HRESULT WINAPI DllCanUnloadNow(void)
147 return S_FALSE;
150 /*******************************************************************************
151 * DllGetClassObject [QEDIT.@]
152 * Retrieves class object from a DLL object
154 * PARAMS
155 * rclsid [I] CLSID for the class object
156 * riid [I] Reference to identifier of interface for class object
157 * ppv [O] Address of variable to receive interface pointer for riid
159 * RETURNS
160 * Success: S_OK
161 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
162 * E_UNEXPECTED, E_NOINTERFACE
165 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
167 unsigned int i;
168 IClassFactoryImpl *factory;
170 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
172 if ( !IsEqualGUID( &IID_IClassFactory, riid )
173 && ! IsEqualGUID( &IID_IUnknown, riid) )
174 return E_NOINTERFACE;
176 for (i = 0; i < ARRAY_SIZE(object_creation); i++)
178 if (IsEqualGUID(object_creation[i].clsid, rclsid))
179 break;
182 if (i == ARRAY_SIZE(object_creation))
184 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
185 return CLASS_E_CLASSNOTAVAILABLE;
188 factory = CoTaskMemAlloc(sizeof(*factory));
189 if (factory == NULL) return E_OUTOFMEMORY;
191 factory->IClassFactory_iface.lpVtbl = &DSCF_Vtbl;
192 factory->ref = 1;
194 factory->create_instance = object_creation[i].create_instance;
196 *ppv = &factory->IClassFactory_iface;
197 return S_OK;
200 static const REGPINTYPES reg_null_mt = {&GUID_NULL, &GUID_NULL};
202 static const REGFILTERPINS2 reg_sample_grabber_pins[2] =
205 .cInstances = 1,
206 .nMediaTypes = 1,
207 .lpMediaType = &reg_null_mt,
210 .dwFlags = REG_PINFLAG_B_OUTPUT,
211 .cInstances = 1,
212 .nMediaTypes = 1,
213 .lpMediaType = &reg_null_mt,
217 static const REGFILTER2 reg_sample_grabber =
219 .dwVersion = 2,
220 .dwMerit = MERIT_DO_NOT_USE,
221 .u.s2.cPins2 = 2,
222 .u.s2.rgPins2 = reg_sample_grabber_pins,
225 static const REGFILTERPINS2 reg_null_renderer_pins[1] =
228 .dwFlags = REG_PINFLAG_B_OUTPUT,
229 .cInstances = 1,
230 .nMediaTypes = 1,
231 .lpMediaType = &reg_null_mt,
235 static const REGFILTER2 reg_null_renderer =
237 .dwVersion = 2,
238 .dwMerit = MERIT_DO_NOT_USE,
239 .u.s2.cPins2 = 1,
240 .u.s2.rgPins2 = reg_null_renderer_pins,
243 /***********************************************************************
244 * DllRegisterServer (QEDIT.@)
246 HRESULT WINAPI DllRegisterServer(void)
248 IFilterMapper2 *mapper;
249 HRESULT hr;
251 if (FAILED(hr = __wine_register_resources(qedit_instance)))
252 return hr;
254 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
255 &IID_IFilterMapper2, (void **)&mapper)))
256 return hr;
258 IFilterMapper2_RegisterFilter(mapper, &CLSID_SampleGrabber, L"SampleGrabber",
259 NULL, NULL, NULL, &reg_sample_grabber);
260 IFilterMapper2_RegisterFilter(mapper, &CLSID_NullRenderer, L"Null Renderer",
261 NULL, NULL, NULL, &reg_null_renderer);
263 IFilterMapper2_Release(mapper);
264 return S_OK;
267 /***********************************************************************
268 * DllUnregisterServer (QEDIT.@)
270 HRESULT WINAPI DllUnregisterServer(void)
272 IFilterMapper2 *mapper;
273 HRESULT hr;
275 if (FAILED(hr = __wine_unregister_resources(qedit_instance)))
276 return hr;
278 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
279 &IID_IFilterMapper2, (void **)&mapper)))
280 return hr;
282 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_SampleGrabber);
283 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_NullRenderer);
285 IFilterMapper2_Release(mapper);
286 return S_OK;