# HG changeset patch # User sesse # Date 1268078257 0 # Node ID c121d03db8b942d35ef6a2337a16fe0a890e6b41 # Parent 4dfdb57de907a48b31b5f09f26dd4579a38a4969 Implement DirectShow filter graph. DirectShow specifies that a filter (codec) can expect JoinFilterGraph to be called, and store a reference to the graph manager. Implement a very bare-bones graph manager (all functions are stubs, and no extra interfaces are implemented) and give it to the codec on init. diff -r 4dfdb57de907 -r c121d03db8b9 Makefile --- a/Makefile Mon Mar 08 19:54:07 2010 +0000 +++ b/Makefile Mon Mar 08 19:57:37 2010 +0000 @@ -322,6 +322,7 @@ loader/dshow/DS_VideoDecoder.c \ loader/dshow/allocator.c \ loader/dshow/cmediasample.c \ + loader/dshow/graph.c \ loader/dshow/guids.c \ loader/dshow/inputpin.c \ loader/dshow/mediatype.c \ diff -r 4dfdb57de907 -r c121d03db8b9 loader/dshow/DS_Filter.c --- a/loader/dshow/DS_Filter.c Mon Mar 08 19:54:07 2010 +0000 +++ b/loader/dshow/DS_Filter.c Mon Mar 08 19:57:37 2010 +0000 @@ -5,6 +5,7 @@ #include "config.h" #include "DS_Filter.h" +#include "graph.h" #include "loader/drv.h" #include "loader/com.h" #include @@ -125,6 +126,7 @@ // char eb[250]; const char* em = NULL; MemAllocator* tempAll; + FilterGraph* graph; ALLOCATOR_PROPERTIES props,props1; DS_Filter* This = malloc(sizeof(DS_Filter)); if (!This) @@ -166,6 +168,7 @@ ULONG fetched; HRESULT result; unsigned int i; + static const uint16_t filter_name[] = { 'F', 'i', 'l', 't', 'e', 'r', 0 }; This->m_iHandle = LoadLibraryA(dllname); if (!This->m_iHandle) @@ -199,6 +202,10 @@ em = "object does not provide IBaseFilter interface"; break; } + + graph = FilterGraphCreate(); + result = This->m_pFilter->vt->JoinFilterGraph(This->m_pFilter, (IFilterGraph*)graph, filter_name); + // enumerate pins result = This->m_pFilter->vt->EnumPins(This->m_pFilter, &enum_pins); if (result || !enum_pins) diff -r 4dfdb57de907 -r c121d03db8b9 loader/dshow/allocator.c --- a/loader/dshow/allocator.c Mon Mar 08 19:54:07 2010 +0000 +++ b/loader/dshow/allocator.c Mon Mar 08 19:57:37 2010 +0000 @@ -116,7 +116,7 @@ static long MemAllocator_CreateAllocator(GUID* clsid, const GUID* iid, void** ppv) { - IMemAllocator* p; + IUnknown* p; int result; if (!ppv) return -1; @@ -124,9 +124,9 @@ if (memcmp(clsid, &CLSID_MemoryAllocator, sizeof(GUID))) return -1; - p = (IMemAllocator*) MemAllocatorCreate(); - result = p->vt->QueryInterface((IUnknown*)p, iid, ppv); - p->vt->Release((IUnknown*)p); + p = (IUnknown*) MemAllocatorCreate(); + result = p->vt->QueryInterface(p, iid, ppv); + p->vt->Release(p); return result; } diff -r 4dfdb57de907 -r c121d03db8b9 loader/dshow/guids.c --- a/loader/dshow/guids.c Mon Mar 08 19:54:07 2010 +0000 +++ b/loader/dshow/guids.c Mon Mar 08 19:57:37 2010 +0000 @@ -11,6 +11,8 @@ {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; const GUID IID_IEnumPins={0x56a86892, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; +const GUID IID_IFilterGraph={0x56a8689f, 0x0ad4, 0x11ce, + {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; const GUID IID_IEnumMediaTypes={0x89c31040, 0x846b, 0x11ce, {0x97, 0xd3, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}}; const GUID IID_IMemInputPin={0x56a8689d, 0x0ad4, 0x11ce, @@ -64,6 +66,8 @@ {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; const GUID MEDIASUBTYPE_IF09={0x39304649, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; +const GUID CLSID_FilterGraph={0xe436ebb3, 0x524f, 0x11ce, + {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; const GUID CLSID_MemoryAllocator={0x1e651cc0, 0xb199, 0x11d0, {0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45}}; const GUID IID_DivxHidden={0x598eba01, 0xb49a, 0x11d2, diff -r 4dfdb57de907 -r c121d03db8b9 loader/dshow/guids.h --- a/loader/dshow/guids.h Mon Mar 08 19:54:07 2010 +0000 +++ b/loader/dshow/guids.h Mon Mar 08 19:57:37 2010 +0000 @@ -46,6 +46,7 @@ extern const GUID IID_IBaseFilter; extern const GUID IID_IEnumPins; extern const GUID IID_IEnumMediaTypes; +extern const GUID IID_IFilterGraph; extern const GUID IID_IMemInputPin; extern const GUID IID_IMemAllocator; extern const GUID IID_IMediaSample; @@ -54,6 +55,7 @@ extern const GUID CLSID_DivxDecompressorCF; extern const GUID IID_IDivxFilterInterface; extern const GUID CLSID_IV50_Decoder; +extern const GUID CLSID_FilterGraph; extern const GUID CLSID_MemoryAllocator; extern const GUID MEDIATYPE_Video; // avoid a clash with MinGW-W64 libuuid diff -r 4dfdb57de907 -r c121d03db8b9 loader/dshow/interfaces.h --- a/loader/dshow/interfaces.h Mon Mar 08 19:54:07 2010 +0000 +++ b/loader/dshow/interfaces.h Mon Mar 08 19:57:37 2010 +0000 @@ -329,4 +329,32 @@ HRESULT STDCALL ( *get_AspectRatio )(IDivxFilterInterface* This, int* x, IDivxFilterInterface* Thisit, int* y); }; +typedef struct IEnumFilters IEnumFilters; + +typedef struct IFilterGraph_vt +{ + INHERIT_IUNKNOWN(); + + HRESULT STDCALL ( *AddFilter )(IFilterGraph* This, + /* [in] */ IBaseFilter* pFilter, + /* [string][in] */ unsigned short* pName); + HRESULT STDCALL ( *RemoveFilter )(IFilterGraph* This, + /* [in] */ IBaseFilter* pFilter); + HRESULT STDCALL ( *EnumFilters )(IFilterGraph* This, + /* [out] */ IEnumFilters** ppEnum); + HRESULT STDCALL ( *FindFilterByName )(IFilterGraph* This, + /* [string][in] */ unsigned short* pName, + /* [out] */ IBaseFilter** ppFilter); + HRESULT STDCALL ( *ConnectDirect )(IFilterGraph* This, + /* [in] */ IPin* ppinOut, + /* [in] */ IPin* ppinIn, + /* [in] */ const AM_MEDIA_TYPE* pmt); + HRESULT STDCALL ( *Reconnect )(IFilterGraph* This, + /* [in] */ IPin* ppin); + HRESULT STDCALL ( *Disconnect )(IFilterGraph* This, + /* [in] */ IPin* ppin); + HRESULT STDCALL ( *SetDefaultSyncSource )(IFilterGraph* This); +} IFilterGraph_vt; +struct IFilterGraph { IFilterGraph_vt *vt; }; + #endif /*MPLAYER_INTERFACES_H */