ReactOS  0.4.14-dev-98-gb0d4763
mediastreamfilter.c
Go to the documentation of this file.
1 /*
2  * Implementation of MediaStream Filter
3  *
4  * Copyright 2008, 2012 Christian Costa
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 #include "wine/debug.h"
22 
23 #define COBJMACROS
24 
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "dshow.h"
28 
29 #include "wine/strmbase.h"
30 
31 #include "amstream_private.h"
32 
33 #include "ddstream.h"
34 
36 
37 typedef struct {
42 
44 {
45  return CONTAINING_RECORD((IBaseFilter *)iface, IMediaStreamFilterImpl, filter.IBaseFilter_iface);
46 }
47 
48 /*** IUnknown methods ***/
49 
51 {
52  TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ret_iface);
53 
54  *ret_iface = NULL;
55 
56  if (IsEqualIID(riid, &IID_IUnknown) ||
58  IsEqualIID(riid, &IID_IMediaFilter) ||
60  IsEqualIID(riid, &IID_IMediaStreamFilter))
61  *ret_iface = iface;
62 
63  if (*ret_iface)
64  {
65  IMediaStreamFilter_AddRef(*ret_iface);
66  return S_OK;
67  }
68 
69  return E_NOINTERFACE;
70 }
71 
73 {
75  ULONG ref = BaseFilterImpl_AddRef(&This->filter.IBaseFilter_iface);
76 
77  TRACE("(%p)->(): new ref = %u\n", iface, ref);
78 
79  return ref;
80 }
81 
83 {
85  ULONG ref = InterlockedDecrement(&This->filter.refCount);
86 
87  TRACE("(%p)->(): new ref = %u\n", iface, ref);
88 
89  if (!ref)
90  {
91  ULONG i;
92  for (i = 0; i < This->nb_streams; i++)
93  {
94  IAMMediaStream_JoinFilter(This->streams[i], NULL);
95  IAMMediaStream_Release(This->streams[i]);
96  }
97  CoTaskMemFree(This->streams);
98  BaseFilter_Destroy(&This->filter);
100  }
101 
102  return ref;
103 }
104 
105 /*** IPersist methods ***/
106 
108 {
110  return BaseFilterImpl_GetClassID(&This->filter.IBaseFilter_iface, clsid);
111 }
112 
113 /*** IBaseFilter methods ***/
114 
116 {
117  FIXME("(%p)->(): Stub!\n", iface);
118 
119  return E_NOTIMPL;
120 }
121 
123 {
124  FIXME("(%p)->(): Stub!\n", iface);
125 
126  return E_NOTIMPL;
127 }
128 
130 {
131  FIXME("(%p)->(%s): Stub!\n", iface, wine_dbgstr_longlong(start));
132 
133  return E_NOTIMPL;
134 }
135 
137 {
139  return BaseFilterImpl_GetState(&This->filter.IBaseFilter_iface, ms_timeout, state);
140 }
141 
143 {
145  return BaseFilterImpl_SetSyncSource(&This->filter.IBaseFilter_iface, clock);
146 }
147 
149 {
151  return BaseFilterImpl_GetSyncSource(&This->filter.IBaseFilter_iface, clock);
152 }
153 
155 {
157  return BaseFilterImpl_EnumPins(&This->filter.IBaseFilter_iface, enum_pins);
158 }
159 
161 {
162  FIXME("(%p)->(%s,%p): Stub!\n", iface, debugstr_w(id), pin);
163 
164  return E_NOTIMPL;
165 }
166 
168 {
170  return BaseFilterImpl_QueryFilterInfo(&This->filter.IBaseFilter_iface, info);
171 }
172 
174 {
176  return BaseFilterImpl_JoinFilterGraph(&This->filter.IBaseFilter_iface, graph, name);
177 }
178 
180 {
182  return BaseFilterImpl_QueryVendorInfo(&This->filter.IBaseFilter_iface, vendor_info);
183 }
184 
185 /*** IMediaStreamFilter methods ***/
186 
188 {
190  IAMMediaStream** streams;
191  HRESULT hr;
192 
193  TRACE("(%p)->(%p)\n", iface, pAMMediaStream);
194 
195  streams = CoTaskMemRealloc(This->streams, (This->nb_streams + 1) * sizeof(IAMMediaStream*));
196  if (!streams)
197  return E_OUTOFMEMORY;
198  This->streams = streams;
199 
200  hr = IAMMediaStream_JoinFilter(pAMMediaStream, iface);
201  if (FAILED(hr))
202  return hr;
203 
204  This->streams[This->nb_streams] = pAMMediaStream;
205  This->nb_streams++;
206 
207  IAMMediaStream_AddRef(pAMMediaStream);
208 
209  return S_OK;
210 }
211 
213 {
215  MSPID purpose_id;
216  unsigned int i;
217 
218  TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(idPurpose), ppMediaStream);
219 
220  for (i = 0; i < This->nb_streams; i++)
221  {
222  IAMMediaStream_GetInformation(This->streams[i], &purpose_id, NULL);
223  if (IsEqualIID(&purpose_id, idPurpose))
224  {
225  *ppMediaStream = (IMediaStream *)This->streams[i];
226  IMediaStream_AddRef(*ppMediaStream);
227  return S_OK;
228  }
229  }
230 
231  return MS_E_NOSTREAM;
232 }
233 
235 {
236  FIXME("(%p)->(%d,%p): Stub!\n", iface, Index, ppMediaStream);
237 
238  return E_NOTIMPL;
239 }
240 
242 {
243  FIXME("(%p)->(%d): Stub!\n", iface, bRenderer);
244 
245  return E_NOTIMPL;
246 }
247 
249 {
250  FIXME("(%p)->(%p): Stub!\n", iface, pTime);
251 
252  return E_NOTIMPL;
253 }
254 
256 {
257  FIXME("(%p)->(%p): Stub!\n", iface, pCurrentStreamTime);
258 
259  return E_NOTIMPL;
260 }
261 
263 {
264  FIXME("(%p)->(%s): Stub!\n", iface, wine_dbgstr_longlong(WaitStreamTime));
265 
266  return E_NOTIMPL;
267 }
268 
270 {
271  FIXME("(%p)->(%d): Stub!\n", iface, bCancelEOS);
272 
273  return E_NOTIMPL;
274 }
275 
277 {
278  FIXME("(%p)->(): Stub!\n", iface);
279 
280  return E_NOTIMPL;
281 }
282 
283 static const IMediaStreamFilterVtbl MediaStreamFilter_Vtbl =
284 {
309 };
310 
312 {
314 
315  if (pos < This->nb_streams)
316  {
317  IPin *pin = NULL;
318  IAMMediaStream_QueryInterface(This->streams[pos], &IID_IPin, (void **)&pin);
319  return pin;
320  }
321 
322  return NULL;
323 }
324 
326 {
328 
329  return This->nb_streams;
330 }
331 
335 };
336 
337 HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, void **ppObj)
338 {
340 
341  TRACE("(%p,%p)\n", pUnkOuter, ppObj);
342 
343  if( pUnkOuter )
344  return CLASS_E_NOAGGREGATION;
345 
347  if (!object)
348  return E_OUTOFMEMORY;
349 
350  BaseFilter_Init(&object->filter, (IBaseFilterVtbl*)&MediaStreamFilter_Vtbl, &CLSID_MediaStreamFilter, (DWORD_PTR)(__FILE__ ": MediaStreamFilterImpl.csFilter"), &BaseFuncTable);
351 
352  *ppObj = &object->filter.IBaseFilter_iface;
353 
354  return S_OK;
355 }
const GUID IID_IBaseFilter
static HRESULT WINAPI MediaStreamFilterImpl_GetMediaStream(IMediaStreamFilter *iface, REFMSPID idPurpose, IMediaStream **ppMediaStream)
static IMediaStreamFilterImpl * impl_from_IMediaStreamFilter(IMediaStreamFilter *iface)
HRESULT WINAPI BaseFilterImpl_SetSyncSource(IBaseFilter *iface, IReferenceClock *pClock)
Definition: filter.c:101
#define REFIID
Definition: guiddef.h:118
static HRESULT WINAPI MediaStreamFilterImpl_GetClassID(IMediaStreamFilter *iface, CLSID *clsid)
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
HRESULT hr
Definition: shlfolder.c:183
Definition: scsiwmi.h:51
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static HRESULT WINAPI MediaStreamFilterImpl_GetCurrentStreamTime(IMediaStreamFilter *iface, REFERENCE_TIME *pCurrentStreamTime)
static HRESULT WINAPI MediaStreamFilterImpl_SetSyncSource(IMediaStreamFilter *iface, IReferenceClock *clock)
REFIID riid
Definition: precomp.h:44
HRESULT WINAPI BaseFilterImpl_GetState(IBaseFilter *iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
Definition: filter.c:87
const GUID IID_IPersist
Definition: proxy.cpp:14
static HRESULT WINAPI MediaStreamFilterImpl_GetSyncSource(IMediaStreamFilter *iface, IReferenceClock **clock)
static HRESULT WINAPI MediaStreamFilterImpl_QueryInterface(IMediaStreamFilter *iface, REFIID riid, void **ret_iface)
static ULONG WINAPI MediaStreamFilterImpl_AddRef(IMediaStreamFilter *iface)
static HRESULT WINAPI MediaStreamFilterImpl_AddMediaStream(IMediaStreamFilter *iface, IAMMediaStream *pAMMediaStream)
static HRESULT WINAPI MediaStreamFilterImpl_Pause(IMediaStreamFilter *iface)
Definition: send.c:47
static HRESULT WINAPI MediaStreamFilterImpl_EndOfStream(IMediaStreamFilter *iface)
static const IMediaStreamFilterVtbl MediaStreamFilter_Vtbl
Definition: regsvr.c:103
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
HRESULT WINAPI BaseFilterImpl_GetClassID(IBaseFilter *iface, CLSID *pClsid)
Definition: filter.c:77
#define debugstr_w
Definition: kernel32.h:32
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110
static const BaseFilterFuncTable BaseFuncTable
_In_ PCCERT_CONTEXT _In_opt_ LPFILETIME pTime
Definition: wincrypt.h:4840
smooth NULL
Definition: ftsmooth.c:416
static HRESULT WINAPI MediaStreamFilterImpl_EnumPins(IMediaStreamFilter *iface, IEnumPins **enum_pins)
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
HRESULT WINAPI BaseFilter_Destroy(BaseFilter *This)
Definition: filter.c:214
HRESULT WINAPI BaseFilterImpl_QueryVendorInfo(IBaseFilter *iface, LPWSTR *pVendorInfo)
Definition: filter.c:178
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
IAMMediaStream ** streams
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
LONG HRESULT
Definition: typedefs.h:77
static HRESULT WINAPI MediaStreamFilterImpl_WaitUntil(IMediaStreamFilter *iface, REFERENCE_TIME WaitStreamTime)
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
static const UCHAR Index[8]
Definition: usbohci.c:18
WINE_DEFAULT_DEBUG_CHANNEL(amstream)
unsigned long DWORD
Definition: ntddk_ex.h:95
static ULONG WINAPI MediaStreamFilterImpl_Release(IMediaStreamFilter *iface)
static HRESULT WINAPI MediaStreamFilterImpl_Flush(IMediaStreamFilter *iface, BOOL bCancelEOS)
static IPin *WINAPI MediaStreamFilterImpl_GetPin(BaseFilter *iface, int pos)
REFCLSID clsid
Definition: msctf.c:84
#define InterlockedDecrement
Definition: armddk.h:52
static HRESULT WINAPI MediaStreamFilterImpl_FindPin(IMediaStreamFilter *iface, LPCWSTR id, IPin **pin)
static int state
Definition: maze.c:121
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
HRESULT WINAPI BaseFilterImpl_EnumPins(IBaseFilter *iface, IEnumPins **ppEnum)
Definition: filter.c:135
uint32_t DWORD_PTR
Definition: typedefs.h:63
static HRESULT WINAPI MediaStreamFilterImpl_Stop(IMediaStreamFilter *iface)
#define S_OK
Definition: intsafe.h:59
static HRESULT WINAPI MediaStreamFilterImpl_QueryVendorInfo(IMediaStreamFilter *iface, LPWSTR *vendor_info)
static HRESULT WINAPI MediaStreamFilterImpl_JoinFilterGraph(IMediaStreamFilter *iface, IFilterGraph *graph, LPCWSTR name)
GLuint start
Definition: gl.h:1545
Definition: axcore.idl:91
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT WINAPI BaseFilterImpl_QueryFilterInfo(IBaseFilter *iface, FILTER_INFO *pInfo)
Definition: filter.c:145
_Check_return_ _CRTIMP clock_t __cdecl clock(void)
Definition: clock.c:23
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
ULONG WINAPI BaseFilterImpl_AddRef(IBaseFilter *iface)
Definition: filter.c:54
HRESULT WINAPI BaseFilterImpl_GetSyncSource(IBaseFilter *iface, IReferenceClock **ppClock)
Definition: filter.c:119
Definition: name.c:36
HRESULT WINAPI BaseFilterImpl_JoinFilterGraph(IBaseFilter *iface, IFilterGraph *pGraph, LPCWSTR pName)
Definition: filter.c:159
unsigned int ULONG
Definition: retypes.h:1
static HRESULT WINAPI MediaStreamFilterImpl_ReferenceTimeToStreamTime(IMediaStreamFilter *iface, REFERENCE_TIME *pTime)
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
HRESULT WINAPI BaseFilter_Init(BaseFilter *This, const IBaseFilterVtbl *Vtbl, const CLSID *pClsid, DWORD_PTR DebugInfo, const BaseFilterFuncTable *pBaseFuncsTable)
Definition: filter.c:196
LPVOID WINAPI CoTaskMemRealloc(LPVOID pvOld, SIZE_T size)
Definition: ifs.c:440
static HRESULT WINAPI MediaStreamFilterImpl_QueryFilterInfo(IMediaStreamFilter *iface, FILTER_INFO *info)
static HRESULT WINAPI MediaStreamFilterImpl_Run(IMediaStreamFilter *iface, REFERENCE_TIME start)
static HRESULT WINAPI MediaStreamFilterImpl_GetState(IMediaStreamFilter *iface, DWORD ms_timeout, FILTER_STATE *state)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static HRESULT WINAPI MediaStreamFilterImpl_SupportSeeking(IMediaStreamFilter *iface, BOOL bRenderer)
const GUID IID_IPin
Definition: pincontrol.cpp:15
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define HeapFree(x, y, z)
Definition: compat.h:394
HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, void **ppObj)
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
static HRESULT WINAPI MediaStreamFilterImpl_EnumMediaStreams(IMediaStreamFilter *iface, LONG Index, IMediaStream **ppMediaStream)
void * object
Definition: jmemsys.h:48
static LONG WINAPI MediaStreamFilterImpl_GetPinCount(BaseFilter *iface)