dsound: Add full duplex tests.
[wine/gsoc_dplay.git] / dlls / amstream / amstream.c
blob97be65bca5dda54f3a4ac990dabc96fb3ec79864
1 /*
2 * Implementation of IAMMultiMediaStream Interface
4 * Copyright 2004 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "config.h"
25 #include "wine/debug.h"
27 #define COBJMACROS
29 #include "winbase.h"
30 #include "wingdi.h"
32 #include "amstream_private.h"
33 #include "amstream.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(amstream);
37 typedef struct {
38 IAMMultiMediaStream lpVtbl;
39 LONG ref;
40 IGraphBuilder* pFilterGraph;
41 ULONG nbStreams;
42 IMediaStream** pStreams;
43 STREAM_TYPE StreamType;
44 } IAMMultiMediaStreamImpl;
46 static const struct IAMMultiMediaStreamVtbl AM_Vtbl;
48 HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj)
50 IAMMultiMediaStreamImpl* object;
52 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
54 if( pUnkOuter )
55 return CLASS_E_NOAGGREGATION;
57 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAMMultiMediaStreamImpl));
59 object->lpVtbl.lpVtbl = &AM_Vtbl;
60 object->ref = 1;
62 *ppObj = object;
64 return S_OK;
67 /*** IUnknown methods ***/
68 static HRESULT WINAPI IAMMultiMediaStreamImpl_QueryInterface(IAMMultiMediaStream* iface, REFIID riid, void** ppvObject)
70 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
72 FIXME("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
74 if (IsEqualGUID(riid, &IID_IUnknown) ||
75 IsEqualGUID(riid, &IID_IAMMultiMediaStream))
77 IClassFactory_AddRef(iface);
78 *ppvObject = This;
79 return S_OK;
82 ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
84 return E_NOINTERFACE;
87 static ULONG WINAPI IAMMultiMediaStreamImpl_AddRef(IAMMultiMediaStream* iface)
89 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
91 TRACE("(%p/%p)\n", iface, This);
93 return InterlockedIncrement(&This->ref);
96 static ULONG WINAPI IAMMultiMediaStreamImpl_Release(IAMMultiMediaStream* iface)
98 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
99 ULONG ref = InterlockedDecrement(&This->ref);
101 TRACE("(%p/%p)\n", iface, This);
103 if (!ref)
104 HeapFree(GetProcessHeap(), 0, This);
106 return ref;
109 /*** IMultiMediaStream methods ***/
110 static HRESULT WINAPI IAMMultiMediaStreamImpl_GetInformation(IAMMultiMediaStream* iface, char* pdwFlags, STREAM_TYPE* pStreamType)
112 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
114 FIXME("(%p/%p)->(%p,%p) stub!\n", This, iface, pdwFlags, pStreamType);
116 return E_NOTIMPL;
119 static HRESULT WINAPI IAMMultiMediaStreamImpl_GetMediaStream(IAMMultiMediaStream* iface, REFMSPID idPurpose, IMediaStream** ppMediaStream)
121 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
122 MSPID PurposeId;
123 int i;
125 TRACE("(%p/%p)->(%p,%p)\n", This, iface, idPurpose, ppMediaStream);
127 for (i = 0; i < This->nbStreams; i++)
129 IMediaStream_GetInformation(This->pStreams[i], &PurposeId, NULL);
130 if (IsEqualIID(&PurposeId, idPurpose))
132 *ppMediaStream = This->pStreams[i];
133 IMediaStream_AddRef(*ppMediaStream);
134 return S_OK;
138 return MS_E_NOSTREAM;
141 static HRESULT WINAPI IAMMultiMediaStreamImpl_EnumMediaStreams(IAMMultiMediaStream* iface, long Index, IMediaStream** ppMediaStream)
143 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
145 FIXME("(%p/%p)->(%ld,%p) stub!\n", This, iface, Index, ppMediaStream);
147 return E_NOTIMPL;
150 static HRESULT WINAPI IAMMultiMediaStreamImpl_GetState(IAMMultiMediaStream* iface, STREAM_STATE* pCurrentState)
152 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
154 FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentState);
156 return E_NOTIMPL;
159 static HRESULT WINAPI IAMMultiMediaStreamImpl_SetState(IAMMultiMediaStream* iface, STREAM_STATE NewState)
161 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
163 FIXME("(%p/%p)->() stub!\n", This, iface);
165 return E_NOTIMPL;
168 static HRESULT WINAPI IAMMultiMediaStreamImpl_GetTime(IAMMultiMediaStream* iface, STREAM_TIME* pCurrentTime)
170 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
172 FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentTime);
174 return E_NOTIMPL;
177 static HRESULT WINAPI IAMMultiMediaStreamImpl_GetDuration(IAMMultiMediaStream* iface, STREAM_TIME* pDuration)
179 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
181 FIXME("(%p/%p)->(%p) stub!\n", This, iface, pDuration);
183 return E_NOTIMPL;
186 static HRESULT WINAPI IAMMultiMediaStreamImpl_Seek(IAMMultiMediaStream* iface, STREAM_TIME SeekTime)
188 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
190 FIXME("(%p/%p)->() stub!\n", This, iface);
192 return E_NOTIMPL;
195 static HRESULT WINAPI IAMMultiMediaStreamImpl_GetEndOfStream(IAMMultiMediaStream* iface, HANDLE* phEOS)
197 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
199 FIXME("(%p/%p)->(%p) stub!\n", This, iface, phEOS);
201 return E_NOTIMPL;
204 /*** IAMMultiMediaStream methods ***/
205 static HRESULT WINAPI IAMMultiMediaStreamImpl_Initialize(IAMMultiMediaStream* iface, STREAM_TYPE StreamType, DWORD dwFlags, IGraphBuilder* pFilterGraph)
207 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
208 HRESULT hr = S_OK;
210 FIXME("(%p/%p)->(%lx,%lx,%p) partial stub!\n", This, iface, (DWORD)StreamType, dwFlags, pFilterGraph);
212 if (pFilterGraph)
214 This->pFilterGraph = pFilterGraph;
215 IGraphBuilder_AddRef(This->pFilterGraph);
217 else
219 hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, (LPVOID*)&This->pFilterGraph);
222 if (SUCCEEDED(hr))
224 This->StreamType = StreamType;
227 return hr;
230 static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilterGraph(IAMMultiMediaStream* iface, IGraphBuilder** ppGraphBuilder)
232 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
234 FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppGraphBuilder);
236 return E_NOTIMPL;
239 static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilter(IAMMultiMediaStream* iface, IMediaStreamFilter** ppFilter)
241 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
243 FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppFilter);
245 return E_NOTIMPL;
248 static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream* iface, IUnknown* pStreamObject, const MSPID* PurposeId,
249 DWORD dwFlags, IMediaStream** ppNewStream)
251 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
252 HRESULT hr;
253 IMediaStream* pStream;
254 IMediaStream** pNewStreams;
256 FIXME("(%p/%p)->(%p,%p,%lx,%p) partial stub!\n", This, iface, pStreamObject, PurposeId, dwFlags, ppNewStream);
258 hr = MediaStream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream);
259 if (SUCCEEDED(hr))
261 pNewStreams = (IMediaStream**)CoTaskMemAlloc((This->nbStreams+1)*sizeof(IMediaStream*));
262 if (!pNewStreams)
264 IMediaStream_Release(pStream);
265 return E_OUTOFMEMORY;
267 if (This->nbStreams)
268 CopyMemory(pNewStreams, This->pStreams, This->nbStreams*sizeof(IMediaStream*));
269 CoTaskMemFree(This->pStreams);
270 This->pStreams = pNewStreams;
271 This->pStreams[This->nbStreams] = pStream;
272 This->nbStreams++;
274 if (ppNewStream)
275 *ppNewStream = pStream;
278 return hr;
281 static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* iface, LPCWSTR pszFileName, DWORD dwFlags)
283 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
285 FIXME("(%p/%p)->(%s,%lx) stub!\n", This, iface, debugstr_w(pszFileName), dwFlags);
287 return E_NOTIMPL;
290 static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenMoniker(IAMMultiMediaStream* iface, IBindCtx* pCtx, IMoniker* pMoniker, DWORD dwFlags)
292 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
294 FIXME("(%p/%p)->(%p,%p,%lx) stub!\n", This, iface, pCtx, pMoniker, dwFlags);
296 return E_NOTIMPL;
299 static HRESULT WINAPI IAMMultiMediaStreamImpl_Render(IAMMultiMediaStream* iface, DWORD dwFlags)
301 IAMMultiMediaStreamImpl *This = (IAMMultiMediaStreamImpl *)iface;
303 FIXME("(%p/%p)->(%lx) stub!\n", This, iface, dwFlags);
305 return E_NOTIMPL;
308 static const IAMMultiMediaStreamVtbl AM_Vtbl =
310 IAMMultiMediaStreamImpl_QueryInterface,
311 IAMMultiMediaStreamImpl_AddRef,
312 IAMMultiMediaStreamImpl_Release,
313 IAMMultiMediaStreamImpl_GetInformation,
314 IAMMultiMediaStreamImpl_GetMediaStream,
315 IAMMultiMediaStreamImpl_EnumMediaStreams,
316 IAMMultiMediaStreamImpl_GetState,
317 IAMMultiMediaStreamImpl_SetState,
318 IAMMultiMediaStreamImpl_GetTime,
319 IAMMultiMediaStreamImpl_GetDuration,
320 IAMMultiMediaStreamImpl_Seek,
321 IAMMultiMediaStreamImpl_GetEndOfStream,
322 IAMMultiMediaStreamImpl_Initialize,
323 IAMMultiMediaStreamImpl_GetFilterGraph,
324 IAMMultiMediaStreamImpl_GetFilter,
325 IAMMultiMediaStreamImpl_AddMediaStream,
326 IAMMultiMediaStreamImpl_OpenFile,
327 IAMMultiMediaStreamImpl_OpenMoniker,
328 IAMMultiMediaStreamImpl_Render