2 * Implementation of IMediaStream Interface
4 * Copyright 2005, 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"
31 #include "amstream_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(amstream);
39 const IMediaStreamVtbl *lpVtbl;
41 IMultiMediaStream* Parent;
43 STREAM_TYPE StreamType;
47 IDirectDrawMediaStream IDirectDrawMediaStream_iface;
49 IMultiMediaStream* Parent;
51 STREAM_TYPE StreamType;
52 } IDirectDrawMediaStreamImpl;
54 static const struct IMediaStreamVtbl MediaStream_Vtbl;
55 static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStream_Vtbl;
57 HRESULT MediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, STREAM_TYPE StreamType, IMediaStream** ppMediaStream)
59 IMediaStreamImpl* object;
61 TRACE("(%p,%s,%p)\n", Parent, debugstr_guid(pPurposeId), ppMediaStream);
63 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl));
66 ERR("Out of memory\n");
70 object->lpVtbl = &MediaStream_Vtbl;
73 object->Parent = Parent;
74 object->PurposeId = *pPurposeId;
75 object->StreamType = StreamType;
77 *ppMediaStream = (IMediaStream*)object;
82 /*** IUnknown methods ***/
83 static HRESULT WINAPI IMediaStreamImpl_QueryInterface(IMediaStream* iface, REFIID riid, void** ppvObject)
85 IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
87 TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
89 if (IsEqualGUID(riid, &IID_IUnknown) ||
90 IsEqualGUID(riid, &IID_IMediaStream))
92 IUnknown_AddRef(iface);
97 ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
101 static ULONG WINAPI IMediaStreamImpl_AddRef(IMediaStream* iface)
103 IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
105 TRACE("(%p/%p)\n", iface, This);
107 return InterlockedIncrement(&This->ref);
110 static ULONG WINAPI IMediaStreamImpl_Release(IMediaStream* iface)
112 IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
113 ULONG ref = InterlockedDecrement(&This->ref);
115 TRACE("(%p/%p)\n", iface, This);
118 HeapFree(GetProcessHeap(), 0, This);
123 /*** IMediaStream methods ***/
124 static HRESULT WINAPI IMediaStreamImpl_GetMultiMediaStream(IMediaStream* iface, IMultiMediaStream** ppMultiMediaStream)
126 IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
128 FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppMultiMediaStream);
134 static HRESULT WINAPI IMediaStreamImpl_GetInformation(IMediaStream* iface, MSPID* pPurposeId, STREAM_TYPE* pType)
136 IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
138 TRACE("(%p/%p)->(%p,%p)\n", This, iface, pPurposeId, pType);
141 *pPurposeId = This->PurposeId;
143 *pType = This->StreamType;
148 static HRESULT WINAPI IMediaStreamImpl_SetSameFormat(IMediaStream* iface, IMediaStream* pStreamThatHasDesiredFormat, DWORD dwFlags)
150 IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
152 FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, dwFlags);
157 static HRESULT WINAPI IMediaStreamImpl_AllocateSample(IMediaStream* iface, DWORD dwFlags, IStreamSample** ppSample)
159 IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
161 FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, dwFlags, ppSample);
166 static HRESULT WINAPI IMediaStreamImpl_CreateSharedSample(IMediaStream* iface, IStreamSample* pExistingSample, DWORD dwFlags, IStreamSample** ppSample)
168 IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
170 FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, pExistingSample, dwFlags, ppSample);
175 static HRESULT WINAPI IMediaStreamImpl_SendEndOfStream(IMediaStream* iface, DWORD dwFlags)
177 IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
179 FIXME("(%p/%p)->(%x) stub!\n", This, iface, dwFlags);
184 static const struct IMediaStreamVtbl MediaStream_Vtbl =
186 IMediaStreamImpl_QueryInterface,
187 IMediaStreamImpl_AddRef,
188 IMediaStreamImpl_Release,
189 IMediaStreamImpl_GetMultiMediaStream,
190 IMediaStreamImpl_GetInformation,
191 IMediaStreamImpl_SetSameFormat,
192 IMediaStreamImpl_AllocateSample,
193 IMediaStreamImpl_CreateSharedSample,
194 IMediaStreamImpl_SendEndOfStream
197 HRESULT DirectDrawMediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, STREAM_TYPE StreamType, IMediaStream** ppMediaStream)
199 IDirectDrawMediaStreamImpl* object;
201 TRACE("(%p,%s,%p)\n", Parent, debugstr_guid(pPurposeId), ppMediaStream);
203 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl));
206 ERR("Out of memory\n");
207 return E_OUTOFMEMORY;
210 object->IDirectDrawMediaStream_iface.lpVtbl = &DirectDrawMediaStream_Vtbl;
213 object->Parent = Parent;
214 object->PurposeId = *pPurposeId;
215 object->StreamType = StreamType;
217 *ppMediaStream = (IMediaStream*)&object->IDirectDrawMediaStream_iface;
222 static inline IDirectDrawMediaStreamImpl *impl_from_IDirectDrawMediaStream(IDirectDrawMediaStream *iface)
224 return CONTAINING_RECORD(iface, IDirectDrawMediaStreamImpl, IDirectDrawMediaStream_iface);
227 static HRESULT WINAPI IDirectDrawMediaStreamImpl_QueryInterface(IDirectDrawMediaStream *iface,
228 REFIID riid, void **ppv)
230 IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
232 TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppv);
234 if (IsEqualGUID(riid, &IID_IUnknown) ||
235 IsEqualGUID(riid, &IID_IMediaStream) ||
236 IsEqualGUID(riid, &IID_IDirectDrawMediaStream))
238 IUnknown_AddRef(iface);
243 ERR("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppv);
244 return E_NOINTERFACE;
247 static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetFormat(IDirectDrawMediaStream *iface,
248 DDSURFACEDESC *pDDSDCurrent, IDirectDrawPalette **ppDirectDrawPalette,
249 DDSURFACEDESC *pDDSDDesired, DWORD *pdwFlags)
251 FIXME("(%p)->(%p,%p,%p,%p) stub!\n", iface, pDDSDCurrent, ppDirectDrawPalette, pDDSDDesired,
258 static HRESULT WINAPI IDirectDrawMediaStreamImpl_SetFormat(IDirectDrawMediaStream *iface,
259 const DDSURFACEDESC *pDDSurfaceDesc, IDirectDrawPalette *pDirectDrawPalette)
261 FIXME("(%p)->(%p,%p) stub!\n", iface, pDDSurfaceDesc, pDirectDrawPalette);
266 static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetDirectDraw(IDirectDrawMediaStream *iface,
267 IDirectDraw **ppDirectDraw)
269 FIXME("(%p)->(%p) stub!\n", iface, ppDirectDraw);
274 static HRESULT WINAPI IDirectDrawMediaStreamImpl_SetDirectDraw(IDirectDrawMediaStream *iface,
275 IDirectDraw *pDirectDraw)
277 FIXME("(%p)->(%p) stub!\n", iface, pDirectDraw);
282 static HRESULT WINAPI IDirectDrawMediaStreamImpl_CreateSample(IDirectDrawMediaStream *iface,
283 IDirectDrawSurface *pSurface, const RECT *pRect, DWORD dwFlags,
284 IDirectDrawStreamSample **ppSample)
286 FIXME("(%p)->(%p,%p,%x,%p) stub!\n", iface, pSurface, pRect, dwFlags, ppSample);
291 static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetTimePerFrame(IDirectDrawMediaStream *iface,
292 STREAM_TIME *pFrameTime)
294 FIXME("(%p)->(%p) stub!\n", iface, pFrameTime);
299 /* Note: Hack so we can reuse the old functions without compiler warnings */
300 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
301 # define XCAST(fun) (typeof(DirectDrawMediaStream_Vtbl.fun))
303 # define XCAST(fun) (void*)
306 static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStream_Vtbl =
308 IDirectDrawMediaStreamImpl_QueryInterface,
309 XCAST(AddRef)IMediaStreamImpl_AddRef,
310 XCAST(Release)IMediaStreamImpl_Release,
311 XCAST(GetMultiMediaStream)IMediaStreamImpl_GetMultiMediaStream,
312 XCAST(GetInformation)IMediaStreamImpl_GetInformation,
313 XCAST(SetSameFormat)IMediaStreamImpl_SetSameFormat,
314 XCAST(AllocateSample)IMediaStreamImpl_AllocateSample,
315 XCAST(CreateSharedSample)IMediaStreamImpl_CreateSharedSample,
316 XCAST(SendEndOfStream)IMediaStreamImpl_SendEndOfStream,
317 IDirectDrawMediaStreamImpl_GetFormat,
318 IDirectDrawMediaStreamImpl_SetFormat,
319 IDirectDrawMediaStreamImpl_GetDirectDraw,
320 IDirectDrawMediaStreamImpl_SetDirectDraw,
321 IDirectDrawMediaStreamImpl_CreateSample,
322 IDirectDrawMediaStreamImpl_GetTimePerFrame