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"
28 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
30 HINSTANCE qcap_instance
;
32 static LONG objects_ref
= 0;
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
))
52 IClassFactory_AddRef(iface
);
57 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
61 static ULONG WINAPI
class_factory_AddRef(IClassFactory
*iface
)
66 static ULONG WINAPI
class_factory_Release(IClassFactory
*iface
)
71 static HRESULT WINAPI
class_factory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID iid
, void **out
)
73 struct class_factory
*factory
= impl_from_IClassFactory(iface
);
77 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface
, outer
, debugstr_guid(iid
), out
);
79 if (outer
&& !IsEqualGUID(iid
, &IID_IUnknown
))
83 if (SUCCEEDED(hr
= factory
->create_instance(outer
, &unk
)))
85 hr
= IUnknown_QueryInterface(unk
, iid
, out
);
86 IUnknown_Release(unk
);
91 static HRESULT WINAPI
class_factory_LockServer(IClassFactory
*iface
, BOOL lock
)
93 TRACE("iface %p, lock %d.\n", iface
, lock
);
96 InterlockedIncrement(&objects_ref
);
98 InterlockedDecrement(&objects_ref
);
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
);
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
;
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] =
167 .lpMediaType
= ®_avi_mux_sink_mt
,
171 static const REGFILTER2 reg_avi_mux
=
174 .dwMerit
= MERIT_DO_NOT_USE
,
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] =
186 .lpMediaType
= ®_video_mt
,
189 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
192 .lpMediaType
= ®_video_mt
,
195 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
198 .lpMediaType
= ®_video_mt
,
202 static const REGFILTER2 reg_smart_tee
=
205 .dwMerit
= MERIT_DO_NOT_USE
,
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] =
217 .lpMediaType
= ®_file_writer_sink_mt
,
221 static const REGFILTER2 reg_file_writer
=
224 .dwMerit
= MERIT_DO_NOT_USE
,
226 .u
.s2
.rgPins2
= reg_file_writer_pins
,
229 /***********************************************************************
230 * DllRegisterServer (QCAP.@)
232 HRESULT WINAPI
DllRegisterServer(void)
234 IFilterMapper2
*mapper
;
237 if (FAILED(hr
= __wine_register_resources()))
240 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
241 &IID_IFilterMapper2
, (void **)&mapper
)))
244 IFilterMapper2_RegisterFilter(mapper
, &CLSID_AviDest
, L
"AVI Mux",
245 NULL
, NULL
, NULL
, ®_avi_mux
);
246 IFilterMapper2_RegisterFilter(mapper
, &CLSID_FileWriter
, L
"File writer",
247 NULL
, NULL
, NULL
, ®_file_writer
);
248 IFilterMapper2_RegisterFilter(mapper
, &CLSID_SmartTee
, L
"Smart Tee",
249 NULL
, NULL
, NULL
, ®_smart_tee
);
251 IFilterMapper2_Release(mapper
);
255 /***********************************************************************
256 * DllUnregisterServer (QCAP.@)
258 HRESULT WINAPI
DllUnregisterServer(void)
260 IFilterMapper2
*mapper
;
263 if (FAILED(hr
= __wine_unregister_resources()))
266 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
267 &IID_IFilterMapper2
, (void **)&mapper
)))
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
);
278 /***********************************************************************
279 * DllCanUnloadNow (QCAP.@)
281 HRESULT WINAPI
DllCanUnloadNow(void)
285 return objects_ref
? S_FALSE
: S_OK
;
288 DWORD
ObjectRefCount(BOOL increment
)
291 return InterlockedIncrement(&objects_ref
);
292 return InterlockedDecrement(&objects_ref
);