core: Do not call *_aid_from_lang when audio_lang is NULL
[mplayer/glamo.git] / loader / dshow / graph.c
blob01bf6c7253ff353da8711ec934519ea1d92e20e5
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 static long FilterGraph_CreateGraph(GUID* clsid, const GUID* iid, void** ppv)
39 IUnknown* p;
40 int result;
41 if (!ppv)
42 return -1;
43 *ppv = 0;
44 if (memcmp(clsid, &CLSID_FilterGraph, sizeof(*clsid)))
45 return -1;
47 p = (IUnknown*) FilterGraphCreate();
48 result = p->vt->QueryInterface(p, iid, ppv);
49 p->vt->Release(p);
51 return result;
54 static void FilterGraph_Destroy(FilterGraph* This)
56 Debug printf("FilterGraph_Destroy(%p) called (%d, %d)\n", This, This->refcount, GraphKeeper);
57 #ifdef WIN32_LOADER
58 if (--GraphKeeper == 0)
59 UnregisterComClass(&CLSID_FilterGraph, FilterGraph_CreateGraph);
60 #endif
61 free(This->vt);
62 free(This);
65 HRESULT STDCALL FilterGraph_AddFilter(FilterGraph* This,
66 IBaseFilter* pFilter,
67 unsigned short* pName)
69 Debug printf("FilterGraph_AddFilter(%p) called\n", This);
70 return E_NOTIMPL;
73 HRESULT STDCALL FilterGraph_RemoveFilter(FilterGraph* This, IBaseFilter* pFilter)
75 Debug printf("FilterGraph_RemoveFilter(%p) called\n", This);
76 return E_NOTIMPL;
79 HRESULT STDCALL FilterGraph_EnumFilters(FilterGraph* This, IEnumFilters** ppEnum)
81 Debug printf("FilterGraph_EnumFilters(%p) called\n", This);
82 return E_NOTIMPL;
85 HRESULT STDCALL FilterGraph_FindFilterByName(FilterGraph* This,
86 unsigned short* pName,
87 IBaseFilter** ppFilter)
89 Debug printf("FilterGraph_FindFilterByName(%p) called\n", This);
90 return E_NOTIMPL;
93 HRESULT STDCALL FilterGraph_ConnectDirect(FilterGraph* This,
94 IPin* ppinOut,
95 IPin* ppinIn,
96 const AM_MEDIA_TYPE* pmt)
98 Debug printf("FilterGraph_ConnectDirect(%p) called\n", This);
99 return E_NOTIMPL;
102 HRESULT STDCALL FilterGraph_Reconnect(FilterGraph* This, IPin* ppin)
104 Debug printf("FilterGraph_Reconnect(%p) called\n", This);
105 return E_NOTIMPL;
108 HRESULT STDCALL FilterGraph_Disconnect(FilterGraph* This, IPin* ppin)
110 Debug printf("FilterGraph_Disconnect(%p) called\n", This);
111 return E_NOTIMPL;
114 HRESULT STDCALL FilterGraph_SetDefaultSyncSource(FilterGraph* This)
116 Debug printf("FilterGraph_SetDefaultSyncSource(%p) called\n", This);
117 return E_NOTIMPL;
120 IMPLEMENT_IUNKNOWN(FilterGraph)
122 FilterGraph* FilterGraphCreate()
124 FilterGraph* This = calloc(1, sizeof(*This));
126 if (!This)
127 return NULL;
129 Debug printf("FilterGraphCreate() called -> %p\n", This);
131 This->refcount = 1;
133 This->vt = calloc(1, sizeof(*This->vt));
135 if (!This->vt) {
136 free(This);
137 return NULL;
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;
156 #ifdef WIN32_LOADER
157 if (GraphKeeper++ == 0)
158 RegisterComClass(&CLSID_FilterGraph, FilterGraph_CreateGraph);
159 #endif
161 return This;