amstream: Get rid of the explicit implementation of IMediaStream.

This commit is contained in:
Michael Stefaniuc 2011-08-16 10:24:15 +02:00 committed by Alexandre Julliard
parent 2b55b5b663
commit f49d6df198
3 changed files with 101 additions and 175 deletions

View File

@ -276,11 +276,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream
FIXME("(%p/%p)->(%p,%s,%x,%p) partial stub!\n", This, iface, pStreamObject, debugstr_guid(PurposeId), dwFlags, ppNewStream); FIXME("(%p/%p)->(%p,%s,%x,%p) partial stub!\n", This, iface, pStreamObject, debugstr_guid(PurposeId), dwFlags, ppNewStream);
if (IsEqualGUID(PurposeId, &MSPID_PrimaryVideo)) hr = mediastream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream);
hr = DirectDrawMediaStream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream);
else
hr = MediaStream_create((IMultiMediaStream*)iface, PurposeId, This->StreamType, &pStream);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
pNewStreams = CoTaskMemAlloc((This->nbStreams+1)*sizeof(IMediaStream*)); pNewStreams = CoTaskMemAlloc((This->nbStreams+1)*sizeof(IMediaStream*));

View File

@ -36,7 +36,7 @@
HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN;
HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; HRESULT MediaStreamFilter_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN;
HRESULT MediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, STREAM_TYPE StreamType, IMediaStream** ppMediaStream) DECLSPEC_HIDDEN; HRESULT mediastream_create(IMultiMediaStream *Parent, const MSPID *pPurposeId,
HRESULT DirectDrawMediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, STREAM_TYPE StreamType, IMediaStream** ppMediaStream) DECLSPEC_HIDDEN; STREAM_TYPE StreamType, IMediaStream **ppMediaStream) DECLSPEC_HIDDEN;
#endif /* __AMSTREAM_PRIVATE_INCLUDED__ */ #endif /* __AMSTREAM_PRIVATE_INCLUDED__ */

View File

