evr/mixer: Maintain streaming state flag.
[wine.git] / dlls / qedit / main.c
bloba4a4f5ec38c733579e32c6eb01d21721c1473ef2
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 qedit_instance;
28 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
30 if (reason == DLL_PROCESS_ATTACH)
32 qedit_instance = instance;
33 DisableThreadLibraryCalls(instance);
35 else if (reason == DLL_PROCESS_DETACH && !reserved)
37 strmbase_release_typelibs();
39 return TRUE;
42 /******************************************************************************
43 * DirectShow ClassFactory
45 typedef struct {
46 IClassFactory IClassFactory_iface;
47 LONG ref;
48 HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
49 } IClassFactoryImpl;
51 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
53 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
56 struct object_creation_info
58 const CLSID *clsid;
59 HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
62 static const struct object_creation_info object_creation[] =
64 {&CLSID_AMTimeline, timeline_create},
65 {&CLSID_MediaDet, media_detector_create},
66 {&CLSID_NullRenderer, null_renderer_create},
67 {&CLSID_SampleGrabber, sample_grabber_create},
70 static HRESULT WINAPI DSCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
72 if (IsEqualGUID(riid, &IID_IUnknown)
73 || IsEqualGUID(riid, &IID_IClassFactory))
75 IClassFactory_AddRef(iface);
76 *ppobj = iface;
77 return S_OK;
80 *ppobj = NULL;
81 WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
82 return E_NOINTERFACE;
85 static ULONG WINAPI DSCF_AddRef(IClassFactory *iface)
87 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
88 return InterlockedIncrement(&This->ref);
91 static ULONG WINAPI DSCF_Release(IClassFactory *iface)
93 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
94 ULONG ref = InterlockedDecrement(&This->ref);
96 if (ref == 0)
97 CoTaskMemFree(This);
99 return ref;
102 static HRESULT WINAPI DSCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid,
103 void **ppobj)
105 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
106 HRESULT hres;
107 LPUNKNOWN punk;
109 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
111 *ppobj = NULL;
112 if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
113 return E_NOINTERFACE;
115 hres = This->create_instance(pOuter, &punk);
116 if (SUCCEEDED(hres)) {
117 hres = IUnknown_QueryInterface(punk, riid, ppobj);
118 IUnknown_Release(punk);
120 return hres;
123 static HRESULT WINAPI DSCF_LockServer(IClassFactory *iface, BOOL dolock)
125 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
126 FIXME("(%p)->(%d),stub!\n",This,dolock);
127 return S_OK;
130 static const IClassFactoryVtbl DSCF_Vtbl =
132 DSCF_QueryInterface,
133 DSCF_AddRef,
134 DSCF_Release,
135 DSCF_CreateInstance,
136 DSCF_LockServer
140 /***********************************************************************
141 * DllCanUnloadNow (QEDIT.@)
143 HRESULT WINAPI DllCanUnloadNow(void)
145 return S_FALSE;
148 /*******************************************************************************
149 * DllGetClassObject [QEDIT.@]
150 * Retrieves class object from a DLL object
152 * PARAMS
153 * rclsid [I] CLSID for the class object
154 * riid [I] Reference to identifier of interface for class object
155 * ppv [O] Address of variable to receive interface pointer for riid
157 * RETURNS
158 * Success: S_OK
159 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
160 * E_UNEXPECTED, E_NOINTERFACE
163 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
165 unsigned int i;
166 IClassFactoryImpl *factory;
168 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
170 if ( !IsEqualGUID( &IID_IClassFactory, riid )
171 && ! IsEqualGUID( &IID_IUnknown, riid) )
172 return E_NOINTERFACE;
174 for (i = 0; i < ARRAY_SIZE(object_creation); i++)
176 if (IsEqualGUID(object_creation[i].clsid, rclsid))
177 break;
180 if (i == ARRAY_SIZE(object_creation))
182 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
183 return CLASS_E_CLASSNOTAVAILABLE;
186 factory = CoTaskMemAlloc(sizeof(*factory));
187 if (factory == NULL) return E_OUTOFMEMORY;
189 factory->IClassFactory_iface.lpVtbl = &DSCF_Vtbl;
190 factory->ref = 1;
192 factory->create_instance = object_creation[i].create_instance;
194 *ppv = &factory->IClassFactory_iface;
195 return S_OK;
198 static const REGPINTYPES reg_null_mt = {&GUID_NULL, &GUID_NULL};
200 static const REGFILTERPINS2 reg_sample_grabber_pins[2] =
203 .cInstances = 1,
204 .nMediaTypes = 1,
205 .lpMediaType = &reg_null_mt,
208 .dwFlags = REG_PINFLAG_B_OUTPUT,
209 .cInstances = 1,
210 .nMediaTypes = 1,
211 .lpMediaType = &reg_null_mt,
215 static const REGFILTER2 reg_sample_grabber =
217 .dwVersion = 2,
218 .dwMerit = MERIT_DO_NOT_USE,
219 .u.s2.cPins2 = 2,
220 .u.s2.rgPins2 = reg_sample_grabber_pins,
223 static const REGFILTERPINS2 reg_null_renderer_pins[1] =
226 .dwFlags = REG_PINFLAG_B_OUTPUT,
227 .cInstances = 1,
228 .nMediaTypes = 1,
229 .lpMediaType = &reg_null_mt,
233 static const REGFILTER2 reg_null_renderer =
235 .dwVersion = 2,
236 .dwMerit = MERIT_DO_NOT_USE,
237 .u.s2.cPins2 = 1,
238 .u.s2.rgPins2 = reg_null_renderer_pins,
241 /***********************************************************************
242 * DllRegisterServer (QEDIT.@)
244 HRESULT WINAPI DllRegisterServer(void)
246 IFilterMapper2 *mapper;
247 HRESULT hr;
249 if (FAILED(hr = __wine_register_resources(qedit_instance)))
250 return hr;
252 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
253 &IID_IFilterMapper2, (void **)&mapper)))
254 return hr;
256 IFilterMapper2_RegisterFilter(mapper, &CLSID_SampleGrabber, L"SampleGrabber",
257 NULL, NULL, NULL, &reg_sample_grabber);
258 IFilterMapper2_RegisterFilter(mapper, &CLSID_NullRenderer, L"Null Renderer",
259 NULL, NULL, NULL, &reg_null_renderer);
261 IFilterMapper2_Release(mapper);
262 return S_OK;
265 /***********************************************************************
266 * DllUnregisterServer (QEDIT.@)
268 HRESULT WINAPI DllUnregisterServer(void)
270 IFilterMapper2 *mapper;
271 HRESULT hr;
273 if (FAILED(hr = __wine_unregister_resources(qedit_instance)))
274 return hr;
276 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
277 &IID_IFilterMapper2, (void **)&mapper)))
278 return hr;
280 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_SampleGrabber);
281 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_NullRenderer);
283 IFilterMapper2_Release(mapper);
284 return S_OK;