dmband: Set DMUS_PATCH_PMSG bank LSB/MSB from instrument patch.
[wine.git] / dlls / qedit / main.c
blob652da939e379a594b041311a1a6a1cac2180f80e
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(quartz);
28 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
30 if (reason == DLL_PROCESS_ATTACH)
32 DisableThreadLibraryCalls(instance);
34 else if (reason == DLL_PROCESS_DETACH && !reserved)
36 strmbase_release_typelibs();
38 return TRUE;
41 /******************************************************************************
42 * DirectShow ClassFactory
44 typedef struct {
45 IClassFactory IClassFactory_iface;
46 LONG ref;
47 HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
48 } IClassFactoryImpl;
50 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
52 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
55 struct object_creation_info
57 const CLSID *clsid;
58 HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
61 static const struct object_creation_info object_creation[] =
63 {&CLSID_AMTimeline, timeline_create},
64 {&CLSID_MediaDet, media_detector_create},
65 {&CLSID_NullRenderer, null_renderer_create},
66 {&CLSID_SampleGrabber, sample_grabber_create},
69 static HRESULT WINAPI DSCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
71 if (IsEqualGUID(riid, &IID_IUnknown)
72 || IsEqualGUID(riid, &IID_IClassFactory))
74 IClassFactory_AddRef(iface);
75 *ppobj = iface;
76 return S_OK;
79 *ppobj = NULL;
80 WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
81 return E_NOINTERFACE;
84 static ULONG WINAPI DSCF_AddRef(IClassFactory *iface)
86 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
87 return InterlockedIncrement(&This->ref);
90 static ULONG WINAPI DSCF_Release(IClassFactory *iface)
92 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
93 ULONG ref = InterlockedDecrement(&This->ref);
95 if (ref == 0)
96 CoTaskMemFree(This);
98 return ref;
101 static HRESULT WINAPI DSCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid,
102 void **ppobj)
104 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
105 HRESULT hres;
106 LPUNKNOWN punk;
108 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
110 *ppobj = NULL;
111 if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
112 return E_NOINTERFACE;
114 hres = This->create_instance(pOuter, &punk);
115 if (SUCCEEDED(hres)) {
116 hres = IUnknown_QueryInterface(punk, riid, ppobj);
117 IUnknown_Release(punk);
119 return hres;
122 static HRESULT WINAPI DSCF_LockServer(IClassFactory *iface, BOOL dolock)
124 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
125 FIXME("(%p)->(%d),stub!\n",This,dolock);
126 return S_OK;
129 static const IClassFactoryVtbl DSCF_Vtbl =
131 DSCF_QueryInterface,
132 DSCF_AddRef,
133 DSCF_Release,
134 DSCF_CreateInstance,
135 DSCF_LockServer
139 /*******************************************************************************
140 * DllGetClassObject [QEDIT.@]
141 * Retrieves class object from a DLL object
143 * PARAMS
144 * rclsid [I] CLSID for the class object
145 * riid [I] Reference to identifier of interface for class object
146 * ppv [O] Address of variable to receive interface pointer for riid
148 * RETURNS
149 * Success: S_OK
150 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
151 * E_UNEXPECTED, E_NOINTERFACE
154 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
156 unsigned int i;
157 IClassFactoryImpl *factory;
159 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
161 if ( !IsEqualGUID( &IID_IClassFactory, riid )
162 && ! IsEqualGUID( &IID_IUnknown, riid) )
163 return E_NOINTERFACE;
165 for (i = 0; i < ARRAY_SIZE(object_creation); i++)
167 if (IsEqualGUID(object_creation[i].clsid, rclsid))
168 break;
171 if (i == ARRAY_SIZE(object_creation))
173 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
174 return CLASS_E_CLASSNOTAVAILABLE;
177 factory = CoTaskMemAlloc(sizeof(*factory));
178 if (factory == NULL) return E_OUTOFMEMORY;
180 factory->IClassFactory_iface.lpVtbl = &DSCF_Vtbl;
181 factory->ref = 1;
183 factory->create_instance = object_creation[i].create_instance;
185 *ppv = &factory->IClassFactory_iface;
186 return S_OK;
189 static const REGPINTYPES reg_null_mt = {&GUID_NULL, &GUID_NULL};
191 static const REGFILTERPINS2 reg_sample_grabber_pins[2] =
194 .cInstances = 1,
195 .nMediaTypes = 1,
196 .lpMediaType = &reg_null_mt,
199 .dwFlags = REG_PINFLAG_B_OUTPUT,
200 .cInstances = 1,
201 .nMediaTypes = 1,
202 .lpMediaType = &reg_null_mt,
206 static const REGFILTER2 reg_sample_grabber =
208 .dwVersion = 2,
209 .dwMerit = MERIT_DO_NOT_USE,
210 .u.s2.cPins2 = 2,
211 .u.s2.rgPins2 = reg_sample_grabber_pins,
214 static const REGFILTERPINS2 reg_null_renderer_pins[1] =
217 .dwFlags = REG_PINFLAG_B_OUTPUT,
218 .cInstances = 1,
219 .nMediaTypes = 1,
220 .lpMediaType = &reg_null_mt,
224 static const REGFILTER2 reg_null_renderer =
226 .dwVersion = 2,
227 .dwMerit = MERIT_DO_NOT_USE,
228 .u.s2.cPins2 = 1,
229 .u.s2.rgPins2 = reg_null_renderer_pins,
232 /***********************************************************************
233 * DllRegisterServer (QEDIT.@)
235 HRESULT WINAPI DllRegisterServer(void)
237 IFilterMapper2 *mapper;
238 HRESULT hr;
240 if (FAILED(hr = __wine_register_resources()))
241 return hr;
243 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
244 &IID_IFilterMapper2, (void **)&mapper)))
245 return hr;
247 IFilterMapper2_RegisterFilter(mapper, &CLSID_SampleGrabber, L"SampleGrabber",
248 NULL, NULL, NULL, &reg_sample_grabber);
249 IFilterMapper2_RegisterFilter(mapper, &CLSID_NullRenderer, L"Null Renderer",
250 NULL, NULL, NULL, &reg_null_renderer);
252 IFilterMapper2_Release(mapper);
253 return S_OK;
256 /***********************************************************************
257 * DllUnregisterServer (QEDIT.@)
259 HRESULT WINAPI DllUnregisterServer(void)
261 IFilterMapper2 *mapper;
262 HRESULT hr;
264 if (FAILED(hr = __wine_unregister_resources()))
265 return hr;
267 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
268 &IID_IFilterMapper2, (void **)&mapper)))
269 return hr;
271 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_SampleGrabber);
272 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_NullRenderer);
274 IFilterMapper2_Release(mapper);
275 return S_OK;