gdi32: Use NtGdiExcludeClipRect for ExcludeClipRect implementation.
[wine.git] / dlls / qcap / qcap_main.c
blobac7ac6a26aa6c0c58de3b5c736a61b60da3931fb
1 /*
2 * DirectShow capture
4 * Copyright (C) 2003 Dominik Strasser
5 * Copyright (C) 2005 Rolf Kalbermatter
6 * Copyright (C) 2019 Zebediah Figura
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define WINE_NO_NAMELESS_EXTENSION
25 #include "qcap_private.h"
26 #include "rpcproxy.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
30 HINSTANCE qcap_instance;
32 static LONG objects_ref = 0;
34 struct class_factory
36 IClassFactory IClassFactory_iface;
37 HRESULT (*create_instance)(IUnknown *outer, IUnknown **out);
40 static inline struct class_factory *impl_from_IClassFactory(IClassFactory *iface)
42 return CONTAINING_RECORD(iface, struct class_factory, IClassFactory_iface);
45 static HRESULT WINAPI class_factory_QueryInterface(IClassFactory *iface, REFIID iid, void **out)
47 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
49 if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IClassFactory))
51 *out = iface;
52 IClassFactory_AddRef(iface);
53 return S_OK;
56 *out = NULL;
57 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
58 return E_NOINTERFACE;
61 static ULONG WINAPI class_factory_AddRef(IClassFactory *iface)
63 return 2;
66 static ULONG WINAPI class_factory_Release(IClassFactory *iface)
68 return 1;
71 static HRESULT WINAPI class_factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID iid, void **out)
73 struct class_factory *factory = impl_from_IClassFactory(iface);
74 IUnknown *unk;
75 HRESULT hr;
77 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
79 if (outer && !IsEqualGUID(iid, &IID_IUnknown))
80 return E_NOINTERFACE;
82 *out = NULL;
83 if (SUCCEEDED(hr = factory->create_instance(outer, &unk)))
85 hr = IUnknown_QueryInterface(unk, iid, out);
86 IUnknown_Release(unk);
88 return hr;
91 static HRESULT WINAPI class_factory_LockServer(IClassFactory *iface, BOOL lock)
93 TRACE("iface %p, lock %d.\n", iface, lock);
95 if (lock)
96 InterlockedIncrement(&objects_ref);
97 else
98 InterlockedDecrement(&objects_ref);
99 return S_OK;
102 static const IClassFactoryVtbl class_factory_vtbl =
104 class_factory_QueryInterface,
105 class_factory_AddRef,
106 class_factory_Release,
107 class_factory_CreateInstance,
108 class_factory_LockServer,
111 static struct class_factory audio_record_cf = {{&class_factory_vtbl}, audio_record_create};
112 static struct class_factory avi_compressor_cf = {{&class_factory_vtbl}, avi_compressor_create};
113 static struct class_factory avi_mux_cf = {{&class_factory_vtbl}, avi_mux_create};
114 static struct class_factory capture_graph_cf = {{&class_factory_vtbl}, capture_graph_create};
115 static struct class_factory file_writer_cf = {{&class_factory_vtbl}, file_writer_create};
116 static struct class_factory smart_tee_cf = {{&class_factory_vtbl}, smart_tee_create};
117 static struct class_factory vfw_capture_cf = {{&class_factory_vtbl}, vfw_capture_create};
119 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
121 if (reason == DLL_PROCESS_ATTACH)
123 qcap_instance = instance;
124 DisableThreadLibraryCalls(instance);
126 return TRUE;
129 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out)
131 struct class_factory *factory;
133 TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid), debugstr_guid(iid), out);
135 if (IsEqualGUID(clsid, &CLSID_AudioRecord))
136 factory = &audio_record_cf;
137 else if (IsEqualGUID(clsid, &CLSID_AVICo))
138 factory = &avi_compressor_cf;
139 else if (IsEqualGUID(clsid, &CLSID_AviDest))
140 factory = &avi_mux_cf;
141 else if (IsEqualGUID(clsid, &CLSID_CaptureGraphBuilder))
142 factory = &capture_graph_cf;
143 else if (IsEqualGUID(clsid, &CLSID_CaptureGraphBuilder2))
144 factory = &capture_graph_cf;
145 else if (IsEqualGUID(clsid, &CLSID_FileWriter))
146 factory = &file_writer_cf;
147 else if (IsEqualGUID(clsid, &CLSID_SmartTee))
148 factory = &smart_tee_cf;
149 else if (IsEqualGUID(clsid, &CLSID_VfwCapture))
150 factory = &vfw_capture_cf;
151 else
153 FIXME("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid));
154 return CLASS_E_CLASSNOTAVAILABLE;
157 return IClassFactory_QueryInterface(&factory->IClassFactory_iface, iid, out);
160 static const REGPINTYPES reg_avi_mux_sink_mt = {&MEDIATYPE_Stream, &MEDIASUBTYPE_Avi};
162 static const REGFILTERPINS2 reg_avi_mux_pins[1] =
165 .cInstances = 1,
166 .nMediaTypes = 1,
167 .lpMediaType = &reg_avi_mux_sink_mt,
171 static const REGFILTER2 reg_avi_mux =
173 .dwVersion = 2,
174 .dwMerit = MERIT_DO_NOT_USE,
175 .u.s2.cPins2 = 1,
176 .u.s2.rgPins2 = reg_avi_mux_pins,
179 static const REGPINTYPES reg_video_mt = {&MEDIATYPE_Video, &GUID_NULL};
181 static const REGFILTERPINS2 reg_smart_tee_pins[3] =
184 .cInstances = 1,
185 .nMediaTypes = 1,
186 .lpMediaType = &reg_video_mt,
189 .dwFlags = REG_PINFLAG_B_OUTPUT,
190 .cInstances = 1,
191 .nMediaTypes = 1,
192 .lpMediaType = &reg_video_mt,
195 .dwFlags = REG_PINFLAG_B_OUTPUT,
196 .cInstances = 1,
197 .nMediaTypes = 1,
198 .lpMediaType = &reg_video_mt,
202 static const REGFILTER2 reg_smart_tee =
204 .dwVersion = 2,
205 .dwMerit = MERIT_DO_NOT_USE,
206 .u.s2.cPins2 = 3,
207 .u.s2.rgPins2 = reg_smart_tee_pins,
210 static const REGPINTYPES reg_file_writer_sink_mt = {&GUID_NULL, &GUID_NULL};
212 static const REGFILTERPINS2 reg_file_writer_pins[1] =
215 .cInstances = 1,
216 .nMediaTypes = 1,
217 .lpMediaType = &reg_file_writer_sink_mt,
221 static const REGFILTER2 reg_file_writer =
223 .dwVersion = 2,
224 .dwMerit = MERIT_DO_NOT_USE,
225 .u.s2.cPins2 = 1,
226 .u.s2.rgPins2 = reg_file_writer_pins,
229 /***********************************************************************
230 * DllRegisterServer (QCAP.@)
232 HRESULT WINAPI DllRegisterServer(void)
234 IFilterMapper2 *mapper;
235 HRESULT hr;
237 if (FAILED(hr = __wine_register_resources()))
238 return hr;
240 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
241 &IID_IFilterMapper2, (void **)&mapper)))
242 return hr;
244 IFilterMapper2_RegisterFilter(mapper, &CLSID_AviDest, L"AVI Mux",
245 NULL, NULL, NULL, &reg_avi_mux);
246 IFilterMapper2_RegisterFilter(mapper, &CLSID_FileWriter, L"File writer",
247 NULL, NULL, NULL, &reg_file_writer);
248 IFilterMapper2_RegisterFilter(mapper, &CLSID_SmartTee, L"Smart Tee",
249 NULL, NULL, NULL, &reg_smart_tee);
251 IFilterMapper2_Release(mapper);
252 return S_OK;
255 /***********************************************************************
256 * DllUnregisterServer (QCAP.@)
258 HRESULT WINAPI DllUnregisterServer(void)
260 IFilterMapper2 *mapper;
261 HRESULT hr;
263 if (FAILED(hr = __wine_unregister_resources()))
264 return hr;
266 if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
267 &IID_IFilterMapper2, (void **)&mapper)))
268 return hr;
270 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_AviDest);
271 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_FileWriter);
272 IFilterMapper2_UnregisterFilter(mapper, NULL, NULL, &CLSID_SmartTee);
274 IFilterMapper2_Release(mapper);
275 return S_OK;
278 /***********************************************************************
279 * DllCanUnloadNow (QCAP.@)
281 HRESULT WINAPI DllCanUnloadNow(void)
283 TRACE(".\n");
285 return objects_ref ? S_FALSE : S_OK;
288 DWORD ObjectRefCount(BOOL increment)
290 if (increment)
291 return InterlockedIncrement(&objects_ref);
292 return InterlockedDecrement(&objects_ref);