2012-03-28 21:53:33 +02:00
|
|
|
/*
|
|
|
|
* Generic Implementation of strmbase Base Renderer classes
|
|
|
|
*
|
|
|
|
* Copyright 2012 Aric Stewart, CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2012-04-02 14:52:15 +02:00
|
|
|
#include "strmbase_private.h"
|
2012-03-28 21:53:33 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
|
|
|
|
|
2019-10-24 03:04:23 +02:00
|
|
|
static inline struct strmbase_renderer *impl_from_strmbase_filter(struct strmbase_filter *iface)
|
2012-03-28 21:53:33 +02:00
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct strmbase_renderer, filter);
|
2012-03-28 21:53:33 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 14:52:08 +02:00
|
|
|
static const IQualityControlVtbl Renderer_QualityControl_Vtbl = {
|
|
|
|
QualityControlImpl_QueryInterface,
|
|
|
|
QualityControlImpl_AddRef,
|
|
|
|
QualityControlImpl_Release,
|
|
|
|
QualityControlImpl_Notify,
|
|
|
|
QualityControlImpl_SetSink
|
|
|
|
};
|
|
|
|
|
2019-10-24 03:04:23 +02:00
|
|
|
static inline struct strmbase_renderer *impl_from_IPin(IPin *iface)
|
2019-06-21 03:13:19 +02:00
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct strmbase_renderer, sink.pin.IPin_iface);
|
2019-06-21 03:13:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BaseRenderer_InputPin_ReceiveConnection(IPin *iface, IPin *peer, const AM_MEDIA_TYPE *mt)
|
2012-03-31 03:08:07 +02:00
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
struct strmbase_renderer *filter = impl_from_IPin(iface);
|
2015-10-19 10:57:50 +02:00
|
|
|
HRESULT hr;
|
2012-03-31 03:08:07 +02:00
|
|
|
|
2019-06-21 03:13:19 +02:00
|
|
|
TRACE("iface %p, peer %p, mt %p.\n", iface, peer, mt);
|
2019-10-06 02:18:50 +02:00
|
|
|
strmbase_dump_media_type(mt);
|
2012-03-31 03:08:07 +02:00
|
|
|
|
2019-09-06 02:02:16 +02:00
|
|
|
EnterCriticalSection(&filter->filter.csFilter);
|
2019-06-21 03:13:19 +02:00
|
|
|
hr = BaseInputPinImpl_ReceiveConnection(iface, peer, mt);
|
2012-03-31 03:08:07 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2019-06-21 03:13:19 +02:00
|
|
|
if (filter->pFuncsTable->pfnCompleteConnect)
|
|
|
|
hr = filter->pFuncsTable->pfnCompleteConnect(filter, peer);
|
2012-03-31 03:08:07 +02:00
|
|
|
}
|
2019-09-06 02:02:16 +02:00
|
|
|
LeaveCriticalSection(&filter->filter.csFilter);
|
2012-03-31 03:08:07 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI BaseRenderer_InputPin_Disconnect(IPin * iface)
|
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
struct strmbase_renderer *filter = impl_from_IPin(iface);
|
2012-03-31 03:08:07 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-06-21 03:13:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2012-03-31 03:08:07 +02:00
|
|
|
|
2019-09-06 02:02:16 +02:00
|
|
|
EnterCriticalSection(&filter->filter.csFilter);
|
2012-03-31 03:08:07 +02:00
|
|
|
hr = BasePinImpl_Disconnect(iface);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2019-06-21 03:13:19 +02:00
|
|
|
if (filter->pFuncsTable->pfnBreakConnect)
|
|
|
|
hr = filter->pFuncsTable->pfnBreakConnect(filter);
|
2012-03-31 03:08:07 +02:00
|
|
|
}
|
2019-06-21 03:13:19 +02:00
|
|
|
BaseRendererImpl_ClearPendingSample(filter);
|
2019-09-06 02:02:16 +02:00
|
|
|
LeaveCriticalSection(&filter->filter.csFilter);
|
2012-03-31 03:08:07 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-03-28 21:53:33 +02:00
|
|
|
static HRESULT WINAPI BaseRenderer_InputPin_EndOfStream(IPin * iface)
|
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
struct strmbase_renderer *pFilter = impl_from_IPin(iface);
|
2015-10-19 10:57:50 +02:00
|
|
|
HRESULT hr;
|
2012-03-28 21:53:33 +02:00
|
|
|
|
2019-06-21 03:13:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2012-03-28 21:53:33 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&pFilter->csRenderLock);
|
2014-07-17 18:37:37 +02:00
|
|
|
EnterCriticalSection(&pFilter->filter.csFilter);
|
2012-03-28 21:53:33 +02:00
|
|
|
hr = BaseInputPinImpl_EndOfStream(iface);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (pFilter->pFuncsTable->pfnEndOfStream)
|
|
|
|
hr = pFilter->pFuncsTable->pfnEndOfStream(pFilter);
|
|
|
|
else
|
|
|
|
hr = BaseRendererImpl_EndOfStream(pFilter);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&pFilter->filter.csFilter);
|
2014-07-17 18:37:37 +02:00
|
|
|
LeaveCriticalSection(&pFilter->csRenderLock);
|
2012-03-28 21:53:33 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-03-31 03:08:07 +02:00
|
|
|
static HRESULT WINAPI BaseRenderer_InputPin_BeginFlush(IPin * iface)
|
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
struct strmbase_renderer *pFilter = impl_from_IPin(iface);
|
2015-10-19 10:57:50 +02:00
|
|
|
HRESULT hr;
|
2012-03-31 03:08:07 +02:00
|
|
|
|
2019-06-21 03:13:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2012-03-31 03:08:07 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&pFilter->csRenderLock);
|
2014-07-17 18:28:42 +02:00
|
|
|
EnterCriticalSection(&pFilter->filter.csFilter);
|
2012-03-31 03:08:07 +02:00
|
|
|
hr = BaseInputPinImpl_BeginFlush(iface);
|
|
|
|
if (SUCCEEDED(hr))
|
2019-07-03 05:25:45 +02:00
|
|
|
hr = BaseRendererImpl_BeginFlush(pFilter);
|
2012-03-31 03:08:07 +02:00
|
|
|
LeaveCriticalSection(&pFilter->filter.csFilter);
|
|
|
|
LeaveCriticalSection(&pFilter->csRenderLock);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-03-28 21:53:33 +02:00
|
|
|
static HRESULT WINAPI BaseRenderer_InputPin_EndFlush(IPin * iface)
|
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
struct strmbase_renderer *pFilter = impl_from_IPin(iface);
|
2015-10-19 10:57:50 +02:00
|
|
|
HRESULT hr;
|
2012-03-28 21:53:33 +02:00
|
|
|
|
2019-06-21 03:13:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2012-03-28 21:53:33 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&pFilter->csRenderLock);
|
2014-07-17 18:35:43 +02:00
|
|
|
EnterCriticalSection(&pFilter->filter.csFilter);
|
2012-03-28 21:53:33 +02:00
|
|
|
hr = BaseInputPinImpl_EndFlush(iface);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (pFilter->pFuncsTable->pfnEndFlush)
|
|
|
|
hr = pFilter->pFuncsTable->pfnEndFlush(pFilter);
|
|
|
|
else
|
|
|
|
hr = BaseRendererImpl_EndFlush(pFilter);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&pFilter->filter.csFilter);
|
2014-07-17 18:35:43 +02:00
|
|
|
LeaveCriticalSection(&pFilter->csRenderLock);
|
2012-03-28 21:53:33 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPinVtbl BaseRenderer_InputPin_Vtbl =
|
|
|
|
{
|
2019-09-26 05:36:23 +02:00
|
|
|
BasePinImpl_QueryInterface,
|
2019-06-19 03:17:35 +02:00
|
|
|
BasePinImpl_AddRef,
|
|
|
|
BasePinImpl_Release,
|
2012-03-28 21:53:33 +02:00
|
|
|
BaseInputPinImpl_Connect,
|
2012-03-31 03:08:07 +02:00
|
|
|
BaseRenderer_InputPin_ReceiveConnection,
|
|
|
|
BaseRenderer_InputPin_Disconnect,
|
2012-03-28 21:53:33 +02:00
|
|
|
BasePinImpl_ConnectedTo,
|
|
|
|
BasePinImpl_ConnectionMediaType,
|
|
|
|
BasePinImpl_QueryPinInfo,
|
|
|
|
BasePinImpl_QueryDirection,
|
|
|
|
BasePinImpl_QueryId,
|
2018-05-04 06:47:13 +02:00
|
|
|
BasePinImpl_QueryAccept,
|
2012-03-28 21:53:33 +02:00
|
|
|
BasePinImpl_EnumMediaTypes,
|
|
|
|
BasePinImpl_QueryInternalConnections,
|
|
|
|
BaseRenderer_InputPin_EndOfStream,
|
2012-03-31 03:08:07 +02:00
|
|
|
BaseRenderer_InputPin_BeginFlush,
|
2012-03-28 21:53:33 +02:00
|
|
|
BaseRenderer_InputPin_EndFlush,
|
|
|
|
BaseInputPinImpl_NewSegment
|
|
|
|
};
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static IPin *renderer_get_pin(struct strmbase_filter *iface, unsigned int index)
|
2012-03-28 21:53:33 +02:00
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
struct strmbase_renderer *filter = impl_from_strmbase_filter(iface);
|
2012-03-28 21:53:33 +02:00
|
|
|
|
2019-06-21 03:13:19 +02:00
|
|
|
if (index == 0)
|
|
|
|
return &filter->sink.pin.IPin_iface;
|
|
|
|
return NULL;
|
2012-03-28 21:53:33 +02:00
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static void renderer_destroy(struct strmbase_filter *iface)
|
2019-05-28 06:09:55 +02:00
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
struct strmbase_renderer *filter = impl_from_strmbase_filter(iface);
|
2019-05-28 06:09:55 +02:00
|
|
|
filter->pFuncsTable->renderer_destroy(filter);
|
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static HRESULT renderer_query_interface(struct strmbase_filter *iface, REFIID iid, void **out)
|
2019-05-28 06:09:55 +02:00
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
struct strmbase_renderer *filter = impl_from_strmbase_filter(iface);
|
2019-05-31 05:59:36 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (filter->pFuncsTable->renderer_query_interface
|
|
|
|
&& SUCCEEDED(hr = filter->pFuncsTable->renderer_query_interface(filter, iid, out)))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsEqualIID(iid, &IID_IMediaSeeking) || IsEqualIID(iid, &IID_IMediaPosition))
|
|
|
|
return IUnknown_QueryInterface(filter->pPosition, iid, out);
|
|
|
|
else if (IsEqualIID(iid, &IID_IQualityControl))
|
|
|
|
{
|
|
|
|
*out = &filter->qcimpl->IQualityControl_iface;
|
|
|
|
IUnknown_AddRef((IUnknown *)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-10-28 00:28:02 +01:00
|
|
|
static HRESULT renderer_init_stream(struct strmbase_filter *iface)
|
|
|
|
{
|
|
|
|
struct strmbase_renderer *filter = impl_from_strmbase_filter(iface);
|
|
|
|
|
|
|
|
if (filter->sink.pin.peer)
|
|
|
|
ResetEvent(filter->state_event);
|
|
|
|
filter->sink.end_of_stream = FALSE;
|
|
|
|
BaseRendererImpl_ClearPendingSample(filter);
|
|
|
|
ResetEvent(filter->flush_event);
|
|
|
|
if (filter->pFuncsTable->renderer_init_stream)
|
|
|
|
filter->pFuncsTable->renderer_init_stream(filter);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT renderer_start_stream(struct strmbase_filter *iface, REFERENCE_TIME start)
|
|
|
|
{
|
|
|
|
struct strmbase_renderer *filter = impl_from_strmbase_filter(iface);
|
|
|
|
|
|
|
|
filter->stream_start = start;
|
|
|
|
SetEvent(filter->state_event);
|
|
|
|
if (filter->sink.pin.peer)
|
|
|
|
filter->sink.end_of_stream = FALSE;
|
|
|
|
QualityControlRender_Start(filter->qcimpl, filter->stream_start);
|
|
|
|
if (filter->sink.pin.peer && filter->pFuncsTable->renderer_start_stream)
|
|
|
|
filter->pFuncsTable->renderer_start_stream(filter);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT renderer_stop_stream(struct strmbase_filter *iface)
|
|
|
|
{
|
|
|
|
struct strmbase_renderer *filter = impl_from_strmbase_filter(iface);
|
|
|
|
|
|
|
|
if (filter->sink.pin.peer && filter->pFuncsTable->renderer_stop_stream)
|
|
|
|
filter->pFuncsTable->renderer_stop_stream(filter);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT renderer_cleanup_stream(struct strmbase_filter *iface)
|
|
|
|
{
|
|
|
|
struct strmbase_renderer *filter = impl_from_strmbase_filter(iface);
|
|
|
|
|
|
|
|
RendererPosPassThru_ResetMediaTime(filter->pPosition);
|
|
|
|
SetEvent(filter->state_event);
|
|
|
|
SetEvent(filter->flush_event);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT renderer_wait_state(struct strmbase_filter *iface, DWORD timeout)
|
|
|
|
{
|
|
|
|
struct strmbase_renderer *filter = impl_from_strmbase_filter(iface);
|
|
|
|
|
|
|
|
if (WaitForSingleObject(filter->state_event, timeout) == WAIT_TIMEOUT)
|
|
|
|
return VFW_S_STATE_INTERMEDIATE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:29 +02:00
|
|
|
static const struct strmbase_filter_ops filter_ops =
|
|
|
|
{
|
2019-05-28 06:09:55 +02:00
|
|
|
.filter_get_pin = renderer_get_pin,
|
|
|
|
.filter_destroy = renderer_destroy,
|
2019-05-31 05:59:36 +02:00
|
|
|
.filter_query_interface = renderer_query_interface,
|
2019-10-28 00:28:02 +01:00
|
|
|
.filter_init_stream = renderer_init_stream,
|
|
|
|
.filter_start_stream = renderer_start_stream,
|
|
|
|
.filter_stop_stream = renderer_stop_stream,
|
|
|
|
.filter_cleanup_stream = renderer_cleanup_stream,
|
|
|
|
.filter_wait_state = renderer_wait_state,
|
2019-05-28 06:09:55 +02:00
|
|
|
};
|
|
|
|
|
2019-09-25 02:10:10 +02:00
|
|
|
static HRESULT sink_query_accept(struct strmbase_pin *pin, const AM_MEDIA_TYPE *mt)
|
2012-03-28 21:53:33 +02:00
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
struct strmbase_renderer *filter = impl_from_IPin(&pin->IPin_iface);
|
2019-06-21 03:13:19 +02:00
|
|
|
return filter->pFuncsTable->pfnCheckMediaType(filter, mt);
|
2012-03-28 21:53:33 +02:00
|
|
|
}
|
|
|
|
|
2019-09-26 05:36:23 +02:00
|
|
|
static HRESULT sink_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
|
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
struct strmbase_renderer *filter = impl_from_IPin(&iface->IPin_iface);
|
2019-10-02 05:43:12 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (filter->pFuncsTable->renderer_pin_query_interface
|
|
|
|
&& SUCCEEDED(hr = filter->pFuncsTable->renderer_pin_query_interface(filter, iid, out)))
|
|
|
|
return hr;
|
2019-09-26 05:36:23 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_IMemInputPin))
|
|
|
|
*out = &filter->sink.IMemInputPin_iface;
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-06-21 03:13:19 +02:00
|
|
|
static HRESULT WINAPI BaseRenderer_Receive(BaseInputPin *pin, IMediaSample *sample)
|
2012-03-28 21:53:33 +02:00
|
|
|
{
|
2019-10-24 03:04:23 +02:00
|
|
|
struct strmbase_renderer *filter = impl_from_IPin(&pin->pin.IPin_iface);
|
2019-06-21 03:13:19 +02:00
|
|
|
return BaseRendererImpl_Receive(filter, sample);
|
2012-03-28 21:53:33 +02:00
|
|
|
}
|
|
|
|
|
2019-09-25 02:10:10 +02:00
|
|
|
static const BaseInputPinFuncTable input_BaseInputFuncTable =
|
|
|
|
{
|
|
|
|
.base.pin_query_accept = sink_query_accept,
|
2019-09-26 05:36:23 +02:00
|
|
|
.base.pin_query_interface = sink_query_interface,
|
2019-09-25 02:10:11 +02:00
|
|
|
.base.pin_get_media_type = strmbase_pin_get_media_type,
|
2019-09-25 02:10:10 +02:00
|
|
|
.pfnReceive = BaseRenderer_Receive,
|
2012-03-28 21:53:33 +02:00
|
|
|
};
|
|
|
|
|
2019-10-24 03:04:23 +02:00
|
|
|
void strmbase_renderer_cleanup(struct strmbase_renderer *filter)
|
2012-03-28 21:53:33 +02:00
|
|
|
{
|
2019-09-27 04:40:53 +02:00
|
|
|
if (filter->sink.pin.peer)
|
|
|
|
IPin_Disconnect(filter->sink.pin.peer);
|
2019-06-21 03:13:19 +02:00
|
|
|
IPin_Disconnect(&filter->sink.pin.IPin_iface);
|
|
|
|
strmbase_sink_cleanup(&filter->sink);
|
2012-03-28 21:53:33 +02:00
|
|
|
|
2019-05-16 01:16:55 +02:00
|
|
|
if (filter->pPosition)
|
|
|
|
IUnknown_Release(filter->pPosition);
|
|
|
|
|
|
|
|
filter->csRenderLock.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&filter->csRenderLock);
|
2012-03-28 21:53:33 +02:00
|
|
|
|
2019-05-16 01:16:55 +02:00
|
|
|
BaseRendererImpl_ClearPendingSample(filter);
|
2019-07-02 05:49:45 +02:00
|
|
|
CloseHandle(filter->state_event);
|
2019-07-02 05:49:48 +02:00
|
|
|
CloseHandle(filter->advise_event);
|
|
|
|
CloseHandle(filter->flush_event);
|
2019-05-16 01:16:55 +02:00
|
|
|
QualityControlImpl_Destroy(filter->qcimpl);
|
2019-05-22 07:02:12 +02:00
|
|
|
strmbase_filter_cleanup(&filter->filter);
|
2019-05-16 01:16:55 +02:00
|
|
|
}
|
|
|
|
|
2019-10-24 03:04:23 +02:00
|
|
|
HRESULT WINAPI BaseRendererImpl_Receive(struct strmbase_renderer *This, IMediaSample *pSample)
|
2012-03-28 21:53:33 +02:00
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
REFERENCE_TIME start, stop;
|
2012-03-31 03:08:07 +02:00
|
|
|
AM_MEDIA_TYPE *pmt;
|
2012-03-28 21:53:33 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->%p\n", This, pSample);
|
|
|
|
|
2019-06-21 03:13:19 +02:00
|
|
|
if (This->sink.end_of_stream || This->sink.flushing)
|
2012-03-31 03:08:07 +02:00
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
if (This->filter.state == State_Stopped)
|
|
|
|
return VFW_E_WRONG_STATE;
|
|
|
|
|
|
|
|
if (IMediaSample_GetMediaType(pSample, &pmt) == S_OK)
|
|
|
|
{
|
2019-10-06 02:18:50 +02:00
|
|
|
TRACE("Format change.\n");
|
|
|
|
strmbase_dump_media_type(pmt);
|
|
|
|
|
2012-03-31 03:08:07 +02:00
|
|
|
if (FAILED(This->pFuncsTable->pfnCheckMediaType(This, pmt)))
|
|
|
|
{
|
|
|
|
return VFW_E_TYPE_NOT_ACCEPTED;
|
|
|
|
}
|
2019-01-29 20:28:58 +01:00
|
|
|
DeleteMediaType(pmt);
|
2012-03-31 03:08:07 +02:00
|
|
|
}
|
|
|
|
|
2012-03-31 03:08:25 +02:00
|
|
|
This->pMediaSample = pSample;
|
|
|
|
IMediaSample_AddRef(pSample);
|
|
|
|
|
2012-03-28 21:53:33 +02:00
|
|
|
if (This->pFuncsTable->pfnPrepareReceive)
|
|
|
|
hr = This->pFuncsTable->pfnPrepareReceive(This, pSample);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (hr == VFW_E_SAMPLE_REJECTED)
|
|
|
|
return S_OK;
|
|
|
|
else
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csRenderLock);
|
2019-07-03 05:25:45 +02:00
|
|
|
if (This->filter.state == State_Paused)
|
2019-07-02 05:49:45 +02:00
|
|
|
SetEvent(This->state_event);
|
2012-03-28 21:53:33 +02:00
|
|
|
|
|
|
|
/* Wait for render Time */
|
2019-07-02 05:49:46 +02:00
|
|
|
if (This->filter.pClock && SUCCEEDED(IMediaSample_GetTime(pSample, &start, &stop)))
|
2012-03-28 21:53:33 +02:00
|
|
|
{
|
|
|
|
hr = S_FALSE;
|
|
|
|
RendererPosPassThru_RegisterMediaTime(This->pPosition, start);
|
|
|
|
if (This->pFuncsTable->pfnShouldDrawSampleNow)
|
|
|
|
hr = This->pFuncsTable->pfnShouldDrawSampleNow(This, pSample, &start, &stop);
|
|
|
|
|
|
|
|
if (hr == S_OK)
|
|
|
|
;/* Do not wait: drop through */
|
|
|
|
else if (hr == S_FALSE)
|
|
|
|
{
|
2019-07-02 05:49:46 +02:00
|
|
|
REFERENCE_TIME now;
|
|
|
|
DWORD_PTR cookie;
|
|
|
|
|
|
|
|
IReferenceClock_GetTime(This->filter.pClock, &now);
|
|
|
|
|
2019-10-04 17:02:45 +02:00
|
|
|
if (now - This->stream_start - start <= -10000)
|
2019-07-02 05:49:46 +02:00
|
|
|
{
|
2019-07-02 05:49:48 +02:00
|
|
|
HANDLE handles[2] = {This->advise_event, This->flush_event};
|
|
|
|
|
2019-10-04 17:02:45 +02:00
|
|
|
IReferenceClock_AdviseTime(This->filter.pClock, This->stream_start,
|
2019-07-02 05:49:48 +02:00
|
|
|
start, (HEVENT)This->advise_event, &cookie);
|
2019-07-02 05:49:46 +02:00
|
|
|
|
|
|
|
LeaveCriticalSection(&This->csRenderLock);
|
|
|
|
|
2019-07-02 05:49:48 +02:00
|
|
|
WaitForMultipleObjects(2, handles, FALSE, INFINITE);
|
2019-07-02 05:49:46 +02:00
|
|
|
IReferenceClock_Unadvise(This->filter.pClock, cookie);
|
|
|
|
|
|
|
|
EnterCriticalSection(&This->csRenderLock);
|
|
|
|
}
|
2012-03-28 21:53:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&This->csRenderLock);
|
|
|
|
/* Drop Sample */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
2019-07-02 05:49:46 +02:00
|
|
|
else
|
|
|
|
start = stop = -1;
|
2012-03-28 21:53:33 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
2012-04-02 14:52:08 +02:00
|
|
|
{
|
2019-07-02 05:49:46 +02:00
|
|
|
QualityControlRender_BeginRender(This->qcimpl, start, stop);
|
2012-03-28 21:53:33 +02:00
|
|
|
hr = This->pFuncsTable->pfnDoRenderSample(This, pSample);
|
2012-04-02 14:52:15 +02:00
|
|
|
QualityControlRender_EndRender(This->qcimpl);
|
2012-04-02 14:52:08 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 14:52:15 +02:00
|
|
|
QualityControlRender_DoQOS(This->qcimpl);
|
2012-03-31 03:08:25 +02:00
|
|
|
|
|
|
|
BaseRendererImpl_ClearPendingSample(This);
|
2012-03-28 21:53:33 +02:00
|
|
|
LeaveCriticalSection(&This->csRenderLock);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-10-23 01:30:07 +02:00
|
|
|
static const IBaseFilterVtbl strmbase_renderer_vtbl =
|
|
|
|
{
|
|
|
|
BaseFilterImpl_QueryInterface,
|
|
|
|
BaseFilterImpl_AddRef,
|
|
|
|
BaseFilterImpl_Release,
|
|
|
|
BaseFilterImpl_GetClassID,
|
2019-10-28 00:28:02 +01:00
|
|
|
BaseFilterImpl_Stop,
|
|
|
|
BaseFilterImpl_Pause,
|
|
|
|
BaseFilterImpl_Run,
|
|
|
|
BaseFilterImpl_GetState,
|
2019-10-28 00:28:04 +01:00
|
|
|
BaseFilterImpl_SetSyncSource,
|
2019-10-23 01:30:07 +02:00
|
|
|
BaseFilterImpl_GetSyncSource,
|
|
|
|
BaseFilterImpl_EnumPins,
|
|
|
|
BaseFilterImpl_FindPin,
|
|
|
|
BaseFilterImpl_QueryFilterInfo,
|
|
|
|
BaseFilterImpl_JoinFilterGraph,
|
|
|
|
BaseFilterImpl_QueryVendorInfo
|
|
|
|
};
|
|
|
|
|
2019-10-24 03:04:23 +02:00
|
|
|
HRESULT WINAPI BaseRendererImpl_EndOfStream(struct strmbase_renderer *iface)
|
2012-03-28 21:53:33 +02:00
|
|
|
{
|
|
|
|
IMediaEventSink* pEventSink;
|
|
|
|
IFilterGraph *graph;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
|
|
|
|
graph = iface->filter.filterInfo.pGraph;
|
|
|
|
if (graph)
|
|
|
|
{ hr = IFilterGraph_QueryInterface(iface->filter.filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, (LONG_PTR)iface);
|
|
|
|
IMediaEventSink_Release(pEventSink);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RendererPosPassThru_EOS(iface->pPosition);
|
2019-07-02 05:49:45 +02:00
|
|
|
SetEvent(iface->state_event);
|
2012-03-28 21:53:33 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-10-24 03:04:23 +02:00
|
|
|
HRESULT WINAPI BaseRendererImpl_BeginFlush(struct strmbase_renderer *iface)
|
2012-03-31 03:08:07 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n", iface);
|
2012-03-31 03:08:25 +02:00
|
|
|
BaseRendererImpl_ClearPendingSample(iface);
|
2019-07-02 05:49:48 +02:00
|
|
|
SetEvent(iface->flush_event);
|
2012-03-31 03:08:07 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-10-24 03:04:23 +02:00
|
|
|
HRESULT WINAPI BaseRendererImpl_EndFlush(struct strmbase_renderer *iface)
|
2012-03-28 21:53:33 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n", iface);
|
2019-10-04 17:02:45 +02:00
|
|
|
QualityControlRender_Start(iface->qcimpl, iface->stream_start);
|
2012-03-28 21:53:33 +02:00
|
|
|
RendererPosPassThru_ResetMediaTime(iface->pPosition);
|
2019-07-02 05:49:48 +02:00
|
|
|
ResetEvent(iface->flush_event);
|
2012-03-31 03:08:25 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-10-24 03:04:23 +02:00
|
|
|
HRESULT WINAPI BaseRendererImpl_ClearPendingSample(struct strmbase_renderer *iface)
|
2012-03-31 03:08:25 +02:00
|
|
|
{
|
|
|
|
if (iface->pMediaSample)
|
|
|
|
{
|
|
|
|
IMediaSample_Release(iface->pMediaSample);
|
|
|
|
iface->pMediaSample = NULL;
|
|
|
|
}
|
2012-03-28 21:53:33 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2019-10-24 03:04:22 +02:00
|
|
|
|
2019-10-24 03:04:23 +02:00
|
|
|
HRESULT WINAPI strmbase_renderer_init(struct strmbase_renderer *filter, IUnknown *outer,
|
2019-10-24 03:04:24 +02:00
|
|
|
const CLSID *clsid, const WCHAR *sink_name, const struct strmbase_renderer_ops *ops)
|
2019-10-24 03:04:22 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
memset(filter, 0, sizeof(*filter));
|
|
|
|
strmbase_filter_init(&filter->filter, &strmbase_renderer_vtbl, outer, clsid, &filter_ops);
|
|
|
|
|
2019-10-24 03:04:24 +02:00
|
|
|
filter->pFuncsTable = ops;
|
2019-10-24 03:04:22 +02:00
|
|
|
|
|
|
|
strmbase_sink_init(&filter->sink, &BaseRenderer_InputPin_Vtbl, &filter->filter,
|
|
|
|
sink_name, &input_BaseInputFuncTable, NULL);
|
|
|
|
|
|
|
|
hr = CreatePosPassThru(outer ? outer : (IUnknown *)&filter->filter.IBaseFilter_iface,
|
|
|
|
TRUE, &filter->sink.pin.IPin_iface, &filter->pPosition);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
strmbase_sink_cleanup(&filter->sink);
|
|
|
|
strmbase_filter_cleanup(&filter->filter);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
InitializeCriticalSection(&filter->csRenderLock);
|
2019-10-24 03:04:23 +02:00
|
|
|
filter->csRenderLock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": strmbase_renderer.csRenderLock");
|
2019-10-24 03:04:22 +02:00
|
|
|
filter->state_event = CreateEventW(NULL, TRUE, TRUE, NULL);
|
|
|
|
filter->advise_event = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
filter->flush_event = CreateEventW(NULL, TRUE, TRUE, NULL);
|
|
|
|
|
2019-10-28 00:28:03 +01:00
|
|
|
QualityControlImpl_Create(&filter->sink.pin, &filter->qcimpl);
|
2019-10-24 03:04:22 +02:00
|
|
|
filter->qcimpl->IQualityControl_iface.lpVtbl = &Renderer_QualityControl_Vtbl;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|