From 18deeb4aff87e89f3e5bd9247d8f96449316bb25 Mon Sep 17 00:00:00 2001 From: sesse Date: Mon, 8 Mar 2010 19:57:37 +0000 Subject: 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. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30866 b3059339-0415-0410-9bf9-f77b7e298cf2 --- loader/dshow/DS_Filter.c | 7 +++++++ loader/dshow/allocator.c | 8 ++++---- loader/dshow/guids.c | 4 ++++ loader/dshow/guids.h | 2 ++ loader/dshow/interfaces.h | 28 ++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 4 deletions(-) (limited to 'loader') diff --git a/loader/dshow/DS_Filter.c b/loader/dshow/DS_Filter.c index e3102cf264..693d59c25f 100644 --- a/loader/dshow/DS_Filter.c +++ b/loader/dshow/DS_Filter.c @@ -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 @@ DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, // 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 @@ DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, 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 @@ DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, 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 --git a/loader/dshow/allocator.c b/loader/dshow/allocator.c index b75f1bebfb..a90bd9d3d2 100644 --- a/loader/dshow/allocator.c +++ b/loader/dshow/allocator.c @@ -116,7 +116,7 @@ static inline avm_list_t* avm_list_find(avm_list_t* head, void* member) 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 @@ static long MemAllocator_CreateAllocator(GUID* clsid, const GUID* iid, void** pp 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 --git a/loader/dshow/guids.c b/loader/dshow/guids.c index 73cf7f5456..5d793bb14d 100644 --- a/loader/dshow/guids.c +++ b/loader/dshow/guids.c @@ -11,6 +11,8 @@ const GUID IID_IBaseFilter={0x56a86895, 0x0ad4, 0x11ce, {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 @@ const GUID MEDIASUBTYPE_I420={0x30323449, 0x0000, 0x0010, {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 --git a/loader/dshow/guids.h b/loader/dshow/guids.h index 80686558b4..76a4970d27 100644 --- a/loader/dshow/guids.h +++ b/loader/dshow/guids.h @@ -46,6 +46,7 @@ typedef GUID IID; 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 IID_Iv50Hidden; 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 --git a/loader/dshow/interfaces.h b/loader/dshow/interfaces.h index 5c927a55be..af9544ada5 100644 --- a/loader/dshow/interfaces.h +++ b/loader/dshow/interfaces.h @@ -329,4 +329,32 @@ struct IDivxFilterInterface_vt 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 */ -- cgit v1.2.3