strmbase: Standardize "class" function into functions tables in the structs.

This allows the standardization of the "class" functions to use the 
class as the argument and will aid in expanding the implementation of 
these functions.
This commit is contained in:
Aric Stewart 2010-10-13 11:02:01 -05:00 committed by Alexandre Julliard
parent 8f3c3723bb
commit 3c2dfd186a
12 changed files with 280 additions and 153 deletions

View File

@ -79,7 +79,7 @@ typedef struct VfwPinImpl
const IKsPropertySetVtbl * KSP_VT;
} VfwPinImpl;
static IPin* WINAPI VfwCapture_GetPin(IBaseFilter *iface, int pos)
static IPin* WINAPI VfwCapture_GetPin(BaseFilter *iface, int pos)
{
VfwCapture *This = (VfwCapture *)iface;
@ -90,11 +90,16 @@ static IPin* WINAPI VfwCapture_GetPin(IBaseFilter *iface, int pos)
return This->pOutputPin;
}
static LONG WINAPI VfwCapture_GetPinCount(IBaseFilter *iface)
static LONG WINAPI VfwCapture_GetPinCount(BaseFilter *iface)
{
return 1;
}
static const BaseFilterFuncTable BaseFuncTable = {
VfwCapture_GetPin,
VfwCapture_GetPinCount
};
IUnknown * WINAPI QCAP_createVFWCaptureFilter(IUnknown *pUnkOuter, HRESULT *phr)
{
VfwCapture *pVfwCapture;
@ -112,7 +117,7 @@ IUnknown * WINAPI QCAP_createVFWCaptureFilter(IUnknown *pUnkOuter, HRESULT *phr)
if (!pVfwCapture)
return NULL;
BaseFilter_Init(&pVfwCapture->filter, &VfwCapture_Vtbl, &CLSID_VfwCapture, (DWORD_PTR)(__FILE__ ": VfwCapture.csFilter"), VfwCapture_GetPin, VfwCapture_GetPinCount);
BaseFilter_Init(&pVfwCapture->filter, &VfwCapture_Vtbl, &CLSID_VfwCapture, (DWORD_PTR)(__FILE__ ": VfwCapture.csFilter"), &BaseFuncTable);
pVfwCapture->IAMStreamConfig_vtbl = &IAMStreamConfig_VTable;
pVfwCapture->IAMVideoProcAmp_vtbl = &IAMVideoProcAmp_VTable;
@ -646,7 +651,7 @@ static const IKsPropertySetVtbl KSP_VTable =
KSP_QuerySupported
};
static HRESULT WINAPI VfwPin_GetMediaType(IPin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
static HRESULT WINAPI VfwPin_GetMediaType(BasePin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
{
VfwPinImpl *This = (VfwPinImpl *)iface;
AM_MEDIA_TYPE *vfw_pmt;
@ -664,12 +669,12 @@ static HRESULT WINAPI VfwPin_GetMediaType(IPin *iface, int iPosition, AM_MEDIA_T
return hr;
}
LONG WINAPI VfwPin_GetMediaTypeVersion(IPin *iface)
LONG WINAPI VfwPin_GetMediaTypeVersion(BasePin *iface)
{
return 1;
}
static HRESULT WINAPI VfwPin_DecideBufferSize(IPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
static HRESULT WINAPI VfwPin_DecideBufferSize(BaseOutputPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
{
ALLOCATOR_PROPERTIES actual;
@ -685,6 +690,15 @@ static HRESULT WINAPI VfwPin_DecideBufferSize(IPin *iface, IMemAllocator *pAlloc
return IMemAllocator_SetProperties(pAlloc, ppropInputRequest, &actual);
}
static const BasePinFuncTable output_BaseFuncTable = {
NULL,
BaseOutputPinImpl_AttemptConnection
};
static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
VfwPin_DecideBufferSize
};
static HRESULT
VfwPin_Construct( IBaseFilter * pBaseFilter, LPCRITICAL_SECTION pCritSec,
IPin ** ppPin )
@ -700,7 +714,7 @@ VfwPin_Construct( IBaseFilter * pBaseFilter, LPCRITICAL_SECTION pCritSec,
lstrcpyW(piOutput.achName, wszOutputPinName);
ObjectRefCount(TRUE);
hr = BaseOutputPin_Construct(&VfwPin_Vtbl, sizeof(VfwPinImpl), &piOutput, VfwPin_DecideBufferSize, NULL, pCritSec, ppPin);
hr = BaseOutputPin_Construct(&VfwPin_Vtbl, sizeof(VfwPinImpl), &piOutput, &output_BaseFuncTable, &output_BaseOutputFuncTable, pCritSec, ppPin);
if (SUCCEEDED(hr))
{
@ -770,7 +784,7 @@ VfwPin_EnumMediaTypes(IPin * iface, IEnumMediaTypes ** ppEnum)
VfwPinImpl *This = (VfwPinImpl *)iface;
hr = qcap_driver_get_format(This->driver_info, &pmt);
if (SUCCEEDED(hr))
hr = EnumMediaTypes_Construct(iface, VfwPin_GetMediaType, VfwPin_GetMediaTypeVersion, ppEnum);
hr = EnumMediaTypes_Construct((BasePin*)iface, VfwPin_GetMediaType, VfwPin_GetMediaTypeVersion, ppEnum);
TRACE("%p -- %x\n", This, hr);
DeleteMediaType(pmt);

View File

@ -207,9 +207,8 @@ static HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, const BYTE *d
return hr;
}
static HRESULT WINAPI DSoundRender_Receive(IPin *iface, IMediaSample * pSample)
static HRESULT WINAPI DSoundRender_Receive(BaseInputPin *pin, IMediaSample * pSample)
{
BaseInputPin *pin = (BaseInputPin*)iface;
DSoundRenderImpl *This = (DSoundRenderImpl*)pin->pin.pinInfo.pFilter;
LPBYTE pbSrcStream = NULL;
LONG cbSrcStream = 0;
@ -217,7 +216,7 @@ static HRESULT WINAPI DSoundRender_Receive(IPin *iface, IMediaSample * pSample)
HRESULT hr;
AM_MEDIA_TYPE *amt;
TRACE("%p %p\n", iface, pSample);
TRACE("%p %p\n", pin, pSample);
/* Slightly incorrect, Pause completes when a frame is received so we should signal
* pause completion here, but for sound playing a single frame doesn't make sense
@ -341,7 +340,7 @@ static HRESULT WINAPI DSoundRender_Receive(IPin *iface, IMediaSample * pSample)
return hr;
}
static HRESULT WINAPI DSoundRender_CheckMediaType(IPin *iface, const AM_MEDIA_TYPE * pmt)
static HRESULT WINAPI DSoundRender_CheckMediaType(BasePin *iface, const AM_MEDIA_TYPE * pmt)
{
WAVEFORMATEX* format;
@ -363,7 +362,7 @@ static HRESULT WINAPI DSoundRender_CheckMediaType(IPin *iface, const AM_MEDIA_TY
return S_OK;
}
static IPin* WINAPI DSoundRender_GetPin(IBaseFilter *iface, int pos)
static IPin* WINAPI DSoundRender_GetPin(BaseFilter *iface, int pos)
{
DSoundRenderImpl *This = (DSoundRenderImpl *)iface;
@ -374,12 +373,27 @@ static IPin* WINAPI DSoundRender_GetPin(IBaseFilter *iface, int pos)
return (IPin*)This->pInputPin;
}
static LONG WINAPI DSoundRender_GetPinCount(IBaseFilter *iface)
static LONG WINAPI DSoundRender_GetPinCount(BaseFilter *iface)
{
/* Our pins are static */
return 1;
}
static const BaseFilterFuncTable BaseFuncTable = {
DSoundRender_GetPin,
DSoundRender_GetPinCount
};
static const BasePinFuncTable input_BaseFuncTable = {
DSoundRender_CheckMediaType,
NULL
};
static const BaseInputPinFuncTable input_BaseInputFuncTable = {
DSoundRender_Receive
};
HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv)
{
HRESULT hr;
@ -398,7 +412,7 @@ HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv)
return E_OUTOFMEMORY;
ZeroMemory(pDSoundRender, sizeof(DSoundRenderImpl));
BaseFilter_Init(&pDSoundRender->filter, &DSoundRender_Vtbl, &CLSID_DSoundRender, (DWORD_PTR)(__FILE__ ": DSoundRenderImpl.csFilter"), DSoundRender_GetPin, DSoundRender_GetPinCount);
BaseFilter_Init(&pDSoundRender->filter, &DSoundRender_Vtbl, &CLSID_DSoundRender, (DWORD_PTR)(__FILE__ ": DSoundRenderImpl.csFilter"), &BaseFuncTable);
pDSoundRender->IBasicAudio_vtbl = &IBasicAudio_Vtbl;
pDSoundRender->IReferenceClock_vtbl = &IReferenceClock_Vtbl;
@ -408,7 +422,7 @@ HRESULT DSoundRender_create(IUnknown * pUnkOuter, LPVOID * ppv)
piInput.dir = PINDIR_INPUT;
piInput.pFilter = (IBaseFilter *)pDSoundRender;
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
hr = BaseInputPin_Construct(&DSoundRender_InputPin_Vtbl, &piInput, DSoundRender_CheckMediaType, DSoundRender_Receive, &pDSoundRender->filter.csFilter, NULL, (IPin **)&pDSoundRender->pInputPin);
hr = BaseInputPin_Construct(&DSoundRender_InputPin_Vtbl, &piInput, &input_BaseFuncTable, &input_BaseInputFuncTable, &pDSoundRender->filter.csFilter, NULL, (IPin **)&pDSoundRender->pInputPin);
if (SUCCEEDED(hr))
{
@ -694,7 +708,7 @@ static HRESULT WINAPI DSoundRender_InputPin_ReceiveConnection(IPin * iface, IPin
if (This->pin.pConnectedTo)
hr = VFW_E_ALREADY_CONNECTED;
if (SUCCEEDED(hr) && This->fnCheckMediaType(iface, pmt) != S_OK)
if (SUCCEEDED(hr) && This->pin.pFuncsTable->pfnCheckMediaType((BasePin*)This, pmt) != S_OK)
hr = VFW_E_TYPE_NOT_ACCEPTED;
if (SUCCEEDED(hr))

View File

@ -328,7 +328,7 @@ static HRESULT GetClassMediaFile(IAsyncReader * pReader, LPCOLESTR pszFileName,
return hr;
}
static IPin* WINAPI AsyncReader_GetPin(IBaseFilter *iface, int pos)
static IPin* WINAPI AsyncReader_GetPin(BaseFilter *iface, int pos)
{
AsyncReader *This = (AsyncReader *)iface;
@ -339,7 +339,7 @@ static IPin* WINAPI AsyncReader_GetPin(IBaseFilter *iface, int pos)
return This->pOutputPin;
}
static LONG WINAPI AsyncReader_GetPinCount(IBaseFilter *iface)
static LONG WINAPI AsyncReader_GetPinCount(BaseFilter *iface)
{
AsyncReader *This = (AsyncReader *)iface;
@ -349,6 +349,11 @@ static LONG WINAPI AsyncReader_GetPinCount(IBaseFilter *iface)
return 1;
}
static const BaseFilterFuncTable BaseFuncTable = {
AsyncReader_GetPin,
AsyncReader_GetPinCount
};
HRESULT AsyncReader_create(IUnknown * pUnkOuter, LPVOID * ppv)
{
AsyncReader *pAsyncRead;
@ -361,7 +366,7 @@ HRESULT AsyncReader_create(IUnknown * pUnkOuter, LPVOID * ppv)
if (!pAsyncRead)
return E_OUTOFMEMORY;
BaseFilter_Init(&pAsyncRead->filter, &AsyncReader_Vtbl, &CLSID_AsyncReader, (DWORD_PTR)(__FILE__ ": AsyncReader.csFilter"), AsyncReader_GetPin, AsyncReader_GetPinCount);
BaseFilter_Init(&pAsyncRead->filter, &AsyncReader_Vtbl, &CLSID_AsyncReader, (DWORD_PTR)(__FILE__ ": AsyncReader.csFilter"), &BaseFuncTable);
pAsyncRead->lpVtblFSF = &FileSource_Vtbl;
pAsyncRead->pOutputPin = NULL;
@ -544,7 +549,7 @@ static HRESULT WINAPI FileSource_Load(IFileSourceFilter * iface, LPCOLESTR pszFi
/* create pin */
hr = FileAsyncReader_Construct(hFile, (IBaseFilter *)&This->filter.lpVtbl, &This->filter.csFilter, &This->pOutputPin);
BaseFilterImpl_IncrementPinVersion((IBaseFilter *)&This->filter.lpVtbl);
BaseFilterImpl_IncrementPinVersion((BaseFilter *)&This->filter.lpVtbl);
if (SUCCEEDED(hr))
hr = IPin_QueryInterface(This->pOutputPin, &IID_IAsyncReader, (LPVOID *)&pReader);
@ -690,7 +695,7 @@ static HRESULT WINAPI FileAsyncReaderPin_QueryAccept(IPin *iface, const AM_MEDIA
return S_FALSE;
}
static HRESULT WINAPI FileAsyncReaderPin_GetMediaType(IPin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
static HRESULT WINAPI FileAsyncReaderPin_GetMediaType(BasePin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
{
FileAsyncReader *This = (FileAsyncReader *)iface;
if (iPosition < 0)
@ -759,7 +764,7 @@ static HRESULT WINAPI FileAsyncReaderPin_EnumMediaTypes(IPin * iface, IEnumMedia
{
TRACE("(%p)\n", ppEnum);
return EnumMediaTypes_Construct(iface, FileAsyncReaderPin_GetMediaType, BasePinImpl_GetMediaTypeVersion, ppEnum);
return EnumMediaTypes_Construct((BasePin*)iface, FileAsyncReaderPin_GetMediaType, BasePinImpl_GetMediaTypeVersion, ppEnum);
}
static const IPinVtbl FileAsyncReaderPin_Vtbl =
@ -788,7 +793,7 @@ static const IPinVtbl FileAsyncReaderPin_Vtbl =
/* specific AM_MEDIA_TYPE - it cannot be NULL */
/* this differs from standard OutputPin_AttemptConnection only in that it
* doesn't need the IMemInputPin interface on the receiving pin */
static HRESULT WINAPI FileAsyncReaderPin_AttemptConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
static HRESULT WINAPI FileAsyncReaderPin_AttemptConnection(BasePin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
{
BaseOutputPin *This = (BaseOutputPin *)iface;
HRESULT hr;
@ -802,7 +807,7 @@ static HRESULT WINAPI FileAsyncReaderPin_AttemptConnection(IPin * iface, IPin *
IPin_AddRef(pReceivePin);
CopyMediaType(&This->pin.mtCurrent, pmt);
hr = IPin_ReceiveConnection(pReceivePin, iface, pmt);
hr = IPin_ReceiveConnection(pReceivePin, (IPin*)iface, pmt);
if (FAILED(hr))
{
@ -815,7 +820,7 @@ static HRESULT WINAPI FileAsyncReaderPin_AttemptConnection(IPin * iface, IPin *
return hr;
}
static HRESULT WINAPI FileAsyncReaderPin_DecideBufferSize(IPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
static HRESULT WINAPI FileAsyncReaderPin_DecideBufferSize(BaseOutputPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
{
FileAsyncReader *This = (FileAsyncReader *)iface;
ALLOCATOR_PROPERTIES actual;
@ -832,6 +837,14 @@ static HRESULT WINAPI FileAsyncReaderPin_DecideBufferSize(IPin *iface, IMemAlloc
return IMemAllocator_SetProperties(pAlloc, &This->allocProps, &actual);
}
static const BasePinFuncTable output_BaseFuncTable = {
NULL,
FileAsyncReaderPin_AttemptConnection
};
static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
FileAsyncReaderPin_DecideBufferSize
};
static HRESULT FileAsyncReader_Construct(HANDLE hFile, IBaseFilter * pBaseFilter, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
{
@ -842,7 +855,7 @@ static HRESULT FileAsyncReader_Construct(HANDLE hFile, IBaseFilter * pBaseFilter
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = pBaseFilter;
strcpyW(piOutput.achName, wszOutputPinName);
hr = BaseOutputPin_Construct(&FileAsyncReaderPin_Vtbl, sizeof(FileAsyncReader), &piOutput, FileAsyncReaderPin_DecideBufferSize, FileAsyncReaderPin_AttemptConnection, pCritSec, ppPin);
hr = BaseOutputPin_Construct(&FileAsyncReaderPin_Vtbl, sizeof(FileAsyncReader), &piOutput, &output_BaseFuncTable, &output_BaseOutputFuncTable, pCritSec, ppPin);
if (SUCCEEDED(hr))
{

View File

@ -61,14 +61,13 @@ typedef struct NullRendererImpl
BOOL bAggregatable;
} NullRendererImpl;
static HRESULT WINAPI NullRenderer_Receive(IPin *iface, IMediaSample * pSample)
static HRESULT WINAPI NullRenderer_Receive(BaseInputPin *pin, IMediaSample * pSample)
{
BaseInputPin *pin = (BaseInputPin*)iface;
NullRendererImpl *This = ((NullRendererImpl*)pin->pin.pinInfo.pFilter);
HRESULT hr = S_OK;
REFERENCE_TIME start, stop;
TRACE("%p %p\n", iface, pSample);
TRACE("%p %p\n", pin, pSample);
if (SUCCEEDED(IMediaSample_GetTime(pSample, &start, &stop)))
MediaSeekingPassThru_RegisterMediaTime(This->seekthru_unk, start);
@ -80,13 +79,13 @@ static HRESULT WINAPI NullRenderer_Receive(IPin *iface, IMediaSample * pSample)
return hr;
}
static HRESULT WINAPI NullRenderer_CheckMediaType(IPin *iface, const AM_MEDIA_TYPE * pmt)
static HRESULT WINAPI NullRenderer_CheckMediaType(BasePin *iface, const AM_MEDIA_TYPE * pmt)
{
TRACE("Not a stub!\n");
return S_OK;
}
static IPin* WINAPI NullRenderer_GetPin(IBaseFilter *iface, int pos)
static IPin* WINAPI NullRenderer_GetPin(BaseFilter *iface, int pos)
{
NullRendererImpl *This = (NullRendererImpl *)iface;
@ -97,11 +96,26 @@ static IPin* WINAPI NullRenderer_GetPin(IBaseFilter *iface, int pos)
return (IPin *)This->pInputPin;
}
static LONG WINAPI NullRenderer_GetPinCount(IBaseFilter *iface)
static LONG WINAPI NullRenderer_GetPinCount(BaseFilter *iface)
{
return 1;
}
static const BaseFilterFuncTable BaseFuncTable = {
NullRenderer_GetPin,
NullRenderer_GetPinCount
};
static const BasePinFuncTable input_BaseFuncTable = {
NullRenderer_CheckMediaType,
NULL
};
static const BaseInputPinFuncTable input_BaseInputFuncTable = {
NullRenderer_Receive
};
HRESULT NullRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
{
HRESULT hr;
@ -118,14 +132,14 @@ HRESULT NullRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
pNullRenderer->bAggregatable = FALSE;
pNullRenderer->IInner_vtbl = &IInner_VTable;
BaseFilter_Init(&pNullRenderer->filter, &NullRenderer_Vtbl, &CLSID_NullRenderer, (DWORD_PTR)(__FILE__ ": NullRendererImpl.csFilter"), NullRenderer_GetPin, NullRenderer_GetPinCount);
BaseFilter_Init(&pNullRenderer->filter, &NullRenderer_Vtbl, &CLSID_NullRenderer, (DWORD_PTR)(__FILE__ ": NullRendererImpl.csFilter"), &BaseFuncTable);
/* construct input pin */
piInput.dir = PINDIR_INPUT;
piInput.pFilter = (IBaseFilter *)pNullRenderer;
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
hr = BaseInputPin_Construct(&NullRenderer_InputPin_Vtbl, &piInput, NullRenderer_CheckMediaType, NullRenderer_Receive, &pNullRenderer->filter.csFilter, NULL, (IPin **)&pNullRenderer->pInputPin);
hr = BaseInputPin_Construct(&NullRenderer_InputPin_Vtbl, &piInput, &input_BaseFuncTable, &input_BaseInputFuncTable, &pNullRenderer->filter.csFilter, NULL, (IPin **)&pNullRenderer->pInputPin);
if (SUCCEEDED(hr))
{

View File

@ -43,7 +43,7 @@ static const IPinVtbl Parser_InputPin_Vtbl;
static HRESULT WINAPI Parser_ChangeStart(IMediaSeeking *iface);
static HRESULT WINAPI Parser_ChangeStop(IMediaSeeking *iface);
static HRESULT WINAPI Parser_ChangeRate(IMediaSeeking *iface);
static HRESULT WINAPI Parser_OutputPin_DecideBufferSize(IPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
static HRESULT WINAPI Parser_OutputPin_DecideBufferSize(BaseOutputPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
static inline ParserImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
{
@ -51,7 +51,7 @@ static inline ParserImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
}
/* FIXME: WRONG */
static IPin* WINAPI Parser_GetPin(IBaseFilter *iface, int pos)
static IPin* WINAPI Parser_GetPin(BaseFilter *iface, int pos)
{
ParserImpl *This = (ParserImpl *)iface;
@ -65,20 +65,25 @@ static IPin* WINAPI Parser_GetPin(IBaseFilter *iface, int pos)
return This->ppPins[pos];
}
static LONG WINAPI Parser_GetPinCount(IBaseFilter *iface)
static LONG WINAPI Parser_GetPinCount(BaseFilter *iface)
{
ParserImpl *This = (ParserImpl *)iface;
return This->cStreams;
}
static const BaseFilterFuncTable BaseFuncTable = {
Parser_GetPin,
Parser_GetPinCount
};
HRESULT Parser_Create(ParserImpl* pParser, const IBaseFilterVtbl *Parser_Vtbl, const CLSID* pClsid, PFN_PROCESS_SAMPLE fnProcessSample, PFN_QUERY_ACCEPT fnQueryAccept, PFN_PRE_CONNECT fnPreConnect, PFN_CLEANUP fnCleanup, PFN_DISCONNECT fnDisconnect, REQUESTPROC fnRequest, STOPPROCESSPROC fnDone, SourceSeeking_ChangeStop stop, SourceSeeking_ChangeStart start, SourceSeeking_ChangeRate rate)
{
HRESULT hr;
PIN_INFO piInput;
/* pTransformFilter is already allocated */
BaseFilter_Init(&pParser->filter, Parser_Vtbl, pClsid, (DWORD_PTR)(__FILE__ ": ParserImpl.csFilter"), Parser_GetPin, Parser_GetPinCount);
BaseFilter_Init(&pParser->filter, Parser_Vtbl, pClsid, (DWORD_PTR)(__FILE__ ": ParserImpl.csFilter"), &BaseFuncTable);
pParser->fnDisconnect = fnDisconnect;
@ -402,6 +407,15 @@ HRESULT WINAPI Parser_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
return BaseFilterImpl_QueryVendorInfo(iface, pVendorInfo);
}
static const BasePinFuncTable output_BaseFuncTable = {
NULL,
BaseOutputPinImpl_AttemptConnection
};
static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
Parser_OutputPin_DecideBufferSize
};
HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PROPERTIES * props, const AM_MEDIA_TYPE * amt)
{
IPin ** ppOldPins;
@ -412,7 +426,7 @@ HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PR
This->ppPins = CoTaskMemAlloc((This->cStreams + 2) * sizeof(IPin *));
memcpy(This->ppPins, ppOldPins, (This->cStreams + 1) * sizeof(IPin *));
hr = BaseOutputPin_Construct(&Parser_OutputPin_Vtbl, sizeof(Parser_OutputPin), piOutput, Parser_OutputPin_DecideBufferSize, NULL, &This->filter.csFilter, This->ppPins + (This->cStreams + 1));
hr = BaseOutputPin_Construct(&Parser_OutputPin_Vtbl, sizeof(Parser_OutputPin), piOutput, &output_BaseFuncTable, &output_BaseOutputFuncTable, &This->filter.csFilter, This->ppPins + (This->cStreams + 1));
if (SUCCEEDED(hr))
{
@ -426,7 +440,7 @@ HRESULT Parser_AddPin(ParserImpl * This, const PIN_INFO * piOutput, ALLOCATOR_PR
pin->pin.custom_allocator = 1;
pin->allocProps = *props;
This->cStreams++;
BaseFilterImpl_IncrementPinVersion((IBaseFilter*)This);
BaseFilterImpl_IncrementPinVersion((BaseFilter*)This);
CoTaskMemFree(ppOldPins);
}
else
@ -459,7 +473,7 @@ static HRESULT Parser_RemoveOutputPins(ParserImpl * This)
IPin_Release(ppOldPins[i + 1]);
}
BaseFilterImpl_IncrementPinVersion((IBaseFilter*)This);
BaseFilterImpl_IncrementPinVersion((BaseFilter*)This);
This->cStreams = 0;
CoTaskMemFree(ppOldPins);
@ -530,7 +544,7 @@ static const IMediaSeekingVtbl Parser_Seeking_Vtbl =
SourceSeekingImpl_GetPreroll
};
static HRESULT WINAPI Parser_OutputPin_DecideBufferSize(IPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
static HRESULT WINAPI Parser_OutputPin_DecideBufferSize(BaseOutputPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
{
Parser_OutputPin *This = (Parser_OutputPin *)iface;
ALLOCATOR_PROPERTIES actual;
@ -547,7 +561,7 @@ static HRESULT WINAPI Parser_OutputPin_DecideBufferSize(IPin *iface, IMemAllocat
return IMemAllocator_SetProperties(pAlloc, &This->allocProps, &actual);
}
static HRESULT WINAPI Parser_OutputPin_GetMediaType(IPin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
static HRESULT WINAPI Parser_OutputPin_GetMediaType(BasePin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
{
Parser_OutputPin *This = (Parser_OutputPin *)iface;
if (iPosition < 0)
@ -610,7 +624,7 @@ static HRESULT WINAPI Parser_OutputPin_EnumMediaTypes(IPin * iface, IEnumMediaTy
/* override this method to allow enumeration of your types */
return EnumMediaTypes_Construct(iface, Parser_OutputPin_GetMediaType, BasePinImpl_GetMediaTypeVersion, ppEnum);
return EnumMediaTypes_Construct((BasePin*)iface, Parser_OutputPin_GetMediaType, BasePinImpl_GetMediaTypeVersion, ppEnum);
}
static HRESULT WINAPI Parser_OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)

View File

@ -346,16 +346,15 @@ static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data,
return S_OK;
}
static HRESULT WINAPI VideoRenderer_Receive(IPin* iface, IMediaSample * pSample)
static HRESULT WINAPI VideoRenderer_Receive(BaseInputPin* pin, IMediaSample * pSample)
{
BaseInputPin* pin = (BaseInputPin*)iface;
VideoRendererImpl *This = (VideoRendererImpl *)pin->pin.pinInfo.pFilter;
LPBYTE pbSrcStream = NULL;
LONG cbSrcStream = 0;
REFERENCE_TIME tStart, tStop;
HRESULT hr;
TRACE("(%p)->(%p)\n", iface, pSample);
TRACE("(%p)->(%p)\n", pin, pSample);
EnterCriticalSection(&This->filter.csFilter);
@ -484,7 +483,7 @@ static HRESULT WINAPI VideoRenderer_Receive(IPin* iface, IMediaSample * pSample)
return S_OK;
}
static HRESULT WINAPI VideoRenderer_CheckMediaType(IPin *iface, const AM_MEDIA_TYPE * pmt)
static HRESULT WINAPI VideoRenderer_CheckMediaType(BasePin *iface, const AM_MEDIA_TYPE * pmt)
{
BaseInputPin* pin = (BaseInputPin*)iface;
VideoRendererImpl *This = (VideoRendererImpl *)pin->pin.pinInfo.pFilter;
@ -534,7 +533,7 @@ static HRESULT WINAPI VideoRenderer_CheckMediaType(IPin *iface, const AM_MEDIA_T
return S_FALSE;
}
static IPin* WINAPI VideoRenderer_GetPin(IBaseFilter *iface, int pos)
static IPin* WINAPI VideoRenderer_GetPin(BaseFilter *iface, int pos)
{
VideoRendererImpl *This = (VideoRendererImpl *)iface;
@ -545,11 +544,25 @@ static IPin* WINAPI VideoRenderer_GetPin(IBaseFilter *iface, int pos)
return (IPin *)This->pInputPin;
}
static LONG WINAPI VideoRenderer_GetPinCount(IBaseFilter *iface)
static LONG WINAPI VideoRenderer_GetPinCount(BaseFilter *iface)
{
return 1;
}
static const BaseFilterFuncTable BaseFuncTable = {
VideoRenderer_GetPin,
VideoRenderer_GetPinCount
};
static const BasePinFuncTable input_BaseFuncTable = {
VideoRenderer_CheckMediaType,
NULL
};
static const BaseInputPinFuncTable input_BaseInputFuncTable = {
VideoRenderer_Receive
};
HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
{
HRESULT hr;
@ -567,7 +580,7 @@ HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
pVideoRenderer->bAggregatable = FALSE;
pVideoRenderer->IInner_vtbl = &IInner_VTable;
BaseFilter_Init(&pVideoRenderer->filter, &VideoRenderer_Vtbl, &CLSID_VideoRenderer, (DWORD_PTR)(__FILE__ ": VideoRendererImpl.csFilter"), VideoRenderer_GetPin, VideoRenderer_GetPinCount);
BaseFilter_Init(&pVideoRenderer->filter, &VideoRenderer_Vtbl, &CLSID_VideoRenderer, (DWORD_PTR)(__FILE__ ": VideoRendererImpl.csFilter"), &BaseFuncTable);
pVideoRenderer->IBasicVideo_vtbl = &IBasicVideo_VTable;
pVideoRenderer->IVideoWindow_vtbl = &IVideoWindow_VTable;
@ -586,7 +599,7 @@ HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
piInput.pFilter = (IBaseFilter *)pVideoRenderer;
lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
hr = BaseInputPin_Construct(&VideoRenderer_InputPin_Vtbl, &piInput, VideoRenderer_CheckMediaType, VideoRenderer_Receive, &pVideoRenderer->filter.csFilter, NULL, (IPin **)&pVideoRenderer->pInputPin);
hr = BaseInputPin_Construct(&VideoRenderer_InputPin_Vtbl, &piInput, &input_BaseFuncTable, &input_BaseInputFuncTable, &pVideoRenderer->filter.csFilter, NULL, (IPin **)&pVideoRenderer->pInputPin);
if (SUCCEEDED(hr))
{

View File

@ -32,7 +32,7 @@ typedef struct IEnumPinsImpl
const IEnumPinsVtbl * lpVtbl;
LONG refCount;
ULONG uIndex;
IBaseFilter *base;
BaseFilter *base;
BaseFilter_GetPin receive_pin;
BaseFilter_GetPinCount receive_pincount;
BaseFilter_GetPinVersion receive_version;
@ -41,7 +41,7 @@ typedef struct IEnumPinsImpl
static const struct IEnumPinsVtbl IEnumPinsImpl_Vtbl;
HRESULT WINAPI EnumPins_Construct(IBaseFilter *base, BaseFilter_GetPin receive_pin, BaseFilter_GetPinCount receive_pincount, BaseFilter_GetPinVersion receive_version, IEnumPins ** ppEnum)
HRESULT WINAPI EnumPins_Construct(BaseFilter *base, BaseFilter_GetPin receive_pin, BaseFilter_GetPinCount receive_pincount, BaseFilter_GetPinVersion receive_version, IEnumPins ** ppEnum)
{
IEnumPinsImpl * pEnumPins;
@ -61,7 +61,7 @@ HRESULT WINAPI EnumPins_Construct(IBaseFilter *base, BaseFilter_GetPin receive_
pEnumPins->receive_pincount = receive_pincount;
pEnumPins->receive_version = receive_version;
pEnumPins->base = base;
IBaseFilter_AddRef(base);
IBaseFilter_AddRef((IBaseFilter*)base);
*ppEnum = (IEnumPins *)(&pEnumPins->lpVtbl);
pEnumPins->Version = receive_version(base);
@ -110,7 +110,7 @@ static ULONG WINAPI IEnumPinsImpl_Release(IEnumPins * iface)
if (!refCount)
{
IBaseFilter_Release(This->base);
IBaseFilter_Release((IBaseFilter*)This->base);
CoTaskMemFree(This);
return 0;
}

View File

@ -148,7 +148,7 @@ HRESULT WINAPI BaseFilterImpl_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
TRACE("(%p)->(%p)\n", iface, ppEnum);
return EnumPins_Construct(iface, This->pfnGetPin, This->pfnGetPinCount, BaseFilterImpl_GetPinVersion, ppEnum);
return EnumPins_Construct(This, This->pFuncsTable->pfnGetPin, This->pFuncsTable->pfnGetPinCount, BaseFilterImpl_GetPinVersion, ppEnum);
}
@ -192,21 +192,19 @@ HRESULT WINAPI BaseFilterImpl_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVend
return E_NOTIMPL;
}
LONG WINAPI BaseFilterImpl_GetPinVersion(IBaseFilter * iface)
LONG WINAPI BaseFilterImpl_GetPinVersion(BaseFilter * This)
{
BaseFilter * This = (BaseFilter*)iface;
TRACE("(%p)\n", This);
return This->pinVersion;
}
VOID WINAPI BaseFilterImpl_IncrementPinVersion(IBaseFilter * iface)
VOID WINAPI BaseFilterImpl_IncrementPinVersion(BaseFilter * This)
{
BaseFilter * This = (BaseFilter*)iface;
InterlockedIncrement(&This->pinVersion);
TRACE("(%p) -> New pinVersion %i\n", This,This->pinVersion);
}
HRESULT WINAPI BaseFilter_Init(BaseFilter * This, const IBaseFilterVtbl *Vtbl, const CLSID *pClsid, DWORD_PTR DebugInfo, BaseFilter_GetPin pfGetPin, BaseFilter_GetPinCount pfGetPinCount)
HRESULT WINAPI BaseFilter_Init(BaseFilter * This, const IBaseFilterVtbl *Vtbl, const CLSID *pClsid, DWORD_PTR DebugInfo, const BaseFilterFuncTable* pBaseFuncsTable)
{
This->lpVtbl = Vtbl;
This->refCount = 1;
@ -219,8 +217,7 @@ HRESULT WINAPI BaseFilter_Init(BaseFilter * This, const IBaseFilterVtbl *Vtbl, c
This->csFilter.DebugInfo->Spare[0] = DebugInfo;
This->pinVersion = 1;
This->pfnGetPin = pfGetPin;
This->pfnGetPinCount = pfGetPinCount;
This->pFuncsTable = pBaseFuncsTable;
return S_OK;
}

View File

@ -87,7 +87,7 @@ typedef struct IEnumMediaTypesImpl
{
const IEnumMediaTypesVtbl * lpVtbl;
LONG refCount;
IPin *basePin;
BasePin *basePin;
BasePin_GetMediaType enumMediaFunction;
BasePin_GetMediaTypeVersion mediaVersionFunction;
LONG currentVersion;
@ -97,7 +97,7 @@ typedef struct IEnumMediaTypesImpl
static const struct IEnumMediaTypesVtbl IEnumMediaTypesImpl_Vtbl;
HRESULT WINAPI EnumMediaTypes_Construct(IPin *basePin, BasePin_GetMediaType enumFunc, BasePin_GetMediaTypeVersion versionFunc, IEnumMediaTypes ** ppEnum)
HRESULT WINAPI EnumMediaTypes_Construct(BasePin *basePin, BasePin_GetMediaType enumFunc, BasePin_GetMediaTypeVersion versionFunc, IEnumMediaTypes ** ppEnum)
{
ULONG i;
IEnumMediaTypesImpl * pEnumMediaTypes = CoTaskMemAlloc(sizeof(IEnumMediaTypesImpl));
@ -113,7 +113,7 @@ HRESULT WINAPI EnumMediaTypes_Construct(IPin *basePin, BasePin_GetMediaType enum
pEnumMediaTypes->uIndex = 0;
pEnumMediaTypes->enumMediaFunction = enumFunc;
pEnumMediaTypes->mediaVersionFunction = versionFunc;
IPin_AddRef(basePin);
IPin_AddRef((IPin*)basePin);
pEnumMediaTypes->basePin = basePin;
i = 0;
@ -183,7 +183,7 @@ static ULONG WINAPI IEnumMediaTypesImpl_Release(IEnumMediaTypes * iface)
if (This->enumMediaDetails.pMediaTypes[i].pbFormat)
CoTaskMemFree(This->enumMediaDetails.pMediaTypes[i].pbFormat);
CoTaskMemFree(This->enumMediaDetails.pMediaTypes);
IPin_Release(This->basePin);
IPin_Release((IPin*)This->basePin);
CoTaskMemFree(This);
}
return refCount;

View File

@ -169,14 +169,14 @@ static BOOL CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE *
}
/*** Common Base Pin function */
HRESULT WINAPI BasePinImpl_GetMediaType(IPin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
HRESULT WINAPI BasePinImpl_GetMediaType(BasePin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
{
if (iPosition < 0)
return E_INVALIDARG;
return VFW_S_NO_MORE_ITEMS;
}
LONG WINAPI BasePinImpl_GetMediaTypeVersion(IPin *iface)
LONG WINAPI BasePinImpl_GetMediaTypeVersion(BasePin *iface)
{
return 1;
}
@ -320,7 +320,7 @@ HRESULT WINAPI BasePinImpl_EnumMediaTypes(IPin * iface, IEnumMediaTypes ** ppEnu
/* override this method to allow enumeration of your types */
return EnumMediaTypes_Construct(iface, BasePinImpl_GetMediaType, BasePinImpl_GetMediaTypeVersion , ppEnum);
return EnumMediaTypes_Construct(This, BasePinImpl_GetMediaType, BasePinImpl_GetMediaTypeVersion , ppEnum);
}
HRESULT WINAPI BasePinImpl_QueryInternalConnections(IPin * iface, IPin ** apPin, ULONG * cPin)
@ -396,7 +396,7 @@ HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const
/* if we have been a specific type to connect with, then we can either connect
* with that or fail. We cannot choose different AM_MEDIA_TYPE */
if (pmt && !IsEqualGUID(&pmt->majortype, &GUID_NULL) && !IsEqualGUID(&pmt->subtype, &GUID_NULL))
hr = This->pAttemptConnection(iface, pReceivePin, pmt);
hr = This->pin.pFuncsTable->pfnAttemptConnection((BasePin*)This, pReceivePin, pmt);
else
{
/* negotiate media type */
@ -417,7 +417,7 @@ HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const
&& !IsEqualGUID(&GUID_NULL, &pmtCandidate->formattype))
assert(pmtCandidate->pbFormat);
if (( !pmt || CompareMediaTypes(pmt, pmtCandidate, TRUE) ) &&
(This->pAttemptConnection(iface, pReceivePin, pmtCandidate) == S_OK))
(This->pin.pFuncsTable->pfnAttemptConnection((BasePin*)This, pReceivePin, pmtCandidate) == S_OK))
{
hr = S_OK;
DeleteMediaType(pmtCandidate);
@ -439,7 +439,7 @@ HRESULT WINAPI BaseOutputPinImpl_Connect(IPin * iface, IPin * pReceivePin, const
assert(pmtCandidate);
dump_AM_MEDIA_TYPE(pmtCandidate);
if (( !pmt || CompareMediaTypes(pmt, pmtCandidate, TRUE) ) &&
(This->pAttemptConnection(iface, pReceivePin, pmtCandidate) == S_OK))
(This->pin.pFuncsTable->pfnAttemptConnection((BasePin*)This, pReceivePin, pmtCandidate) == S_OK))
{
hr = S_OK;
DeleteMediaType(pmtCandidate);
@ -744,7 +744,7 @@ HRESULT WINAPI BaseOutputPinImpl_DecideAllocator(BaseOutputPin *This, IMemInputP
ZeroMemory(&rProps, sizeof(ALLOCATOR_PROPERTIES));
IMemInputPin_GetAllocatorRequirements(pPin, &rProps);
hr = This->pDecideBufferSize((IPin*)This, *pAlloc, &rProps);
hr = This->pFuncsTable->pfnDecideBufferSize(This, *pAlloc, &rProps);
}
if (SUCCEEDED(hr))
@ -767,7 +767,7 @@ HRESULT WINAPI BaseOutputPinImpl_DecideAllocator(BaseOutputPin *This, IMemInputP
/* Function called as a helper to IPin_Connect */
/* specific AM_MEDIA_TYPE - it cannot be NULL */
static HRESULT WINAPI OutputPin_AttemptConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(BasePin* iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
{
BaseOutputPin *This = (BaseOutputPin *)iface;
HRESULT hr;
@ -782,7 +782,7 @@ static HRESULT WINAPI OutputPin_AttemptConnection(IPin * iface, IPin * pReceiveP
IPin_AddRef(pReceivePin);
CopyMediaType(&This->pin.mtCurrent, pmt);
hr = IPin_ReceiveConnection(pReceivePin, iface, pmt);
hr = IPin_ReceiveConnection(pReceivePin, (IPin*)iface, pmt);
/* get the IMemInputPin interface we will use to deliver samples to the
* connected pin */
@ -820,9 +820,7 @@ static HRESULT WINAPI OutputPin_AttemptConnection(IPin * iface, IPin * pReceiveP
return hr;
}
static HRESULT OutputPin_Init(const IPinVtbl *OutputPin_Vtbl, const PIN_INFO *
pPinInfo, BaseOutputPin_DecideBufferSize pBufferProc, BasePin_AttemptConnection pConnectProc, LPCRITICAL_SECTION pCritSec,
BaseOutputPin * pPinImpl)
static HRESULT OutputPin_Init(const IPinVtbl *OutputPin_Vtbl, const PIN_INFO * pPinInfo, const BasePinFuncTable* pBaseFuncsTable, const BaseOutputPinFuncTable* pBaseOutputFuncsTable, LPCRITICAL_SECTION pCritSec, BaseOutputPin * pPinImpl)
{
TRACE("\n");
@ -832,16 +830,13 @@ BaseOutputPin * pPinImpl)
pPinImpl->pin.pConnectedTo = NULL;
pPinImpl->pin.pCritSec = pCritSec;
Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo);
pPinImpl->pin.pFuncsTable = pBaseFuncsTable;
ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE));
/* Output pin attributes */
pPinImpl->pMemInputPin = NULL;
if(pConnectProc)
pPinImpl->pAttemptConnection = pConnectProc;
else
pPinImpl->pAttemptConnection = OutputPin_AttemptConnection;
pPinImpl->pFuncsTable = pBaseOutputFuncsTable;
pPinImpl->pDecideBufferSize = pBufferProc;
/* If custom_allocator is set, you will need to specify an allocator
* in the alloc member of the struct before an output pin can connect
*/
@ -852,7 +847,7 @@ BaseOutputPin * pPinImpl)
return S_OK;
}
HRESULT WINAPI BaseOutputPin_Construct(const IPinVtbl *OutputPin_Vtbl, LONG outputpin_size, const PIN_INFO * pPinInfo, BaseOutputPin_DecideBufferSize pBufferProc, BasePin_AttemptConnection pConnectProc, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
HRESULT WINAPI BaseOutputPin_Construct(const IPinVtbl *OutputPin_Vtbl, LONG outputpin_size, const PIN_INFO * pPinInfo, const BasePinFuncTable* pBaseFuncsTable, const BaseOutputPinFuncTable* pBaseOutputFuncsTable, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
{
BaseOutputPin * pPinImpl;
@ -865,13 +860,14 @@ HRESULT WINAPI BaseOutputPin_Construct(const IPinVtbl *OutputPin_Vtbl, LONG outp
}
assert(outputpin_size >= sizeof(BaseOutputPin));
assert(pBaseFuncsTable->pfnAttemptConnection);
pPinImpl = CoTaskMemAlloc(outputpin_size);
if (!pPinImpl)
return E_OUTOFMEMORY;
if (SUCCEEDED(OutputPin_Init(OutputPin_Vtbl, pPinInfo, pBufferProc, pConnectProc, pCritSec, pPinImpl)))
if (SUCCEEDED(OutputPin_Init(OutputPin_Vtbl, pPinInfo, pBaseFuncsTable, pBaseOutputFuncsTable, pCritSec, pPinImpl)))
{
*ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
return S_OK;
@ -956,7 +952,7 @@ HRESULT WINAPI BaseInputPinImpl_ReceiveConnection(IPin * iface, IPin * pReceiveP
if (This->pin.pConnectedTo)
hr = VFW_E_ALREADY_CONNECTED;
if (SUCCEEDED(hr) && This->fnCheckMediaType((IPin*)This, pmt) != S_OK)
if (SUCCEEDED(hr) && This->pin.pFuncsTable->pfnCheckMediaType((BasePin*)This, pmt) != S_OK)
hr = VFW_E_TYPE_NOT_ACCEPTED; /* FIXME: shouldn't we just map common errors onto
* VFW_E_TYPE_NOT_ACCEPTED and pass the value on otherwise? */
@ -994,7 +990,7 @@ HRESULT WINAPI BaseInputPinImpl_QueryAccept(IPin * iface, const AM_MEDIA_TYPE *
TRACE("(%p/%p)->(%p)\n", This, iface, pmt);
return (This->fnCheckMediaType((IPin*)This, pmt) == S_OK ? S_OK : S_FALSE);
return (This->pin.pFuncsTable->pfnCheckMediaType((BasePin*)This, pmt) == S_OK ? S_OK : S_FALSE);
}
HRESULT WINAPI BaseInputPinImpl_EndOfStream(IPin * iface)
@ -1187,11 +1183,12 @@ static HRESULT WINAPI MemInputPin_GetAllocatorRequirements(IMemInputPin * iface,
static HRESULT WINAPI MemInputPin_Receive(IMemInputPin * iface, IMediaSample * pSample)
{
BaseInputPin *This = impl_from_IMemInputPin(iface);
HRESULT hr;
HRESULT hr = S_FALSE;
/* this trace commented out for performance reasons */
/*TRACE("(%p/%p)->(%p)\n", This, iface, pSample);*/
hr = This->fnReceive((IPin*)This, pSample);
if (This->pFuncsTable->pfnReceive)
hr = This->pFuncsTable->pfnReceive(This, pSample);
return hr;
}
@ -1235,7 +1232,7 @@ static const IMemInputPinVtbl MemInputPin_Vtbl =
};
static HRESULT InputPin_Init(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo,
BasePin_CheckMediaType pCheckMediaType, BaseInputPin_Receive pReceive,
const BasePinFuncTable* pBaseFuncsTable, const BaseInputPinFuncTable* pBaseInputFuncsTable,
LPCRITICAL_SECTION pCritSec, IMemAllocator *allocator, BaseInputPin * pPinImpl)
{
TRACE("\n");
@ -1246,10 +1243,10 @@ static HRESULT InputPin_Init(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPi
pPinImpl->pin.pCritSec = pCritSec;
Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo);
ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE));
pPinImpl->pin.pFuncsTable = pBaseFuncsTable;
/* Input pin attributes */
pPinImpl->fnCheckMediaType = pCheckMediaType;
pPinImpl->fnReceive = pReceive;
pPinImpl->pFuncsTable = pBaseInputFuncsTable;
pPinImpl->pAllocator = pPinImpl->preferred_allocator = allocator;
if (pPinImpl->preferred_allocator)
IMemAllocator_AddRef(pPinImpl->preferred_allocator);
@ -1264,13 +1261,15 @@ static HRESULT InputPin_Init(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPi
}
HRESULT BaseInputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo,
BasePin_CheckMediaType pCheckMediaType, BaseInputPin_Receive pReceive,
const BasePinFuncTable* pBaseFuncsTable, const BaseInputPinFuncTable* pBaseInputFuncsTable,
LPCRITICAL_SECTION pCritSec, IMemAllocator *allocator, IPin ** ppPin)
{
BaseInputPin * pPinImpl;
*ppPin = NULL;
assert(pBaseFuncsTable->pfnCheckMediaType);
if (pPinInfo->dir != PINDIR_INPUT)
{
ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir);
@ -1282,7 +1281,7 @@ HRESULT BaseInputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * p
if (!pPinImpl)
return E_OUTOFMEMORY;
if (SUCCEEDED(InputPin_Init(InputPin_Vtbl, pPinInfo, pCheckMediaType, pReceive, pCritSec, allocator, pPinImpl)))
if (SUCCEEDED(InputPin_Init(InputPin_Vtbl, pPinInfo, pBaseFuncsTable, pBaseInputFuncsTable, pCritSec, allocator, pPinImpl)))
{
*ppPin = (IPin *)pPinImpl;
return S_OK;

View File

@ -45,7 +45,7 @@ static const IBaseFilterVtbl TransformFilter_Vtbl;
static const IPinVtbl TransformFilter_InputPin_Vtbl;
static const IPinVtbl TransformFilter_OutputPin_Vtbl;
static HRESULT WINAPI TransformFilter_Input_CheckMediaType(IPin *iface, const AM_MEDIA_TYPE * pmt)
static HRESULT WINAPI TransformFilter_Input_CheckMediaType(BasePin *iface, const AM_MEDIA_TYPE * pmt)
{
BaseInputPin* This = (BaseInputPin*) iface;
TransformFilter * pTransform;
@ -60,12 +60,11 @@ static HRESULT WINAPI TransformFilter_Input_CheckMediaType(IPin *iface, const AM
return S_OK;
}
static HRESULT WINAPI TransformFilter_Input_Receive(IPin *iface, IMediaSample *pInSample)
static HRESULT WINAPI TransformFilter_Input_Receive(BaseInputPin *This, IMediaSample *pInSample)
{
HRESULT hr = S_FALSE;
BaseInputPin* This = (BaseInputPin*) iface;
TransformFilter * pTransform;
TRACE("%p\n", iface);
TRACE("%p\n", This);
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
EnterCriticalSection(&pTransform->filter.csFilter);
@ -103,14 +102,13 @@ static HRESULT WINAPI TransformFilter_Output_QueryAccept(IPin *iface, const AM_M
return S_FALSE;
}
static HRESULT WINAPI TransformFilter_Output_DecideBufferSize(IPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
static HRESULT WINAPI TransformFilter_Output_DecideBufferSize(BaseOutputPin *This, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
{
BasePin *This = (BasePin *)iface;
TransformFilter *pTransformFilter = (TransformFilter *)This->pinInfo.pFilter;
TransformFilter *pTransformFilter = (TransformFilter *)This->pin.pinInfo.pFilter;
return pTransformFilter->pFuncsTable->pfnDecideBufferSize(pTransformFilter, pAlloc, ppropInputRequest);
}
static IPin* WINAPI TransformFilter_GetPin(IBaseFilter *iface, int pos)
static IPin* WINAPI TransformFilter_GetPin(BaseFilter *iface, int pos)
{
TransformFilter *This = (TransformFilter *)iface;
@ -121,20 +119,43 @@ static IPin* WINAPI TransformFilter_GetPin(IBaseFilter *iface, int pos)
return This->ppPins[pos];
}
static LONG WINAPI TransformFilter_GetPinCount(IBaseFilter *iface)
static LONG WINAPI TransformFilter_GetPinCount(BaseFilter *iface)
{
TransformFilter *This = (TransformFilter *)iface;
return (This->npins+1);
}
static const BaseFilterFuncTable tfBaseFuncTable = {
TransformFilter_GetPin,
TransformFilter_GetPinCount
};
static const BasePinFuncTable tf_input_BaseFuncTable = {
TransformFilter_Input_CheckMediaType,
NULL,
};
static const BaseInputPinFuncTable tf_input_BaseInputFuncTable = {
TransformFilter_Input_Receive
};
static const BasePinFuncTable tf_output_BaseFuncTable = {
NULL,
BaseOutputPinImpl_AttemptConnection,
};
static const BaseOutputPinFuncTable tf_output_BaseOutputFuncTable = {
TransformFilter_Output_DecideBufferSize
};
static HRESULT TransformFilter_Init(const IBaseFilterVtbl *pVtbl, const CLSID* pClsid, const TransformFilterFuncTable* pFuncsTable, TransformFilter* pTransformFilter)
{
HRESULT hr;
PIN_INFO piInput;
PIN_INFO piOutput;
BaseFilter_Init(&pTransformFilter->filter, pVtbl, pClsid, (DWORD_PTR)(__FILE__ ": TransformFilter.csFilter"), TransformFilter_GetPin, TransformFilter_GetPinCount);
BaseFilter_Init(&pTransformFilter->filter, pVtbl, pClsid, (DWORD_PTR)(__FILE__ ": TransformFilter.csFilter"), &tfBaseFuncTable);
/* pTransformFilter is already allocated */
pTransformFilter->pFuncsTable = pFuncsTable;
@ -151,11 +172,11 @@ static HRESULT TransformFilter_Init(const IBaseFilterVtbl *pVtbl, const CLSID* p
piOutput.pFilter = (IBaseFilter *)pTransformFilter;
lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0]));
hr = BaseInputPin_Construct(&TransformFilter_InputPin_Vtbl, &piInput, TransformFilter_Input_CheckMediaType, TransformFilter_Input_Receive, &pTransformFilter->filter.csFilter, NULL, &pTransformFilter->ppPins[0]);
hr = BaseInputPin_Construct(&TransformFilter_InputPin_Vtbl, &piInput, &tf_input_BaseFuncTable, &tf_input_BaseInputFuncTable, &pTransformFilter->filter.csFilter, NULL, &pTransformFilter->ppPins[0]);
if (SUCCEEDED(hr))
{
hr = BaseOutputPin_Construct(&TransformFilter_OutputPin_Vtbl, sizeof(BaseOutputPin), &piOutput, TransformFilter_Output_DecideBufferSize, NULL, &pTransformFilter->filter.csFilter, &pTransformFilter->ppPins[1]);
hr = BaseOutputPin_Construct(&TransformFilter_OutputPin_Vtbl, sizeof(BaseOutputPin), &piOutput, &tf_output_BaseFuncTable, &tf_output_BaseOutputFuncTable, &pTransformFilter->filter.csFilter, &pTransformFilter->ppPins[1]);
if (FAILED(hr))
ERR("Cannot create output pin (%x)\n", hr);
@ -487,9 +508,8 @@ static const IPinVtbl TransformFilter_InputPin_Vtbl =
TransformFilter_InputPin_NewSegment
};
static HRESULT WINAPI TransformFilter_Output_GetMediaType(IPin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
static HRESULT WINAPI TransformFilter_Output_GetMediaType(BasePin *This, int iPosition, AM_MEDIA_TYPE *pmt)
{
BasePin *This = (BasePin *)iface;
TransformFilter *pTransform = (TransformFilter *)This->pinInfo.pFilter;
if (iPosition < 0)
@ -505,7 +525,7 @@ static HRESULT WINAPI TransformFilter_Output_EnumMediaTypes(IPin * iface, IEnumM
BasePin *This = (BasePin *)iface;
TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
return EnumMediaTypes_Construct(iface, TransformFilter_Output_GetMediaType, BasePinImpl_GetMediaTypeVersion, ppEnum);
return EnumMediaTypes_Construct(This, TransformFilter_Output_GetMediaType, BasePinImpl_GetMediaTypeVersion, ppEnum);
}
static const IPinVtbl TransformFilter_OutputPin_Vtbl =

View File

@ -24,22 +24,6 @@ void WINAPI FreeMediaType(AM_MEDIA_TYPE * pMediaType);
AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const * pSrc);
void WINAPI DeleteMediaType(AM_MEDIA_TYPE * pMediaType);
typedef HRESULT (WINAPI *BasePin_GetMediaType)(IPin* iface, int iPosition, AM_MEDIA_TYPE *amt);
typedef LONG (WINAPI *BasePin_GetMediaTypeVersion)(IPin* iface);
typedef HRESULT (WINAPI *BasePin_AttemptConnection)(IPin *iface, IPin *pReceivePin, const AM_MEDIA_TYPE *pmt);
typedef HRESULT (WINAPI *BasePin_CheckMediaType)(IPin *iface, const AM_MEDIA_TYPE *pmt);
typedef HRESULT (WINAPI *BaseOutputPin_DecideBufferSize)(IPin *iface, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
typedef IPin* (WINAPI *BaseFilter_GetPin)(IBaseFilter* iface, int iPosition);
typedef LONG (WINAPI *BaseFilter_GetPinCount)(IBaseFilter* iface);
typedef LONG (WINAPI *BaseFilter_GetPinVersion)(IBaseFilter* iface);
typedef HRESULT (WINAPI *BaseInputPin_Receive)(IPin *This, IMediaSample *pSample);
HRESULT WINAPI EnumMediaTypes_Construct(IPin *iface, BasePin_GetMediaType enumFunc, BasePin_GetMediaTypeVersion versionFunc, IEnumMediaTypes ** ppEnum);
HRESULT WINAPI EnumPins_Construct(IBaseFilter *base, BaseFilter_GetPin receive_pin, BaseFilter_GetPinCount receive_pincount, BaseFilter_GetPinVersion receive_version, IEnumPins ** ppEnum);
/* Pin functions */
typedef struct BasePin
@ -50,21 +34,42 @@ typedef struct BasePin
PIN_INFO pinInfo;
IPin * pConnectedTo;
AM_MEDIA_TYPE mtCurrent;
const struct BasePinFuncTable* pFuncsTable;
} BasePin;
typedef HRESULT (WINAPI *BasePin_CheckMediaType)(BasePin *This, const AM_MEDIA_TYPE *pmt);
typedef HRESULT (WINAPI *BasePin_AttemptConnection)(BasePin *This, IPin *pReceivePin, const AM_MEDIA_TYPE *pmt);
typedef LONG (WINAPI *BasePin_GetMediaTypeVersion)(BasePin *This);
typedef HRESULT (WINAPI *BasePin_GetMediaType)(BasePin *This, int iPosition, AM_MEDIA_TYPE *amt);
typedef struct BasePinFuncTable {
/* Required for Input Pins*/
BasePin_CheckMediaType pfnCheckMediaType;
/* Required for Output Pins*/
BasePin_AttemptConnection pfnAttemptConnection;
} BasePinFuncTable;
typedef struct BaseOutputPin
{
/* inheritance C style! */
BasePin pin;
IMemInputPin * pMemInputPin;
BasePin_AttemptConnection pAttemptConnection;
BaseOutputPin_DecideBufferSize pDecideBufferSize;
BOOL custom_allocator;
IMemAllocator *alloc;
BOOL readonly;
const struct BaseOutputPinFuncTable* pFuncsTable;
} BaseOutputPin;
typedef HRESULT (WINAPI *BaseOutputPin_DecideBufferSize)(BaseOutputPin *This, IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);
typedef struct BaseOutputPinFuncTable {
/* Required */
BaseOutputPin_DecideBufferSize pfnDecideBufferSize;
} BaseOutputPinFuncTable;
typedef struct BaseInputPin
{
/* inheritance C style! */
@ -72,18 +77,25 @@ typedef struct BaseInputPin
const IMemInputPinVtbl * lpVtblMemInput;
IMemAllocator * pAllocator;
BaseInputPin_Receive fnReceive;
BasePin_CheckMediaType fnCheckMediaType;
REFERENCE_TIME tStart;
REFERENCE_TIME tStop;
double dRate;
BOOL flushing, end_of_stream;
IMemAllocator *preferred_allocator;
const struct BaseInputPinFuncTable* pFuncsTable;
} BaseInputPin;
typedef HRESULT (WINAPI *BaseInputPin_Receive)(BaseInputPin *This, IMediaSample *pSample);
typedef struct BaseInputPinFuncTable {
/* Optional */
BaseInputPin_Receive pfnReceive;
} BaseInputPinFuncTable;
/* Base Pin */
HRESULT WINAPI BasePinImpl_GetMediaType(IPin *iface, int iPosition, AM_MEDIA_TYPE *pmt);
LONG WINAPI BasePinImpl_GetMediaTypeVersion(IPin *iface);
HRESULT WINAPI BasePinImpl_GetMediaType(BasePin *This, int iPosition, AM_MEDIA_TYPE *pmt);
LONG WINAPI BasePinImpl_GetMediaTypeVersion(BasePin *This);
ULONG WINAPI BasePinImpl_AddRef(IPin * iface);
HRESULT WINAPI BasePinImpl_Disconnect(IPin * iface);
HRESULT WINAPI BasePinImpl_ConnectedTo(IPin * iface, IPin ** ppPin);
@ -113,8 +125,9 @@ HRESULT WINAPI BaseOutputPinImpl_Active(BaseOutputPin * This);
HRESULT WINAPI BaseOutputPinImpl_Inactive(BaseOutputPin * This);
HRESULT WINAPI BaseOutputPinImpl_InitAllocator(BaseOutputPin *This, IMemAllocator **pMemAlloc);
HRESULT WINAPI BaseOutputPinImpl_DecideAllocator(BaseOutputPin *This, IMemInputPin *pPin, IMemAllocator **pAlloc);
HRESULT WINAPI BaseOutputPinImpl_AttemptConnection(BasePin *This, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
HRESULT WINAPI BaseOutputPin_Construct(const IPinVtbl *OutputPin_Vtbl, LONG outputpin_size, const PIN_INFO * pPinInfo, BaseOutputPin_DecideBufferSize pBufferProc, BasePin_AttemptConnection pConnectProc, LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
HRESULT WINAPI BaseOutputPin_Construct(const IPinVtbl *OutputPin_Vtbl, LONG outputpin_size, const PIN_INFO * pPinInfo, const BasePinFuncTable* pBaseFuncsTable, const BaseOutputPinFuncTable* pBaseOutputFuncsTable, LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
/* Base Input Pin */
HRESULT WINAPI BaseInputPinImpl_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
@ -127,7 +140,7 @@ HRESULT WINAPI BaseInputPinImpl_BeginFlush(IPin * iface);
HRESULT WINAPI BaseInputPinImpl_EndFlush(IPin * iface);
HRESULT WINAPI BaseInputPinImpl_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
HRESULT BaseInputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, BasePin_CheckMediaType pQueryAccept, BaseInputPin_Receive pSampleProc, LPCRITICAL_SECTION pCritSec, IMemAllocator *, IPin ** ppPin);
HRESULT BaseInputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, const BasePinFuncTable* pBaseFuncsTable, const BaseInputPinFuncTable* pBaseInputFuncsTable, LPCRITICAL_SECTION pCritSec, IMemAllocator *, IPin ** ppPin);
typedef struct BaseFilter
{
@ -142,9 +155,18 @@ typedef struct BaseFilter
CLSID clsid;
LONG pinVersion;
const struct BaseFilterFuncTable* pFuncsTable;
} BaseFilter;
typedef IPin* (WINAPI *BaseFilter_GetPin)(BaseFilter* iface, int iPosition);
typedef LONG (WINAPI *BaseFilter_GetPinCount)(BaseFilter* iface);
typedef LONG (WINAPI *BaseFilter_GetPinVersion)(BaseFilter* iface);
typedef struct BaseFilterFuncTable {
/* Required */
BaseFilter_GetPin pfnGetPin;
BaseFilter_GetPinCount pfnGetPinCount;
} BaseFilter;
} BaseFilterFuncTable;
HRESULT WINAPI BaseFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv);
ULONG WINAPI BaseFilterImpl_AddRef(IBaseFilter * iface);
@ -158,10 +180,15 @@ HRESULT WINAPI BaseFilterImpl_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *
HRESULT WINAPI BaseFilterImpl_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName );
HRESULT WINAPI BaseFilterImpl_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo);
LONG WINAPI BaseFilterImpl_GetPinVersion(IBaseFilter* This);
VOID WINAPI BaseFilterImpl_IncrementPinVersion(IBaseFilter* This);
LONG WINAPI BaseFilterImpl_GetPinVersion(BaseFilter* This);
VOID WINAPI BaseFilterImpl_IncrementPinVersion(BaseFilter* This);
HRESULT WINAPI BaseFilter_Init(BaseFilter * This, const IBaseFilterVtbl *Vtbl, const CLSID *pClsid, DWORD_PTR DebugInfo, BaseFilter_GetPin pfGetPin, BaseFilter_GetPinCount pfGetPinCount);
HRESULT WINAPI BaseFilter_Init(BaseFilter * This, const IBaseFilterVtbl *Vtbl, const CLSID *pClsid, DWORD_PTR DebugInfo, const BaseFilterFuncTable* pBaseFuncsTable);
/* Enums */
HRESULT WINAPI EnumMediaTypes_Construct(BasePin *iface, BasePin_GetMediaType enumFunc, BasePin_GetMediaTypeVersion versionFunc, IEnumMediaTypes ** ppEnum);
HRESULT WINAPI EnumPins_Construct(BaseFilter *base, BaseFilter_GetPin receive_pin, BaseFilter_GetPinCount receive_pincount, BaseFilter_GetPinVersion receive_version, IEnumPins ** ppEnum);
/* Transform Filter */
typedef struct TransformFilter
@ -190,7 +217,9 @@ typedef HRESULT (WINAPI *TransformFilter_NewSegment) (TransformFilter *iface,
REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
typedef struct TransformFilterFuncTable {
/* Required */
TransformFilter_DecideBufferSize pfnDecideBufferSize;
/* Optional */
TransformFilter_StartStreaming pfnStartStreaming;
TransformFilter_Receive pfnReceive;
TransformFilter_StopStreaming pfnStopStreaming;