mfplay: Add support for same-thread event callback.
[wine.git] / dlls / wineqtdecoder / main.c
blob8256398919217bd235d2437f4e778d47e8c6b422
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
30 #define WINE_NO_NAMELESS_EXTENSION
32 #include "windef.h"
33 #include "winbase.h"
34 #include "wingdi.h"
35 #include "winerror.h"
36 #include "objbase.h"
37 #include "uuids.h"
38 #include "strmif.h"
39 #include "rpcproxy.h"
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
43 #include "wine/strmbase.h"
45 #include "wineqtdecoder_classes.h"
47 #include "initguid.h"
48 DEFINE_GUID(WINESUBTYPE_QTSplitter, 0xFFFFFFFF, 0x5927, 0x4894, 0xA3,0x86, 0x35,0x94,0x60,0xEE,0x87,0xC9);
50 WINE_DEFAULT_DEBUG_CHANNEL(qtdecoder);
52 extern HRESULT video_decoder_create(IUnknown *outer, IUnknown **out);
53 extern HRESULT qt_splitter_create(IUnknown *outer, IUnknown **out);
55 static const WCHAR wQTVName[] =
56 {'Q','T',' ','V','i','d','e','o',' ','D','e','c','o','d','e','r',0};
57 static const WCHAR wQTDName[] =
58 {'Q','T',' ','V','i','d','e','o',' ','D','e','m','u','x',0};
60 static HINSTANCE wineqtdecoder_instance;
62 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
64 if (reason == DLL_PROCESS_ATTACH)
66 wineqtdecoder_instance = instance;
67 DisableThreadLibraryCalls(instance);
69 return TRUE;
72 struct class_factory
74 IClassFactory IClassFactory_iface;
75 HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
78 static inline struct class_factory *impl_from_IClassFactory(IClassFactory *iface)
80 return CONTAINING_RECORD(iface, struct class_factory, IClassFactory_iface);
83 static HRESULT WINAPI class_factory_QueryInterface(IClassFactory *iface, REFIID iid, void **out)
85 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
87 if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IClassFactory))
89 *out = iface;
90 IClassFactory_AddRef(iface);
91 return S_OK;
94 *out = NULL;
95 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
96 return E_NOINTERFACE;
99 static ULONG WINAPI class_factory_AddRef(IClassFactory *iface)
101 return 2;
104 static ULONG WINAPI class_factory_Release(IClassFactory *iface)
106 return 1;
109 static HRESULT WINAPI class_factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID iid, void **out)
111 struct class_factory *factory = impl_from_IClassFactory(iface);
112 IUnknown *unk;
113 HRESULT hr;
115 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
117 if (outer && !IsEqualGUID(iid, &IID_IUnknown))
118 return E_NOINTERFACE;
120 *out = NULL;
121 if (SUCCEEDED(hr = factory->create_instance(outer, &unk)))
123 hr = IUnknown_QueryInterface(unk, iid, out);
124 IUnknown_Release(unk);
126 return hr;
129 static HRESULT WINAPI class_factory_LockServer(IClassFactory *iface, BOOL lock)
131 TRACE("iface %p, lock %d.\n", iface, lock);
132 return S_OK;
135 static const IClassFactoryVtbl class_factory_vtbl =
137 class_factory_QueryInterface,
138 class_factory_AddRef,
139 class_factory_Release,
140 class_factory_CreateInstance,
141 class_factory_LockServer,
144 static struct class_factory qt_splitter_cf = {{&class_factory_vtbl}, qt_splitter_create};
145 static struct class_factory video_decoder_cf = {{&class_factory_vtbl}, video_decoder_create};
147 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out)
149 struct class_factory *factory;
151 TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid), debugstr_guid(iid), out);
153 if (IsEqualGUID(clsid, &CLSID_QTSplitter))
154 factory = &qt_splitter_cf;
155 else if (IsEqualGUID(clsid, &CLSID_QTVDecoder))
156 factory = &video_decoder_cf;
157 else
159 FIXME("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid));
160 return CLASS_E_CLASSNOTAVAILABLE;
163 return IClassFactory_QueryInterface(&factory->IClassFactory_iface, iid, out);
166 static const REGPINTYPES reg_audio_mt = {&MEDIATYPE_Audio, &GUID_NULL};
167 static const REGPINTYPES reg_stream_mt = {&MEDIATYPE_Stream, &GUID_NULL};
168 static const REGPINTYPES reg_video_mt = {&MEDIATYPE_Video, &GUID_NULL};
170 static const REGFILTERPINS2 reg_qt_splitter_pins[3] =
173 .nMediaTypes = 1,
174 .lpMediaType = &reg_stream_mt,
177 .dwFlags = REG_PINFLAG_B_OUTPUT | REG_PINFLAG_B_ZERO,
178 .nMediaTypes = 1,
179 .lpMediaType = &reg_audio_mt,
182 .dwFlags = REG_PINFLAG_B_OUTPUT | REG_PINFLAG_B_ZERO,
183 .nMediaTypes = 1,
184 .lpMediaType = &reg_video_mt,
188 static const REGFILTER2 reg_qt_splitter =
190 .dwVersion = 2,
191 .dwMerit = MERIT_NORMAL - 1,
192 .u.s2.cPins2 = 3,
193 .u.s2.rgPins2 = reg_qt_splitter_pins,
196 static const REGFILTERPINS2 reg_video_decoder_pins[2] =
199 .nMediaTypes = 1,
200 .lpMediaType = &reg_video_mt,
203 .dwFlags = REG_PINFLAG_B_OUTPUT,
204 .nMediaTypes = 1,
205 .lpMediaType = &reg_video_mt,
209 static const REGFILTER2 reg_video_decoder =
211 .dwVersion = 2,
212 .dwMerit = MERIT_NORMAL - 1,
213 .u.s2.cPins2 = 2,
214 .u.s2.rgPins2 = reg_video_decoder_pins,
217 HRESULT WINAPI DllRegisterServer(void)
219 IFilterMapper2 *mapper;
220 HRESULT hr;
222 TRACE(".\n");
224 if (FAILED(hr = __wine_register_resources(wineqtdecoder_instance)))
225 return hr;
227 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
228 &IID_IFilterMapper2, (void **)&mapper)))
229 return hr;
231 IFilterMapper2_RegisterFilter(mapper, &CLSID_QTSplitter, wQTDName, NULL, NULL, NULL, &reg_qt_splitter);
232 IFilterMapper2_RegisterFilter(mapper, &CLSID_QTVDecoder, wQTVName, NULL, NULL, NULL, &reg_video_decoder);
234 IFilterMapper2_Release(mapper);
235 return S_OK;
238 HRESULT WINAPI DllUnregisterServer(void)
240 IFilterMapper2 *mapper;
241 HRESULT hr;
243 TRACE(".\n");
245 if (FAILED(hr = __wine_unregister_resources(wineqtdecoder_instance)))
246 return hr;
248 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
249 &IID_IFilterMapper2, (void **)&mapper)))
250 return hr;
252 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_QTSplitter);
253 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_QTVDecoder);
255 IFilterMapper2_Release(mapper);
256 return S_OK;
259 HRESULT WINAPI DllCanUnloadNow(void)
261 TRACE(".\n");
262 return S_FALSE;