quartz: Standardize COM aggregation for VideoRenderer.

This commit is contained in:
Michael Stefaniuc 2012-07-02 01:06:01 +02:00 committed by Alexandre Julliard
parent eb6388c4a5
commit 37cfaa2d02
2 changed files with 37 additions and 66 deletions

View File

@ -38,8 +38,6 @@
#define BYTES_FROM_MEDIATIME(time) SEC_FROM_MEDIATIME(time)
#define MSEC_FROM_MEDIATIME(time) ((time) / 10000)
#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
HRESULT FilterGraph_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN;
HRESULT FilterGraphNoThread_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN;
HRESULT FilterMapper2_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN;

View File

@ -54,8 +54,9 @@ typedef struct VideoRendererImpl
BaseControlWindow baseControlWindow;
BaseControlVideo baseControlVideo;
const IUnknownVtbl * IInner_vtbl;
IUnknown IUnknown_inner;
IAMFilterMiscFlags IAMFilterMiscFlags_iface;
IUnknown *outer_unk;
BOOL init;
HANDLE hThread;
@ -69,9 +70,6 @@ typedef struct VideoRendererImpl
RECT WindowPos;
LONG VideoWidth;
LONG VideoHeight;
IUnknown * pUnkOuter;
BOOL bUnkOuterValid;
BOOL bAggregatable;
} VideoRendererImpl;
static inline VideoRendererImpl *impl_from_BaseWindow(BaseWindow *iface)
@ -652,10 +650,7 @@ HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
*ppv = NULL;
pVideoRenderer = CoTaskMemAlloc(sizeof(VideoRendererImpl));
pVideoRenderer->pUnkOuter = pUnkOuter;
pVideoRenderer->bUnkOuterValid = FALSE;
pVideoRenderer->bAggregatable = FALSE;
pVideoRenderer->IInner_vtbl = &IInner_VTable;
pVideoRenderer->IUnknown_inner.lpVtbl = &IInner_VTable;
pVideoRenderer->IAMFilterMiscFlags_iface.lpVtbl = &IAMFilterMiscFlags_Vtbl;
pVideoRenderer->init = 0;
@ -663,6 +658,11 @@ HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
ZeroMemory(&pVideoRenderer->DestRect, sizeof(RECT));
ZeroMemory(&pVideoRenderer->WindowPos, sizeof(RECT));
if (pUnkOuter)
pVideoRenderer->outer_unk = pUnkOuter;
else
pVideoRenderer->outer_unk = &pVideoRenderer->IUnknown_inner;
hr = BaseRenderer_Init(&pVideoRenderer->renderer, &VideoRenderer_Vtbl, pUnkOuter, &CLSID_VideoRenderer, (DWORD_PTR)(__FILE__ ": VideoRendererImpl.csFilter"), &BaseFuncTable);
if (FAILED(hr))
@ -681,7 +681,7 @@ HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
goto fail;
}
*ppv = pVideoRenderer;
*ppv = &pVideoRenderer->IUnknown_inner;
return S_OK;
fail:
@ -696,18 +696,21 @@ HRESULT VideoRendererDefault_create(IUnknown * pUnkOuter, LPVOID * ppv)
return VideoRenderer_create(pUnkOuter, ppv);
}
static HRESULT WINAPI VideoRendererInner_QueryInterface(IUnknown * iface, REFIID riid, LPVOID * ppv)
static inline VideoRendererImpl *impl_from_IUnknown(IUnknown *iface)
{
ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
return CONTAINING_RECORD(iface, VideoRendererImpl, IUnknown_inner);
}
if (This->bAggregatable)
This->bUnkOuterValid = TRUE;
static HRESULT WINAPI VideoRendererInner_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
{
VideoRendererImpl *This = impl_from_IUnknown(iface);
TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
*ppv = NULL;
if (IsEqualIID(riid, &IID_IUnknown))
*ppv = &This->IInner_vtbl;
*ppv = &This->IUnknown_inner;
else if (IsEqualIID(riid, &IID_IBasicVideo))
*ppv = &This->baseControlVideo.IBasicVideo_iface;
else if (IsEqualIID(riid, &IID_IVideoWindow))
@ -724,7 +727,7 @@ static HRESULT WINAPI VideoRendererInner_QueryInterface(IUnknown * iface, REFIID
if (*ppv)
{
IUnknown_AddRef((IUnknown *)(*ppv));
IUnknown_AddRef((IUnknown *)*ppv);
return S_OK;
}
@ -736,20 +739,20 @@ static HRESULT WINAPI VideoRendererInner_QueryInterface(IUnknown * iface, REFIID
static ULONG WINAPI VideoRendererInner_AddRef(IUnknown *iface)
{
ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
VideoRendererImpl *This = impl_from_IUnknown(iface);
ULONG refCount = BaseFilterImpl_AddRef(&This->renderer.filter.IBaseFilter_iface);
TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
TRACE("(%p)->(): new ref = %d\n", This, refCount);
return refCount;
}
static ULONG WINAPI VideoRendererInner_Release(IUnknown *iface)
{
ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
VideoRendererImpl *This = impl_from_IUnknown(iface);
ULONG refCount = BaseRendererImpl_Release(&This->renderer.filter.IBaseFilter_iface);
TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
TRACE("(%p)->(): new ref = %d\n", This, refCount);
if (!refCount)
{
@ -779,49 +782,19 @@ static const IUnknownVtbl IInner_VTable =
static HRESULT WINAPI VideoRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
{
VideoRendererImpl *This = impl_from_IBaseFilter(iface);
if (This->bAggregatable)
This->bUnkOuterValid = TRUE;
if (This->pUnkOuter)
{
if (This->bAggregatable)
return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
if (IsEqualIID(riid, &IID_IUnknown))
{
HRESULT hr;
IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
hr = IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
This->bAggregatable = TRUE;
return hr;
}
*ppv = NULL;
return E_NOINTERFACE;
}
return IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
}
static ULONG WINAPI VideoRenderer_AddRef(IBaseFilter * iface)
{
VideoRendererImpl *This = impl_from_IBaseFilter(iface);
if (This->pUnkOuter && This->bUnkOuterValid)
return IUnknown_AddRef(This->pUnkOuter);
return IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
return IUnknown_AddRef(This->outer_unk);
}
static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
{
VideoRendererImpl *This = impl_from_IBaseFilter(iface);
if (This->pUnkOuter && This->bUnkOuterValid)
return IUnknown_Release(This->pUnkOuter);
return IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
return IUnknown_Release(This->outer_unk);
}
/** IMediaFilter methods **/
@ -877,7 +850,7 @@ static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
return VideoRenderer_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppvObj);
return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
}
static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
@ -885,7 +858,7 @@ static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
TRACE("(%p/%p)->()\n", This, iface);
return VideoRenderer_AddRef(&This->renderer.filter.IBaseFilter_iface);
return IUnknown_AddRef(This->outer_unk);
}
static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
@ -893,7 +866,7 @@ static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
TRACE("(%p/%p)->()\n", This, iface);
return VideoRenderer_Release(&This->renderer.filter.IBaseFilter_iface);
return IUnknown_Release(This->outer_unk);
}
static const IBasicVideoVtbl IBasicVideo_VTable =
@ -948,7 +921,7 @@ static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
return VideoRenderer_QueryInterface(&This->renderer.filter.IBaseFilter_iface, riid, ppvObj);
return IUnknown_QueryInterface(This->outer_unk, riid, ppvObj);
}
static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
@ -956,7 +929,7 @@ static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
TRACE("(%p/%p)->()\n", This, iface);
return VideoRenderer_AddRef(&This->renderer.filter.IBaseFilter_iface);
return IUnknown_AddRef(This->outer_unk);
}
static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
@ -964,7 +937,7 @@ static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
TRACE("(%p/%p)->()\n", This, iface);
return VideoRenderer_Release(&This->renderer.filter.IBaseFilter_iface);
return IUnknown_Release(This->outer_unk);
}
static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
@ -1061,19 +1034,19 @@ static HRESULT WINAPI AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags *iface
void **ppv)
{
VideoRendererImpl *This = impl_from_IAMFilterMiscFlags(iface);
return IUnknown_QueryInterface((IUnknown*)This, riid, ppv);
return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
}
static ULONG WINAPI AMFilterMiscFlags_AddRef(IAMFilterMiscFlags *iface)
{
VideoRendererImpl *This = impl_from_IAMFilterMiscFlags(iface);
return IUnknown_AddRef((IUnknown*)This);
return IUnknown_AddRef(This->outer_unk);
}
static ULONG WINAPI AMFilterMiscFlags_Release(IAMFilterMiscFlags *iface)
{
VideoRendererImpl *This = impl_from_IAMFilterMiscFlags(iface);
return IUnknown_Release((IUnknown*)This);
return IUnknown_Release(This->outer_unk);
}
static ULONG WINAPI AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags *iface)