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/
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;
38 static long FilterGraph_CreateGraph(GUID
* clsid
, const GUID
* iid
, void** ppv
)
45 if (memcmp(clsid
, &CLSID_FilterGraph
, sizeof(*clsid
)))
48 p
= (IUnknown
*) FilterGraphCreate();
49 result
= p
->vt
->QueryInterface(p
, iid
, ppv
);
56 static void FilterGraph_Destroy(FilterGraph
* This
)
58 Debug
printf("FilterGraph_Destroy(%p) called (%d, %d)\n", This
, This
->refcount
, GraphKeeper
);
60 if (--GraphKeeper
== 0)
61 UnregisterComClass(&CLSID_FilterGraph
, FilterGraph_CreateGraph
);
67 static HRESULT STDCALL
FilterGraph_AddFilter(IFilterGraph
* This
,
69 unsigned short* pName
)
71 Debug
printf("FilterGraph_AddFilter(%p) called\n", This
);
75 static HRESULT STDCALL
FilterGraph_RemoveFilter(IFilterGraph
* This
, IBaseFilter
* pFilter
)
77 Debug
printf("FilterGraph_RemoveFilter(%p) called\n", This
);
81 static HRESULT STDCALL
FilterGraph_EnumFilters(IFilterGraph
* This
, IEnumFilters
** ppEnum
)
83 Debug
printf("FilterGraph_EnumFilters(%p) called\n", This
);
87 static HRESULT STDCALL
FilterGraph_FindFilterByName(IFilterGraph
* This
,
88 unsigned short* pName
,
89 IBaseFilter
** ppFilter
)
91 Debug
printf("FilterGraph_FindFilterByName(%p) called\n", This
);
95 static HRESULT STDCALL
FilterGraph_ConnectDirect(IFilterGraph
* This
,
98 const AM_MEDIA_TYPE
* pmt
)
100 Debug
printf("FilterGraph_ConnectDirect(%p) called\n", This
);
104 static HRESULT STDCALL
FilterGraph_Reconnect(IFilterGraph
* This
, IPin
* ppin
)
106 Debug
printf("FilterGraph_Reconnect(%p) called\n", This
);
110 static HRESULT STDCALL
FilterGraph_Disconnect(IFilterGraph
* This
, IPin
* ppin
)
112 Debug
printf("FilterGraph_Disconnect(%p) called\n", This
);
116 static HRESULT STDCALL
FilterGraph_SetDefaultSyncSource(IFilterGraph
* This
)
118 Debug
printf("FilterGraph_SetDefaultSyncSource(%p) called\n", This
);
122 IMPLEMENT_IUNKNOWN(FilterGraph
)
124 FilterGraph
* FilterGraphCreate()
126 FilterGraph
* This
= calloc(1, sizeof(*This
));
131 Debug
printf("FilterGraphCreate() called -> %p\n", This
);
135 This
->vt
= calloc(1, sizeof(*This
->vt
));
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
;
159 if (GraphKeeper
++ == 0)
160 RegisterComClass(&CLSID_FilterGraph
, FilterGraph_CreateGraph
);