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;
37 static long FilterGraph_CreateGraph(GUID
* clsid
, const GUID
* iid
, void** ppv
)
44 if (memcmp(clsid
, &CLSID_FilterGraph
, sizeof(*clsid
)))
47 p
= (IUnknown
*) FilterGraphCreate();
48 result
= p
->vt
->QueryInterface(p
, iid
, ppv
);
54 static void FilterGraph_Destroy(FilterGraph
* This
)
56 Debug
printf("FilterGraph_Destroy(%p) called (%d, %d)\n", This
, This
->refcount
, GraphKeeper
);
58 if (--GraphKeeper
== 0)
59 UnregisterComClass(&CLSID_FilterGraph
, FilterGraph_CreateGraph
);
65 HRESULT STDCALL
FilterGraph_AddFilter(FilterGraph
* This
,
67 unsigned short* pName
)
69 Debug
printf("FilterGraph_AddFilter(%p) called\n", This
);
73 HRESULT STDCALL
FilterGraph_RemoveFilter(FilterGraph
* This
, IBaseFilter
* pFilter
)
75 Debug
printf("FilterGraph_RemoveFilter(%p) called\n", This
);
79 HRESULT STDCALL
FilterGraph_EnumFilters(FilterGraph
* This
, IEnumFilters
** ppEnum
)
81 Debug
printf("FilterGraph_EnumFilters(%p) called\n", This
);
85 HRESULT STDCALL
FilterGraph_FindFilterByName(FilterGraph
* This
,
86 unsigned short* pName
,
87 IBaseFilter
** ppFilter
)
89 Debug
printf("FilterGraph_FindFilterByName(%p) called\n", This
);
93 HRESULT STDCALL
FilterGraph_ConnectDirect(FilterGraph
* This
,
96 const AM_MEDIA_TYPE
* pmt
)
98 Debug
printf("FilterGraph_ConnectDirect(%p) called\n", This
);
102 HRESULT STDCALL
FilterGraph_Reconnect(FilterGraph
* This
, IPin
* ppin
)
104 Debug
printf("FilterGraph_Reconnect(%p) called\n", This
);
108 HRESULT STDCALL
FilterGraph_Disconnect(FilterGraph
* This
, IPin
* ppin
)
110 Debug
printf("FilterGraph_Disconnect(%p) called\n", This
);
114 HRESULT STDCALL
FilterGraph_SetDefaultSyncSource(FilterGraph
* This
)
116 Debug
printf("FilterGraph_SetDefaultSyncSource(%p) called\n", This
);
120 IMPLEMENT_IUNKNOWN(FilterGraph
)
122 FilterGraph
* FilterGraphCreate()
124 FilterGraph
* This
= calloc(1, sizeof(*This
));
129 Debug
printf("FilterGraphCreate() called -> %p\n", This
);
133 This
->vt
= calloc(1, sizeof(*This
->vt
));
140 This
->vt
->QueryInterface
= FilterGraph_QueryInterface
;
141 This
->vt
->AddRef
= FilterGraph_AddRef
;
142 This
->vt
->Release
= FilterGraph_Release
;
144 This
->vt
->AddFilter
= FilterGraph_AddFilter
;
145 This
->vt
->RemoveFilter
= FilterGraph_RemoveFilter
;
146 This
->vt
->EnumFilters
= FilterGraph_EnumFilters
;
147 This
->vt
->FindFilterByName
= FilterGraph_FindFilterByName
;
148 This
->vt
->ConnectDirect
= FilterGraph_ConnectDirect
;
149 This
->vt
->Reconnect
= FilterGraph_Reconnect
;
150 This
->vt
->Disconnect
= FilterGraph_Disconnect
;
151 This
->vt
->SetDefaultSyncSource
= FilterGraph_SetDefaultSyncSource
;
153 This
->interfaces
[0] = IID_IUnknown
;
154 This
->interfaces
[1] = IID_IFilterGraph
;
157 if (GraphKeeper
++ == 0)
158 RegisterComClass(&CLSID_FilterGraph
, FilterGraph_CreateGraph
);