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 const IDirectDrawMediaStreamVtbl
*lpVtbl
;
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
->lpVtbl
= &DirectDrawMediaStream_Vtbl
;
213 object
->Parent
= Parent
;
214 object
->PurposeId
= *pPurposeId
;
215 object
->StreamType
= StreamType
;
217 *ppMediaStream
= (IMediaStream
*)object
;
222 static HRESULT WINAPI
IDirectDrawMediaStreamImpl_QueryInterface(IDirectDrawMediaStream
* iface
, REFIID riid
, void** ppvObject
)
224 IMediaStreamImpl
*This
= (IMediaStreamImpl
*)iface
;
226 TRACE("(%p/%p)->(%s,%p)\n", iface
, This
, debugstr_guid(riid
), ppvObject
);
228 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
229 IsEqualGUID(riid
, &IID_IMediaStream
) ||
230 IsEqualGUID(riid
, &IID_IDirectDrawMediaStream
))
232 IUnknown_AddRef(iface
);
237 ERR("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
238 return E_NOINTERFACE
;
241 static HRESULT WINAPI
IDirectDrawMediaStreamImpl_GetFormat(IDirectDrawMediaStream
* iface
, DDSURFACEDESC
*pDDSDCurrent
,
242 IDirectDrawPalette
**ppDirectDrawPalette
, DDSURFACEDESC
*pDDSDDesired
, DWORD
*pdwFlags
)
244 FIXME("(%p)->(%p,%p,%p,%p) stub!\n", iface
, pDDSDCurrent
, ppDirectDrawPalette
, pDDSDDesired
, pdwFlags
);
250 static HRESULT WINAPI
IDirectDrawMediaStreamImpl_SetFormat(IDirectDrawMediaStream
* iface
, const DDSURFACEDESC
*pDDSurfaceDesc
,
251 IDirectDrawPalette
*pDirectDrawPalette
)
253 FIXME("(%p)->(%p,%p) stub!\n", iface
, pDDSurfaceDesc
, pDirectDrawPalette
);
258 static HRESULT WINAPI
IDirectDrawMediaStreamImpl_GetDirectDraw(IDirectDrawMediaStream
* iface
, IDirectDraw
**ppDirectDraw
)
260 FIXME("(%p)->(%p) stub!\n", iface
, ppDirectDraw
);
265 static HRESULT WINAPI
IDirectDrawMediaStreamImpl_SetDirectDraw(IDirectDrawMediaStream
* iface
, IDirectDraw
*pDirectDraw
)
267 FIXME("(%p)->(%p) stub!\n", iface
, pDirectDraw
);
272 static HRESULT WINAPI
IDirectDrawMediaStreamImpl_CreateSample(IDirectDrawMediaStream
* iface
, IDirectDrawSurface
*pSurface
, const RECT
*pRect
,
273 DWORD dwFlags
, IDirectDrawStreamSample
**ppSample
)
275 FIXME("(%p)->(%p,%p,%x,%p) stub!\n", iface
, pSurface
, pRect
, dwFlags
, ppSample
);
280 static HRESULT WINAPI
IDirectDrawMediaStreamImpl_GetTimePerFrame(IDirectDrawMediaStream
* iface
, STREAM_TIME
*pFrameTime
)
282 FIXME("(%p)->(%p) stub!\n", iface
, pFrameTime
);
287 /* Note: Hack so we can reuse the old functions without compiler warnings */
288 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
289 # define XCAST(fun) (typeof(DirectDrawMediaStream_Vtbl.fun))
291 # define XCAST(fun) (void*)
294 static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStream_Vtbl
=
296 IDirectDrawMediaStreamImpl_QueryInterface
,
297 XCAST(AddRef
)IMediaStreamImpl_AddRef
,
298 XCAST(Release
)IMediaStreamImpl_Release
,
299 XCAST(GetMultiMediaStream
)IMediaStreamImpl_GetMultiMediaStream
,
300 XCAST(GetInformation
)IMediaStreamImpl_GetInformation
,
301 XCAST(SetSameFormat
)IMediaStreamImpl_SetSameFormat
,
302 XCAST(AllocateSample
)IMediaStreamImpl_AllocateSample
,
303 XCAST(CreateSharedSample
)IMediaStreamImpl_CreateSharedSample
,
304 XCAST(SendEndOfStream
)IMediaStreamImpl_SendEndOfStream
,
305 IDirectDrawMediaStreamImpl_GetFormat
,
306 IDirectDrawMediaStreamImpl_SetFormat
,
307 IDirectDrawMediaStreamImpl_GetDirectDraw
,
308 IDirectDrawMediaStreamImpl_SetDirectDraw
,
309 IDirectDrawMediaStreamImpl_CreateSample
,
310 IDirectDrawMediaStreamImpl_GetTimePerFrame