ole32/tests: For win9x and winme the size of the data on the clipboard may be larger...
[wine/multimedia.git] / dlls / amstream / mediastream.c
blob697b03bdff1537cefe13e0aeec05c47679219999
1 /*
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"
26 #define COBJMACROS
28 #include "winbase.h"
29 #include "wingdi.h"
31 #include "amstream_private.h"
32 #include "amstream.h"
34 #include "ddstream.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(amstream);
38 typedef struct {
39 IMediaStream lpVtbl;
40 LONG ref;
41 IMultiMediaStream* Parent;
42 MSPID PurposeId;
43 STREAM_TYPE StreamType;
44 } IMediaStreamImpl;
46 typedef struct {
47 IDirectDrawMediaStream lpVtbl;
48 LONG ref;
49 IMultiMediaStream* Parent;
50 MSPID PurposeId;
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));
64 if (!object)
66 ERR("Out of memory\n");
67 return E_OUTOFMEMORY;
70 object->lpVtbl.lpVtbl = &MediaStream_Vtbl;
71 object->ref = 1;
73 object->Parent = Parent;
74 object->PurposeId = *pPurposeId;
75 object->StreamType = StreamType;
77 *ppMediaStream = (IMediaStream*)object;
79 return S_OK;
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 IClassFactory_AddRef(iface);
93 *ppvObject = This;
94 return S_OK;
97 ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
98 return E_NOINTERFACE;
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);
117 if (!ref)
118 HeapFree(GetProcessHeap(), 0, This);
120 return ref;
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);
130 return S_FALSE;
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);
140 if (pPurposeId)
141 *pPurposeId = This->PurposeId;
142 if (pType)
143 *pType = This->StreamType;
145 return S_OK;
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);
154 return S_FALSE;
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);
163 return S_FALSE;
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);
172 return S_FALSE;
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);
181 return S_FALSE;
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));
204 if (!object)
206 ERR("Out of memory\n");
207 return E_OUTOFMEMORY;
210 object->lpVtbl.lpVtbl = &DirectDrawMediaStream_Vtbl;
211 object->ref = 1;
213 object->Parent = Parent;
214 object->PurposeId = *pPurposeId;
215 object->StreamType = StreamType;
217 *ppMediaStream = (IMediaStream*)object;
219 return S_OK;
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 IClassFactory_AddRef(iface);
233 *ppvObject = This;
234 return S_OK;
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);
246 return E_NOTIMPL;
250 static HRESULT WINAPI IDirectDrawMediaStreamImpl_SetFormat(IDirectDrawMediaStream* iface, const DDSURFACEDESC *pDDSurfaceDesc,
251 IDirectDrawPalette *pDirectDrawPalette)
253 FIXME("(%p)->(%p,%p) stub!\n", iface, pDDSurfaceDesc, pDirectDrawPalette);
255 return E_NOTIMPL;
258 static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetDirectDraw(IDirectDrawMediaStream* iface, IDirectDraw **ppDirectDraw)
260 FIXME("(%p)->(%p) stub!\n", iface, ppDirectDraw);
262 return E_NOTIMPL;
265 static HRESULT WINAPI IDirectDrawMediaStreamImpl_SetDirectDraw(IDirectDrawMediaStream* iface, IDirectDraw *pDirectDraw)
267 FIXME("(%p)->(%p) stub!\n", iface, pDirectDraw);
269 return E_NOTIMPL;
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);
277 return E_NOTIMPL;
280 static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetTimePerFrame(IDirectDrawMediaStream* iface, STREAM_TIME *pFrameTime)
282 FIXME("(%p)->(%p) stub!\n", iface, pFrameTime);
284 return E_NOTIMPL;
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))
290 #else
291 # define XCAST(fun) (void*)
292 #endif
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
312 #undef XCAST