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
25 #include "wine/debug.h"
32 #include "amstream_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(amstream
);
38 IAMMultiMediaStream lpVtbl
;
40 IGraphBuilder
* pFilterGraph
;
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
);
55 return CLASS_E_NOAGGREGATION
;
57 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IAMMultiMediaStreamImpl
));
59 object
->lpVtbl
.lpVtbl
= &AM_Vtbl
;
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
);
82 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
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
);
104 HeapFree(GetProcessHeap(), 0, This
);
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
);
119 static HRESULT WINAPI
IAMMultiMediaStreamImpl_GetMediaStream(IAMMultiMediaStream
* iface
, REFMSPID idPurpose
, IMediaStream
** ppMediaStream
)
121 IAMMultiMediaStreamImpl
*This
= (IAMMultiMediaStreamImpl
*)iface
;
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
);
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
);
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
);
159 static HRESULT WINAPI
IAMMultiMediaStreamImpl_SetState(IAMMultiMediaStream
* iface
, STREAM_STATE NewState
)
161 IAMMultiMediaStreamImpl
*This
= (IAMMultiMediaStreamImpl
*)iface
;
163 FIXME("(%p/%p)->() stub!\n", This
, iface
);
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
);
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
);
186 static HRESULT WINAPI
IAMMultiMediaStreamImpl_Seek(IAMMultiMediaStream
* iface
, STREAM_TIME SeekTime
)
188 IAMMultiMediaStreamImpl
*This
= (IAMMultiMediaStreamImpl
*)iface
;
190 FIXME("(%p/%p)->() stub!\n", This
, iface
);
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
);
204 /*** IAMMultiMediaStream methods ***/
205 static HRESULT WINAPI
IAMMultiMediaStreamImpl_Initialize(IAMMultiMediaStream
* iface
, STREAM_TYPE StreamType
, DWORD dwFlags
, IGraphBuilder
* pFilterGraph
)
207 IAMMultiMediaStreamImpl
*This
= (IAMMultiMediaStreamImpl
*)iface
;
210 FIXME("(%p/%p)->(%lx,%lx,%p) partial stub!\n", This
, iface
, (DWORD
)StreamType
, dwFlags
, pFilterGraph
);
214 This
->pFilterGraph
= pFilterGraph
;
215 IGraphBuilder_AddRef(This
->pFilterGraph
);
219 hr
= CoCreateInstance(&CLSID_FilterGraph
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IGraphBuilder
, (LPVOID
*)&This
->pFilterGraph
);
224 This
->StreamType
= StreamType
;
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
);
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
);
248 static HRESULT WINAPI
IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream
* iface
, IUnknown
* pStreamObject
, const MSPID
* PurposeId
,
249 DWORD dwFlags
, IMediaStream
** ppNewStream
)
251 IAMMultiMediaStreamImpl
*This
= (IAMMultiMediaStreamImpl
*)iface
;
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
);
261 pNewStreams
= (IMediaStream
**)CoTaskMemAlloc((This
->nbStreams
+1)*sizeof(IMediaStream
*));
264 IMediaStream_Release(pStream
);
265 return E_OUTOFMEMORY
;
268 CopyMemory(pNewStreams
, This
->pStreams
, This
->nbStreams
*sizeof(IMediaStream
*));
269 CoTaskMemFree(This
->pStreams
);
270 This
->pStreams
= pNewStreams
;
271 This
->pStreams
[This
->nbStreams
] = pStream
;
275 *ppNewStream
= pStream
;
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
);
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
);
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
);
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