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
|
|
|
*/
|
|
|
|
#include "config.h"
|
2010-10-07 21:48:19 +02:00
|
|
|
#include <stdarg.h>
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
#define COBJMACROS
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "dshow.h"
|
2010-10-07 21:48:19 +02:00
|
|
|
#include "amvideo.h"
|
2005-01-31 17:24:00 +01:00
|
|
|
#include "strmif.h"
|
|
|
|
#include "vfw.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
2010-10-07 21:48:19 +02:00
|
|
|
#include "wine/strmbase.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
|
|
|
|
|
|
|
static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
|
|
|
|
static const WCHAR wcsOutputPinName[] = {'o','u','t','p','u','t',' ','p','i','n',0};
|
|
|
|
|
|
|
|
static const IBaseFilterVtbl TransformFilter_Vtbl;
|
|
|
|
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
|
|
|
|
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
|
|
|
{
|
2010-10-07 21:48:19 +02:00
|
|
|
BaseInputPin* This = (BaseInputPin*) iface;
|
|
|
|
TransformFilter * pTransform;
|
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
TRACE("%p\n", iface);
|
2010-10-07 21:48:19 +02:00
|
|
|
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
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
|
|
|
{
|
|
|
|
HRESULT hr = S_FALSE;
|
|
|
|
TransformFilter * pTransform;
|
2010-10-13 18:02:01 +02:00
|
|
|
TRACE("%p\n", This);
|
2010-10-07 21:48:19 +02:00
|
|
|
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
|
|
|
|
|
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
|
|
|
|
2010-10-05 21:37:42 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_Output_QueryAccept(IPin *iface, const AM_MEDIA_TYPE * pmt)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePin *This = (BasePin *)iface;
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter *pTransformFilter = (TransformFilter *)This->pinInfo.pFilter;
|
2008-07-22 13:13:44 +02:00
|
|
|
AM_MEDIA_TYPE* outpmt = &pTransformFilter->pmt;
|
2005-01-31 17:24:00 +01:00
|
|
|
TRACE("%p\n", iface);
|
|
|
|
|
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
|
|
|
{
|
2010-10-13 18:02:01 +02:00
|
|
|
TransformFilter *pTransformFilter = (TransformFilter *)This->pin.pinInfo.pFilter;
|
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)
|
|
|
|
{
|
|
|
|
TransformFilter *pTransform = (TransformFilter *)This->pinInfo.pFilter;
|
|
|
|
|
|
|
|
if (iPosition < 0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (iPosition > 0)
|
|
|
|
return VFW_S_NO_MORE_ITEMS;
|
|
|
|
CopyMediaType(pmt, &pTransform->pmt);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
static IPin* WINAPI TransformFilter_GetPin(BaseFilter *iface, int pos)
|
2010-10-07 21:48:01 +02:00
|
|
|
{
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter *This = (TransformFilter *)iface;
|
2010-10-07 21:48:01 +02:00
|
|
|
|
|
|
|
if (pos >= This->npins || pos < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
IPin_AddRef(This->ppPins[pos]);
|
|
|
|
return This->ppPins[pos];
|
|
|
|
}
|
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
static LONG WINAPI TransformFilter_GetPinCount(BaseFilter *iface)
|
2010-10-07 21:48:01 +02:00
|
|
|
{
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter *This = (TransformFilter *)iface;
|
2010-10-07 21:48:01 +02:00
|
|
|
|
|
|
|
return (This->npins+1);
|
|
|
|
}
|
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
static const BaseFilterFuncTable tfBaseFuncTable = {
|
|
|
|
TransformFilter_GetPin,
|
|
|
|
TransformFilter_GetPinCount
|
|
|
|
};
|
|
|
|
|
|
|
|
static const BasePinFuncTable tf_input_BaseFuncTable = {
|
|
|
|
TransformFilter_Input_CheckMediaType,
|
|
|
|
NULL,
|
2010-10-13 18:02:08 +02:00
|
|
|
BasePinImpl_GetMediaTypeVersion,
|
|
|
|
BasePinImpl_GetMediaType
|
2010-10-13 18:02:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const BaseInputPinFuncTable tf_input_BaseInputFuncTable = {
|
|
|
|
TransformFilter_Input_Receive
|
|
|
|
};
|
|
|
|
|
|
|
|
static const BasePinFuncTable tf_output_BaseFuncTable = {
|
|
|
|
NULL,
|
|
|
|
BaseOutputPinImpl_AttemptConnection,
|
2010-10-13 18:02:08 +02:00
|
|
|
BasePinImpl_GetMediaTypeVersion,
|
|
|
|
TransformFilter_Output_GetMediaType
|
2010-10-13 18:02:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static const BaseOutputPinFuncTable tf_output_BaseOutputFuncTable = {
|
2010-10-13 18:02:14 +02:00
|
|
|
TransformFilter_Output_DecideBufferSize,
|
|
|
|
BaseOutputPinImpl_DecideAllocator,
|
|
|
|
BaseOutputPinImpl_BreakConnect
|
2010-10-13 18:02:01 +02:00
|
|
|
};
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
static HRESULT TransformFilter_Init(const IBaseFilterVtbl *pVtbl, const CLSID* pClsid, const TransformFilterFuncTable* pFuncsTable, TransformFilter* pTransformFilter)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
PIN_INFO piInput;
|
|
|
|
PIN_INFO piOutput;
|
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
BaseFilter_Init(&pTransformFilter->filter, pVtbl, pClsid, (DWORD_PTR)(__FILE__ ": TransformFilter.csFilter"), &tfBaseFuncTable);
|
2010-10-07 21:47:33 +02:00
|
|
|
|
2012-01-16 21:14:23 +01:00
|
|
|
InitializeCriticalSection(&pTransformFilter->csReceive);
|
|
|
|
pTransformFilter->csReceive.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__": TransformFilter.csReceive");
|
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
/* pTransformFilter is already allocated */
|
2005-02-21 21:37:45 +01:00
|
|
|
pTransformFilter->pFuncsTable = pFuncsTable;
|
2008-07-11 06:41:35 +02:00
|
|
|
ZeroMemory(&pTransformFilter->pmt, sizeof(pTransformFilter->pmt));
|
2008-07-22 14:35:28 +02:00
|
|
|
pTransformFilter->npins = 2;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
pTransformFilter->ppPins = CoTaskMemAlloc(2 * sizeof(IPin *));
|
|
|
|
|
|
|
|
/* construct input pin */
|
|
|
|
piInput.dir = PINDIR_INPUT;
|
|
|
|
piInput.pFilter = (IBaseFilter *)pTransformFilter;
|
2005-03-28 16:17:51 +02:00
|
|
|
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
|
2005-01-31 17:24:00 +01:00
|
|
|
piOutput.dir = PINDIR_OUTPUT;
|
|
|
|
piOutput.pFilter = (IBaseFilter *)pTransformFilter;
|
2005-03-28 16:17:51 +02:00
|
|
|
lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0]));
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2010-10-13 18:02:01 +02:00
|
|
|
hr = BaseInputPin_Construct(&TransformFilter_InputPin_Vtbl, &piInput, &tf_input_BaseFuncTable, &tf_input_BaseInputFuncTable, &pTransformFilter->filter.csFilter, NULL, &pTransformFilter->ppPins[0]);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2010-10-13 18:02:01 +02:00
|
|
|
hr = BaseOutputPin_Construct(&TransformFilter_OutputPin_Vtbl, sizeof(BaseOutputPin), &piOutput, &tf_output_BaseFuncTable, &tf_output_BaseOutputFuncTable, &pTransformFilter->filter.csFilter, &pTransformFilter->ppPins[1]);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2008-04-01 22:41:25 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("Cannot create output pin (%x)\n", hr);
|
2010-11-05 23:19:14 +01:00
|
|
|
else {
|
|
|
|
QualityControlImpl_init(&pTransformFilter->qcimpl, (IPin*)pTransformFilter->ppPins[0], (IBaseFilter*)pTransformFilter);
|
|
|
|
pTransformFilter->qcimpl.lpVtbl = &TransformFilter_QualityControl_Vtbl;
|
|
|
|
}
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
2010-05-22 16:15:03 +02:00
|
|
|
if (FAILED(hr))
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
|
|
|
CoTaskMemFree(pTransformFilter->ppPins);
|
2010-10-07 21:47:33 +02:00
|
|
|
BaseFilterImpl_Release((IBaseFilter*)pTransformFilter);
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
HRESULT TransformFilter_Construct(const IBaseFilterVtbl *pVtbl, LONG filter_size, const CLSID* pClsid, const TransformFilterFuncTable* pFuncsTable, IBaseFilter ** ppTransformFilter)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter* pTf;
|
|
|
|
|
|
|
|
*ppTransformFilter = NULL;
|
|
|
|
|
|
|
|
assert(filter_size >= sizeof(TransformFilter));
|
|
|
|
|
|
|
|
pTf = CoTaskMemAlloc(filter_size);
|
|
|
|
|
|
|
|
if (!pTf)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2011-06-26 16:32:39 +02:00
|
|
|
ZeroMemory(pTf, filter_size);
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
if (SUCCEEDED(TransformFilter_Init(pVtbl, pClsid, pFuncsTable, pTf)))
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-07 21:48:19 +02:00
|
|
|
*ppTransformFilter = (IBaseFilter*)(&pTf->filter.lpVtbl);
|
2005-01-31 17:24:00 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
CoTaskMemFree(pTf);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
HRESULT WINAPI TransformFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
TransformFilter *This = (TransformFilter *)iface;
|
|
|
|
TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_guid(riid), ppv);
|
|
|
|
|
2010-11-05 23:19:14 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IQualityControl)) {
|
|
|
|
*ppv = (IQualityControl*)&This->qcimpl;
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2010-10-07 21:48:19 +02:00
|
|
|
hr = BaseFilterImpl_QueryInterface(iface, riid, ppv);
|
|
|
|
|
2010-11-09 23:42:38 +01:00
|
|
|
if (FAILED(hr) && !IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow) &&
|
|
|
|
!IsEqualIID(riid, &IID_IAMFilterMiscFlags))
|
2010-10-07 21:48:19 +02:00
|
|
|
FIXME("No interface for %s!\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
return hr;
|
2005-01-31 17:24:00 +01:00
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter *This = (TransformFilter *)iface;
|
2010-10-07 21:47:33 +02:00
|
|
|
ULONG refCount = BaseFilterImpl_Release(iface);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
if (!refCount)
|
|
|
|
{
|
|
|
|
ULONG i;
|
|
|
|
|
2008-07-22 14:35:28 +02:00
|
|
|
for (i = 0; i < This->npins; i++)
|
2007-03-13 18:47:47 +01:00
|
|
|
{
|
|
|
|
IPin *pConnectedTo;
|
|
|
|
|
|
|
|
if (SUCCEEDED(IPin_ConnectedTo(This->ppPins[i], &pConnectedTo)))
|
|
|
|
{
|
|
|
|
IPin_Disconnect(pConnectedTo);
|
|
|
|
IPin_Release(pConnectedTo);
|
|
|
|
}
|
|
|
|
IPin_Disconnect(This->ppPins[i]);
|
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
IPin_Release(This->ppPins[i]);
|
2007-03-13 18:47:47 +01:00
|
|
|
}
|
2005-01-31 17:24:00 +01:00
|
|
|
|
2007-03-08 12:03:06 +01:00
|
|
|
CoTaskMemFree(This->ppPins);
|
2007-03-19 21:26:09 +01:00
|
|
|
|
2005-01-31 17:24:00 +01:00
|
|
|
TRACE("Destroying transform filter\n");
|
2012-01-16 21:14:23 +01:00
|
|
|
This->csReceive.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&This->csReceive);
|
2008-07-11 06:41:35 +02:00
|
|
|
FreeMediaType(&This->pmt);
|
2005-01-31 17:24:00 +01:00
|
|
|
CoTaskMemFree(This);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IMediaFilter methods **/
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter * iface)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter *This = (TransformFilter *)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);
|
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
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter *This = (TransformFilter *)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
|
|
|
}
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter *This = (TransformFilter *)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
|
|
|
{
|
2010-10-05 21:38:11 +02:00
|
|
|
((BaseInputPin *)This->ppPins[0])->end_of_stream = 0;
|
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))
|
2010-10-05 21:37:56 +02:00
|
|
|
hr = BaseOutputPinImpl_Active((BaseOutputPin *)This->ppPins[1]);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** IBaseFilter implementation **/
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
HRESULT WINAPI TransformFilterImpl_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter *This = (TransformFilter *)iface;
|
2005-01-31 17:24:00 +01:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IBaseFilterVtbl TransformFilter_Vtbl =
|
|
|
|
{
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilterImpl_QueryInterface,
|
2010-10-07 21:47:33 +02:00
|
|
|
BaseFilterImpl_AddRef,
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilterImpl_Release,
|
2010-10-07 21:47:33 +02:00
|
|
|
BaseFilterImpl_GetClassID,
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilterImpl_Stop,
|
|
|
|
TransformFilterImpl_Pause,
|
|
|
|
TransformFilterImpl_Run,
|
2010-10-07 21:47:33 +02:00
|
|
|
BaseFilterImpl_GetState,
|
|
|
|
BaseFilterImpl_SetSyncSource,
|
|
|
|
BaseFilterImpl_GetSyncSource,
|
2010-10-07 21:48:01 +02:00
|
|
|
BaseFilterImpl_EnumPins,
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilterImpl_FindPin,
|
2010-10-07 21:47:33 +02:00
|
|
|
BaseFilterImpl_QueryFilterInfo,
|
|
|
|
BaseFilterImpl_JoinFilterGraph,
|
|
|
|
BaseFilterImpl_QueryVendorInfo
|
2005-01-31 17:24:00 +01: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
|
|
|
{
|
2010-10-05 21:38:11 +02:00
|
|
|
BaseInputPin* This = (BaseInputPin*) iface;
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter* pTransform;
|
2005-03-02 11:12:12 +01:00
|
|
|
IPin* ppin;
|
|
|
|
HRESULT hr;
|
2010-10-07 21:48:19 +02:00
|
|
|
|
2005-03-02 11:12:12 +01:00
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
|
|
|
/* Since we process samples synchronously, just forward notification downstream */
|
2010-10-07 21:48:19 +02:00
|
|
|
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
|
2005-03-02 11:12:12 +01:00
|
|
|
if (!pTransform)
|
|
|
|
hr = E_FAIL;
|
|
|
|
else
|
|
|
|
hr = IPin_ConnectedTo(pTransform->ppPins[1], &ppin);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IPin_EndOfStream(ppin);
|
|
|
|
IPin_Release(ppin);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("%x\n", hr);
|
2005-03-02 11:12:12 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2007-04-03 08:45:27 +02:00
|
|
|
static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
2010-10-05 21:38:11 +02:00
|
|
|
BaseInputPin* This = (BaseInputPin*) iface;
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter* pTransform;
|
|
|
|
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
|
|
|
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2010-10-05 21:38:11 +02:00
|
|
|
BaseInputPin* This = (BaseInputPin*) iface;
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter* pTransform;
|
2007-04-03 08:45:27 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
|
|
|
|
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)
|
|
|
|
{
|
2010-10-05 21:38:11 +02:00
|
|
|
BaseInputPin* This = (BaseInputPin*) iface;
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter* pTransform;
|
2010-05-12 17:10:04 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
|
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)
|
|
|
|
{
|
2010-10-05 21:38:11 +02:00
|
|
|
BaseInputPin* This = (BaseInputPin*) iface;
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter* pTransform;
|
2010-05-12 17:10:04 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
|
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)
|
|
|
|
{
|
2010-10-05 21:38:11 +02:00
|
|
|
BaseInputPin* This = (BaseInputPin*) iface;
|
2010-10-07 21:48:19 +02:00
|
|
|
TransformFilter* pTransform;
|
2010-05-12 17:10:04 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", iface);
|
|
|
|
|
2010-10-07 21:48:19 +02:00
|
|
|
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
|
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,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_AddRef,
|
2010-10-05 21:38:11 +02:00
|
|
|
BaseInputPinImpl_Release,
|
|
|
|
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,
|
2010-10-05 21:38:11 +02:00
|
|
|
BaseInputPinImpl_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
|
|
|
};
|
|
|
|
|
2007-04-03 08:45:27 +02:00
|
|
|
static const IPinVtbl TransformFilter_OutputPin_Vtbl =
|
2005-01-31 17:24:00 +01:00
|
|
|
{
|
2010-10-05 21:37:56 +02:00
|
|
|
BaseOutputPinImpl_QueryInterface,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_AddRef,
|
2010-10-05 21:37:56 +02:00
|
|
|
BaseOutputPinImpl_Release,
|
|
|
|
BaseOutputPinImpl_Connect,
|
|
|
|
BaseOutputPinImpl_ReceiveConnection,
|
|
|
|
BaseOutputPinImpl_Disconnect,
|
2010-10-05 21:37:42 +02:00
|
|
|
BasePinImpl_ConnectedTo,
|
|
|
|
BasePinImpl_ConnectionMediaType,
|
|
|
|
BasePinImpl_QueryPinInfo,
|
|
|
|
BasePinImpl_QueryDirection,
|
|
|
|
BasePinImpl_QueryId,
|
|
|
|
TransformFilter_Output_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;
|
|
|
|
TransformFilter *This = (TransformFilter *)qc->self;
|
|
|
|
|
|
|
|
if (This->pFuncsTable->pfnNotify)
|
|
|
|
return This->pFuncsTable->pfnNotify(This, sender, qm);
|
|
|
|
else
|
|
|
|
return QualityControlImpl_Notify(iface, sender, qm);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IQualityControlVtbl TransformFilter_QualityControl_Vtbl = {
|
|
|
|
QualityControlImpl_QueryInterface,
|
|
|
|
QualityControlImpl_AddRef,
|
|
|
|
QualityControlImpl_Release,
|
|
|
|
TransformFilter_QualityControlImpl_Notify,
|
|
|
|
QualityControlImpl_SetSink
|
|
|
|
};
|