cleanup: Silence compilation warnings on MinGW-w64
[mplayer.git] / loader / dshow / graph.c
blob14517a627fe99e77c09729feb8ba31f6e2383276
1 /*
2 * Implemention of FilterGraph. Based on allocator.c.
3 * Copyright 2010 Steinar H. Gunderson
5 * This file is part of MPlayer.
7 * MPlayer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * MPlayer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Modified for use with MPlayer, detailed changelog at
22 * http://svn.mplayerhq.hu/mplayer/trunk/
25 #include <stdio.h>
26 #include <stdlib.h>
28 #include "config.h"
29 #include "loader/com.h"
30 #include "loader/dshow/graph.h"
31 #include "loader/wine/winerror.h"
33 // How many FilterGraph objects exist.
34 // Used for knowing when to register and unregister the class in COM.
35 static int GraphKeeper = 0;
37 #ifdef WIN32_LOADER
38 static long FilterGraph_CreateGraph(GUID* clsid, const GUID* iid, void** ppv)
40 IUnknown* p;
41 int result;
42 if (!ppv)
43 return -1;
44 *ppv = 0;
45 if (memcmp(clsid, &CLSID_FilterGraph, sizeof(*clsid)))
46 return -1;
48 p = (IUnknown*) FilterGraphCreate();
49 result = p->vt->QueryInterface(p, iid, ppv);
50 p->vt->Release(p);
52 return result;
54 #endif
56 static void FilterGraph_Destroy(FilterGraph* This)
58 Debug printf("FilterGraph_Destroy(%p) called (%d, %d)\n", This, This->refcount, GraphKeeper);
59 #ifdef WIN32_LOADER
60 if (--GraphKeeper == 0)
61 UnregisterComClass(&CLSID_FilterGraph, FilterGraph_CreateGraph);
62 #endif
63 free(This->vt);
64 free(This);
67 static HRESULT STDCALL FilterGraph_AddFilter(IFilterGraph* This,
68 IBaseFilter* pFilter,
69 unsigned short* pName)
71 Debug printf("FilterGraph_AddFilter(%p) called\n", This);
72 return E_NOTIMPL;
75 static HRESULT STDCALL FilterGraph_RemoveFilter(IFilterGraph* This, IBaseFilter* pFilter)
77 Debug printf("FilterGraph_RemoveFilter(%p) called\n", This);
78 return E_NOTIMPL;
81 static HRESULT STDCALL FilterGraph_EnumFilters(IFilterGraph* This, IEnumFilters** ppEnum)
83 Debug printf("FilterGraph_EnumFilters(%p) called\n", This);
84 return E_NOTIMPL;
87 static HRESULT STDCALL FilterGraph_FindFilterByName(IFilterGraph* This,
88 unsigned short* pName,
89 IBaseFilter** ppFilter)
91 Debug printf("FilterGraph_FindFilterByName(%p) called\n", This);
92 return E_NOTIMPL;
95 static HRESULT STDCALL FilterGraph_ConnectDirect(IFilterGraph* This,
96 IPin* ppinOut,
97 IPin* ppinIn,
98 const AM_MEDIA_TYPE* pmt)
100 Debug printf("FilterGraph_ConnectDirect(%p) called\n", This);
101 return E_NOTIMPL;
104 static HRESULT STDCALL FilterGraph_Reconnect(IFilterGraph* This, IPin* ppin)
106 Debug printf("FilterGraph_Reconnect(%p) called\n", This);
107 return E_NOTIMPL;
110 static HRESULT STDCALL FilterGraph_Disconnect(IFilterGraph* This, IPin* ppin)
112 Debug printf("FilterGraph_Disconnect(%p) called\n", This);
113 return E_NOTIMPL;
116 static HRESULT STDCALL FilterGraph_SetDefaultSyncSource(IFilterGraph* This)
118 Debug printf("FilterGraph_SetDefaultSyncSource(%p) called\n", This);
119 return E_NOTIMPL;
122 IMPLEMENT_IUNKNOWN(FilterGraph)
124 FilterGraph* FilterGraphCreate()
126 FilterGraph* This = calloc(1, sizeof(*This));
128 if (!This)
129 return NULL;
131 Debug printf("FilterGraphCreate() called -> %p\n", This);
133 This->refcount = 1;
135 This->vt = calloc(1, sizeof(*This->vt));
137 if (!This->vt) {
138 free(This);
139 return NULL;
142 This->vt->QueryInterface = FilterGraph_QueryInterface;
143 This->vt->AddRef = FilterGraph_AddRef;
144 This->vt->Release = FilterGraph_Release;
146 This->vt->AddFilter = FilterGraph_AddFilter;
147 This->vt->RemoveFilter = FilterGraph_RemoveFilter;
148 This->vt->EnumFilters = FilterGraph_EnumFilters;
149 This->vt->FindFilterByName = FilterGraph_FindFilterByName;
150 This->vt->ConnectDirect = FilterGraph_ConnectDirect;
151 This->vt->Reconnect = FilterGraph_Reconnect;
152 This->vt->Disconnect = FilterGraph_Disconnect;
153 This->vt->SetDefaultSyncSource = FilterGraph_SetDefaultSyncSource;
155 This->interfaces[0] = IID_IUnknown;
156 This->interfaces[1] = IID_IFilterGraph;
158 #ifdef WIN32_LOADER
159 if (GraphKeeper++ == 0)
160 RegisterComClass(&CLSID_FilterGraph, FilterGraph_CreateGraph);
161 #endif
163 return This;