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
|
|
|
|
|
|
|
static const IPinVtbl TransformFilter_InputPin_Vtbl;
|
|
|
|
static const IPinVtbl TransformFilter_OutputPin_Vtbl;
|
2010-11-05 23:19:14 +01:00
|
|
|
static const IQualityControlVtbl TransformFilter_QualityControl_Vtbl;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2012-03-26 21:06:13 +02:00
|
|
|
static inline TransformFilter *impl_from_IBaseFilter( IBaseFilter *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, TransformFilter, filter.IBaseFilter_iface);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_Input_CheckMediaType(BasePin *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
|
|
|
}
|
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_Input_Receive(BaseInputPin *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
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->end_of_stream || This->flushing)
|
|
|
|
{
|
2012-01-16 21:14:23 +01:00
|
|
|
LeaveCriticalSection(&pTransform->csReceive);
|
2010-10-07 21:48:19 +02:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-01-23 15:33:02 +01:00
|
|
|
LeaveCriticalSection(&pTransform->csReceive);
|
2010-10-07 21:48:19 +02:00
|
|
|
if (pTransform->pFuncsTable->pfnReceive)
|
|
|
|
hr = pTransform->pFuncsTable->pfnReceive(pTransform, pInSample);
|
|
|
|
else
|
|
|
|
hr = S_FALSE;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-05-04 06:47:13 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_Output_CheckMediaType(BasePin *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;
|
|
|
|
}
|
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_Output_DecideBufferSize(BaseOutputPin *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);
|
|
|
|
}
|
|
|
|
|
2010-10-13 18:02:08 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_Output_GetMediaType(BasePin *This, int iPosition, AM_MEDIA_TYPE *pmt)
|
|
|
|
{
|
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 E_INVALIDARG;
|
|
|
|
if (iPosition > 0)
|
|
|
|
return VFW_S_NO_MORE_ITEMS;
|
|
|
|
CopyMediaType(pmt, &pTransform->pmt);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-08-29 03:24:30 +02:00
|
|
|
static IPin *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)
|
|
|
|
return &filter->sink.pin.IPin_iface;
|
|
|
|
else if (index == 1)
|
|
|
|
return &filter->source.pin.IPin_iface;
|
|
|
|
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-06-21 03:13:17 +02:00
|
|
|
if (filter->sink.pin.pConnectedTo)
|
|
|
|
IPin_Disconnect(filter->sink.pin.pConnectedTo);
|
|
|
|
IPin_Disconnect(&filter->sink.pin.IPin_iface);
|
2019-05-25 22:21:22 +02:00
|
|
|
|
2019-06-21 03:13:17 +02:00
|
|
|
if (filter->source.pin.pConnectedTo)
|
|
|
|
IPin_Disconnect(filter->source.pin.pConnectedTo);
|
|
|
|
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);
|
|
|
|
QualityControlImpl_Destroy(filter->qcimpl);
|
|
|
|
IUnknown_Release(filter->seekthru_unk);
|
|
|
|
strmbase_filter_cleanup(&filter->filter);
|
|
|
|
CoTaskMemFree(filter);
|
|
|
|
}
|
|
|
|
|
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,
|
2010-10-13 18:02:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const BaseInputPinFuncTable tf_input_BaseInputFuncTable = {
|
2014-01-06 17:54:13 +01:00
|
|
|
{
|
|
|
|
TransformFilter_Input_CheckMediaType,
|
|
|
|
BasePinImpl_GetMediaType
|
|
|
|
},
|
2010-10-13 18:02:01 +02:00
|
|
|
TransformFilter_Input_Receive
|
|
|
|
};
|
|
|
|
|
|
|
|
static const BaseOutputPinFuncTable tf_output_BaseOutputFuncTable = {
|
2014-01-06 17:54:13 +01:00
|
|
|
{
|
2018-05-04 06:47:13 +02:00
|
|
|
TransformFilter_Output_CheckMediaType,
|
2014-01-06 17:54:13 +01:00
|
|
|
TransformFilter_Output_GetMediaType
|
|
|
|
},
|
2019-05-09 17:12:33 +02:00
|
|
|
BaseOutputPinImpl_AttemptConnection,
|
2010-10-13 18:02:14 +02:00
|
|
|
TransformFilter_Output_DecideBufferSize,
|
|
|
|
BaseOutputPinImpl_DecideAllocator,
|
2010-10-13 18:02:01 +02:00
|
|
|
};
|
|
|
|
|
2019-05-15 02:42:00 +02:00
|
|
|
static HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter *iface)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2012-03-26 21:06:13 +02:00
|
|
|
TransformFilter *This = impl_from_IBaseFilter(iface);
|
2008-07-22 13:09:55 +02:00
|
|
|
HRESULT hr = S_OK;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
TRACE("(%p/%p)\n", This, iface);
|
|
|
|
|
2012-01-16 21:14:23 +01:00
|
|
|
EnterCriticalSection(&This->csReceive);
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
This->filter.state = State_Stopped;
|
2010-10-07 21:48:19 +02:00
|
|
|
if (This->pFuncsTable->pfnStopStreaming)
|
|
|
|
hr = This->pFuncsTable->pfnStopStreaming(This);
|
2016-01-30 17:01:22 +01:00
|
|
|
if (SUCCEEDED(hr))
|
2019-06-21 03:13:17 +02:00
|
|
|
hr = BaseOutputPinImpl_Inactive(&This->source);
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
2012-01-16 21:14:23 +01:00
|
|
|
LeaveCriticalSection(&This->csReceive);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2008-07-22 13:09:55 +02:00
|
|
|
return hr;
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 02:42:00 +02:00
|
|
|
static HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter *iface)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2012-03-26 21:06:13 +02:00
|
|
|
TransformFilter *This = impl_from_IBaseFilter(iface);
|
2008-07-22 13:09:55 +02:00
|
|
|
HRESULT hr;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->()\n", This, iface);
|
|
|
|
|
2012-01-16 21:14:23 +01:00
|
|
|
EnterCriticalSection(&This->csReceive);
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
if (This->filter.state == State_Stopped)
|
2008-07-22 13:09:55 +02:00
|
|
|
hr = IBaseFilter_Run(iface, -1);
|
|
|
|
else
|
|
|
|
hr = S_OK;
|
2008-04-05 01:27:29 +02:00
|
|
|
|
2008-07-22 13:09:55 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2010-10-07 21:47:33 +02:00
|
|
|
This->filter.state = State_Paused;
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
2012-01-16 21:14:23 +01:00
|
|
|
LeaveCriticalSection(&This->csReceive);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2008-07-22 13:09:55 +02:00
|
|
|
return hr;
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
|
2019-05-15 02:42:00 +02:00
|
|
|
static HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter *iface, REFERENCE_TIME tStart)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
2012-03-26 21:06:13 +02:00
|
|
|
TransformFilter *This = impl_from_IBaseFilter(iface);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
|
|
|
|
|
2012-01-16 21:14:23 +01:00
|
|
|
EnterCriticalSection(&This->csReceive);
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
if (This->filter.state == State_Stopped)
|
2008-07-05 03:42:09 +02:00
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
This->sink.end_of_stream = FALSE;
|
2010-10-07 21:48:19 +02:00
|
|
|
if (This->pFuncsTable->pfnStartStreaming)
|
|
|
|
hr = This->pFuncsTable->pfnStartStreaming(This);
|
2008-07-22 13:09:55 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2019-06-21 03:13:17 +02:00
|
|
|
hr = BaseOutputPinImpl_Active(&This->source);
|
2008-07-05 03:42:09 +02:00
|
|
|
}
|
2008-04-05 01:27:29 +02:00
|
|
|
|
2008-07-22 13:09:55 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2010-10-07 21:47:33 +02:00
|
|
|
This->filter.rtStreamStart = tStart;
|
|
|
|
This->filter.state = State_Running;
|
2008-07-22 13:09:55 +02:00
|
|
|
}
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
2012-01-16 21:14:23 +01:00
|
|
|
LeaveCriticalSection(&This->csReceive);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-05-15 02:42:00 +02:00
|
|
|
static const IBaseFilterVtbl transform_vtbl =
|
|
|
|
{
|
2019-05-19 04:38:49 +02:00
|
|
|
BaseFilterImpl_QueryInterface,
|
2019-05-15 02:42:00 +02:00
|
|
|
BaseFilterImpl_AddRef,
|
2019-05-25 22:21:22 +02:00
|
|
|
BaseFilterImpl_Release,
|
2019-05-15 02:42:00 +02:00
|
|
|
BaseFilterImpl_GetClassID,
|
|
|
|
TransformFilterImpl_Stop,
|
|
|
|
TransformFilterImpl_Pause,
|
|
|
|
TransformFilterImpl_Run,
|
|
|
|
BaseFilterImpl_GetState,
|
|
|
|
BaseFilterImpl_SetSyncSource,
|
|
|
|
BaseFilterImpl_GetSyncSource,
|
|
|
|
BaseFilterImpl_EnumPins,
|
|
|
|
BaseFilterImpl_FindPin,
|
|
|
|
BaseFilterImpl_QueryFilterInfo,
|
|
|
|
BaseFilterImpl_JoinFilterGraph,
|
|
|
|
BaseFilterImpl_QueryVendorInfo
|
|
|
|
};
|
|
|
|
|
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-08-29 03:24:29 +02:00
|
|
|
strmbase_filter_init(&filter->filter, &transform_vtbl, 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-09-06 02:02:15 +02:00
|
|
|
strmbase_sink_init(&filter->sink, &TransformFilter_InputPin_Vtbl, &filter->filter,
|
|
|
|
wcsInputPinName, &tf_input_BaseInputFuncTable, NULL);
|
2019-05-15 02:42:00 +02:00
|
|
|
|
2019-09-06 02:02:15 +02:00
|
|
|
strmbase_source_init(&filter->source, &TransformFilter_OutputPin_Vtbl, &filter->filter,
|
|
|
|
wcsOutputPinName, &tf_output_BaseOutputFuncTable);
|
2019-05-15 02:42:00 +02:00
|
|
|
|
2019-06-21 03:13:17 +02:00
|
|
|
QualityControlImpl_Create(&filter->sink.pin.IPin_iface,
|
|
|
|
&filter->filter.IBaseFilter_iface, &filter->qcimpl);
|
|
|
|
filter->qcimpl->IQualityControl_iface.lpVtbl = &TransformFilter_QualityControl_Vtbl;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-09-02 12:17:29 +02:00
|
|
|
HRESULT WINAPI TransformFilterImpl_Notify(TransformFilter *filter, IBaseFilter *sender, Quality qm)
|
2012-04-02 14:52:15 +02:00
|
|
|
{
|
2019-09-02 12:17:29 +02:00
|
|
|
return QualityControlImpl_Notify(&filter->qcimpl->IQualityControl_iface, sender, qm);
|
2012-04-02 14:52:15 +02:00
|
|
|
}
|
|
|
|
|
2005-06-20 20:39:40 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_InputPin_EndOfStream(IPin * iface)
|
2005-03-02 11:12:12 +01:00
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *filter = impl_from_sink_IPin(iface);
|
2010-10-07 21:48:19 +02:00
|
|
|
|
2019-06-21 03:13:17 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2005-03-02 11:12:12 +01:00
|
|
|
|
2019-06-21 03:13:17 +02:00
|
|
|
if (filter->source.pin.pConnectedTo)
|
|
|
|
return IPin_EndOfStream(filter->source.pin.pConnectedTo);
|
|
|
|
return VFW_E_NOT_CONNECTED;
|
2005-03-02 11:12:12 +01:00
|
|
|
}
|
|
|
|
|
2007-04-03 08:45:27 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *pTransform = impl_from_sink_IPin(iface);
|
2010-10-07 21:48:19 +02:00
|
|
|
HRESULT hr = S_OK;
|
2007-04-03 08:45:27 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p, %p)\n", iface, pReceivePin, pmt);
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
if (pTransform->pFuncsTable->pfnSetMediaType)
|
|
|
|
hr = pTransform->pFuncsTable->pfnSetMediaType(pTransform, PINDIR_INPUT, pmt);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && pTransform->pFuncsTable->pfnCompleteConnect)
|
|
|
|
hr = pTransform->pFuncsTable->pfnCompleteConnect(pTransform, PINDIR_INPUT, pReceivePin);
|
2007-04-03 08:45:27 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2010-10-05 21:38:11 +02:00
|
|
|
hr = BaseInputPinImpl_ReceiveConnection(iface, pReceivePin, pmt);
|
2010-10-07 21:48:19 +02:00
|
|
|
if (FAILED(hr) && pTransform->pFuncsTable->pfnBreakConnect)
|
|
|
|
pTransform->pFuncsTable->pfnBreakConnect(pTransform, PINDIR_INPUT);
|
2007-04-03 08:45:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_InputPin_Disconnect(IPin * iface)
|
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *pTransform = impl_from_sink_IPin(iface);
|
2007-04-03 08:45:27 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
if (pTransform->pFuncsTable->pfnBreakConnect)
|
|
|
|
pTransform->pFuncsTable->pfnBreakConnect(pTransform, PINDIR_INPUT);
|
2007-04-03 08:45:27 +02:00
|
|
|
|
2010-10-05 21:37:42 +02:00
|
|
|
return BasePinImpl_Disconnect(iface);
|
2007-04-03 08:45:27 +02:00
|
|
|
}
|
|
|
|
|
2010-05-12 17:10:04 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_InputPin_BeginFlush(IPin * iface)
|
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *pTransform = impl_from_sink_IPin(iface);
|
2010-05-12 17:10:04 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
EnterCriticalSection(&pTransform->filter.csFilter);
|
2010-05-12 17:10:04 +02:00
|
|
|
if (pTransform->pFuncsTable->pfnBeginFlush)
|
2010-10-07 21:48:19 +02:00
|
|
|
hr = pTransform->pFuncsTable->pfnBeginFlush(pTransform);
|
2010-05-12 17:10:04 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2010-10-05 21:38:11 +02:00
|
|
|
hr = BaseInputPinImpl_BeginFlush(iface);
|
2010-10-07 21:47:33 +02:00
|
|
|
LeaveCriticalSection(&pTransform->filter.csFilter);
|
2010-05-12 17:10:04 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_InputPin_EndFlush(IPin * iface)
|
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *pTransform = impl_from_sink_IPin(iface);
|
2010-05-12 17:10:04 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
EnterCriticalSection(&pTransform->filter.csFilter);
|
2010-05-12 17:10:04 +02:00
|
|
|
if (pTransform->pFuncsTable->pfnEndFlush)
|
2010-10-07 21:48:19 +02:00
|
|
|
hr = pTransform->pFuncsTable->pfnEndFlush(pTransform);
|
2010-05-12 17:10:04 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2010-10-05 21:38:11 +02:00
|
|
|
hr = BaseInputPinImpl_EndFlush(iface);
|
2010-10-07 21:47:33 +02:00
|
|
|
LeaveCriticalSection(&pTransform->filter.csFilter);
|
2010-05-12 17:10:04 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI TransformFilter_InputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
|
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *pTransform = impl_from_sink_IPin(iface);
|
2010-05-12 17:10:04 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
2016-11-25 10:10:46 +01:00
|
|
|
TRACE("(%p)->(%s %s %e)\n", iface, wine_dbgstr_longlong(tStart), wine_dbgstr_longlong(tStop), dRate);
|
2010-05-12 17:10:04 +02:00
|
|
|
|
2010-10-07 21:47:33 +02:00
|
|
|
EnterCriticalSection(&pTransform->filter.csFilter);
|
2010-05-12 17:10:04 +02:00
|
|
|
if (pTransform->pFuncsTable->pfnNewSegment)
|
2010-10-07 21:48:19 +02:00
|
|
|
hr = pTransform->pFuncsTable->pfnNewSegment(pTransform, tStart, tStop, dRate);
|
2010-05-12 17:10:04 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2010-10-05 21:38:11 +02:00
|
|
|
hr = BaseInputPinImpl_NewSegment(iface, tStart, tStop, dRate);
|
2010-10-07 21:47:33 +02:00
|
|
|
LeaveCriticalSection(&pTransform->filter.csFilter);
|
2010-05-12 17:10:04 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
static const IPinVtbl TransformFilter_InputPin_Vtbl =
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-05 21:38:11 +02:00
|
|
|
BaseInputPinImpl_QueryInterface,
|
2019-06-19 03:17:35 +02:00
|
|
|
BasePinImpl_AddRef,
|
|
|
|
BasePinImpl_Release,
|
2010-10-05 21:38:11 +02:00
|
|
|
BaseInputPinImpl_Connect,
|
2007-04-03 08:45:27 +02:00
|
|
|
TransformFilter_InputPin_ReceiveConnection,
|
|
|
|
TransformFilter_InputPin_Disconnect,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_ConnectedTo,
|
|
|
|
BasePinImpl_ConnectionMediaType,
|
|
|
|
BasePinImpl_QueryPinInfo,
|
|
|
|
BasePinImpl_QueryDirection,
|
|
|
|
BasePinImpl_QueryId,
|
2018-05-04 06:47:13 +02:00
|
|
|
BasePinImpl_QueryAccept,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_EnumMediaTypes,
|
|
|
|
BasePinImpl_QueryInternalConnections,
|
2005-03-02 11:12:12 +01:00
|
|
|
TransformFilter_InputPin_EndOfStream,
|
2010-05-12 17:10:04 +02:00
|
|
|
TransformFilter_InputPin_BeginFlush,
|
|
|
|
TransformFilter_InputPin_EndFlush,
|
|
|
|
TransformFilter_InputPin_NewSegment
|
2005-01-31 17:24:00 +01:00
|
|
|
};
|
|
|
|
|
2019-05-19 04:38:47 +02:00
|
|
|
static HRESULT WINAPI transform_source_QueryInterface(IPin *iface, REFIID iid, void **out)
|
|
|
|
{
|
2019-06-21 03:13:17 +02:00
|
|
|
TransformFilter *filter = impl_from_source_IPin(iface);
|
|
|
|
|
2019-05-19 04:38:47 +02:00
|
|
|
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IPin))
|
|
|
|
*out = iface;
|
|
|
|
else if (IsEqualGUID(iid, &IID_IQualityControl))
|
|
|
|
*out = &filter->qcimpl->IQualityControl_iface;
|
|
|
|
else if (IsEqualGUID(iid, &IID_IMediaSeeking))
|
|
|
|
return IUnknown_QueryInterface(filter->seekthru_unk, iid, out);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-04-03 08:45:27 +02:00
|
|
|
static const IPinVtbl TransformFilter_OutputPin_Vtbl =
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2019-05-19 04:38:47 +02:00
|
|
|
transform_source_QueryInterface,
|
2019-06-19 03:17:35 +02:00
|
|
|
BasePinImpl_AddRef,
|
|
|
|
BasePinImpl_Release,
|
2010-10-05 21:37:56 +02:00
|
|
|
BaseOutputPinImpl_Connect,
|
|
|
|
BaseOutputPinImpl_ReceiveConnection,
|
|
|
|
BaseOutputPinImpl_Disconnect,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_ConnectedTo,
|
|
|
|
BasePinImpl_ConnectionMediaType,
|
|
|
|
BasePinImpl_QueryPinInfo,
|
|
|
|
BasePinImpl_QueryDirection,
|
|
|
|
BasePinImpl_QueryId,
|
2018-05-04 06:47:13 +02:00
|
|
|
BasePinImpl_QueryAccept,
|
2010-10-13 18:02:08 +02:00
|
|
|
BasePinImpl_EnumMediaTypes,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_QueryInternalConnections,
|
2010-10-05 21:37:56 +02:00
|
|
|
BaseOutputPinImpl_EndOfStream,
|
|
|
|
BaseOutputPinImpl_BeginFlush,
|
|
|
|
BaseOutputPinImpl_EndFlush,
|
2010-11-01 13:42:14 +01:00
|
|
|
BasePinImpl_NewSegment
|
2005-01-31 17:24:00 +01:00
|
|
|
};
|
2010-11-05 23:19:14 +01:00
|
|
|
|
2011-07-03 17:32:25 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_QualityControlImpl_Notify(IQualityControl *iface, IBaseFilter *sender, Quality qm) {
|
2010-11-05 23:19:14 +01:00
|
|
|
QualityControlImpl *qc = (QualityControlImpl*)iface;
|
2012-03-26 21:06:13 +02:00
|
|
|
TransformFilter *This = impl_from_IBaseFilter(qc->self);
|
2010-11-05 23:19:14 +01:00
|
|
|
|
|
|
|
if (This->pFuncsTable->pfnNotify)
|
|
|
|
return This->pFuncsTable->pfnNotify(This, sender, qm);
|
|
|
|
else
|
2012-04-02 14:52:15 +02:00
|
|
|
return TransformFilterImpl_Notify(This, sender, qm);
|
2010-11-05 23:19:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IQualityControlVtbl TransformFilter_QualityControl_Vtbl = {
|
|
|
|
QualityControlImpl_QueryInterface,
|
|
|
|
QualityControlImpl_AddRef,
|
|
|
|
QualityControlImpl_Release,
|
|
|
|
TransformFilter_QualityControlImpl_Notify,
|
|
|
|
QualityControlImpl_SetSink
|
|
|
|
};
|