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
;
34 IClassFactory IClassFactory_iface
;
35 HRESULT (*create_instance
)(IUnknown
*outer
, IUnknown
**out
);
38 static inline struct class_factory
*impl_from_IClassFactory(IClassFactory
*iface
)
40 return CONTAINING_RECORD(iface
, struct class_factory
, IClassFactory_iface
);
43 static HRESULT WINAPI
class_factory_QueryInterface(IClassFactory
*iface
, REFIID iid
, void **out
)
45 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
47 if (IsEqualGUID(iid
, &IID_IUnknown
) || IsEqualGUID(iid
, &IID_IClassFactory
))
50 IClassFactory_AddRef(iface
);
55 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
59 static ULONG WINAPI
class_factory_AddRef(IClassFactory
*iface
)
64 static ULONG WINAPI
class_factory_Release(IClassFactory
*iface
)
69 static HRESULT WINAPI
class_factory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID iid
, void **out
)
71 struct class_factory
*factory
= impl_from_IClassFactory(iface
);
75 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface
, outer
, debugstr_guid(iid
), out
);
77 if (outer
&& !IsEqualGUID(iid
, &IID_IUnknown
))
81 if (SUCCEEDED(hr
= factory
->create_instance(outer
, &unk
)))
83 hr
= IUnknown_QueryInterface(unk
, iid
, out
);
84 IUnknown_Release(unk
);
89 static HRESULT WINAPI
class_factory_LockServer(IClassFactory
*iface
, BOOL lock
)
91 TRACE("iface %p, lock %d.\n", iface
, lock
);
95 static const IClassFactoryVtbl class_factory_vtbl
=
97 class_factory_QueryInterface
,
99 class_factory_Release
,
100 class_factory_CreateInstance
,
101 class_factory_LockServer
,
104 static struct class_factory audio_record_cf
= {{&class_factory_vtbl
}, audio_record_create
};
105 static struct class_factory avi_compressor_cf
= {{&class_factory_vtbl
}, avi_compressor_create
};
106 static struct class_factory avi_mux_cf
= {{&class_factory_vtbl
}, avi_mux_create
};
107 static struct class_factory capture_graph_cf
= {{&class_factory_vtbl
}, capture_graph_create
};
108 static struct class_factory file_writer_cf
= {{&class_factory_vtbl
}, file_writer_create
};
109 static struct class_factory smart_tee_cf
= {{&class_factory_vtbl
}, smart_tee_create
};
110 static struct class_factory vfw_capture_cf
= {{&class_factory_vtbl
}, vfw_capture_create
};
112 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, void *reserved
)
114 if (reason
== DLL_PROCESS_ATTACH
)
116 qcap_instance
= instance
;
117 DisableThreadLibraryCalls(instance
);
122 HRESULT WINAPI
DllGetClassObject(REFCLSID clsid
, REFIID iid
, void **out
)
124 struct class_factory
*factory
;
126 TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid
), debugstr_guid(iid
), out
);
128 if (IsEqualGUID(clsid
, &CLSID_AudioRecord
))
129 factory
= &audio_record_cf
;
130 else if (IsEqualGUID(clsid
, &CLSID_AVICo
))
131 factory
= &avi_compressor_cf
;
132 else if (IsEqualGUID(clsid
, &CLSID_AviDest
))
133 factory
= &avi_mux_cf
;
134 else if (IsEqualGUID(clsid
, &CLSID_CaptureGraphBuilder
))
135 factory
= &capture_graph_cf
;
136 else if (IsEqualGUID(clsid
, &CLSID_CaptureGraphBuilder2
))
137 factory
= &capture_graph_cf
;
138 else if (IsEqualGUID(clsid
, &CLSID_FileWriter
))
139 factory
= &file_writer_cf
;
140 else if (IsEqualGUID(clsid
, &CLSID_SmartTee
))
141 factory
= &smart_tee_cf
;
142 else if (IsEqualGUID(clsid
, &CLSID_VfwCapture
))
143 factory
= &vfw_capture_cf
;
146 FIXME("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid
));
147 return CLASS_E_CLASSNOTAVAILABLE
;
150 return IClassFactory_QueryInterface(&factory
->IClassFactory_iface
, iid
, out
);
153 static const REGPINTYPES reg_avi_mux_sink_mt
= {&MEDIATYPE_Stream
, &MEDIASUBTYPE_Avi
};
155 static const REGFILTERPINS2 reg_avi_mux_pins
[1] =
160 .lpMediaType
= ®_avi_mux_sink_mt
,
164 static const REGFILTER2 reg_avi_mux
=
167 .dwMerit
= MERIT_DO_NOT_USE
,
169 .u
.s2
.rgPins2
= reg_avi_mux_pins
,
172 static const REGPINTYPES reg_video_mt
= {&MEDIATYPE_Video
, &GUID_NULL
};
174 static const REGFILTERPINS2 reg_smart_tee_pins
[3] =
179 .lpMediaType
= ®_video_mt
,
182 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
185 .lpMediaType
= ®_video_mt
,
188 .dwFlags
= REG_PINFLAG_B_OUTPUT
,
191 .lpMediaType
= ®_video_mt
,
195 static const REGFILTER2 reg_smart_tee
=
198 .dwMerit
= MERIT_DO_NOT_USE
,
200 .u
.s2
.rgPins2
= reg_smart_tee_pins
,
203 static const REGPINTYPES reg_file_writer_sink_mt
= {&GUID_NULL
, &GUID_NULL
};
205 static const REGFILTERPINS2 reg_file_writer_pins
[1] =
210 .lpMediaType
= ®_file_writer_sink_mt
,
214 static const REGFILTER2 reg_file_writer
=
217 .dwMerit
= MERIT_DO_NOT_USE
,
219 .u
.s2
.rgPins2
= reg_file_writer_pins
,
222 /***********************************************************************
223 * DllRegisterServer (QCAP.@)
225 HRESULT WINAPI
DllRegisterServer(void)
227 IFilterMapper2
*mapper
;
230 if (FAILED(hr
= __wine_register_resources()))
233 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
234 &IID_IFilterMapper2
, (void **)&mapper
)))
237 IFilterMapper2_RegisterFilter(mapper
, &CLSID_AviDest
, L
"AVI Mux",
238 NULL
, NULL
, NULL
, ®_avi_mux
);
239 IFilterMapper2_RegisterFilter(mapper
, &CLSID_FileWriter
, L
"File writer",
240 NULL
, NULL
, NULL
, ®_file_writer
);
241 IFilterMapper2_RegisterFilter(mapper
, &CLSID_SmartTee
, L
"Smart Tee",
242 NULL
, NULL
, NULL
, ®_smart_tee
);
244 IFilterMapper2_Release(mapper
);
248 /***********************************************************************
249 * DllUnregisterServer (QCAP.@)
251 HRESULT WINAPI
DllUnregisterServer(void)
253 IFilterMapper2
*mapper
;
256 if (FAILED(hr
= __wine_unregister_resources()))
259 if (FAILED(hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
,
260 &IID_IFilterMapper2
, (void **)&mapper
)))
263 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_AviDest
);
264 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_FileWriter
);
265 IFilterMapper2_UnregisterFilter(mapper
, NULL
, NULL
, &CLSID_SmartTee
);
267 IFilterMapper2_Release(mapper
);