strmbase: Move TransformFilter implementation to strmbase.

This commit is contained in:
Aric Stewart 2010-10-07 14:48:19 -05:00 committed by Alexandre Julliard
parent 791087089c
commit 34f3f7cae3
7 changed files with 375 additions and 230 deletions

View File

@ -24,7 +24,6 @@ C_SRCS = \
pin.c \ pin.c \
regsvr.c \ regsvr.c \
systemclock.c \ systemclock.c \
transform.c \
videorenderer.c \ videorenderer.c \
waveparser.c waveparser.c

View File

@ -37,13 +37,13 @@
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "transform.h"
WINE_DEFAULT_DEBUG_CHANNEL(quartz); WINE_DEFAULT_DEBUG_CHANNEL(quartz);
typedef struct ACMWrapperImpl typedef struct ACMWrapperImpl
{ {
TransformFilterImpl tf; TransformFilter tf;
IUnknown *seekthru_unk;
HACMSTREAM has; HACMSTREAM has;
LPWAVEFORMATEX pWfIn; LPWAVEFORMATEX pWfIn;
LPWAVEFORMATEX pWfOut; LPWAVEFORMATEX pWfOut;
@ -52,10 +52,11 @@ typedef struct ACMWrapperImpl
LONGLONG lasttime_sent; LONGLONG lasttime_sent;
} ACMWrapperImpl; } ACMWrapperImpl;
static HRESULT WINAPI ACMWrapper_ProcessSampleData(IPin *iface, IMediaSample *pSample) static const IBaseFilterVtbl ACMWrapper_Vtbl;
static HRESULT WINAPI ACMWrapper_Receive(TransformFilter *tf, IMediaSample *pSample)
{ {
BaseInputPin *pin = (BaseInputPin*) iface; ACMWrapperImpl* This = (ACMWrapperImpl*)tf;
ACMWrapperImpl* This = (ACMWrapperImpl*)pin->pin.pinInfo.pFilter;
AM_MEDIA_TYPE amt; AM_MEDIA_TYPE amt;
IMediaSample* pOutSample = NULL; IMediaSample* pOutSample = NULL;
DWORD cbDstStream, cbSrcStream; DWORD cbDstStream, cbSrcStream;
@ -68,18 +69,6 @@ static HRESULT WINAPI ACMWrapper_ProcessSampleData(IPin *iface, IMediaSample *pS
LONGLONG tStart = -1, tStop = -1, tMed; LONGLONG tStart = -1, tStop = -1, tMed;
EnterCriticalSection(&This->tf.filter.csFilter); EnterCriticalSection(&This->tf.filter.csFilter);
if (This->tf.filter.state == State_Stopped)
{
LeaveCriticalSection(&This->tf.filter.csFilter);
return VFW_E_WRONG_STATE;
}
if (pin->end_of_stream || pin->flushing)
{
LeaveCriticalSection(&This->tf.filter.csFilter);
return S_FALSE;
}
hr = IMediaSample_GetPointer(pSample, &pbSrcStream); hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
if (FAILED(hr)) if (FAILED(hr))
{ {
@ -235,12 +224,15 @@ error:
return hr; return hr;
} }
static HRESULT ACMWrapper_ConnectInput(BaseInputPin *pin, const AM_MEDIA_TYPE * pmt) static HRESULT WINAPI ACMWrapper_SetMediaType(TransformFilter *tf, PIN_DIRECTION dir, const AM_MEDIA_TYPE * pmt)
{ {
ACMWrapperImpl* This = (ACMWrapperImpl *)pin->pin.pinInfo.pFilter; ACMWrapperImpl* This = (ACMWrapperImpl *)tf;
MMRESULT res; MMRESULT res;
TRACE("(%p)->(%p)\n", This, pmt); TRACE("(%p)->(%i %p)\n", This, dir, pmt);
if (dir != PINDIR_INPUT)
return S_OK;
/* Check root (GUID w/o FOURCC) */ /* Check root (GUID w/o FOURCC) */
if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Audio)) && if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Audio)) &&
@ -287,28 +279,62 @@ static HRESULT ACMWrapper_ConnectInput(BaseInputPin *pin, const AM_MEDIA_TYPE *
return VFW_E_TYPE_NOT_ACCEPTED; return VFW_E_TYPE_NOT_ACCEPTED;
} }
static HRESULT ACMWrapper_Cleanup(BaseInputPin *pin) static HRESULT WINAPI ACMWrapper_CompleteConnect(TransformFilter *tf, PIN_DIRECTION dir, IPin *pin)
{ {
ACMWrapperImpl *This = (ACMWrapperImpl *)pin->pin.pinInfo.pFilter; ACMWrapperImpl* This = (ACMWrapperImpl *)tf;
MMRESULT res;
HACMSTREAM drv;
TRACE("(%p)->()\n", This); TRACE("(%p)\n", This);
if (This->has) if (dir != PINDIR_INPUT)
acmStreamClose(This->has, 0); return S_OK;
This->has = 0; if (!(res = acmStreamOpen(&drv, NULL, This->pWfIn, This->pWfOut, NULL, 0, 0, 0)))
This->lasttime_real = This->lasttime_sent = -1; {
This->has = drv;
/* Update buffer size of media samples in output */
((BaseOutputPin*)This->tf.ppPins[1])->allocProps.cbBuffer = This->pWfOut->nAvgBytesPerSec / 2;
TRACE("Connection accepted\n");
return S_OK;
}
FIXME("acmStreamOpen returned %d\n", res);
TRACE("Unable to find a suitable ACM decompressor\n");
return VFW_E_TYPE_NOT_ACCEPTED;
}
static HRESULT WINAPI ACMWrapper_BreakConnect(TransformFilter *tf, PIN_DIRECTION dir)
{
ACMWrapperImpl *This = (ACMWrapperImpl *)tf;
TRACE("(%p)->(%i)\n", This,dir);
if (dir == PINDIR_INPUT)
{
if (This->has)
acmStreamClose(This->has, 0);
This->has = 0;
This->lasttime_real = This->lasttime_sent = -1;
}
return S_OK; return S_OK;
} }
static const TransformFuncsTable ACMWrapper_FuncsTable = { static const TransformFilterFuncTable ACMWrapper_FuncsTable = {
NULL, NULL,
ACMWrapper_ProcessSampleData, ACMWrapper_Receive,
NULL, NULL,
NULL, NULL,
ACMWrapper_ConnectInput, ACMWrapper_SetMediaType,
ACMWrapper_Cleanup ACMWrapper_CompleteConnect,
ACMWrapper_BreakConnect,
NULL,
NULL,
NULL,
NULL
}; };
HRESULT ACMWrapper_create(IUnknown * pUnkOuter, LPVOID * ppv) HRESULT ACMWrapper_create(IUnknown * pUnkOuter, LPVOID * ppv)
@ -323,17 +349,55 @@ HRESULT ACMWrapper_create(IUnknown * pUnkOuter, LPVOID * ppv)
if (pUnkOuter) if (pUnkOuter)
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
/* Note: This memory is managed by the transform filter once created */ hr = TransformFilter_Construct(&ACMWrapper_Vtbl, sizeof(ACMWrapperImpl), &CLSID_ACMWrapper, &ACMWrapper_FuncsTable, (IBaseFilter**)&This);
This = CoTaskMemAlloc(sizeof(ACMWrapperImpl));
ZeroMemory(This, sizeof(ACMWrapperImpl));
hr = TransformFilter_Create(&(This->tf), &CLSID_ACMWrapper, &ACMWrapper_FuncsTable);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
else
{
ISeekingPassThru *passthru;
hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown*)This, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&This->seekthru_unk);
IUnknown_QueryInterface(This->seekthru_unk, &IID_ISeekingPassThru, (void**)&passthru);
ISeekingPassThru_Init(passthru, FALSE, (IPin*)This->tf.ppPins[0]);
ISeekingPassThru_Release(passthru);
}
*ppv = This; *ppv = This;
This->lasttime_real = This->lasttime_sent = -1; This->lasttime_real = This->lasttime_sent = -1;
return hr; return hr;
} }
HRESULT WINAPI ACMWrapper_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
{
HRESULT hr;
ACMWrapperImpl *This = (ACMWrapperImpl *)iface;
TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
if (IsEqualIID(riid, &IID_IMediaSeeking))
return IUnknown_QueryInterface(This->seekthru_unk, riid, ppv);
hr = TransformFilterImpl_QueryInterface(iface, riid, ppv);
return hr;
}
static const IBaseFilterVtbl ACMWrapper_Vtbl =
{
ACMWrapper_QueryInterface,
BaseFilterImpl_AddRef,
TransformFilterImpl_Release,
BaseFilterImpl_GetClassID,
TransformFilterImpl_Stop,
TransformFilterImpl_Pause,
TransformFilterImpl_Run,
BaseFilterImpl_GetState,
BaseFilterImpl_SetSyncSource,
BaseFilterImpl_GetSyncSource,
BaseFilterImpl_EnumPins,
TransformFilterImpl_FindPin,
BaseFilterImpl_QueryFilterInfo,
BaseFilterImpl_JoinFilterGraph,
BaseFilterImpl_QueryVendorInfo
};

