taskmgr: Shell32 is imported, no need to load it again.
[wine.git] / dlls / wineqtdecoder / main.c
blob435951ba933d4c9721d61e3783436516013df819
1 /*
2 * DirectShow filter for QuickTime Toolkit on Mac OS X
4 * Copyright (C) 2010 Aric Stewart, CodeWeavers
5 * Copyright (C) 2019 Zebediah Figura
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
23 #include <assert.h>
24 #include <stdio.h>
25 #include <stdarg.h>
27 #define COBJMACROS
28 #define NONAMELESSSTRUCT
29 #define NONAMELESSUNION
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wingdi.h"
34 #include "winerror.h"
35 #include "objbase.h"
36 #include "uuids.h"
37 #include "strmif.h"
38 #include "rpcproxy.h"
40 #include "wine/unicode.h"
41 #include "wine/debug.h"
42 #include "wine/strmbase.h"
44 #include "wineqtdecoder_classes.h"
46 #include "initguid.h"
47 DEFINE_GUID(WINESUBTYPE_QTSplitter, 0xFFFFFFFF, 0x5927, 0x4894, 0xA3,0x86, 0x35,0x94,0x60,0xEE,0x87,0xC9);
49 WINE_DEFAULT_DEBUG_CHANNEL(qtdecoder);
51 extern HRESULT video_decoder_create(IUnknown *outer, IUnknown **out);
52 extern HRESULT qt_splitter_create(IUnknown *outer, IUnknown **out);
54 static const WCHAR wQTVName[] =
55 {'Q','T',' ','V','i','d','e','o',' ','D','e','c','o','d','e','r',0};
56 static const WCHAR wQTDName[] =
57 {'Q','T',' ','V','i','d','e','o',' ','D','e','m','u','x',0};
59 static HINSTANCE wineqtdecoder_instance;
61 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
63 if (reason == DLL_PROCESS_ATTACH)
65 wineqtdecoder_instance = instance;
66 DisableThreadLibraryCalls(instance);
68 return TRUE;
71 struct class_factory
73 IClassFactory IClassFactory_iface;
74 HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
77 static inline struct class_factory *impl_from_IClassFactory(IClassFactory *iface)
79 return CONTAINING_RECORD(iface, struct class_factory, IClassFactory_iface);
82 static HRESULT WINAPI class_factory_QueryInterface(IClassFactory *iface, REFIID iid, void **out)
84 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
86 if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IClassFactory))
88 *out = iface;
89 IClassFactory_AddRef(iface);
90 return S_OK;
93 *out = NULL;
94 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
95 return E_NOINTERFACE;
98 static ULONG WINAPI class_factory_AddRef(IClassFactory *iface)
100 return 2;
103 static ULONG WINAPI class_factory_Release(IClassFactory *iface)
105 return 1;
108 static HRESULT WINAPI class_factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID iid, void **out)
110 struct class_factory *factory = impl_from_IClassFactory(iface);
111 IUnknown *unk;
112 HRESULT hr;
114 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
116 if (outer && !IsEqualGUID(iid, &IID_IUnknown))
117 return E_NOINTERFACE;
119 *out = NULL;
120 if (SUCCEEDED(hr = factory->create_instance(outer, &unk)))
122 hr = IUnknown_QueryInterface(unk, iid, out);
123 IUnknown_Release(unk);
125 return hr;
128 static HRESULT WINAPI class_factory_LockServer(IClassFactory *iface, BOOL lock)
130 TRACE("iface %p, lock %d.\n", iface, lock);
131 return S_OK;
134 static const IClassFactoryVtbl class_factory_vtbl =
136 class_factory_QueryInterface,
137 class_factory_AddRef,
138 class_factory_Release,
139 class_factory_CreateInstance,
140 class_factory_LockServer,
143 static struct class_factory qt_splitter_cf = {{&class_factory_vtbl}, qt_splitter_create};
144 static struct class_factory video_decoder_cf = {{&class_factory_vtbl}, video_decoder_create};
146 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out)
148 struct class_factory *factory;
150 TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid), debugstr_guid(iid), out);
152 if (IsEqualGUID(clsid, &CLSID_QTSplitter))
153 factory = &qt_splitter_cf;
154 else if (IsEqualGUID(clsid, &CLSID_QTVDecoder))
155 factory = &video_decoder_cf;
156 else
158 FIXME("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid));
159 return CLASS_E_CLASSNOTAVAILABLE;
162 return IClassFactory_QueryInterface(&factory->IClassFactory_iface, iid, out);
165 static const REGPINTYPES reg_audio_mt = {&MEDIATYPE_Audio, &GUID_NULL};
166 static const REGPINTYPES reg_stream_mt = {&MEDIATYPE_Stream, &GUID_NULL};
167 static const REGPINTYPES reg_video_mt = {&MEDIATYPE_Video, &GUID_NULL};
169 static const REGFILTERPINS2 reg_qt_splitter_pins[3] =
172 .nMediaTypes = 1,
173 .lpMediaType = &reg_stream_mt,
176 .dwFlags = REG_PINFLAG_B_OUTPUT | REG_PINFLAG_B_ZERO,
177 .nMediaTypes = 1,
178 .lpMediaType = &reg_audio_mt,
181 .dwFlags = REG_PINFLAG_B_OUTPUT | REG_PINFLAG_B_ZERO,
182 .nMediaTypes = 1,
183 .lpMediaType = &reg_video_mt,
187 static const REGFILTER2 reg_qt_splitter =
189 .dwVersion = 2,
190 .dwMerit = MERIT_NORMAL - 1,
191 .u.s2.cPins2 = 3,
192 .u.s2.rgPins2 = reg_qt_splitter_pins,
195 static const REGFILTERPINS2 reg_video_decoder_pins[2] =
198 .nMediaTypes = 1,
199 .lpMediaType = &reg_video_mt,
202 .dwFlags = REG_PINFLAG_B_OUTPUT,
203 .nMediaTypes = 1,
204 .lpMediaType = &reg_video_mt,
208 static const REGFILTER2 reg_video_decoder =
210 .dwVersion = 2,
211 .dwMerit = MERIT_NORMAL - 1,
212 .u.s2.cPins2 = 2,
213 .u.s2.rgPins2 = reg_video_decoder_pins,
216 HRESULT WINAPI DllRegisterServer(void)
218 IFilterMapper2 *mapper;
219 HRESULT hr;
221 TRACE(".\n");
223 if (FAILED(hr = __wine_register_resources(wineqtdecoder_instance)))
224 return hr;
226 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
227 &IID_IFilterMapper2, (void **)&mapper)))
228 return hr;
230 IFilterMapper2_RegisterFilter(mapper, &CLSID_QTSplitter, wQTDName, NULL, NULL, NULL, &reg_qt_splitter);
231 IFilterMapper2_RegisterFilter(mapper, &CLSID_QTVDecoder, wQTVName, NULL, NULL, NULL, &reg_video_decoder);
233 IFilterMapper2_Release(mapper);
234 return S_OK;
237 HRESULT WINAPI DllUnregisterServer(void)
239 IFilterMapper2 *mapper;
240 HRESULT hr;
242 TRACE(".\n");
244 if (FAILED(hr = __wine_unregister_resources(wineqtdecoder_instance)))
245 return hr;
247 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
248 &IID_IFilterMapper2, (void **)&mapper)))
249 return hr;
251 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_QTSplitter);
252 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_QTVDecoder);
254 IFilterMapper2_Release(mapper);
255 return S_OK;
258 HRESULT WINAPI DllCanUnloadNow(void)
260 TRACE(".\n");
261 return S_FALSE;