qcap/smartteefilter: Use strmbase filter aggregation support.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d78e2d0c8d
commit
c52bc25dd8
|
@ -36,19 +36,12 @@
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(qcap);
|
WINE_DEFAULT_DEBUG_CHANNEL(qcap);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
IUnknown IUnknown_iface;
|
|
||||||
IUnknown *outerUnknown;
|
|
||||||
BaseFilter filter;
|
BaseFilter filter;
|
||||||
BaseInputPin *input;
|
BaseInputPin *input;
|
||||||
BaseOutputPin *capture;
|
BaseOutputPin *capture;
|
||||||
BaseOutputPin *preview;
|
BaseOutputPin *preview;
|
||||||
} SmartTeeFilter;
|
} SmartTeeFilter;
|
||||||
|
|
||||||
static inline SmartTeeFilter *impl_from_IUnknown(IUnknown *iface)
|
|
||||||
{
|
|
||||||
return CONTAINING_RECORD(iface, SmartTeeFilter, IUnknown_iface);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline SmartTeeFilter *impl_from_BaseFilter(BaseFilter *filter)
|
static inline SmartTeeFilter *impl_from_BaseFilter(BaseFilter *filter)
|
||||||
{
|
{
|
||||||
return CONTAINING_RECORD(filter, SmartTeeFilter, filter);
|
return CONTAINING_RECORD(filter, SmartTeeFilter, filter);
|
||||||
|
@ -71,80 +64,6 @@ static inline SmartTeeFilter *impl_from_IPin(IPin *iface)
|
||||||
return impl_from_IBaseFilter(bp->pinInfo.pFilter);
|
return impl_from_IBaseFilter(bp->pinInfo.pFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI Unknown_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
|
|
||||||
{
|
|
||||||
SmartTeeFilter *This = impl_from_IUnknown(iface);
|
|
||||||
if (IsEqualIID(riid, &IID_IUnknown)) {
|
|
||||||
TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppv);
|
|
||||||
*ppv = &This->IUnknown_iface;
|
|
||||||
} else if (IsEqualIID(riid, &IID_IPersist)) {
|
|
||||||
TRACE("(%p)->(IID_IPersist, %p)\n", This, ppv);
|
|
||||||
*ppv = &This->filter.IBaseFilter_iface;
|
|
||||||
} else if (IsEqualIID(riid, &IID_IMediaFilter)) {
|
|
||||||
TRACE("(%p)->(IID_IMediaFilter, %p)\n", This, ppv);
|
|
||||||
*ppv = &This->filter.IBaseFilter_iface;
|
|
||||||
} else if (IsEqualIID(riid, &IID_IBaseFilter)) {
|
|
||||||
TRACE("(%p)->(IID_IBaseFilter, %p)\n", This, ppv);
|
|
||||||
*ppv = &This->filter.IBaseFilter_iface;
|
|
||||||
} else {
|
|
||||||
FIXME("(%p): no interface for %s\n", This, debugstr_guid(riid));
|
|
||||||
*ppv = NULL;
|
|
||||||
return E_NOINTERFACE;
|
|
||||||
}
|
|
||||||
IUnknown_AddRef((IUnknown*)*ppv);
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ULONG WINAPI Unknown_AddRef(IUnknown *iface)
|
|
||||||
{
|
|
||||||
SmartTeeFilter *This = impl_from_IUnknown(iface);
|
|
||||||
return BaseFilterImpl_AddRef(&This->filter.IBaseFilter_iface);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ULONG WINAPI Unknown_Release(IUnknown *iface)
|
|
||||||
{
|
|
||||||
SmartTeeFilter *This = impl_from_IUnknown(iface);
|
|
||||||
ULONG ref = InterlockedDecrement(&This->filter.refcount);
|
|
||||||
|
|
||||||
TRACE("(%p)->() ref=%d\n", This, ref);
|
|
||||||
|
|
||||||
if (!ref) {
|
|
||||||
if(This->input)
|
|
||||||
BaseInputPinImpl_Release(&This->input->pin.IPin_iface);
|
|
||||||
if(This->capture)
|
|
||||||
BaseOutputPinImpl_Release(&This->capture->pin.IPin_iface);
|
|
||||||
if(This->preview)
|
|
||||||
BaseOutputPinImpl_Release(&This->preview->pin.IPin_iface);
|
|
||||||
strmbase_filter_cleanup(&This->filter);
|
|
||||||
CoTaskMemFree(This);
|
|
||||||
}
|
|
||||||
return ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const IUnknownVtbl UnknownVtbl = {
|
|
||||||
Unknown_QueryInterface,
|
|
||||||
Unknown_AddRef,
|
|
||||||
Unknown_Release
|
|
||||||
};
|
|
||||||
|
|
||||||
static HRESULT WINAPI SmartTeeFilter_QueryInterface(IBaseFilter *iface, REFIID riid, void **ppv)
|
|
||||||
{
|
|
||||||
SmartTeeFilter *This = impl_from_IBaseFilter(iface);
|
|
||||||
return IUnknown_QueryInterface(This->outerUnknown, riid, ppv);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ULONG WINAPI SmartTeeFilter_AddRef(IBaseFilter *iface)
|
|
||||||
{
|
|
||||||
SmartTeeFilter *This = impl_from_IBaseFilter(iface);
|
|
||||||
return IUnknown_AddRef(This->outerUnknown);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ULONG WINAPI SmartTeeFilter_Release(IBaseFilter *iface)
|
|
||||||
{
|
|
||||||
SmartTeeFilter *This = impl_from_IBaseFilter(iface);
|
|
||||||
return IUnknown_Release(This->outerUnknown);
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI SmartTeeFilter_Stop(IBaseFilter *iface)
|
static HRESULT WINAPI SmartTeeFilter_Stop(IBaseFilter *iface)
|
||||||
{
|
{
|
||||||
SmartTeeFilter *This = impl_from_IBaseFilter(iface);
|
SmartTeeFilter *This = impl_from_IBaseFilter(iface);
|
||||||
|
@ -182,9 +101,9 @@ static HRESULT WINAPI SmartTeeFilter_Run(IBaseFilter *iface, REFERENCE_TIME tSta
|
||||||
}
|
}
|
||||||
|
|
||||||
static const IBaseFilterVtbl SmartTeeFilterVtbl = {
|
static const IBaseFilterVtbl SmartTeeFilterVtbl = {
|
||||||
SmartTeeFilter_QueryInterface,
|
BaseFilterImpl_QueryInterface,
|
||||||
SmartTeeFilter_AddRef,
|
BaseFilterImpl_AddRef,
|
||||||
SmartTeeFilter_Release,
|
BaseFilterImpl_Release,
|
||||||
BaseFilterImpl_GetClassID,
|
BaseFilterImpl_GetClassID,
|
||||||
SmartTeeFilter_Stop,
|
SmartTeeFilter_Stop,
|
||||||
SmartTeeFilter_Pause,
|
SmartTeeFilter_Pause,
|
||||||
|
@ -217,8 +136,23 @@ static IPin *smart_tee_get_pin(BaseFilter *iface, unsigned int index)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void smart_tee_destroy(BaseFilter *iface)
|
||||||
|
{
|
||||||
|
SmartTeeFilter *filter = impl_from_BaseFilter(iface);
|
||||||
|
|
||||||
|
if (filter->input)
|
||||||
|
BaseInputPinImpl_Release(&filter->input->pin.IPin_iface);
|
||||||
|
if (filter->capture)
|
||||||
|
BaseOutputPinImpl_Release(&filter->capture->pin.IPin_iface);
|
||||||
|
if (filter->preview)
|
||||||
|
BaseOutputPinImpl_Release(&filter->preview->pin.IPin_iface);
|
||||||
|
strmbase_filter_cleanup(&filter->filter);
|
||||||
|
CoTaskMemFree(filter);
|
||||||
|
}
|
||||||
|
|
||||||
static const BaseFilterFuncTable SmartTeeFilterFuncs = {
|
static const BaseFilterFuncTable SmartTeeFilterFuncs = {
|
||||||
.filter_get_pin = smart_tee_get_pin,
|
.filter_get_pin = smart_tee_get_pin,
|
||||||
|
.filter_destroy = smart_tee_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static ULONG WINAPI SmartTeeFilterInput_AddRef(IPin *iface)
|
static ULONG WINAPI SmartTeeFilterInput_AddRef(IPin *iface)
|
||||||
|
@ -586,21 +520,14 @@ IUnknown* WINAPI QCAP_createSmartTeeFilter(IUnknown *outer, HRESULT *phr)
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
SmartTeeFilter *This = NULL;
|
SmartTeeFilter *This = NULL;
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", outer, phr);
|
|
||||||
|
|
||||||
This = CoTaskMemAlloc(sizeof(*This));
|
This = CoTaskMemAlloc(sizeof(*This));
|
||||||
if (This == NULL) {
|
if (This == NULL) {
|
||||||
*phr = E_OUTOFMEMORY;
|
*phr = E_OUTOFMEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(This, 0, sizeof(*This));
|
memset(This, 0, sizeof(*This));
|
||||||
This->IUnknown_iface.lpVtbl = &UnknownVtbl;
|
|
||||||
if (outer)
|
|
||||||
This->outerUnknown = outer;
|
|
||||||
else
|
|
||||||
This->outerUnknown = &This->IUnknown_iface;
|
|
||||||
|
|
||||||
strmbase_filter_init(&This->filter, &SmartTeeFilterVtbl, NULL, &CLSID_SmartTee,
|
strmbase_filter_init(&This->filter, &SmartTeeFilterVtbl, outer, &CLSID_SmartTee,
|
||||||
(DWORD_PTR)(__FILE__ ": SmartTeeFilter.csFilter"), &SmartTeeFilterFuncs);
|
(DWORD_PTR)(__FILE__ ": SmartTeeFilter.csFilter"), &SmartTeeFilterFuncs);
|
||||||
|
|
||||||
inputPinInfo.pFilter = &This->filter.IBaseFilter_iface;
|
inputPinInfo.pFilter = &This->filter.IBaseFilter_iface;
|
||||||
|
@ -626,10 +553,7 @@ IUnknown* WINAPI QCAP_createSmartTeeFilter(IUnknown *outer, HRESULT *phr)
|
||||||
end:
|
end:
|
||||||
*phr = hr;
|
*phr = hr;
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
if (outer)
|
return &This->filter.IUnknown_inner;
|
||||||
return &This->IUnknown_iface;
|
|
||||||
else
|
|
||||||
return (IUnknown*)&This->filter.IBaseFilter_iface;
|
|
||||||
} else {
|
} else {
|
||||||
strmbase_filter_cleanup(&This->filter);
|
strmbase_filter_cleanup(&This->filter);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue