1 /* Implementation of the Audio Capture Filter (CLSID_AudioRecord)
3 * Copyright 2015 Damjan Jovanovic
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.
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.
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
31 #include "qcap_main.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(qcap
);
38 IUnknown IUnknown_iface
;
39 IUnknown
*outerUnknown
;
41 IPersistPropertyBag IPersistPropertyBag_iface
;
42 BaseOutputPin
*output
;
45 static inline AudioRecord
*impl_from_IUnknown(IUnknown
*iface
)
47 return CONTAINING_RECORD(iface
, AudioRecord
, IUnknown_iface
);
50 static inline AudioRecord
*impl_from_BaseFilter(BaseFilter
*filter
)
52 return CONTAINING_RECORD(filter
, AudioRecord
, filter
);
55 static inline AudioRecord
*impl_from_IBaseFilter(IBaseFilter
*iface
)
57 BaseFilter
*filter
= CONTAINING_RECORD(iface
, BaseFilter
, IBaseFilter_iface
);
58 return impl_from_BaseFilter(filter
);
61 static inline AudioRecord
*impl_from_IPersistPropertyBag(IPersistPropertyBag
*iface
)
63 return CONTAINING_RECORD(iface
, AudioRecord
, IPersistPropertyBag_iface
);
66 static HRESULT WINAPI
Unknown_QueryInterface(IUnknown
*iface
, REFIID riid
, LPVOID
*ppv
)
68 AudioRecord
*This
= impl_from_IUnknown(iface
);
69 if (IsEqualIID(riid
, &IID_IUnknown
)) {
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
;
81 } else if (IsEqualIID(riid
, &IID_IPersistPropertyBag
)) {
82 TRACE("(%p)->(IID_IPersistPropertyBag, %p)\n", This
, ppv
);
83 *ppv
= &This
->IPersistPropertyBag_iface
;
85 FIXME("(%p): no interface for %s\n", This
, debugstr_guid(riid
));
89 IUnknown_AddRef((IUnknown
*)*ppv
);
93 static ULONG WINAPI
Unknown_AddRef(IUnknown
*iface
)
95 AudioRecord
*This
= impl_from_IUnknown(iface
);
96 return BaseFilterImpl_AddRef(&This
->filter
.IBaseFilter_iface
);
99 static ULONG WINAPI
Unknown_Release(IUnknown
*iface
)
101 AudioRecord
*This
= impl_from_IUnknown(iface
);
102 ULONG ref
= BaseFilterImpl_Release(&This
->filter
.IBaseFilter_iface
);
103 TRACE("(%p/%p)->() ref=%d\n", iface
, This
, ref
);
110 static const IUnknownVtbl UnknownVtbl
= {
111 Unknown_QueryInterface
,
116 static HRESULT WINAPI
AudioRecord_QueryInterface(IBaseFilter
*iface
, REFIID riid
, void **ppv
)
118 AudioRecord
*This
= impl_from_IBaseFilter(iface
);
119 return IUnknown_QueryInterface(This
->outerUnknown
, riid
, ppv
);
122 static ULONG WINAPI
AudioRecord_AddRef(IBaseFilter
*iface
)
124 AudioRecord
*This
= impl_from_IBaseFilter(iface
);
125 return IUnknown_AddRef(This
->outerUnknown
);
128 static ULONG WINAPI
AudioRecord_Release(IBaseFilter
*iface
)
130 AudioRecord
*This
= impl_from_IBaseFilter(iface
);
131 return IUnknown_Release(This
->outerUnknown
);
134 static HRESULT WINAPI
AudioRecord_Stop(IBaseFilter
*iface
)
136 AudioRecord
*This
= impl_from_IBaseFilter(iface
);
137 FIXME("(%p): stub\n", This
);
141 static HRESULT WINAPI
AudioRecord_Pause(IBaseFilter
*iface
)
143 AudioRecord
*This
= impl_from_IBaseFilter(iface
);
144 FIXME("(%p): stub\n", This
);
148 static HRESULT WINAPI
AudioRecord_Run(IBaseFilter
*iface
, REFERENCE_TIME tStart
)
150 AudioRecord
*This
= impl_from_IBaseFilter(iface
);
151 FIXME("(%p, %x%08x): stub\n", This
, (ULONG
)(tStart
>> 32), (ULONG
)tStart
);
155 static HRESULT WINAPI
AudioRecord_FindPin(IBaseFilter
*iface
, LPCWSTR Id
, IPin
**ppPin
)
157 AudioRecord
*This
= impl_from_IBaseFilter(iface
);
158 FIXME("(%p)->(%s, %p): stub\n", This
, debugstr_w(Id
), ppPin
);
162 static const IBaseFilterVtbl AudioRecordVtbl
= {
163 AudioRecord_QueryInterface
,
166 BaseFilterImpl_GetClassID
,
170 BaseFilterImpl_GetState
,
171 BaseFilterImpl_SetSyncSource
,
172 BaseFilterImpl_GetSyncSource
,
173 BaseFilterImpl_EnumPins
,
175 BaseFilterImpl_QueryFilterInfo
,
176 BaseFilterImpl_JoinFilterGraph
,
177 BaseFilterImpl_QueryVendorInfo
180 static IPin
* WINAPI
AudioRecord_GetPin(BaseFilter
*iface
, int pos
)
182 AudioRecord
*This
= impl_from_BaseFilter(iface
);
183 FIXME("(%p, %d): stub\n", This
, pos
);
187 static LONG WINAPI
AudioRecord_GetPinCount(BaseFilter
*iface
)
189 AudioRecord
*This
= impl_from_BaseFilter(iface
);
190 FIXME("(%p): stub\n", This
);
194 static const BaseFilterFuncTable AudioRecordFuncs
= {
196 AudioRecord_GetPinCount
199 static HRESULT WINAPI
PPB_QueryInterface(IPersistPropertyBag
*iface
, REFIID riid
, LPVOID
*ppv
)
201 AudioRecord
*This
= impl_from_IPersistPropertyBag(iface
);
202 return IUnknown_QueryInterface(This
->outerUnknown
, riid
, ppv
);
205 static ULONG WINAPI
PPB_AddRef(IPersistPropertyBag
*iface
)
207 AudioRecord
*This
= impl_from_IPersistPropertyBag(iface
);
208 return IUnknown_AddRef(This
->outerUnknown
);
211 static ULONG WINAPI
PPB_Release(IPersistPropertyBag
*iface
)
213 AudioRecord
*This
= impl_from_IPersistPropertyBag(iface
);
214 return IUnknown_Release(This
->outerUnknown
);
217 static HRESULT WINAPI
PPB_GetClassID(IPersistPropertyBag
*iface
, CLSID
*pClassID
)
219 AudioRecord
*This
= impl_from_IPersistPropertyBag(iface
);
220 TRACE("(%p/%p)->(%p)\n", iface
, This
, pClassID
);
221 return IBaseFilter_GetClassID(&This
->filter
.IBaseFilter_iface
, pClassID
);
224 static HRESULT WINAPI
PPB_InitNew(IPersistPropertyBag
*iface
)
226 AudioRecord
*This
= impl_from_IPersistPropertyBag(iface
);
227 FIXME("(%p/%p)->(): stub\n", iface
, This
);
231 static HRESULT WINAPI
PPB_Load(IPersistPropertyBag
*iface
, IPropertyBag
*pPropBag
,
232 IErrorLog
*pErrorLog
)
234 AudioRecord
*This
= impl_from_IPersistPropertyBag(iface
);
237 static const WCHAR WaveInIDW
[] = {'W','a','v','e','I','n','I','D',0};
239 TRACE("(%p/%p)->(%p, %p)\n", iface
, This
, pPropBag
, pErrorLog
);
242 hr
= IPropertyBag_Read(pPropBag
, WaveInIDW
, &var
, pErrorLog
);
245 FIXME("FIXME: implement opening waveIn device %d\n", V_I4(&var
));
251 static HRESULT WINAPI
PPB_Save(IPersistPropertyBag
*iface
, IPropertyBag
*pPropBag
,
252 BOOL fClearDirty
, BOOL fSaveAllProperties
)
254 AudioRecord
*This
= impl_from_IPersistPropertyBag(iface
);
255 FIXME("(%p/%p)->(%p, %u, %u): stub\n", iface
, This
, pPropBag
, fClearDirty
, fSaveAllProperties
);
259 static const IPersistPropertyBagVtbl PersistPropertyBagVtbl
=
270 IUnknown
* WINAPI
QCAP_createAudioCaptureFilter(IUnknown
*outer
, HRESULT
*phr
)
273 AudioRecord
*This
= NULL
;
275 FIXME("(%p, %p): the entire CLSID_AudioRecord implementation is just stubs\n", outer
, phr
);
277 This
= CoTaskMemAlloc(sizeof(*This
));
282 memset(This
, 0, sizeof(*This
));
283 This
->IUnknown_iface
.lpVtbl
= &UnknownVtbl
;
284 This
->IPersistPropertyBag_iface
.lpVtbl
= &PersistPropertyBagVtbl
;
286 This
->outerUnknown
= outer
;
288 This
->outerUnknown
= &This
->IUnknown_iface
;
290 hr
= BaseFilter_Init(&This
->filter
, &AudioRecordVtbl
, &CLSID_AudioRecord
,
291 (DWORD_PTR
)(__FILE__
": AudioRecord.csFilter"), &AudioRecordFuncs
);
296 return (IUnknown
*)&This
->filter
.IBaseFilter_iface
;
299 IBaseFilter_Release(&This
->filter
.IBaseFilter_iface
);