ReactOS 0.4.15-dev-8191-gbc6c731
audiorecord.c
Go to the documentation of this file.
1/* Implementation of the Audio Capture Filter (CLSID_AudioRecord)
2 *
3 * Copyright 2015 Damjan Jovanovic
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include <stdarg.h>
21
22#define COBJMACROS
23
24#include "windef.h"
25#include "winbase.h"
26#include "wtypes.h"
27#include "wingdi.h"
28#include "winuser.h"
29#include "dshow.h"
30
31#include "qcap_main.h"
32
33#include "wine/debug.h"
34
36
37typedef struct {
44
46{
47 return CONTAINING_RECORD(iface, AudioRecord, IUnknown_iface);
48}
49
51{
53}
54
56{
57 BaseFilter *filter = CONTAINING_RECORD(iface, BaseFilter, IBaseFilter_iface);
59}
60
62{
63 return CONTAINING_RECORD(iface, AudioRecord, IPersistPropertyBag_iface);
64}
65
67{
70 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
71 *ppv = &This->filter.IBaseFilter_iface;
72 } else if (IsEqualIID(riid, &IID_IPersist)) {
73 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppv);
74 *ppv = &This->filter.IBaseFilter_iface;
75 } else if (IsEqualIID(riid, &IID_IMediaFilter)) {
76 TRACE("(%p)->(IID_IMediaFilter, %p)\n", This, ppv);
77 *ppv = &This->filter.IBaseFilter_iface;
78 } else if (IsEqualIID(riid, &IID_IBaseFilter)) {
79 TRACE("(%p)->(IID_IBaseFilter, %p)\n", This, ppv);
80 *ppv = &This->filter.IBaseFilter_iface;
82 TRACE("(%p)->(IID_IPersistPropertyBag, %p)\n", This, ppv);
83 *ppv = &This->IPersistPropertyBag_iface;
84 } else {
85 FIXME("(%p): no interface for %s\n", This, debugstr_guid(riid));
86 *ppv = NULL;
87 return E_NOINTERFACE;
88 }
89 IUnknown_AddRef((IUnknown*)*ppv);
90 return S_OK;
91}
92
94{
96 return BaseFilterImpl_AddRef(&This->filter.IBaseFilter_iface);
97}
98
100{
102 ULONG ref = BaseFilterImpl_Release(&This->filter.IBaseFilter_iface);
103 TRACE("(%p/%p)->() ref=%d\n", iface, This, ref);
104 if (!ref) {
106 }
107 return ref;
108}
109
110static const IUnknownVtbl UnknownVtbl = {
114};
115
117{
119 return IUnknown_QueryInterface(This->outerUnknown, riid, ppv);
120}
121
123{
125 return IUnknown_AddRef(This->outerUnknown);
126}
127
129{
131 return IUnknown_Release(This->outerUnknown);
132}
133
135{
137 FIXME("(%p): stub\n", This);
138 return E_NOTIMPL;
139}
140
142{
144 FIXME("(%p): stub\n", This);
145 return E_NOTIMPL;
146}
147
149{
151 FIXME("(%p, %s): stub\n", This, wine_dbgstr_longlong(tStart));
152 return E_NOTIMPL;
153}
154
156{
158 FIXME("(%p)->(%s, %p): stub\n", This, debugstr_w(Id), ppPin);
159 return E_NOTIMPL;
160}
161
162static const IBaseFilterVtbl AudioRecordVtbl = {
178};
179
181{
183 FIXME("(%p, %d): stub\n", This, pos);
184 return NULL;
185}
186
188{
190 FIXME("(%p): stub\n", This);
191 return 0;
192}
193
197};
198
200{
202 return IUnknown_QueryInterface(This->outerUnknown, riid, ppv);
203}
204
206{
208 return IUnknown_AddRef(This->outerUnknown);
209}
210
212{
214 return IUnknown_Release(This->outerUnknown);
215}
216
218{
220 TRACE("(%p/%p)->(%p)\n", iface, This, pClassID);
221 return IBaseFilter_GetClassID(&This->filter.IBaseFilter_iface, pClassID);
222}
223
225{
227 FIXME("(%p/%p)->(): stub\n", iface, This);
228 return E_NOTIMPL;
229}
230
232 IErrorLog *pErrorLog)
233{
235 HRESULT hr;
236 VARIANT var;
237 static const WCHAR WaveInIDW[] = {'W','a','v','e','I','n','I','D',0};
238
239 TRACE("(%p/%p)->(%p, %p)\n", iface, This, pPropBag, pErrorLog);
240
241 V_VT(&var) = VT_I4;
242 hr = IPropertyBag_Read(pPropBag, WaveInIDW, &var, pErrorLog);
243 if (SUCCEEDED(hr))
244 {
245 FIXME("FIXME: implement opening waveIn device %d\n", V_I4(&var));
246 }
247
248 return hr;
249}
250
252 BOOL fClearDirty, BOOL fSaveAllProperties)
253{
255 FIXME("(%p/%p)->(%p, %u, %u): stub\n", iface, This, pPropBag, fClearDirty, fSaveAllProperties);
256 return E_NOTIMPL;
257}
258
259static const IPersistPropertyBagVtbl PersistPropertyBagVtbl =
260{
266 PPB_Load,
268};
269
271{
272 HRESULT hr;
274
275 FIXME("(%p, %p): the entire CLSID_AudioRecord implementation is just stubs\n", outer, phr);
276
277 This = CoTaskMemAlloc(sizeof(*This));
278 if (This == NULL) {
280 goto end;
281 }
282 memset(This, 0, sizeof(*This));
283 This->IUnknown_iface.lpVtbl = &UnknownVtbl;
284 This->IPersistPropertyBag_iface.lpVtbl = &PersistPropertyBagVtbl;
285 if (outer)
286 This->outerUnknown = outer;
287 else
288 This->outerUnknown = &This->IUnknown_iface;
289
290 hr = BaseFilter_Init(&This->filter, &AudioRecordVtbl, &CLSID_AudioRecord,
291 (DWORD_PTR)(__FILE__ ": AudioRecord.csFilter"), &AudioRecordFuncs);
292
293end:
294 *phr = hr;
295 if (SUCCEEDED(hr)) {
296 return (IUnknown*)&This->filter.IBaseFilter_iface;
297 } else {
298 if (This)
299 IBaseFilter_Release(&This->filter.IBaseFilter_iface);
300 return NULL;
301 }
302}
DWORD Id
IUnknown *WINAPI QCAP_createAudioCaptureFilter(IUnknown *outer, HRESULT *phr)
Definition: audiorecord.c:270
static HRESULT WINAPI AudioRecord_Run(IBaseFilter *iface, REFERENCE_TIME tStart)
Definition: audiorecord.c:148
static HRESULT WINAPI PPB_InitNew(IPersistPropertyBag *iface)
Definition: audiorecord.c:224
static ULONG WINAPI AudioRecord_AddRef(IBaseFilter *iface)
Definition: audiorecord.c:122
static AudioRecord * impl_from_IUnknown(IUnknown *iface)
Definition: audiorecord.c:45
static LONG WINAPI AudioRecord_GetPinCount(BaseFilter *iface)
Definition: audiorecord.c:187
static HRESULT WINAPI PPB_GetClassID(IPersistPropertyBag *iface, CLSID *pClassID)
Definition: audiorecord.c:217
static HRESULT WINAPI PPB_Load(IPersistPropertyBag *iface, IPropertyBag *pPropBag, IErrorLog *pErrorLog)
Definition: audiorecord.c:231
static ULONG WINAPI Unknown_AddRef(IUnknown *iface)
Definition: audiorecord.c:93
static const IUnknownVtbl UnknownVtbl
Definition: audiorecord.c:110
static ULONG WINAPI PPB_AddRef(IPersistPropertyBag *iface)
Definition: audiorecord.c:205
static HRESULT WINAPI AudioRecord_FindPin(IBaseFilter *iface, LPCWSTR Id, IPin **ppPin)
Definition: audiorecord.c:155
static ULONG WINAPI PPB_Release(IPersistPropertyBag *iface)
Definition: audiorecord.c:211
static const BaseFilterFuncTable AudioRecordFuncs
Definition: audiorecord.c:194
static IPin *WINAPI AudioRecord_GetPin(BaseFilter *iface, int pos)
Definition: audiorecord.c:180
static AudioRecord * impl_from_IPersistPropertyBag(IPersistPropertyBag *iface)
Definition: audiorecord.c:61
static HRESULT WINAPI PPB_Save(IPersistPropertyBag *iface, IPropertyBag *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
Definition: audiorecord.c:251
static AudioRecord * impl_from_BaseFilter(BaseFilter *filter)
Definition: audiorecord.c:50
static const IBaseFilterVtbl AudioRecordVtbl
Definition: audiorecord.c:162
static HRESULT WINAPI PPB_QueryInterface(IPersistPropertyBag *iface, REFIID riid, LPVOID *ppv)
Definition: audiorecord.c:199
static const IPersistPropertyBagVtbl PersistPropertyBagVtbl
Definition: audiorecord.c:259
static HRESULT WINAPI Unknown_QueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppv)
Definition: audiorecord.c:66
static AudioRecord * impl_from_IBaseFilter(IBaseFilter *iface)
Definition: audiorecord.c:55
static ULONG WINAPI AudioRecord_Release(IBaseFilter *iface)
Definition: audiorecord.c:128
static HRESULT WINAPI AudioRecord_Pause(IBaseFilter *iface)
Definition: audiorecord.c:141
static HRESULT WINAPI AudioRecord_QueryInterface(IBaseFilter *iface, REFIID riid, void **ppv)
Definition: audiorecord.c:116
static ULONG WINAPI Unknown_Release(IUnknown *iface)
Definition: audiorecord.c:99
static HRESULT WINAPI AudioRecord_Stop(IBaseFilter *iface)
Definition: audiorecord.c:134
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const GUID IID_IUnknown
#define FIXME(fmt,...)
Definition: debug.h:114
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
const GUID IID_IBaseFilter
#define NULL
Definition: types.h:112
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
@ VT_I4
Definition: compat.h:2298
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint end
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
Definition: axcore.idl:92
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
const char * var
Definition: shader.c:5666
#define V_VT(A)
Definition: oleauto.h:211
#define V_I4(A)
Definition: oleauto.h:247
long LONG
Definition: pedump.c:60
const GUID IID_IPersist
Definition: proxy.cpp:14
const GUID IID_IPersistPropertyBag
Definition: proxy.cpp:11
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI BaseFilterImpl_SetSyncSource(IBaseFilter *iface, IReferenceClock *pClock)
Definition: filter.c:101
HRESULT WINAPI BaseFilterImpl_GetClassID(IBaseFilter *iface, CLSID *pClsid)
Definition: filter.c:77
ULONG WINAPI BaseFilterImpl_Release(IBaseFilter *iface)
Definition: filter.c:64
HRESULT WINAPI BaseFilterImpl_QueryFilterInfo(IBaseFilter *iface, FILTER_INFO *pInfo)
Definition: filter.c:145
ULONG WINAPI BaseFilterImpl_AddRef(IBaseFilter *iface)
Definition: filter.c:54
HRESULT WINAPI BaseFilterImpl_GetState(IBaseFilter *iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
Definition: filter.c:87
HRESULT WINAPI BaseFilterImpl_JoinFilterGraph(IBaseFilter *iface, IFilterGraph *pGraph, LPCWSTR pName)
Definition: filter.c:159
HRESULT WINAPI BaseFilterImpl_QueryVendorInfo(IBaseFilter *iface, LPWSTR *pVendorInfo)
Definition: filter.c:178
HRESULT WINAPI BaseFilterImpl_GetSyncSource(IBaseFilter *iface, IReferenceClock **ppClock)
Definition: filter.c:119
HRESULT WINAPI BaseFilterImpl_EnumPins(IBaseFilter *iface, IEnumPins **ppEnum)
Definition: filter.c:135
HRESULT WINAPI BaseFilter_Init(BaseFilter *This, const IBaseFilterVtbl *Vtbl, const CLSID *pClsid, DWORD_PTR DebugInfo, const BaseFilterFuncTable *pBaseFuncsTable)
Definition: filter.c:196
IUnknown IUnknown_iface
Definition: audiorecord.c:38
BaseFilter filter
Definition: audiorecord.c:40
IUnknown * outerUnknown
Definition: audiorecord.c:39
BaseOutputPin * output
Definition: audiorecord.c:42
IPersistPropertyBag IPersistPropertyBag_iface
Definition: audiorecord.c:41
Definition: send.c:48
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185