ReactOS 0.4.15-dev-5669-g09dde2c
filter.c
Go to the documentation of this file.
1/*
2 * Generic Implementation of IBaseFilter Interface
3 *
4 * Copyright 2010 Aric Stewart, CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#define COBJMACROS
22
23#include "dshow.h"
24#include "wine/debug.h"
25#include "wine/unicode.h"
26#include "wine/strmbase.h"
27#include "uuids.h"
28#include <assert.h>
29
31
33{
34 return CONTAINING_RECORD(iface, BaseFilter, IBaseFilter_iface);
35}
36
38{
39 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
40
41 *ppv = NULL;
42
44 IsEqualIID(riid, &IID_IMediaFilter) || IsEqualIID(riid, &IID_IBaseFilter))
45 {
46 *ppv = iface;
47 IBaseFilter_AddRef(iface);
48 return S_OK;
49 }
50
51 return E_NOINTERFACE;
52}
53
55{
57 ULONG refCount = InterlockedIncrement(&This->refCount);
58
59 TRACE("(%p)->() AddRef from %d\n", This, refCount - 1);
60
61 return refCount;
62}
63
65{
67 ULONG refCount = InterlockedDecrement(&This->refCount);
68
69 TRACE("(%p)->() Release from %d\n", This, refCount + 1);
70
71 if (!refCount)
73
74 return refCount;
75}
76
78{
80 TRACE("(%p)->(%p)\n", This, pClsid);
81
82 *pClsid = This->clsid;
83
84 return S_OK;
85}
86
87HRESULT WINAPI BaseFilterImpl_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState )
88{
90 TRACE("(%p)->(%d, %p)\n", This, dwMilliSecsTimeout, pState);
91
92 EnterCriticalSection(&This->csFilter);
93 {
94 *pState = This->state;
95 }
96 LeaveCriticalSection(&This->csFilter);
97
98 return S_OK;
99}
100
102{
104 TRACE("(%p)->(%p)\n", This, pClock);
105
106 EnterCriticalSection(&This->csFilter);
107 {
108 if (This->pClock)
110 This->pClock = pClock;
111 if (This->pClock)
113 }
114 LeaveCriticalSection(&This->csFilter);
115
116 return S_OK;
117}
118
120{
122 TRACE("(%p)->(%p)\n", This, ppClock);
123
124 EnterCriticalSection(&This->csFilter);
125 {
126 *ppClock = This->pClock;
127 if (This->pClock)
129 }
130 LeaveCriticalSection(&This->csFilter);
131
132 return S_OK;
133}
134
136{
138
139 TRACE("(%p)->(%p)\n", iface, ppEnum);
140
141 return EnumPins_Construct(This, This->pFuncsTable->pfnGetPin, This->pFuncsTable->pfnGetPinCount, BaseFilterImpl_GetPinVersion, ppEnum);
142}
143
144
146{
148 TRACE("(%p)->(%p)\n", This, pInfo);
149
150 strcpyW(pInfo->achName, This->filterInfo.achName);
151 pInfo->pGraph = This->filterInfo.pGraph;
152
153 if (pInfo->pGraph)
154 IFilterGraph_AddRef(pInfo->pGraph);
155
156 return S_OK;
157}
158
160{
162
163 TRACE("(%p)->(%p, %s)\n", This, pGraph, debugstr_w(pName));
164
165 EnterCriticalSection(&This->csFilter);
166 {
167 if (pName)
168 strcpyW(This->filterInfo.achName, pName);
169 else
170 *This->filterInfo.achName = '\0';
171 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
172 }
173 LeaveCriticalSection(&This->csFilter);
174
175 return S_OK;
176}
177
179{
180 TRACE("(%p)->(%p)\n", iface, pVendorInfo);
181 return E_NOTIMPL;
182}
183
185{
186 TRACE("(%p)\n", This);
187 return This->pinVersion;
188}
189
191{
192 InterlockedIncrement(&This->pinVersion);
193 TRACE("(%p) -> New pinVersion %i\n", This,This->pinVersion);
194}
195
196HRESULT WINAPI BaseFilter_Init(BaseFilter * This, const IBaseFilterVtbl *Vtbl, const CLSID *pClsid, DWORD_PTR DebugInfo, const BaseFilterFuncTable* pBaseFuncsTable)
197{
198 This->IBaseFilter_iface.lpVtbl = Vtbl;
199 This->refCount = 1;
201 This->state = State_Stopped;
202 This->rtStreamStart = 0;
203 This->pClock = NULL;
204 ZeroMemory(&This->filterInfo, sizeof(FILTER_INFO));
205 This->clsid = *pClsid;
206 This->csFilter.DebugInfo->Spare[0] = DebugInfo;
207 This->pinVersion = 1;
208
209 This->pFuncsTable = pBaseFuncsTable;
210
211 return S_OK;
212}
213
215{
216 if (This->pClock)
218
219 This->IBaseFilter_iface.lpVtbl = NULL;
220 This->csFilter.DebugInfo->Spare[0] = 0;
221 DeleteCriticalSection(&This->csFilter);
222
223 return S_OK;
224}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const GUID IID_IUnknown
#define E_NOTIMPL
Definition: ddrawi.h:99
const GUID IID_IBaseFilter
#define NULL
Definition: types.h:112
#define IReferenceClock_AddRef(p)
Definition: dmusicc.h:751
#define IReferenceClock_Release(p)
Definition: dmusicc.h:752
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
static LPSTR pName
Definition: security.c:75
long LONG
Definition: pedump.c:60
const GUID IID_IPersist
Definition: proxy.cpp:14
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define strcpyW(d, s)
Definition: unicode.h:29
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
static BaseFilter * impl_from_IBaseFilter(IBaseFilter *iface)
Definition: filter.c:32
LONG WINAPI BaseFilterImpl_GetPinVersion(BaseFilter *This)
Definition: filter.c:184
ULONG WINAPI BaseFilterImpl_AddRef(IBaseFilter *iface)
Definition: filter.c:54
HRESULT WINAPI BaseFilter_Destroy(BaseFilter *This)
Definition: filter.c:214
HRESULT WINAPI BaseFilterImpl_QueryInterface(IBaseFilter *iface, REFIID riid, LPVOID *ppv)
Definition: filter.c:37
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
VOID WINAPI BaseFilterImpl_IncrementPinVersion(BaseFilter *This)
Definition: filter.c:190
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
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI EnumPins_Construct(BaseFilter *base, BaseFilter_GetPin receive_pin, BaseFilter_GetPinCount receive_pincount, BaseFilter_GetPinVersion receive_version, IEnumPins **ppEnum)
Definition: enumpins.c:49
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
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 ZeroMemory
Definition: winbase.h:1670
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185