wined3d: Move IWineD3DDeviceImpl_SetupFullscreenWindow() to swapchain.c.
[wine] / dlls / amstream / mediastreamfilter.c
1 /*
2  * Implementation of MediaStream Filter
3  *
4  * Copyright 2008 Christian Costa
5  *
6  * This file contains the (internal) driver registration functions,
7  * driver enumeration APIs and DirectDraw creation functions.
8  *
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.
13  *
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.
18  *
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
22  */
23
24 #include "wine/debug.h"
25
26 #define COBJMACROS
27
28 #include "winbase.h"
29 #include "wingdi.h"
30
31 #include "amstream_private.h"
32 #include "amstream.h"
33
34 #include "ddstream.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(amstream);
37
38 typedef struct {
39     IMediaStreamFilter 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;
47
48 static const struct IMediaStreamFilterVtbl MediaStreamFilter_Vtbl;
49
50 HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, LPVOID *ppObj)
51 {
52     IMediaStreamFilterImpl* object;
53
54     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
55
56     if( pUnkOuter )
57         return CLASS_E_NOAGGREGATION;
58
59     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamFilterImpl));
60     if (!object)
61     {
62         ERR("Out of memory\n");
63         return E_OUTOFMEMORY;
64     }
65
66     object->lpVtbl.lpVtbl = &MediaStreamFilter_Vtbl;
67     object->ref = 1;
68
69     *ppObj = object;
70
71     return S_OK;
72 }
73
74 /*** IUnknown methods ***/
75
76 static HRESULT WINAPI MediaStreamFilterImpl_QueryInterface(IMediaStreamFilter * iface, REFIID riid, LPVOID * ppv)
77 {
78     IMediaStreamFilterImpl *This = (IMediaStreamFilterImpl *)iface;
79
80     TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
81
82     *ppv = NULL;
83
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;
94
95     if (*ppv)
96     {
97         IUnknown_AddRef((IUnknown *)(*ppv));
98         return S_OK;
99     }
100
101     return E_NOINTERFACE;
102 }
103
104 static ULONG WINAPI MediaStreamFilterImpl_AddRef(IMediaStreamFilter * iface)
105 {
106     IMediaStreamFilterImpl *This = (IMediaStreamFilterImpl *)iface;
107     ULONG refCount = InterlockedIncrement(&This->ref);
108
109     TRACE("(%p)->() AddRef from %d\n", iface, refCount - 1);
110
111     return refCount;
112 }
113
114 static ULONG WINAPI MediaStreamFilterImpl_Release(IMediaStreamFilter * iface)
115 {
116     IMediaStreamFilterImpl *This = (IMediaStreamFilterImpl *)iface;
117     ULONG refCount = InterlockedDecrement(&This->ref);
118
119     TRACE("(%p)->() Release from %d\n", iface, refCount + 1);
120
121     if (!refCount)
122     {
123         This->lpVtbl.lpVtbl = NULL;
124         HeapFree(GetProcessHeap(), 0, This);
125     }
126
127     return refCount;
128 }
129
130 /*** IPersist methods ***/
131
132 static HRESULT WINAPI MediaStreamFilterImpl_GetClassID(IMediaStreamFilter * iface, CLSID * pClsid)
133 {
134     TRACE("(%p)->(%p)\n", iface, pClsid);
135
136     *pClsid = CLSID_MediaStreamFilter;
137
138     return S_OK;
139 }
140
141 /*** IMediaFilter methods ***/
142
143 static HRESULT WINAPI MediaStreamFilterImpl_Stop(IMediaStreamFilter * iface)
144 {
145     FIXME("(%p)->(): Stub!\n", iface);
146
147     return E_NOTIMPL;
148 }
149
150 static HRESULT WINAPI MediaStreamFilterImpl_Pause(IMediaStreamFilter * iface)
151 {
152     FIXME("(%p)->(): Stub!\n", iface);
153
154     return E_NOTIMPL;
155 }
156
157 static HRESULT WINAPI MediaStreamFilterImpl_Run(IMediaStreamFilter * iface, REFERENCE_TIME tStart)
158 {
159     FIXME("(%p)->(%s): Stub!\n", iface, wine_dbgstr_longlong(tStart));
160
161     return E_NOTIMPL;
162 }
163
164 static HRESULT WINAPI MediaStreamFilterImpl_GetState(IMediaStreamFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
165 {
166     FIXME("(%p)->(%d,%p): Stub!\n", iface, dwMilliSecsTimeout, pState);
167
168     return E_NOTIMPL;
169 }
170
171 static HRESULT WINAPI MediaStreamFilterImpl_SetSyncSource(IMediaStreamFilter * iface, IReferenceClock *pClock)
172 {
173     TRACE("(%p)->(%p): Stub!\n", iface, pClock);
174
175     return E_NOTIMPL;
176 }
177
178 static HRESULT WINAPI MediaStreamFilterImpl_GetSyncSource(IMediaStreamFilter * iface, IReferenceClock **ppClock)
179 {
180     FIXME("(%p)->(%p): Stub!\n", iface, ppClock);
181
182     return E_NOTIMPL;
183 }
184
185 /*** IBaseFilter methods ***/
186
187 static HRESULT WINAPI MediaStreamFilterImpl_EnumPins(IMediaStreamFilter * iface, IEnumPins **ppEnum)
188 {
189     FIXME("(%p)->(%p): Stub!\n", iface, ppEnum);
190
191     return E_NOTIMPL;
192 }
193
194 static HRESULT WINAPI MediaStreamFilterImpl_FindPin(IMediaStreamFilter * iface, LPCWSTR Id, IPin **ppPin)
195 {
196     FIXME("(%p)->(%s,%p): Stub!\n", iface, debugstr_w(Id), ppPin);
197
198     return E_NOTIMPL;
199 }
200
201 static HRESULT WINAPI MediaStreamFilterImpl_QueryFilterInfo(IMediaStreamFilter * iface, FILTER_INFO *pInfo)
202 {
203     FIXME("(%p)->(%p): Stub!\n", iface, pInfo);
204
205     return E_NOTIMPL;
206 }
207
208 static HRESULT WINAPI MediaStreamFilterImpl_JoinFilterGraph(IMediaStreamFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
209 {
210     FIXME("(%p)->(%p, %s): Stub!\n", iface, pGraph, debugstr_w(pName));
211
212     return E_NOTIMPL;
213 }
214
215 static HRESULT WINAPI MediaStreamFilterImpl_QueryVendorInfo(IMediaStreamFilter * iface, LPWSTR *pVendorInfo)
216 {
217     FIXME("(%p)->(%p): Stub!\n", iface, pVendorInfo);
218
219     return E_NOTIMPL;
220 }
221
222 /*** IMediaStreamFilter methods ***/
223
224 static HRESULT WINAPI MediaStreamFilterImpl_AddMediaStream(IMediaStreamFilter* iface, IAMMediaStream *pAMMediaStream)
225 {
226     FIXME("(%p)->(%p): Stub!\n", iface, pAMMediaStream);
227
228     return E_NOTIMPL;
229 }
230
231 static HRESULT WINAPI MediaStreamFilterImpl_GetMediaStream(IMediaStreamFilter* iface, REFMSPID idPurpose, IMediaStream **ppMediaStream)
232 {
233     FIXME("(%p)->(%s,%p): Stub!\n", iface, debugstr_guid(idPurpose), ppMediaStream);
234
235     return E_NOTIMPL;
236 }
237
238 static HRESULT WINAPI MediaStreamFilterImpl_EnumMediaStreams(IMediaStreamFilter* iface, LONG Index, IMediaStream **ppMediaStream)
239 {
240     FIXME("(%p)->(%d,%p): Stub!\n", iface, Index, ppMediaStream);
241
242     return E_NOTIMPL;
243 }
244
245 static HRESULT WINAPI MediaStreamFilterImpl_SupportSeeking(IMediaStreamFilter* iface, BOOL bRenderer)
246 {
247     FIXME("(%p)->(%d): Stub!\n", iface, bRenderer);
248
249     return E_NOTIMPL;
250 }
251
252 static HRESULT WINAPI MediaStreamFilterImpl_ReferenceTimeToStreamTime(IMediaStreamFilter* iface, REFERENCE_TIME *pTime)
253 {
254     FIXME("(%p)->(%p): Stub!\n", iface, pTime);
255
256     return E_NOTIMPL;
257 }
258
259 static HRESULT WINAPI MediaStreamFilterImpl_GetCurrentStreamTime(IMediaStreamFilter* iface, REFERENCE_TIME *pCurrentStreamTime)
260 {
261     FIXME("(%p)->(%p): Stub!\n", iface, pCurrentStreamTime);
262
263     return E_NOTIMPL;
264 }
265
266 static HRESULT WINAPI MediaStreamFilterImpl_WaitUntil(IMediaStreamFilter* iface, REFERENCE_TIME WaitStreamTime)
267 {
268     FIXME("(%p)->(%s): Stub!\n", iface, wine_dbgstr_longlong(WaitStreamTime));
269
270     return E_NOTIMPL;
271 }
272
273 static HRESULT WINAPI MediaStreamFilterImpl_Flush(IMediaStreamFilter* iface, BOOL bCancelEOS)
274 {
275     FIXME("(%p)->(%d): Stub!\n", iface, bCancelEOS);
276
277     return E_NOTIMPL;
278 }
279
280 static HRESULT WINAPI MediaStreamFilterImpl_EndOfStream(IMediaStreamFilter* iface)
281 {
282     FIXME("(%p)->(): Stub!\n",  iface);
283
284     return E_NOTIMPL;
285 }
286
287 static const IMediaStreamFilterVtbl MediaStreamFilter_Vtbl =
288 {
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
313 };