View File

@ -38,19 +38,21 @@
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "transform.h"
WINE_DEFAULT_DEBUG_CHANNEL(quartz); WINE_DEFAULT_DEBUG_CHANNEL(quartz);
typedef struct AVIDecImpl typedef struct AVIDecImpl
{ {
TransformFilterImpl tf; TransformFilter tf;
IUnknown *seekthru_unk;
HIC hvid; HIC hvid;
BITMAPINFOHEADER* pBihIn; BITMAPINFOHEADER* pBihIn;
BITMAPINFOHEADER* pBihOut; BITMAPINFOHEADER* pBihOut;
} AVIDecImpl; } AVIDecImpl;
static HRESULT AVIDec_ProcessBegin(TransformFilterImpl* pTransformFilter) static const IBaseFilterVtbl AVIDec_Vtbl;
static HRESULT WINAPI AVIDec_StartStreaming(TransformFilter* pTransformFilter)
{ {
AVIDecImpl* This = (AVIDecImpl*)pTransformFilter; AVIDecImpl* This = (AVIDecImpl*)pTransformFilter;
DWORD result; DWORD result;
@ -66,10 +68,9 @@ static HRESULT AVIDec_ProcessBegin(TransformFilterImpl* pTransformFilter)
return S_OK; return S_OK;
} }
static HRESULT WINAPI AVIDec_ProcessSampleData(IPin *iface, IMediaSample *pSample) static HRESULT WINAPI AVIDec_Receive(TransformFilter *tf, IMediaSample *pSample)
{ {
BaseInputPin *pin = (BaseInputPin*)iface; AVIDecImpl* This = (AVIDecImpl *)tf;
AVIDecImpl* This = (AVIDecImpl *)pin->pin.pinInfo.pFilter;
AM_MEDIA_TYPE amt; AM_MEDIA_TYPE amt;
HRESULT hr; HRESULT hr;
DWORD res; DWORD res;
@ -81,18 +82,6 @@ static HRESULT WINAPI AVIDec_ProcessSampleData(IPin *iface, IMediaSample *pSampl
LONGLONG tStart, tStop; LONGLONG tStart, tStop;
EnterCriticalSection(&This->tf.filter.csFilter); EnterCriticalSection(&This->tf.filter.csFilter);
if (This->tf.filter.state == State_Stopped)
{
LeaveCriticalSection(&This->tf.filter.csFilter);
return VFW_E_WRONG_STATE;
}
if (pin->end_of_stream || pin->flushing)
{
LeaveCriticalSection(&This->tf.filter.csFilter);
return S_FALSE;
}
hr = IMediaSample_GetPointer(pSample, &pbSrcStream); hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
if (FAILED(hr)) if (FAILED(hr))
{ {
@ -164,7 +153,7 @@ error:
return hr; return hr;
} }
static HRESULT AVIDec_ProcessEnd(TransformFilterImpl* pTransformFilter) static HRESULT WINAPI AVIDec_StopStreaming(TransformFilter* pTransformFilter)
{ {
AVIDecImpl* This = (AVIDecImpl*)pTransformFilter; AVIDecImpl* This = (AVIDecImpl*)pTransformFilter;
DWORD result; DWORD result;
@ -183,13 +172,16 @@ static HRESULT AVIDec_ProcessEnd(TransformFilterImpl* pTransformFilter)
return S_OK; return S_OK;
} }
static HRESULT AVIDec_ConnectInput(BaseInputPin *pin, const AM_MEDIA_TYPE * pmt) static HRESULT WINAPI AVIDec_SetMediaType(TransformFilter *tf, PIN_DIRECTION dir, const AM_MEDIA_TYPE * pmt)
{ {
AVIDecImpl* This = (AVIDecImpl*)pin->pin.pinInfo.pFilter; AVIDecImpl* This = (AVIDecImpl*)tf;
HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED; HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED;
TRACE("(%p)->(%p)\n", This, pmt); TRACE("(%p)->(%p)\n", This, pmt);
if (dir != PINDIR_INPUT)
return S_OK;
/* Check root (GUID w/o FOURCC) */ /* Check root (GUID w/o FOURCC) */
if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Video)) && if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Video)) &&
(!memcmp(((const char *)&pmt->subtype)+4, ((const char *)&MEDIATYPE_Video)+4, sizeof(GUID)-4))) (!memcmp(((const char *)&pmt->subtype)+4, ((const char *)&MEDIATYPE_Video)+4, sizeof(GUID)-4)))
@ -269,9 +261,6 @@ static HRESULT AVIDec_ConnectInput(BaseInputPin *pin, const AM_MEDIA_TYPE * pmt)
else else
assert(0); assert(0);
/* Update buffer size of media samples in output */
((BaseOutputPin*)This->tf.ppPins[1])->allocProps.cbBuffer = This->pBihOut->biSizeImage;
TRACE("Connection accepted\n"); TRACE("Connection accepted\n");
return S_OK; return S_OK;
} }
@ -284,33 +273,55 @@ failed:
return hr; return hr;
} }
static HRESULT AVIDec_Cleanup(BaseInputPin *pin) static HRESULT WINAPI AVIDec_CompleteConnect(TransformFilter *tf, PIN_DIRECTION dir, IPin *pin)
{ {
AVIDecImpl *This = (AVIDecImpl *)pin->pin.pinInfo.pFilter; AVIDecImpl* This = (AVIDecImpl*)tf;
TRACE("(%p)\n", This);
if (dir == PINDIR_INPUT)
{
/* Update buffer size of media samples in output */
((BaseOutputPin*)This->tf.ppPins[1])->allocProps.cbBuffer = This->pBihOut->biSizeImage;
}
return S_OK;
}
static HRESULT WINAPI AVIDec_BreakConnect(TransformFilter *tf, PIN_DIRECTION dir)
{
AVIDecImpl *This = (AVIDecImpl *)tf;
TRACE("(%p)->()\n", This); TRACE("(%p)->()\n", This);
if (This->hvid)
ICClose(This->hvid);
if (This->pBihIn)
CoTaskMemFree(This->pBihIn);
if (This->pBihOut)
CoTaskMemFree(This->pBihOut);
This->hvid = NULL; if (dir == PINDIR_INPUT)
This->pBihIn = NULL; {
This->pBihOut = NULL; if (This->hvid)
ICClose(This->hvid);
if (This->pBihIn)
CoTaskMemFree(This->pBihIn);
if (This->pBihOut)
CoTaskMemFree(This->pBihOut);
This->hvid = NULL;
This->pBihIn = NULL;
This->pBihOut = NULL;
}
return S_OK; return S_OK;
} }
static const TransformFuncsTable AVIDec_FuncsTable = { static const TransformFilterFuncTable AVIDec_FuncsTable = {
AVIDec_ProcessBegin, AVIDec_StartStreaming,
AVIDec_ProcessSampleData, AVIDec_Receive,
AVIDec_ProcessEnd, AVIDec_StopStreaming,
NULL, NULL,
AVIDec_ConnectInput, AVIDec_SetMediaType,
AVIDec_Cleanup AVIDec_CompleteConnect,
AVIDec_BreakConnect,
NULL,
NULL,
NULL,
NULL
}; };
HRESULT AVIDec_create(IUnknown * pUnkOuter, LPVOID * ppv) HRESULT AVIDec_create(IUnknown * pUnkOuter, LPVOID * ppv)
@ -325,19 +336,57 @@ HRESULT AVIDec_create(IUnknown * pUnkOuter, LPVOID * ppv)
if (pUnkOuter) if (pUnkOuter)
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
/* Note: This memory is managed by the transform filter once created */ hr = TransformFilter_Construct(&AVIDec_Vtbl, sizeof(AVIDecImpl), &CLSID_AVIDec, &AVIDec_FuncsTable, (IBaseFilter**)&This);
This = CoTaskMemAlloc(sizeof(AVIDecImpl));
if (FAILED(hr))
return hr;
else
{
ISeekingPassThru *passthru;
hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown*)This, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&This->seekthru_unk);
IUnknown_QueryInterface(This->seekthru_unk, &IID_ISeekingPassThru, (void**)&passthru);
ISeekingPassThru_Init(passthru, FALSE, (IPin*)This->tf.ppPins[0]);
ISeekingPassThru_Release(passthru);
}
This->hvid = NULL; This->hvid = NULL;
This->pBihIn = NULL; This->pBihIn = NULL;
This->pBihOut = NULL; This->pBihOut = NULL;
hr = TransformFilter_Create(&(This->tf), &CLSID_AVIDec, &AVIDec_FuncsTable);
if (FAILED(hr))
return hr;
*ppv = This; *ppv = This;
return hr; return hr;
} }
HRESULT WINAPI AVIDec_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
{
HRESULT hr;
AVIDecImpl *This = (AVIDecImpl *)iface;
TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
if (IsEqualIID(riid, &IID_IMediaSeeking))
return IUnknown_QueryInterface(This->seekthru_unk, riid, ppv);
hr = TransformFilterImpl_QueryInterface(iface, riid, ppv);
return hr;
}
static const IBaseFilterVtbl AVIDec_Vtbl =
{
AVIDec_QueryInterface,
BaseFilterImpl_AddRef,
TransformFilterImpl_Release,
BaseFilterImpl_GetClassID,
TransformFilterImpl_Stop,
TransformFilterImpl_Pause,
TransformFilterImpl_Run,
BaseFilterImpl_GetState,
BaseFilterImpl_SetSyncSource,
BaseFilterImpl_GetSyncSource,
BaseFilterImpl_EnumPins,
TransformFilterImpl_FindPin,
BaseFilterImpl_QueryFilterInfo,
BaseFilterImpl_JoinFilterGraph,
BaseFilterImpl_QueryVendorInfo
};

