urlmon: Fixed memory leaks in tests.
[wine.git] / dlls / amstream / mediastreamfilter.c
blob4a4d7123e16f443cbbcf9ece80377c44a67a78cf
1 /*
2 * Implementation of MediaStream Filter
4 * Copyright 2008 Christian Costa
6 * This file contains the (internal) driver registration functions,
7 * driver enumeration APIs and DirectDraw creation functions.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/debug.h"
26 #define COBJMACROS
28 #include "winbase.h"
29 #include "wingdi.h"
31 #include "amstream_private.h"
32 #include "amstream.h"
34 #include "ddstream.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(amstream);
38 typedef struct {
39 const IMediaStreamFilterVtbl *lpVtbl;
40 LONG ref;
41 CRITICAL_SECTION csFilter;
42 FILTER_STATE state;
43 REFERENCE_TIME rtStreamStart;
44 IReferenceClock * pClock;
45 FILTER_INFO filterInfo;
46 } IMediaStreamFilterImpl;
48 static const struct IMediaStreamFilterVtbl MediaStreamFilter_Vtbl;
50 HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, LPVOID *ppObj)
52 IMediaStreamFilterImpl* object;
54 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
56 if( pUnkOuter )
57 return CLASS_E_NOAGGREGATION;
59 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamFilterImpl));
60 if (!object)
62 ERR("Out of memory\n");
63 return E_OUTOFMEMORY;
66 object->lpVtbl = &MediaStreamFilter_Vtbl;
67 object->ref = 1;
69 *ppObj = object;
71 return S_OK;
74 /*** IUnknown methods ***/
76 static HRESULT WINAPI MediaStreamFilterImpl_QueryInterface(IMediaStreamFilter * iface, REFIID riid, LPVOID * ppv)
78 IMediaStreamFilterImpl *This = (IMediaStreamFilterImpl *)iface;
80 TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
82 *ppv = NULL;
84 if (IsEqualIID(riid, &IID_IUnknown))
85 *ppv = This;
86 else if (IsEqualIID(riid, &IID_IPersist))
87 *ppv = This;
88 else if (IsEqualIID(riid, &IID_IMediaFilter))
89 *ppv = This;
90 else if (IsEqualIID(riid, &IID_IBaseFilter))
91 *ppv = This;
92 else if (IsEqualIID(riid, &IID_IMediaStreamFilter))
93 *ppv = This;
95 if (*ppv)
97 IUnknown_AddRef((IUnknown *)(*ppv));
98 return S_OK;
101 return E_NOINTERFACE;
104 static ULONG WINAPI MediaStreamFilterImpl_AddRef(IMediaStreamFilter * iface)
106 IMediaStreamFilterImpl *This = (IMediaStreamFilterImpl *)iface;
107 ULONG refCount = InterlockedIncrement(&This->ref);
109 TRACE("(%p)->() AddRef from %d\n", iface, refCount - 1);
111 return refCount;
114 static ULONG WINAPI MediaStreamFilterImpl_Release(IMediaStreamFilter * iface)
116 IMediaStreamFilterImpl *This = (IMediaStreamFilterImpl *)iface;
117 ULONG refCount = InterlockedDecrement(&This->ref);
119 TRACE("(%p)->() Release from %d\n", iface, refCount + 1);
121 if (!refCount)
123 This->lpVtbl = NULL;
124 HeapFree(GetProcessHeap(), 0, This);
127 return refCount;
130 /*** IPersist methods ***/
132 static HRESULT WINAPI MediaStreamFilterImpl_GetClassID(IMediaStreamFilter * iface, CLSID * pClsid)
134 TRACE("(%p)->(%p)\n", iface, pClsid);
136 *pClsid = CLSID_MediaStreamFilter;
138 return S_OK;
141 /*** IMediaFilter methods ***/
143 static HRESULT WINAPI MediaStreamFilterImpl_Stop(IMediaStreamFilter * iface)
145 FIXME("(%p)->(): Stub!\n", iface);
147 return E_NOTIMPL;
150 static HRESULT WINAPI MediaStreamFilterImpl_Pause(IMediaStreamFilter * iface)
152 FIXME("(%p)->(): Stub!\n", iface);
154 return E_NOTIMPL;
157 static HRESULT WINAPI MediaStreamFilterImpl_Run(IMediaStreamFilter * iface, REFERENCE_TIME tStart)
159 FIXME("(%p)->(%s): Stub!\n", iface, wine_dbgstr_longlong(tStart));
161 return E_NOTIMPL;
164 static HRESULT WINAPI MediaStreamFilterImpl_GetState(IMediaStreamFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
166 FIXME("(%p)->(%d,%p): Stub!\n", iface, dwMilliSecsTimeout, pState);
168 return E_NOTIMPL;
171 static HRESULT WINAPI MediaStreamFilterImpl_SetSyncSource(IMediaStreamFilter * iface, IReferenceClock *pClock)
173 TRACE("(%p)->(%p): Stub!\n", iface, pClock);
175 return E_NOTIMPL;
178 static HRESULT WINAPI MediaStreamFilterImpl_GetSyncSource(IMediaStreamFilter * iface, IReferenceClock **ppClock)
180 FIXME("(%p)->(%p): Stub!\n", iface, ppClock);
182 return E_NOTIMPL;
185 /*** IBaseFilter methods ***/
187 static HRESULT WINAPI MediaStreamFilterImpl_EnumPins(IMediaStreamFilter * iface, IEnumPins **ppEnum)
189 FIXME("(%p)->(%p): Stub!\n", iface, ppEnum);
191 return E_NOTIMPL;
194 static HRESULT WINAPI MediaStreamFilterImpl_FindPin(IMediaStreamFilter * iface, LPCWSTR Id, IPin **ppPin)
196 FIXME("(%p)->(%s,%p): Stub!\n", iface, debugstr_w(Id), ppPin);
198 return E_NOTIMPL;
201 static HRESULT WINAPI MediaStreamFilterImpl_QueryFilterInfo(IMediaStreamFilter * iface, FILTER_INFO *pInfo)
203 FIXME("(%p)->(%p): Stub!\n", iface, pInfo);
205 return E_NOTIMPL;
208 static HRESULT WINAPI MediaStreamFilterImpl_JoinFilterGraph(IMediaStreamFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
210 FIXME("(%p)->(%p, %s): Stub!\n", iface, pGraph, debugstr_w(pName));
212 return E_NOTIMPL;
215 static HRESULT WINAPI MediaStreamFilterImpl_QueryVendorInfo(IMediaStreamFilter * iface, LPWSTR *pVendorInfo)
217 FIXME("(%p)->(%p): Stub!\n", iface, pVendorInfo);
219 return E_NOTIMPL;
222 /*** IMediaStreamFilter methods ***/
224 static HRESULT WINAPI MediaStreamFilterImpl_AddMediaStream(IMediaStreamFilter* iface, IAMMediaStream *pAMMediaStream)
226 FIXME("(%p)->(%p): Stub!\n", iface, pAMMediaStream);
228 return E_NOTIMPL;
231 static HRESULT WINAPI MediaStreamFilterImpl_GetMediaStream(IMediaStreamFilter* iface, REFMSPID idPurpose, IMediaStream **ppMediaStream)
233 FIXME("(%p)->(%s,%p): Stub!\n", iface, debugstr_guid(idPurpose), ppMediaStream);
235 return E_NOTIMPL;
238 static HRESULT WINAPI MediaStreamFilterImpl_EnumMediaStreams(IMediaStreamFilter* iface, LONG Index, IMediaStream **ppMediaStream)
240 FIXME("(%p)->(%d,%p): Stub!\n", iface, Index, ppMediaStream);
242 return E_NOTIMPL;
245 static HRESULT WINAPI MediaStreamFilterImpl_SupportSeeking(IMediaStreamFilter* iface, BOOL bRenderer)
247 FIXME("(%p)->(%d): Stub!\n", iface, bRenderer);
249 return E_NOTIMPL;
252 static HRESULT WINAPI MediaStreamFilterImpl_ReferenceTimeToStreamTime(IMediaStreamFilter* iface, REFERENCE_TIME *pTime)
254 FIXME("(%p)->(%p): Stub!\n", iface, pTime);
256 return E_NOTIMPL;
259 static HRESULT WINAPI MediaStreamFilterImpl_GetCurrentStreamTime(IMediaStreamFilter* iface, REFERENCE_TIME *pCurrentStreamTime)
261 FIXME("(%p)->(%p): Stub!\n", iface, pCurrentStreamTime);
263 return E_NOTIMPL;
266 static HRESULT WINAPI MediaStreamFilterImpl_WaitUntil(IMediaStreamFilter* iface, REFERENCE_TIME WaitStreamTime)
268 FIXME("(%p)->(%s): Stub!\n", iface, wine_dbgstr_longlong(WaitStreamTime));
270 return E_NOTIMPL;
273 static HRESULT WINAPI MediaStreamFilterImpl_Flush(IMediaStreamFilter* iface, BOOL bCancelEOS)
275 FIXME("(%p)->(%d): Stub!\n", iface, bCancelEOS);
277 return E_NOTIMPL;
280 static HRESULT WINAPI MediaStreamFilterImpl_EndOfStream(IMediaStreamFilter* iface)
282 FIXME("(%p)->(): Stub!\n", iface);
284 return E_NOTIMPL;
287 static const IMediaStreamFilterVtbl MediaStreamFilter_Vtbl =
289 MediaStreamFilterImpl_QueryInterface,
290 MediaStreamFilterImpl_AddRef,
291 MediaStreamFilterImpl_Release,
292 MediaStreamFilterImpl_GetClassID,
293 MediaStreamFilterImpl_Stop,
294 MediaStreamFilterImpl_Pause,
295 MediaStreamFilterImpl_Run,
296 MediaStreamFilterImpl_GetState,
297 MediaStreamFilterImpl_SetSyncSource,
298 MediaStreamFilterImpl_GetSyncSource,
299 MediaStreamFilterImpl_EnumPins,
300 MediaStreamFilterImpl_FindPin,
301 MediaStreamFilterImpl_QueryFilterInfo,
302 MediaStreamFilterImpl_JoinFilterGraph,
303 MediaStreamFilterImpl_QueryVendorInfo,
304 MediaStreamFilterImpl_AddMediaStream,
305 MediaStreamFilterImpl_GetMediaStream,
306 MediaStreamFilterImpl_EnumMediaStreams,
307 MediaStreamFilterImpl_SupportSeeking,
308 MediaStreamFilterImpl_ReferenceTimeToStreamTime,
309 MediaStreamFilterImpl_GetCurrentStreamTime,
310 MediaStreamFilterImpl_WaitUntil,
311 MediaStreamFilterImpl_Flush,
312 MediaStreamFilterImpl_EndOfStream