@ -35,14 +35,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(amstream); WINE_DEFAULT_DEBUG_CHANNEL(amstream);
typedef struct {
const IMediaStreamVtbl *lpVtbl;
LONG ref;
IMultiMediaStream* Parent;
MSPID PurposeId;
STREAM_TYPE StreamType;
} IMediaStreamImpl;
typedef struct { typedef struct {
IDirectDrawMediaStream IDirectDrawMediaStream_iface; IDirectDrawMediaStream IDirectDrawMediaStream_iface;
LONG ref; LONG ref;
@ -51,148 +43,6 @@ typedef struct {
STREAM_TYPE StreamType; STREAM_TYPE StreamType;
} IDirectDrawMediaStreamImpl; } IDirectDrawMediaStreamImpl;
static const struct IMediaStreamVtbl MediaStream_Vtbl;
HRESULT MediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, STREAM_TYPE StreamType, IMediaStream** ppMediaStream)
{
IMediaStreamImpl* object;
TRACE("(%p,%s,%p)\n", Parent, debugstr_guid(pPurposeId), ppMediaStream);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl));
if (!object)
{
ERR("Out of memory\n");
return E_OUTOFMEMORY;
}
object->lpVtbl = &MediaStream_Vtbl;
object->ref = 1;
object->Parent = Parent;
object->PurposeId = *pPurposeId;
object->StreamType = StreamType;
*ppMediaStream = (IMediaStream*)object;
return S_OK;
}
/*** IUnknown methods ***/
static HRESULT WINAPI IMediaStreamImpl_QueryInterface(IMediaStream* iface, REFIID riid, void** ppvObject)
{
IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IMediaStream))
{
IUnknown_AddRef(iface);
*ppvObject = This;
return S_OK;
}
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
return E_NOINTERFACE;
}
static ULONG WINAPI IMediaStreamImpl_AddRef(IMediaStream* iface)
{
IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
TRACE("(%p/%p)\n", iface, This);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI IMediaStreamImpl_Release(IMediaStream* iface)
{
IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)\n", iface, This);
if (!ref)
HeapFree(GetProcessHeap(), 0, This);
return ref;
}
/*** IMediaStream methods ***/
static HRESULT WINAPI IMediaStreamImpl_GetMultiMediaStream(IMediaStream* iface, IMultiMediaStream** ppMultiMediaStream)
{
IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppMultiMediaStream);
return S_FALSE;
}
static HRESULT WINAPI IMediaStreamImpl_GetInformation(IMediaStream* iface, MSPID* pPurposeId, STREAM_TYPE* pType)
{
IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
TRACE("(%p/%p)->(%p,%p)\n", This, iface, pPurposeId, pType);
if (pPurposeId)
*pPurposeId = This->PurposeId;
if (pType)
*pType = This->StreamType;
return S_OK;
}
static HRESULT WINAPI IMediaStreamImpl_SetSameFormat(IMediaStream* iface, IMediaStream* pStreamThatHasDesiredFormat, DWORD dwFlags)
{
IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, dwFlags);
return S_FALSE;
}
static HRESULT WINAPI IMediaStreamImpl_AllocateSample(IMediaStream* iface, DWORD dwFlags, IStreamSample** ppSample)
{
IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, dwFlags, ppSample);
return S_FALSE;
}
static HRESULT WINAPI IMediaStreamImpl_CreateSharedSample(IMediaStream* iface, IStreamSample* pExistingSample, DWORD dwFlags, IStreamSample** ppSample)
{
IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, pExistingSample, dwFlags, ppSample);
return S_FALSE;
}
static HRESULT WINAPI IMediaStreamImpl_SendEndOfStream(IMediaStream* iface, DWORD dwFlags)
{
IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
FIXME("(%p/%p)->(%x) stub!\n", This, iface, dwFlags);
return S_FALSE;
}
static const struct IMediaStreamVtbl MediaStream_Vtbl =
{
IMediaStreamImpl_QueryInterface,
IMediaStreamImpl_AddRef,
IMediaStreamImpl_Release,
IMediaStreamImpl_GetMultiMediaStream,
IMediaStreamImpl_GetInformation,
IMediaStreamImpl_SetSameFormat,
IMediaStreamImpl_AllocateSample,
IMediaStreamImpl_CreateSharedSample,
IMediaStreamImpl_SendEndOfStream
};
static inline IDirectDrawMediaStreamImpl *impl_from_IDirectDrawMediaStream(IDirectDrawMediaStream *iface) static inline IDirectDrawMediaStreamImpl *impl_from_IDirectDrawMediaStream(IDirectDrawMediaStream *iface)
{ {
return CONTAINING_RECORD(iface, IDirectDrawMediaStreamImpl, IDirectDrawMediaStream_iface); return CONTAINING_RECORD(iface, IDirectDrawMediaStreamImpl, IDirectDrawMediaStream_iface);
@ -218,6 +68,94 @@ static HRESULT WINAPI IDirectDrawMediaStreamImpl_QueryInterface(IDirectDrawMedia
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI IDirectDrawMediaStreamImpl_AddRef(IDirectDrawMediaStream *iface)
{
IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
TRACE("(%p/%p)\n", iface, This);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI IDirectDrawMediaStreamImpl_Release(IDirectDrawMediaStream *iface)
{
IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)\n", iface, This);
if (!ref)
HeapFree(GetProcessHeap(), 0, This);
return ref;
}
/*** IMediaStream methods ***/
static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetMultiMediaStream(IDirectDrawMediaStream *iface,
IMultiMediaStream** ppMultiMediaStream)
{
IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppMultiMediaStream);
return S_FALSE;
}
static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetInformation(IDirectDrawMediaStream *iface,
MSPID *pPurposeId, STREAM_TYPE *pType)
{
IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, pPurposeId, pType);
if (pPurposeId)
*pPurposeId = This->PurposeId;
if (pType)
*pType = This->StreamType;
return S_OK;
}
static HRESULT WINAPI IDirectDrawMediaStreamImpl_SetSameFormat(IDirectDrawMediaStream *iface,
IMediaStream *pStreamThatHasDesiredFormat, DWORD dwFlags)
{
IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, dwFlags);
return S_FALSE;
}
static HRESULT WINAPI IDirectDrawMediaStreamImpl_AllocateSample(IDirectDrawMediaStream *iface,
DWORD dwFlags, IStreamSample **ppSample)
{
IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, dwFlags, ppSample);
return S_FALSE;
}
static HRESULT WINAPI IDirectDrawMediaStreamImpl_CreateSharedSample(IDirectDrawMediaStream *iface,
IStreamSample *pExistingSample, DWORD dwFlags, IStreamSample **ppSample)
{
IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, pExistingSample, dwFlags, ppSample);
return S_FALSE;
}
static HRESULT WINAPI IDirectDrawMediaStreamImpl_SendEndOfStream(IDirectDrawMediaStream *iface,
DWORD dwFlags)
{
IDirectDrawMediaStreamImpl *This = impl_from_IDirectDrawMediaStream(iface);
FIXME("(%p/%p)->(%x) stub!\n", This, iface, dwFlags);
return S_FALSE;
}
static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetFormat(IDirectDrawMediaStream *iface, static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetFormat(IDirectDrawMediaStream *iface,
DDSURFACEDESC *pDDSDCurrent, IDirectDrawPalette **ppDirectDrawPalette, DDSURFACEDESC *pDDSDCurrent, IDirectDrawPalette **ppDirectDrawPalette,
DDSURFACEDESC *pDDSDDesired, DWORD *pdwFlags) DDSURFACEDESC *pDDSDDesired, DWORD *pdwFlags)
@ -270,24 +208,17 @@ static HRESULT WINAPI IDirectDrawMediaStreamImpl_GetTimePerFrame(IDirectDrawMedi
return E_NOTIMPL; return E_NOTIMPL;
} }
/* Note: Hack so we can reuse the old functions without compiler warnings */
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(DirectDrawMediaStream_Vtbl.fun))
#else
# define XCAST(fun) (void*)
#endif
static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStream_Vtbl = static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStream_Vtbl =
{ {
IDirectDrawMediaStreamImpl_QueryInterface, IDirectDrawMediaStreamImpl_QueryInterface,
XCAST(AddRef)IMediaStreamImpl_AddRef, IDirectDrawMediaStreamImpl_AddRef,
XCAST(Release)IMediaStreamImpl_Release, IDirectDrawMediaStreamImpl_Release,
XCAST(GetMultiMediaStream)IMediaStreamImpl_GetMultiMediaStream, IDirectDrawMediaStreamImpl_GetMultiMediaStream,
XCAST(GetInformation)IMediaStreamImpl_GetInformation, IDirectDrawMediaStreamImpl_GetInformation,
XCAST(SetSameFormat)IMediaStreamImpl_SetSameFormat, IDirectDrawMediaStreamImpl_SetSameFormat,
XCAST(AllocateSample)IMediaStreamImpl_AllocateSample, IDirectDrawMediaStreamImpl_AllocateSample,
XCAST(CreateSharedSample)IMediaStreamImpl_CreateSharedSample, IDirectDrawMediaStreamImpl_CreateSharedSample,
XCAST(SendEndOfStream)IMediaStreamImpl_SendEndOfStream, IDirectDrawMediaStreamImpl_SendEndOfStream,
IDirectDrawMediaStreamImpl_GetFormat, IDirectDrawMediaStreamImpl_GetFormat,
IDirectDrawMediaStreamImpl_SetFormat, IDirectDrawMediaStreamImpl_SetFormat,
IDirectDrawMediaStreamImpl_GetDirectDraw, IDirectDrawMediaStreamImpl_GetDirectDraw,
@ -295,16 +226,15 @@ static const struct IDirectDrawMediaStreamVtbl DirectDrawMediaStream_Vtbl =
IDirectDrawMediaStreamImpl_CreateSample, IDirectDrawMediaStreamImpl_CreateSample,
IDirectDrawMediaStreamImpl_GetTimePerFrame IDirectDrawMediaStreamImpl_GetTimePerFrame
}; };
#undef XCAST
HRESULT DirectDrawMediaStream_create(IMultiMediaStream *Parent, const MSPID *pPurposeId, HRESULT mediastream_create(IMultiMediaStream *Parent, const MSPID *pPurposeId,
STREAM_TYPE StreamType, IMediaStream **ppMediaStream) STREAM_TYPE StreamType, IMediaStream **ppMediaStream)
{ {
IDirectDrawMediaStreamImpl *object; IDirectDrawMediaStreamImpl *object;
TRACE("(%p,%s,%p)\n", Parent, debugstr_guid(pPurposeId), ppMediaStream); TRACE("(%p,%s,%p)\n", Parent, debugstr_guid(pPurposeId), ppMediaStream);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl)); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawMediaStreamImpl));
if (!object) if (!object)
{ {
ERR("Out of memory\n"); ERR("Out of memory\n");