View File

@ -1,50 +0,0 @@
/*
* Transform Filter declarations
*
* Copyright 2005 Christian Costa
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "control_private.h"
typedef struct TransformFilterImpl TransformFilterImpl;
typedef struct TransformFuncsTable {
HRESULT (*pfnProcessBegin) (TransformFilterImpl *This);
BaseInputPin_Receive pfnProcessSampleData;
HRESULT (*pfnProcessEnd) (TransformFilterImpl *This);
HRESULT (*pfnQueryConnect) (TransformFilterImpl *This, const AM_MEDIA_TYPE * pmt);
HRESULT (*pfnConnectInput) (BaseInputPin *pin, const AM_MEDIA_TYPE * pmt);
HRESULT (*pfnCleanup) (BaseInputPin *pin);
HRESULT (*pfnEndOfStream) (BaseInputPin *pin);
HRESULT (*pfnBeginFlush) (BaseInputPin *pin);
HRESULT (*pfnEndFlush) (BaseInputPin *pin);
HRESULT (*pfnNewSegment) (BaseInputPin *pin, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
} TransformFuncsTable;
struct TransformFilterImpl
{
BaseFilter filter;
IUnknown *seekthru_unk;
IPin **ppPins;
ULONG npins;
AM_MEDIA_TYPE pmt;
const TransformFuncsTable * pFuncsTable;
};
HRESULT TransformFilter_Create(TransformFilterImpl*, const CLSID*, const TransformFuncsTable* pFuncsTable);

View File

@ -4,6 +4,7 @@ C_SRCS = \
enumpins.c \ enumpins.c \
filter.c \ filter.c \
mediatype.c \ mediatype.c \
pin.c pin.c \
transform.c
@MAKE_IMPLIB_RULES@ @MAKE_IMPLIB_RULES@

View File

@ -2,6 +2,7 @@
* Transform Filter (Base for decoders, etc...) * Transform Filter (Base for decoders, etc...)
* *
* Copyright 2005 Christian Costa * Copyright 2005 Christian Costa
* Copyright 2010 Aric Stewart, CodeWeavers
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -17,17 +18,15 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "config.h" #include "config.h"
#include <stdarg.h>
#include "quartz_private.h" #define COBJMACROS
#include "control_private.h"
#include "pin.h"
#include "amvideo.h"
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "dshow.h" #include "dshow.h"
#include "amvideo.h"
#include "strmif.h" #include "strmif.h"
#include "vfw.h" #include "vfw.h"
@ -35,10 +34,9 @@
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/strmbase.h"
#include "transform.h" WINE_DEFAULT_DEBUG_CHANNEL(strmbase);
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0}; 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 WCHAR wcsOutputPinName[] = {'o','u','t','p','u','t',' ','p','i','n',0};
@ -49,22 +47,53 @@ 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(IPin *iface, const AM_MEDIA_TYPE * pmt)
{ {
TransformFilterImpl* This = (TransformFilterImpl *)((BasePin *)iface)->pinInfo.pFilter; BaseInputPin* This = (BaseInputPin*) iface;
TRACE("%p\n", iface); TransformFilter * pTransform;
dump_AM_MEDIA_TYPE(pmt);
if (This->pFuncsTable->pfnQueryConnect) TRACE("%p\n", iface);
return This->pFuncsTable->pfnQueryConnect(This, pmt); pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
if (pTransform->pFuncsTable->pfnCheckInputType)
return pTransform->pFuncsTable->pfnCheckInputType(pTransform, pmt);
/* Assume OK if there's no query method (the connection will fail if /* Assume OK if there's no query method (the connection will fail if
needed) */ needed) */
return S_OK; return S_OK;
} }
static HRESULT WINAPI TransformFilter_Input_Receive(IPin *iface, IMediaSample *pInSample)
{
HRESULT hr = S_FALSE;
BaseInputPin* This = (BaseInputPin*) iface;
TransformFilter * pTransform;
TRACE("%p\n", iface);
pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
EnterCriticalSection(&pTransform->filter.csFilter);
if (pTransform->filter.state == State_Stopped)
{
LeaveCriticalSection(&pTransform->filter.csFilter);
return VFW_E_WRONG_STATE;
}
if (This->end_of_stream || This->flushing)
{
LeaveCriticalSection(&pTransform->filter.csFilter);
return S_FALSE;
}
LeaveCriticalSection(&pTransform->filter.csFilter);
if (pTransform->pFuncsTable->pfnReceive)
hr = pTransform->pFuncsTable->pfnReceive(pTransform, pInSample);
else
hr = S_FALSE;
return hr;
}
static HRESULT WINAPI TransformFilter_Output_QueryAccept(IPin *iface, const AM_MEDIA_TYPE * pmt) static HRESULT WINAPI TransformFilter_Output_QueryAccept(IPin *iface, const AM_MEDIA_TYPE * pmt)
{ {
BasePin *This = (BasePin *)iface; BasePin *This = (BasePin *)iface;
TransformFilterImpl *pTransformFilter = (TransformFilterImpl *)This->pinInfo.pFilter; TransformFilter *pTransformFilter = (TransformFilter *)This->pinInfo.pFilter;
AM_MEDIA_TYPE* outpmt = &pTransformFilter->pmt; AM_MEDIA_TYPE* outpmt = &pTransformFilter->pmt;
TRACE("%p\n", iface); TRACE("%p\n", iface);
@ -76,7 +105,7 @@ static HRESULT WINAPI TransformFilter_Output_QueryAccept(IPin *iface, const AM_M
static IPin* WINAPI TransformFilter_GetPin(IBaseFilter *iface, int pos) static IPin* WINAPI TransformFilter_GetPin(IBaseFilter *iface, int pos)
{ {
TransformFilterImpl *This = (TransformFilterImpl *)iface; TransformFilter *This = (TransformFilter *)iface;
if (pos >= This->npins || pos < 0) if (pos >= This->npins || pos < 0)
return NULL; return NULL;
@ -87,18 +116,18 @@ static IPin* WINAPI TransformFilter_GetPin(IBaseFilter *iface, int pos)
static LONG WINAPI TransformFilter_GetPinCount(IBaseFilter *iface) static LONG WINAPI TransformFilter_GetPinCount(IBaseFilter *iface)
{ {
TransformFilterImpl *This = (TransformFilterImpl *)iface; TransformFilter *This = (TransformFilter *)iface;
return (This->npins+1); return (This->npins+1);
} }
HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSID* pClsid, const TransformFuncsTable* pFuncsTable) static HRESULT TransformFilter_Init(const IBaseFilterVtbl *pVtbl, const CLSID* pClsid, const TransformFilterFuncTable* pFuncsTable, TransformFilter* pTransformFilter)
{ {
HRESULT hr; HRESULT hr;
PIN_INFO piInput; PIN_INFO piInput;
PIN_INFO piOutput; PIN_INFO piOutput;
BaseFilter_Init(&pTransformFilter->filter, &TransformFilter_Vtbl, pClsid, (DWORD_PTR)(__FILE__ ": TransformFilterImpl.csFilter"), TransformFilter_GetPin, TransformFilter_GetPinCount); BaseFilter_Init(&pTransformFilter->filter, pVtbl, pClsid, (DWORD_PTR)(__FILE__ ": TransformFilter.csFilter"), TransformFilter_GetPin, TransformFilter_GetPinCount);
/* pTransformFilter is already allocated */ /* pTransformFilter is already allocated */
pTransformFilter->pFuncsTable = pFuncsTable; pTransformFilter->pFuncsTable = pFuncsTable;
@ -115,7 +144,7 @@ HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSI
piOutput.pFilter = (IBaseFilter *)pTransformFilter; piOutput.pFilter = (IBaseFilter *)pTransformFilter;
lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0])); lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0]));
hr = BaseInputPin_Construct(&TransformFilter_InputPin_Vtbl, &piInput, TransformFilter_Input_CheckMediaType, pFuncsTable->pfnProcessSampleData, &pTransformFilter->filter.csFilter, NULL, &pTransformFilter->ppPins[0]); hr = BaseInputPin_Construct(&TransformFilter_InputPin_Vtbl, &piInput, TransformFilter_Input_CheckMediaType, TransformFilter_Input_Receive, &pTransformFilter->filter.csFilter, NULL, &pTransformFilter->ppPins[0]);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
@ -129,58 +158,57 @@ HRESULT TransformFilter_Create(TransformFilterImpl* pTransformFilter, const CLSI
if (FAILED(hr)) if (FAILED(hr))
ERR("Cannot create output pin (%x)\n", hr); ERR("Cannot create output pin (%x)\n", hr);
else
{
ISeekingPassThru *passthru;
hr = CoCreateInstance(&CLSID_SeekingPassThru, (IUnknown*)pTransformFilter, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&pTransformFilter->seekthru_unk);
IUnknown_QueryInterface(pTransformFilter->seekthru_unk, &IID_ISeekingPassThru, (void**)&passthru);
ISeekingPassThru_Init(passthru, FALSE, (IPin*)pTransformFilter->ppPins[0]);
ISeekingPassThru_Release(passthru);
}
} }
if (FAILED(hr)) if (FAILED(hr))
{ {
CoTaskMemFree(pTransformFilter->ppPins); CoTaskMemFree(pTransformFilter->ppPins);
BaseFilterImpl_Release((IBaseFilter*)pTransformFilter); BaseFilterImpl_Release((IBaseFilter*)pTransformFilter);
CoTaskMemFree(pTransformFilter);
} }
return hr; return hr;
} }
static HRESULT WINAPI TransformFilter_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv) HRESULT TransformFilter_Construct(const IBaseFilterVtbl *pVtbl, LONG filter_size, const CLSID* pClsid, const TransformFilterFuncTable* pFuncsTable, IBaseFilter ** ppTransformFilter)
{ {
TransformFilterImpl *This = (TransformFilterImpl *)iface; TransformFilter* pTf;
TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
*ppv = NULL; *ppTransformFilter = NULL;
if (IsEqualIID(riid, &IID_IUnknown)) assert(filter_size >= sizeof(TransformFilter));
*ppv = This;
else if (IsEqualIID(riid, &IID_IPersist))
*ppv = This;
else if (IsEqualIID(riid, &IID_IMediaFilter))
*ppv = This;
else if (IsEqualIID(riid, &IID_IBaseFilter))
*ppv = This;
else if (IsEqualIID(riid, &IID_IMediaSeeking))
return IUnknown_QueryInterface(This->seekthru_unk, riid, ppv);
if (*ppv) pTf = CoTaskMemAlloc(filter_size);
ZeroMemory(pTf, filter_size);
if (!pTf)
return E_OUTOFMEMORY;
if (SUCCEEDED(TransformFilter_Init(pVtbl, pClsid, pFuncsTable, pTf)))
{ {
IUnknown_AddRef((IUnknown *)(*ppv)); *ppTransformFilter = (IBaseFilter*)(&pTf->filter.lpVtbl);
return S_OK; return S_OK;
} }
if (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow)) CoTaskMemFree(pTf);
FIXME("No interface for %s!\n", qzdebugstr_guid(riid)); return E_FAIL;
return E_NOINTERFACE;
} }
static ULONG WINAPI TransformFilter_Release(IBaseFilter * iface) HRESULT WINAPI TransformFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
{ {
TransformFilterImpl *This = (TransformFilterImpl *)iface; HRESULT hr;
TransformFilter *This = (TransformFilter *)iface;
TRACE("(%p/%p)->(%s, %p)\n", This, iface, debugstr_guid(riid), ppv);
hr = BaseFilterImpl_QueryInterface(iface, riid, ppv);
if (FAILED(hr) && (!IsEqualIID(riid, &IID_IPin) && !IsEqualIID(riid, &IID_IVideoWindow)))
FIXME("No interface for %s!\n", debugstr_guid(riid));
return hr;
}
ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface)
{
TransformFilter *This = (TransformFilter *)iface;
ULONG refCount = BaseFilterImpl_Release(iface); ULONG refCount = BaseFilterImpl_Release(iface);
TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1); TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
@ -217,9 +245,9 @@ static ULONG WINAPI TransformFilter_Release(IBaseFilter * iface)
/** IMediaFilter methods **/ /** IMediaFilter methods **/
static HRESULT WINAPI TransformFilter_Stop(IBaseFilter * iface) HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter * iface)
{ {
TransformFilterImpl *This = (TransformFilterImpl *)iface; TransformFilter *This = (TransformFilter *)iface;
HRESULT hr = S_OK; HRESULT hr = S_OK;
TRACE("(%p/%p)\n", This, iface); TRACE("(%p/%p)\n", This, iface);
@ -227,17 +255,17 @@ static HRESULT WINAPI TransformFilter_Stop(IBaseFilter * iface)
EnterCriticalSection(&This->filter.csFilter); EnterCriticalSection(&This->filter.csFilter);
{ {
This->filter.state = State_Stopped; This->filter.state = State_Stopped;
if (This->pFuncsTable->pfnProcessEnd) if (This->pFuncsTable->pfnStopStreaming)
hr = This->pFuncsTable->pfnProcessEnd(This); hr = This->pFuncsTable->pfnStopStreaming(This);
} }
LeaveCriticalSection(&This->filter.csFilter); LeaveCriticalSection(&This->filter.csFilter);
return hr; return hr;
} }
static HRESULT WINAPI TransformFilter_Pause(IBaseFilter * iface) HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface)
{ {
TransformFilterImpl *This = (TransformFilterImpl *)iface; TransformFilter *This = (TransformFilter *)iface;
HRESULT hr; HRESULT hr;
TRACE("(%p/%p)->()\n", This, iface); TRACE("(%p/%p)->()\n", This, iface);
@ -257,10 +285,10 @@ static HRESULT WINAPI TransformFilter_Pause(IBaseFilter * iface)
return hr; return hr;
} }
static HRESULT WINAPI TransformFilter_Run(IBaseFilter * iface, REFERENCE_TIME tStart) HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
TransformFilterImpl *This = (TransformFilterImpl *)iface; TransformFilter *This = (TransformFilter *)iface;
TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart)); TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
@ -269,8 +297,8 @@ static HRESULT WINAPI TransformFilter_Run(IBaseFilter * iface, REFERENCE_TIME tS
if (This->filter.state == State_Stopped) if (This->filter.state == State_Stopped)
{ {
((BaseInputPin *)This->ppPins[0])->end_of_stream = 0; ((BaseInputPin *)This->ppPins[0])->end_of_stream = 0;
if (This->pFuncsTable->pfnProcessBegin) if (This->pFuncsTable->pfnStartStreaming)
hr = This->pFuncsTable->pfnProcessBegin(This); hr = This->pFuncsTable->pfnStartStreaming(This);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = BaseOutputPinImpl_Active((BaseOutputPin *)This->ppPins[1]); hr = BaseOutputPinImpl_Active((BaseOutputPin *)This->ppPins[1]);
} }
@ -288,9 +316,9 @@ static HRESULT WINAPI TransformFilter_Run(IBaseFilter * iface, REFERENCE_TIME tS
/** IBaseFilter implementation **/ /** IBaseFilter implementation **/
static HRESULT WINAPI TransformFilter_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin) HRESULT WINAPI TransformFilterImpl_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
{ {
TransformFilterImpl *This = (TransformFilterImpl *)iface; TransformFilter *This = (TransformFilter *)iface;
TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin); TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
@ -299,18 +327,18 @@ static HRESULT WINAPI TransformFilter_FindPin(IBaseFilter * iface, LPCWSTR Id, I
static const IBaseFilterVtbl TransformFilter_Vtbl = static const IBaseFilterVtbl TransformFilter_Vtbl =
{ {
TransformFilter_QueryInterface, TransformFilterImpl_QueryInterface,
BaseFilterImpl_AddRef, BaseFilterImpl_AddRef,
TransformFilter_Release, TransformFilterImpl_Release,
BaseFilterImpl_GetClassID, BaseFilterImpl_GetClassID,
TransformFilter_Stop, TransformFilterImpl_Stop,
TransformFilter_Pause, TransformFilterImpl_Pause,
TransformFilter_Run, TransformFilterImpl_Run,
BaseFilterImpl_GetState, BaseFilterImpl_GetState,
BaseFilterImpl_SetSyncSource, BaseFilterImpl_SetSyncSource,
BaseFilterImpl_GetSyncSource, BaseFilterImpl_GetSyncSource,
BaseFilterImpl_EnumPins, BaseFilterImpl_EnumPins,
TransformFilter_FindPin, TransformFilterImpl_FindPin,
BaseFilterImpl_QueryFilterInfo, BaseFilterImpl_QueryFilterInfo,
BaseFilterImpl_JoinFilterGraph, BaseFilterImpl_JoinFilterGraph,
BaseFilterImpl_QueryVendorInfo BaseFilterImpl_QueryVendorInfo
@ -319,14 +347,14 @@ static const IBaseFilterVtbl TransformFilter_Vtbl =
static HRESULT WINAPI TransformFilter_InputPin_EndOfStream(IPin * iface) static HRESULT WINAPI TransformFilter_InputPin_EndOfStream(IPin * iface)
{ {
BaseInputPin* This = (BaseInputPin*) iface; BaseInputPin* This = (BaseInputPin*) iface;
TransformFilterImpl* pTransform; TransformFilter* pTransform;
IPin* ppin; IPin* ppin;
HRESULT hr; HRESULT hr;
TRACE("(%p)->()\n", iface); TRACE("(%p)->()\n", iface);
/* Since we process samples synchronously, just forward notification downstream */ /* Since we process samples synchronously, just forward notification downstream */
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter; pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
if (!pTransform) if (!pTransform)
hr = E_FAIL; hr = E_FAIL;
else else
@ -345,19 +373,24 @@ static HRESULT WINAPI TransformFilter_InputPin_EndOfStream(IPin * iface)
static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt) static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt)
{ {
BaseInputPin* This = (BaseInputPin*) iface; BaseInputPin* This = (BaseInputPin*) iface;
TransformFilterImpl* pTransform; TransformFilter* pTransform;
HRESULT hr; HRESULT hr = S_OK;
TRACE("(%p)->(%p, %p)\n", iface, pReceivePin, pmt); TRACE("(%p)->(%p, %p)\n", iface, pReceivePin, pmt);
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter; 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);
hr = pTransform->pFuncsTable->pfnConnectInput(This, pmt);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
hr = BaseInputPinImpl_ReceiveConnection(iface, pReceivePin, pmt); hr = BaseInputPinImpl_ReceiveConnection(iface, pReceivePin, pmt);
if (FAILED(hr)) if (FAILED(hr) && pTransform->pFuncsTable->pfnBreakConnect)
pTransform->pFuncsTable->pfnCleanup(This); pTransform->pFuncsTable->pfnBreakConnect(pTransform, PINDIR_INPUT);
} }
return hr; return hr;
@ -366,12 +399,13 @@ static HRESULT WINAPI TransformFilter_InputPin_ReceiveConnection(IPin * iface, I
static HRESULT WINAPI TransformFilter_InputPin_Disconnect(IPin * iface) static HRESULT WINAPI TransformFilter_InputPin_Disconnect(IPin * iface)
{ {
BaseInputPin* This = (BaseInputPin*) iface; BaseInputPin* This = (BaseInputPin*) iface;
TransformFilterImpl* pTransform; TransformFilter* pTransform;
TRACE("(%p)->()\n", iface); TRACE("(%p)->()\n", iface);
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter; pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
pTransform->pFuncsTable->pfnCleanup(This); if (pTransform->pFuncsTable->pfnBreakConnect)
pTransform->pFuncsTable->pfnBreakConnect(pTransform, PINDIR_INPUT);
return BasePinImpl_Disconnect(iface); return BasePinImpl_Disconnect(iface);
} }
@ -379,15 +413,15 @@ static HRESULT WINAPI TransformFilter_InputPin_Disconnect(IPin * iface)
static HRESULT WINAPI TransformFilter_InputPin_BeginFlush(IPin * iface) static HRESULT WINAPI TransformFilter_InputPin_BeginFlush(IPin * iface)
{ {
BaseInputPin* This = (BaseInputPin*) iface; BaseInputPin* This = (BaseInputPin*) iface;
TransformFilterImpl* pTransform; TransformFilter* pTransform;
HRESULT hr = S_OK; HRESULT hr = S_OK;
TRACE("(%p)->()\n", iface); TRACE("(%p)->()\n", iface);
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter; pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
EnterCriticalSection(&pTransform->filter.csFilter); EnterCriticalSection(&pTransform->filter.csFilter);
if (pTransform->pFuncsTable->pfnBeginFlush) if (pTransform->pFuncsTable->pfnBeginFlush)
hr = pTransform->pFuncsTable->pfnBeginFlush(This); hr = pTransform->pFuncsTable->pfnBeginFlush(pTransform);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = BaseInputPinImpl_BeginFlush(iface); hr = BaseInputPinImpl_BeginFlush(iface);
LeaveCriticalSection(&pTransform->filter.csFilter); LeaveCriticalSection(&pTransform->filter.csFilter);
@ -397,15 +431,15 @@ static HRESULT WINAPI TransformFilter_InputPin_BeginFlush(IPin * iface)
static HRESULT WINAPI TransformFilter_InputPin_EndFlush(IPin * iface) static HRESULT WINAPI TransformFilter_InputPin_EndFlush(IPin * iface)
{ {
BaseInputPin* This = (BaseInputPin*) iface; BaseInputPin* This = (BaseInputPin*) iface;
TransformFilterImpl* pTransform; TransformFilter* pTransform;
HRESULT hr = S_OK; HRESULT hr = S_OK;
TRACE("(%p)->()\n", iface); TRACE("(%p)->()\n", iface);
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter; pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
EnterCriticalSection(&pTransform->filter.csFilter); EnterCriticalSection(&pTransform->filter.csFilter);
if (pTransform->pFuncsTable->pfnEndFlush) if (pTransform->pFuncsTable->pfnEndFlush)
hr = pTransform->pFuncsTable->pfnEndFlush(This); hr = pTransform->pFuncsTable->pfnEndFlush(pTransform);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = BaseInputPinImpl_EndFlush(iface); hr = BaseInputPinImpl_EndFlush(iface);
LeaveCriticalSection(&pTransform->filter.csFilter); LeaveCriticalSection(&pTransform->filter.csFilter);
@ -415,22 +449,22 @@ static HRESULT WINAPI TransformFilter_InputPin_EndFlush(IPin * iface)
static HRESULT WINAPI TransformFilter_InputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) static HRESULT WINAPI TransformFilter_InputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{ {
BaseInputPin* This = (BaseInputPin*) iface; BaseInputPin* This = (BaseInputPin*) iface;
TransformFilterImpl* pTransform; TransformFilter* pTransform;
HRESULT hr = S_OK; HRESULT hr = S_OK;
TRACE("(%p)->()\n", iface); TRACE("(%p)->()\n", iface);
pTransform = (TransformFilterImpl*)This->pin.pinInfo.pFilter; pTransform = (TransformFilter*)This->pin.pinInfo.pFilter;
EnterCriticalSection(&pTransform->filter.csFilter); EnterCriticalSection(&pTransform->filter.csFilter);
if (pTransform->pFuncsTable->pfnNewSegment) if (pTransform->pFuncsTable->pfnNewSegment)
hr = pTransform->pFuncsTable->pfnNewSegment(This, tStart, tStop, dRate); hr = pTransform->pFuncsTable->pfnNewSegment(pTransform, tStart, tStop, dRate);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = BaseInputPinImpl_NewSegment(iface, tStart, tStop, dRate); hr = BaseInputPinImpl_NewSegment(iface, tStart, tStop, dRate);
LeaveCriticalSection(&pTransform->filter.csFilter); LeaveCriticalSection(&pTransform->filter.csFilter);
return hr; return hr;
} }
static const IPinVtbl TransformFilter_InputPin_Vtbl = static const IPinVtbl TransformFilter_InputPin_Vtbl =
{ {
BaseInputPinImpl_QueryInterface, BaseInputPinImpl_QueryInterface,
BasePinImpl_AddRef, BasePinImpl_AddRef,
@ -455,7 +489,7 @@ static const IPinVtbl TransformFilter_InputPin_Vtbl =
static HRESULT WINAPI TransformFilter_Output_GetMediaType(IPin *iface, int iPosition, AM_MEDIA_TYPE *pmt) static HRESULT WINAPI TransformFilter_Output_GetMediaType(IPin *iface, int iPosition, AM_MEDIA_TYPE *pmt)
{ {
BasePin *This = (BasePin *)iface; BasePin *This = (BasePin *)iface;
TransformFilterImpl *pTransform = (TransformFilterImpl *)This->pinInfo.pFilter; TransformFilter *pTransform = (TransformFilter *)This->pinInfo.pFilter;
if (iPosition < 0) if (iPosition < 0)
return E_INVALIDARG; return E_INVALIDARG;

View File

@ -158,3 +158,51 @@ LONG WINAPI BaseFilterImpl_GetPinVersion(IBaseFilter* This);
VOID WINAPI BaseFilterImpl_IncrementPinVersion(IBaseFilter* This); VOID WINAPI BaseFilterImpl_IncrementPinVersion(IBaseFilter* 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, BaseFilter_GetPin pfGetPin, BaseFilter_GetPinCount pfGetPinCount);
/* Transform Filter */
typedef struct TransformFilter
{
BaseFilter filter;
IPin **ppPins;
ULONG npins;
AM_MEDIA_TYPE pmt;
const struct TransformFilterFuncTable * pFuncsTable;
} TransformFilter;
typedef HRESULT (WINAPI *TransformFilter_StartStreaming) (TransformFilter *iface);
typedef HRESULT (WINAPI *TransformFilter_StopStreaming) (TransformFilter *iface);
typedef HRESULT (WINAPI *TransformFilter_Receive) (TransformFilter* iface, IMediaSample* pIn);
typedef HRESULT (WINAPI *TransformFilter_CompleteConnect) (TransformFilter *iface, PIN_DIRECTION dir, IPin *pPin);
typedef HRESULT (WINAPI *TransformFilter_BreakConnect) (TransformFilter *iface, PIN_DIRECTION dir);
typedef HRESULT (WINAPI *TransformFilter_SetMediaType) (TransformFilter *iface, PIN_DIRECTION dir, const AM_MEDIA_TYPE *pMediaType);
typedef HRESULT (WINAPI *TransformFilter_CheckInputType) (TransformFilter *iface, const AM_MEDIA_TYPE *pMediaType);
typedef HRESULT (WINAPI *TransformFilter_EndOfStream) (TransformFilter *iface);
typedef HRESULT (WINAPI *TransformFilter_BeginFlush) (TransformFilter *iface);
typedef HRESULT (WINAPI *TransformFilter_EndFlush) (TransformFilter *iface);
typedef HRESULT (WINAPI *TransformFilter_NewSegment) (TransformFilter *iface,
REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
typedef struct TransformFilterFuncTable {
TransformFilter_StartStreaming pfnStartStreaming;
TransformFilter_Receive pfnReceive;
TransformFilter_StopStreaming pfnStopStreaming;
TransformFilter_CheckInputType pfnCheckInputType;
TransformFilter_SetMediaType pfnSetMediaType;
TransformFilter_CompleteConnect pfnCompleteConnect;
TransformFilter_BreakConnect pfnBreakConnect;
TransformFilter_EndOfStream pfnEndOfStream;
TransformFilter_BeginFlush pfnBeginFlush;
TransformFilter_EndFlush pfnEndFlush;
TransformFilter_NewSegment pfnNewSegment;
} TransformFilterFuncTable;
HRESULT WINAPI TransformFilterImpl_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv);
ULONG WINAPI TransformFilterImpl_Release(IBaseFilter * iface);
HRESULT WINAPI TransformFilterImpl_Stop(IBaseFilter * iface);
HRESULT WINAPI TransformFilterImpl_Pause(IBaseFilter * iface);
HRESULT WINAPI TransformFilterImpl_Run(IBaseFilter * iface, REFERENCE_TIME tStart);
HRESULT WINAPI TransformFilterImpl_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin);
HRESULT TransformFilter_Construct( const IBaseFilterVtbl *filterVtbl, LONG filter_size, const CLSID* pClsid, const TransformFilterFuncTable* pFuncsTable, IBaseFilter ** ppTransformFilter);