2005-01-31 17:24:00 +01:00
|
|
|
/*
|
|
|
|
* Transform Filter (Base for decoders, etc...)
|
|
|
|
*
|
|
|
|
* Copyright 2005 Christian Costa
|
2010-10-07 21:48:19 +02:00
|
|
|
* Copyright 2010 Aric Stewart, CodeWeavers
|
2005-01-31 17:24:00 +01:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-01-31 17:24:00 +01:00
|
|
|
*/
|
2019-05-03 12:32:45 +02:00
|
|
|
|
2012-04-02 14:52:15 +02:00
|
|
|
#include "strmbase_private.h"
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2019-03-06 06:28:38 +01:00
|
|
|
static const WCHAR wcsInputPinName[] = {'I','n',0};
|
|
|
|
static const WCHAR wcsOutputPinName[] = {'O','u','t',0};
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static inline TransformFilter *impl_from_strmbase_filter(struct strmbase_filter *iface)
|
2012-03-26 21:06:13 +02:00
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, TransformFilter, filter);
|
|
|
|
}
|
|
|
|
|
2019-06-21 03:13:17 +02:00
|
|
|
static inline TransformFilter *impl_from_sink_IPin(IPin *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, TransformFilter, sink.pin.IPin_iface);
|
|
|
|
}
|
|
|
|
|
2019-09-25 02:10:10 +02:00
|
|
|
static HRESULT sink_query_accept(struct strmbase_pin *iface, const AM_MEDIA_TYPE *pmt)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *pTransform = impl_from_sink_IPin(&iface->IPin_iface);
|
2010-10-07 21:48:19 +02:00
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
TRACE("%p\n", iface);
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
if (pTransform->pFuncsTable->pfnCheckInputType)
|
|
|
|
return pTransform->pFuncsTable->pfnCheckInputType(pTransform, pmt);
|
2007-04-03 09:06:16 +02:00
|
|
|
/* Assume OK if there's no query method (the connection will fail if
|
|
|
|
needed) */
|
2007-04-03 08:45:27 +02:00
|
|
|
return S_OK;
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
|
2019-11-20 03:18:01 +01:00
|
|
|
static HRESULT WINAPI TransformFilter_Input_Receive(struct strmbase_sink *This, IMediaSample *pInSample)
|
2010-10-07 21:48:19 +02:00
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *pTransform = impl_from_sink_IPin(&This->pin.IPin_iface);
|
2015-10-19 10:57:50 +02:00
|
|
|
HRESULT hr;
|
2019-06-21 03:13:17 +02:00
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
TRACE("%p\n", This);
|
2010-10-07 21:48:19 +02:00
|
|
|
|
2019-11-23 04:14:01 +01:00
|
|
|
/* We do not expect pin connection state to change while the filter is
|
|
|
|
* running. This guarantee is necessary, since otherwise we would have to
|
|
|
|
* take the filter lock, and we can't take the filter lock from a streaming
|
|
|
|
* thread. */
|
|
|
|
if (!pTransform->source.pMemInputPin)
|
|
|
|
{
|
|
|
|
WARN("Source is not connected, returning VFW_E_NOT_CONNECTED.\n");
|
|
|
|
return VFW_E_NOT_CONNECTED;
|
|
|
|
}
|
|
|
|
|
2012-01-16 21:14:23 +01:00
|
|
|
EnterCriticalSection(&pTransform->csReceive);
|
2010-10-07 21:48:19 +02:00
|
|
|
if (pTransform->filter.state == State_Stopped)
|
|
|
|
{
|
2012-01-16 21:14:23 +01:00
|
|
|
LeaveCriticalSection(&pTransform->csReceive);
|
2010-10-07 21:48:19 +02:00
|
|
|
return VFW_E_WRONG_STATE;
|
|
|
|
}
|
|
|
|
|
2019-11-27 00:39:20 +01:00
|
|
|
if (This->flushing)
|
2010-10-07 21:48:19 +02:00
|
|
|
{
|
2012-01-16 21:14:23 +01:00
|
|
|
LeaveCriticalSection(&pTransform->csReceive);
|
2010-10-07 21:48:19 +02:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pTransform->pFuncsTable->pfnReceive)
|
|
|
|
hr = pTransform->pFuncsTable->pfnReceive(pTransform, pInSample);
|
|
|
|
else
|
|
|
|
hr = S_FALSE;
|
|
|
|
|
2019-12-01 02:48:32 +01:00
|
|
|
LeaveCriticalSection(&pTransform->csReceive);
|
2010-10-07 21:48:19 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2019-06-21 03:13:17 +02:00
|
|
|
static inline TransformFilter *impl_from_source_IPin(IPin *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, TransformFilter, source.pin.IPin_iface);
|
|
|
|
}
|
|
|
|
|
2019-09-25 02:10:10 +02:00
|
|
|
static HRESULT source_query_accept(struct strmbase_pin *This, const AM_MEDIA_TYPE *pmt)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *pTransformFilter = impl_from_source_IPin(&This->IPin_iface);
|
2008-07-22 13:13:44 +02:00
|
|
|
AM_MEDIA_TYPE* outpmt = &pTransformFilter->pmt;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2008-07-22 14:35:28 +02:00
|
|
|
if (IsEqualIID(&pmt->majortype, &outpmt->majortype)
|
|
|
|
&& (IsEqualIID(&pmt->subtype, &outpmt->subtype) || IsEqualIID(&outpmt->subtype, &GUID_NULL)))
|
2005-01-31 17:24:00 +01:00
|
|
|
return S_OK;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2019-09-12 21:28:25 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_Output_DecideBufferSize(struct strmbase_source *This,
|
|
|
|
IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
|
2010-10-13 17:46:27 +02:00
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *pTransformFilter = impl_from_source_IPin(&This->pin.IPin_iface);
|
2010-10-13 17:46:27 +02:00
|
|
|
return pTransformFilter->pFuncsTable->pfnDecideBufferSize(pTransformFilter, pAlloc, ppropInputRequest);
|
|
|
|
}
|
|
|
|
|
2019-09-25 02:10:12 +02:00
|
|
|
static HRESULT source_get_media_type(struct strmbase_pin *This, unsigned int iPosition, AM_MEDIA_TYPE *pmt)
|
2010-10-13 18:02:08 +02:00
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *pTransform = impl_from_source_IPin(&This->IPin_iface);
|
2010-10-13 18:02:08 +02:00
|
|
|
|
|
|
|
if (iPosition > 0)
|
|
|
|
return VFW_S_NO_MORE_ITEMS;
|
|
|
|
CopyMediaType(pmt, &pTransform->pmt);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-11-23 04:13:59 +01:00
|
|
|
static struct strmbase_pin *transform_get_pin(struct strmbase_filter *iface, unsigned int index)
|
2010-10-07 21:48:01 +02:00
|
|
|
{
|
2019-08-29 03:24:30 +02:00
|
|
|
TransformFilter *filter = impl_from_strmbase_filter(iface);
|
2010-10-07 21:48:01 +02:00
|
|
|
|
2019-06-21 03:13:17 +02:00
|
|
|
if (index == 0)
|
2019-11-23 04:13:59 +01:00
|
|
|
return &filter->sink.pin;
|
2019-06-21 03:13:17 +02:00
|
|
|
else if (index == 1)
|
2019-11-23 04:13:59 +01:00
|
|
|
return &filter->source.pin;
|
2019-06-21 03:13:17 +02:00
|
|
|
return NULL;
|
2010-10-07 21:48:01 +02:00
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static void transform_destroy(struct strmbase_filter *iface)
|
2019-05-25 22:21:22 +02:00
|
|
|
{
|
2019-08-29 03:24:30 +02:00
|
|
|
TransformFilter *filter = impl_from_strmbase_filter(iface);
|
2019-05-25 22:21:22 +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:17 +02:00
|
|
|
IPin_Disconnect(&filter->sink.pin.IPin_iface);
|
2019-05-25 22:21:22 +02:00
|
|
|
|
2019-09-27 04:40:53 +02:00
|
|
|
if (filter->source.pin.peer)
|
|
|
|
IPin_Disconnect(filter->source.pin.peer);
|
2019-06-21 03:13:17 +02:00
|
|
|
IPin_Disconnect(&filter->source.pin.IPin_iface);
|
2019-06-17 02:35:03 +02:00
|
|
|
|
2019-06-21 03:13:17 +02:00
|
|
|
strmbase_sink_cleanup(&filter->sink);
|
|
|
|
strmbase_source_cleanup(&filter->source);
|
2019-05-25 22:21:22 +02:00
|
|
|
|
|
|
|
filter->csReceive.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&filter->csReceive);
|
|
|
|
FreeMediaType(&filter->pmt);
|
|
|
|
IUnknown_Release(filter->seekthru_unk);
|
|
|
|
strmbase_filter_cleanup(&filter->filter);
|
|
|
|
CoTaskMemFree(filter);
|
|
|
|
}
|
|
|
|
|
2019-10-24 03:04:27 +02:00
|
|
|
static HRESULT transform_init_stream(struct strmbase_filter *iface)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_strmbase_filter(iface);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
EnterCriticalSection(&filter->csReceive);
|
|
|
|
|
|
|
|
if (filter->pFuncsTable->pfnStartStreaming)
|
|
|
|
hr = filter->pFuncsTable->pfnStartStreaming(filter);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = BaseOutputPinImpl_Active(&filter->source);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&filter->csReceive);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT transform_cleanup_stream(struct strmbase_filter *iface)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_strmbase_filter(iface);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
EnterCriticalSection(&filter->csReceive);
|
|
|
|
|
|
|
|
if (filter->pFuncsTable->pfnStopStreaming)
|
|
|
|
hr = filter->pFuncsTable->pfnStopStreaming(filter);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = BaseOutputPinImpl_Inactive(&filter->source);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&filter->csReceive);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:29 +02:00
|
|
|
static const struct strmbase_filter_ops filter_ops =
|
|
|
|
{
|
2019-05-24 00:06:31 +02:00
|
|
|
.filter_get_pin = transform_get_pin,
|
2019-05-25 22:21:22 +02:00
|
|
|
.filter_destroy = transform_destroy,
|
2019-10-24 03:04:27 +02:00
|
|
|
.filter_init_stream = transform_init_stream,
|
|
|
|
.filter_cleanup_stream = transform_cleanup_stream,
|
2010-10-13 18:02:01 +02:00
|
|
|
};
|
|
|
|
|
2019-09-26 05:36:23 +02:00
|
|
|
static HRESULT sink_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_sink_IPin(&iface->IPin_iface);
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_IMemInputPin))
|
|
|
|
*out = &filter->sink.IMemInputPin_iface;
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-12-10 17:35:14 +01:00
|
|
|
static HRESULT sink_connect(struct strmbase_sink *iface, IPin *peer, const AM_MEDIA_TYPE *mt)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_sink_IPin(&iface->pin.IPin_iface);
|
|
|
|
|
|
|
|
if (filter->pFuncsTable->transform_connect_sink)
|
|
|
|
return filter->pFuncsTable->transform_connect_sink(filter, mt);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sink_disconnect(struct strmbase_sink *iface)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_sink_IPin(&iface->pin.IPin_iface);
|
|
|
|
|
|
|
|
if (filter->pFuncsTable->pfnBreakConnect)
|
|
|
|
filter->pFuncsTable->pfnBreakConnect(filter, PINDIR_INPUT);
|
|
|
|
}
|
|
|
|
|
2019-12-13 04:24:35 +01:00
|
|
|
static HRESULT sink_eos(struct strmbase_sink *iface)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_sink_IPin(&iface->pin.IPin_iface);
|
|
|
|
|
|
|
|
if (filter->source.pin.peer)
|
|
|
|
return IPin_EndOfStream(filter->source.pin.peer);
|
|
|
|
return VFW_E_NOT_CONNECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT sink_begin_flush(struct strmbase_sink *iface)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_sink_IPin(&iface->pin.IPin_iface);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
if (filter->pFuncsTable->pfnBeginFlush)
|
|
|
|
hr = filter->pFuncsTable->pfnBeginFlush(filter);
|
|
|
|
if (SUCCEEDED(hr) && filter->source.pin.peer)
|
|
|
|
hr = IPin_BeginFlush(filter->source.pin.peer);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT sink_end_flush(struct strmbase_sink *iface)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_sink_IPin(&iface->pin.IPin_iface);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
if (filter->pFuncsTable->pfnEndFlush)
|
|
|
|
hr = filter->pFuncsTable->pfnEndFlush(filter);
|
|
|
|
if (SUCCEEDED(hr) && filter->source.pin.peer)
|
|
|
|
hr = IPin_EndFlush(filter->source.pin.peer);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT sink_new_segment(struct strmbase_sink *iface,
|
|
|
|
REFERENCE_TIME start, REFERENCE_TIME stop, double rate)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_sink_IPin(&iface->pin.IPin_iface);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
if (filter->pFuncsTable->pfnNewSegment)
|
|
|
|
hr = filter->pFuncsTable->pfnNewSegment(filter, start, stop, rate);
|
|
|
|
if (SUCCEEDED(hr) && filter->source.pin.peer)
|
|
|
|
hr = IPin_NewSegment(filter->source.pin.peer, start, stop, rate);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-11-20 03:18:02 +01:00
|
|
|
static const struct strmbase_sink_ops sink_ops =
|
2019-09-25 02:10:10 +02:00
|
|
|
{
|
|
|
|
.base.pin_query_accept = sink_query_accept,
|
2019-09-25 02:10:11 +02:00
|
|
|
.base.pin_get_media_type = strmbase_pin_get_media_type,
|
2019-09-26 05:36:23 +02:00
|
|
|
.base.pin_query_interface = sink_query_interface,
|
2019-09-25 02:10:10 +02:00
|
|
|
.pfnReceive = TransformFilter_Input_Receive,
|
2019-12-10 17:35:14 +01:00
|
|
|
.sink_connect = sink_connect,
|
|
|
|
.sink_disconnect = sink_disconnect,
|
2019-12-13 04:24:35 +01:00
|
|
|
.sink_eos = sink_eos,
|
|
|
|
.sink_begin_flush = sink_begin_flush,
|
|
|
|
.sink_end_flush = sink_end_flush,
|
|
|
|
.sink_new_segment = sink_new_segment,
|
2010-10-13 18:02:01 +02:00
|
|
|
};
|
|
|
|
|
2019-09-26 05:36:23 +02:00
|
|
|
static HRESULT source_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_source_IPin(&iface->IPin_iface);
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_IQualityControl))
|
2019-11-03 04:33:14 +01:00
|
|
|
*out = &filter->source_IQualityControl_iface;
|
2019-09-26 05:36:23 +02:00
|
|
|
else if (IsEqualGUID(iid, &IID_IMediaSeeking))
|
|
|
|
return IUnknown_QueryInterface(filter->seekthru_unk, iid, out);
|
|
|
|
else
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-09-12 21:28:26 +02:00
|
|
|
static const struct strmbase_source_ops source_ops =
|
|
|
|
{
|
2019-09-25 02:10:10 +02:00
|
|
|
.base.pin_query_accept = source_query_accept,
|
2019-09-25 02:10:11 +02:00
|
|
|
.base.pin_get_media_type = source_get_media_type,
|
2019-09-26 05:36:23 +02:00
|
|
|
.base.pin_query_interface = source_query_interface,
|
2019-09-25 02:10:10 +02:00
|
|
|
.pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection,
|
|
|
|
.pfnDecideBufferSize = TransformFilter_Output_DecideBufferSize,
|
|
|
|
.pfnDecideAllocator = BaseOutputPinImpl_DecideAllocator,
|
2010-10-13 18:02:01 +02:00
|
|
|
};
|
|
|
|
|
2019-11-03 04:33:14 +01:00
|
|
|
static TransformFilter *impl_from_source_IQualityControl(IQualityControl *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, TransformFilter, source_IQualityControl_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI transform_source_qc_QueryInterface(IQualityControl *iface,
|
|
|
|
REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_source_IQualityControl(iface);
|
|
|
|
return IPin_QueryInterface(&filter->source.pin.IPin_iface, iid, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI transform_source_qc_AddRef(IQualityControl *iface)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_source_IQualityControl(iface);
|
|
|
|
return IPin_AddRef(&filter->source.pin.IPin_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI transform_source_qc_Release(IQualityControl *iface)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_source_IQualityControl(iface);
|
|
|
|
return IPin_Release(&filter->source.pin.IPin_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI TransformFilterImpl_Notify(TransformFilter *filter, IBaseFilter *sender, Quality q)
|
|
|
|
{
|
|
|
|
IQualityControl *peer;
|
|
|
|
HRESULT hr = S_FALSE;
|
|
|
|
|
|
|
|
if (filter->source_qc_sink)
|
|
|
|
return IQualityControl_Notify(filter->source_qc_sink, &filter->filter.IBaseFilter_iface, q);
|
|
|
|
|
|
|
|
if (filter->sink.pin.peer
|
|
|
|
&& SUCCEEDED(IPin_QueryInterface(filter->sink.pin.peer, &IID_IQualityControl, (void **)&peer)))
|
|
|
|
{
|
|
|
|
hr = IQualityControl_Notify(peer, &filter->filter.IBaseFilter_iface, q);
|
|
|
|
IQualityControl_Release(peer);
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI transform_source_qc_Notify(IQualityControl *iface,
|
|
|
|
IBaseFilter *sender, Quality q)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_source_IQualityControl(iface);
|
|
|
|
|
|
|
|
TRACE("filter %p, sender %p, type %#x, proportion %u, late %s, timestamp %s.\n",
|
|
|
|
filter, sender, q.Type, q.Proportion, debugstr_time(q.Late), debugstr_time(q.TimeStamp));
|
|
|
|
|
|
|
|
if (filter->pFuncsTable->pfnNotify)
|
|
|
|
return filter->pFuncsTable->pfnNotify(filter, sender, q);
|
|
|
|
return TransformFilterImpl_Notify(filter, sender, q);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI transform_source_qc_SetSink(IQualityControl *iface, IQualityControl *sink)
|
|
|
|
{
|
|
|
|
TransformFilter *filter = impl_from_source_IQualityControl(iface);
|
|
|
|
|
|
|
|
TRACE("filter %p, sink %p.\n", filter, sink);
|
|
|
|
|
|
|
|
filter->source_qc_sink = sink;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IQualityControlVtbl source_qc_vtbl =
|
|
|
|
{
|
|
|
|
transform_source_qc_QueryInterface,
|
|
|
|
transform_source_qc_AddRef,
|
|
|
|
transform_source_qc_Release,
|
|
|
|
transform_source_qc_Notify,
|
|
|
|
transform_source_qc_SetSink,
|
|
|
|
};
|
|
|
|
|
2019-06-06 17:22:53 +02:00
|
|
|
static HRESULT strmbase_transform_init(IUnknown *outer, const CLSID *clsid,
|
2019-05-15 02:42:00 +02:00
|
|
|
const TransformFilterFuncTable *func_table, TransformFilter *filter)
|
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
ISeekingPassThru *passthru;
|
2019-05-15 02:42:00 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-12-05 06:03:31 +01:00
|
|
|
strmbase_filter_init(&filter->filter, outer, clsid, &filter_ops);
|
2019-05-15 02:42:00 +02:00
|
|
|
|
|
|
|
InitializeCriticalSection(&filter->csReceive);
|
|
|
|
filter->csReceive.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": TransformFilter.csReceive");
|
|
|
|
|
|
|
|
/* pTransformFilter is already allocated */
|
|
|
|
filter->pFuncsTable = func_table;
|
|
|
|
ZeroMemory(&filter->pmt, sizeof(filter->pmt));
|
|
|
|
|
2019-12-13 04:24:39 +01:00
|
|
|
strmbase_sink_init(&filter->sink, &filter->filter, wcsInputPinName, &sink_ops, NULL);
|
2019-05-15 02:42:00 +02:00
|
|
|
|
2019-12-08 05:20:38 +01:00
|
|
|
strmbase_source_init(&filter->source, &filter->filter, wcsOutputPinName, &source_ops);
|
2019-11-03 04:33:14 +01:00
|
|
|
filter->source_IQualityControl_iface.lpVtbl = &source_qc_vtbl;
|
2019-06-21 03:13:17 +02:00
|
|
|
|
|
|
|
filter->seekthru_unk = NULL;
|
|
|
|
hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown *)&filter->filter.IBaseFilter_iface,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&filter->seekthru_unk);
|
2019-05-15 02:42:00 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
IUnknown_QueryInterface(filter->seekthru_unk, &IID_ISeekingPassThru, (void **)&passthru);
|
|
|
|
ISeekingPassThru_Init(passthru, FALSE, &filter->sink.pin.IPin_iface);
|
|
|
|
ISeekingPassThru_Release(passthru);
|
2019-05-15 02:42:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
strmbase_sink_cleanup(&filter->sink);
|
|
|
|
strmbase_source_cleanup(&filter->source);
|
2019-05-22 07:02:15 +02:00
|
|
|
strmbase_filter_cleanup(&filter->filter);
|
2019-05-15 02:42:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-06-06 17:22:53 +02:00
|
|
|
HRESULT strmbase_transform_create(LONG filter_size, IUnknown *outer, const CLSID *pClsid,
|
2019-05-15 02:42:00 +02:00
|
|
|
const TransformFilterFuncTable *pFuncsTable, IBaseFilter **ppTransformFilter)
|
|
|
|
{
|
|
|
|
TransformFilter* pTf;
|
|
|
|
|
|
|
|
*ppTransformFilter = NULL;
|
|
|
|
|
|
|
|
assert(filter_size >= sizeof(TransformFilter));
|
|
|
|
|
|
|
|
pTf = CoTaskMemAlloc(filter_size);
|
|
|
|
|
|
|
|
if (!pTf)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ZeroMemory(pTf, filter_size);
|
|
|
|
|
2019-06-06 17:22:53 +02:00
|
|
|
if (SUCCEEDED(strmbase_transform_init(outer, pClsid, pFuncsTable, pTf)))
|
2019-05-15 02:42:00 +02:00
|
|
|
{
|
|
|
|
*ppTransformFilter = &pTf->filter.IBaseFilter_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoTaskMemFree(pTf);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|