Mercurial > mplayer.hg
comparison loader/dshow/DS_Filter.c @ 3467:e3bbf44dbab2
avifile sync
author | arpi |
---|---|
date | Tue, 11 Dec 2001 23:29:24 +0000 |
parents | 623cdb771e97 |
children | 4b0dd1ff6a20 |
comparison
equal
deleted
inserted
replaced
3466:b6caac381405 | 3467:e3bbf44dbab2 |
---|---|
10 | 10 |
11 static void DS_Filter_Start(DS_Filter* This) | 11 static void DS_Filter_Start(DS_Filter* This) |
12 { | 12 { |
13 HRESULT hr; | 13 HRESULT hr; |
14 | 14 |
15 if (This->m_iState != 1) | 15 if (This->m_pAll) |
16 return; | 16 return; |
17 | 17 |
18 //Debug printf("DS_Filter_Start(%p)\n", This); | 18 //Debug printf("DS_Filter_Start(%p)\n", This); |
19 hr = This->m_pFilter->vt->Run(This->m_pFilter, 0); | 19 hr = This->m_pFilter->vt->Run(This->m_pFilter, 0); |
20 if (hr != 0) | 20 if (hr != 0) |
28 Debug printf("WARNING: error getting IMemAllocator interface %x\n", (int)hr); | 28 Debug printf("WARNING: error getting IMemAllocator interface %x\n", (int)hr); |
29 This->m_pImp->vt->Release((IUnknown*)This->m_pImp); | 29 This->m_pImp->vt->Release((IUnknown*)This->m_pImp); |
30 return; | 30 return; |
31 } | 31 } |
32 This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0); | 32 This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0); |
33 This->m_iState = 2; | |
34 } | 33 } |
35 | 34 |
36 static void DS_Filter_Stop(DS_Filter* This) | 35 static void DS_Filter_Stop(DS_Filter* This) |
37 { | 36 { |
38 if (This->m_iState == 2) | 37 if (This->m_pAll) |
39 { | 38 { |
40 This->m_iState = 1; | |
41 //Debug printf("DS_Filter_Stop(%p)\n", This); | 39 //Debug printf("DS_Filter_Stop(%p)\n", This); |
42 if (This->m_pFilter) | 40 This->m_pFilter->vt->Stop(This->m_pFilter); // causes weird crash ??? FIXME |
43 { | |
44 //printf("vt: %p\n", m_pFilter->vt); | |
45 //printf("vtstop %p\n", m_pFilter->vt->Stop); | |
46 This->m_pFilter->vt->Stop(This->m_pFilter); // causes weird crash ??? FIXME | |
47 } | |
48 else | |
49 printf("WARNING: DS_Filter::Stop() m_pFilter is NULL!\n"); | |
50 This->m_pAll->vt->Release((IUnknown*)This->m_pAll); | 41 This->m_pAll->vt->Release((IUnknown*)This->m_pAll); |
51 This->m_pAll = 0; | 42 This->m_pAll = 0; |
52 } | 43 } |
53 } | 44 } |
54 | 45 |
55 void DS_Filter_Destroy(DS_Filter* This) | 46 void DS_Filter_Destroy(DS_Filter* This) |
56 { | 47 { |
57 This->Stop(This); | 48 This->Stop(This); |
58 | |
59 This->m_iState = 0; | |
60 | 49 |
61 if (This->m_pOurInput) | 50 if (This->m_pOurInput) |
62 This->m_pOurInput->vt->Release((IUnknown*)This->m_pOurInput); | 51 This->m_pOurInput->vt->Release((IUnknown*)This->m_pOurInput); |
63 if (This->m_pInputPin) | 52 if (This->m_pInputPin) |
64 This->m_pInputPin->vt->Disconnect(This->m_pInputPin); | 53 This->m_pInputPin->vt->Disconnect(This->m_pInputPin); |
91 | 80 |
92 DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, | 81 DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, |
93 AM_MEDIA_TYPE* in_fmt, | 82 AM_MEDIA_TYPE* in_fmt, |
94 AM_MEDIA_TYPE* out_fmt) | 83 AM_MEDIA_TYPE* out_fmt) |
95 { | 84 { |
85 int init = 0; | |
86 char eb[250]; | |
87 const char* em = NULL; | |
96 DS_Filter* This = (DS_Filter*) malloc(sizeof(DS_Filter)); | 88 DS_Filter* This = (DS_Filter*) malloc(sizeof(DS_Filter)); |
97 if (!This) | 89 if (!This) |
98 return NULL; | 90 return NULL; |
99 | 91 |
100 CodecAlloc(); | 92 CodecAlloc(); |
106 This->m_pParentFilter = NULL; | 98 This->m_pParentFilter = NULL; |
107 This->m_pOurInput = NULL; | 99 This->m_pOurInput = NULL; |
108 This->m_pOurOutput = NULL; | 100 This->m_pOurOutput = NULL; |
109 This->m_pAll = NULL; | 101 This->m_pAll = NULL; |
110 This->m_pImp = NULL; | 102 This->m_pImp = NULL; |
111 This->m_iState = 0; | |
112 | 103 |
113 This->Start = DS_Filter_Start; | 104 This->Start = DS_Filter_Start; |
114 This->Stop = DS_Filter_Stop; | 105 This->Stop = DS_Filter_Stop; |
115 | 106 |
116 for (;;) | 107 for (;;) |
125 unsigned int i; | 116 unsigned int i; |
126 | 117 |
127 This->m_iHandle = LoadLibraryA(dllname); | 118 This->m_iHandle = LoadLibraryA(dllname); |
128 if (!This->m_iHandle) | 119 if (!This->m_iHandle) |
129 { | 120 { |
130 printf("Could not open DirectShow DLL: %.200s\n", dllname); | 121 em = "could not open DirectShow DLL"; |
131 break; | 122 break; |
132 } | 123 } |
133 func = (GETCLASS)GetProcAddress(This->m_iHandle, "DllGetClassObject"); | 124 func = (GETCLASS)GetProcAddress(This->m_iHandle, "DllGetClassObject"); |
134 if (!func) | 125 if (!func) |
135 { | 126 { |
136 printf("Illegal or corrupt DirectShow DLL: %.200s\n", dllname); | 127 em = "illegal or corrupt DirectShow DLL"; |
137 break; | 128 break; |
138 } | 129 } |
139 result = func(id, &IID_IClassFactory, (void**)&factory); | 130 result = func(id, &IID_IClassFactory, (void**)&factory); |
140 if (result || !factory) | 131 if (result || !factory) |
141 { | 132 { |
142 printf("No such class object\n"); | 133 em = "no such class object"; |
143 break; | 134 break; |
144 } | 135 } |
145 result = factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object); | 136 result = factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object); |
146 factory->vt->Release((IUnknown*)factory); | 137 factory->vt->Release((IUnknown*)factory); |
147 if (result || !object) | 138 if (result || !object) |
148 { | 139 { |
149 printf("Class factory failure\n"); | 140 em = "class factory failure"; |
150 break; | 141 break; |
151 } | 142 } |
152 result = object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&This->m_pFilter); | 143 result = object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&This->m_pFilter); |
153 object->vt->Release((IUnknown*)object); | 144 object->vt->Release((IUnknown*)object); |
154 if (result || !This->m_pFilter) | 145 if (result || !This->m_pFilter) |
155 { | 146 { |
156 printf("Object does not have IBaseFilter interface\n"); | 147 em = "object does not have IBaseFilter interface"; |
157 break; | 148 break; |
158 } | 149 } |
159 // enumerate pins | 150 // enumerate pins |
160 result = This->m_pFilter->vt->EnumPins(This->m_pFilter, &enum_pins); | 151 result = This->m_pFilter->vt->EnumPins(This->m_pFilter, &enum_pins); |
161 if (result || !enum_pins) | 152 if (result || !enum_pins) |
162 { | 153 { |
163 printf("Could not enumerate pins\n"); | 154 em = "could not enumerate pins"; |
164 break; | 155 break; |
165 } | 156 } |
166 | 157 |
167 enum_pins->vt->Reset(enum_pins); | 158 enum_pins->vt->Reset(enum_pins); |
168 result = enum_pins->vt->Next(enum_pins, (ULONG)256, (IPin**)array, &fetched); | 159 result = enum_pins->vt->Next(enum_pins, (ULONG)256, (IPin**)array, &fetched); |
184 } | 175 } |
185 array[i]->vt->Release((IUnknown*)(array[i])); | 176 array[i]->vt->Release((IUnknown*)(array[i])); |
186 } | 177 } |
187 if (!This->m_pInputPin) | 178 if (!This->m_pInputPin) |
188 { | 179 { |
189 printf("Input pin not found\n"); | 180 em = "could not find input pin"; |
190 break; | 181 break; |
191 } | 182 } |
192 if (!This->m_pOutputPin) | 183 if (!This->m_pOutputPin) |
193 { | 184 { |
194 printf("Output pin not found\n"); | 185 em = "could not find output pin"; |
195 break; | 186 break; |
196 } | 187 } |
197 result = This->m_pInputPin->vt->QueryInterface((IUnknown*)This->m_pInputPin, | 188 result = This->m_pInputPin->vt->QueryInterface((IUnknown*)This->m_pInputPin, |
198 &IID_IMemInputPin, | 189 &IID_IMemInputPin, |
199 (void**)&This->m_pImp); | 190 (void**)&This->m_pImp); |
200 if (result) | 191 if (result) |
201 { | 192 { |
202 printf("Error getting IMemInputPin interface\n"); | 193 em = "could not get IMemInputPin interface"; |
203 break; | 194 break; |
204 } | 195 } |
205 | 196 |
206 This->m_pOurType = in_fmt; | 197 This->m_pOurType = in_fmt; |
207 This->m_pDestType = out_fmt; | 198 This->m_pDestType = out_fmt; |
208 result = This->m_pInputPin->vt->QueryAccept(This->m_pInputPin, This->m_pOurType); | 199 result = This->m_pInputPin->vt->QueryAccept(This->m_pInputPin, This->m_pOurType); |
209 if (result) | 200 if (result) |
210 { | 201 { |
211 printf("Source format is not accepted\n"); | 202 em = "source format is not accepted"; |
212 break; | 203 break; |
213 } | 204 } |
214 This->m_pParentFilter = CBaseFilter2Create(); | 205 This->m_pParentFilter = CBaseFilter2Create(); |
215 This->m_pSrcFilter = CBaseFilterCreate(This->m_pOurType, This->m_pParentFilter); | 206 This->m_pSrcFilter = CBaseFilterCreate(This->m_pOurType, This->m_pParentFilter); |
216 This->m_pOurInput = This->m_pSrcFilter->GetPin(This->m_pSrcFilter); | 207 This->m_pOurInput = This->m_pSrcFilter->GetPin(This->m_pSrcFilter); |
219 result = This->m_pInputPin->vt->ReceiveConnection(This->m_pInputPin, | 210 result = This->m_pInputPin->vt->ReceiveConnection(This->m_pInputPin, |
220 This->m_pOurInput, | 211 This->m_pOurInput, |
221 This->m_pOurType); | 212 This->m_pOurType); |
222 if (result) | 213 if (result) |
223 { | 214 { |
224 printf("Error connecting to input pin\n"); | 215 em = "could not connect to input pin"; |
225 break; | 216 break; |
226 } | 217 } |
227 | 218 |
228 This->m_pOurOutput = COutputPinCreate(This->m_pDestType); | 219 This->m_pOurOutput = COutputPinCreate(This->m_pDestType); |
229 | 220 |
230 result = This->m_pOutputPin->vt->ReceiveConnection(This->m_pOutputPin, | 221 result = This->m_pOutputPin->vt->ReceiveConnection(This->m_pOutputPin, |
231 (IPin*) This->m_pOurOutput, | 222 (IPin*) This->m_pOurOutput, |
232 This->m_pDestType); | 223 This->m_pDestType); |
233 if (result) | 224 if (result) |
234 { | 225 { |
235 //printf("Tracking ACELP %d 0%x\n", result); | 226 em = "could not connect to output pin"; |
236 printf("Error connecting to output pin\n"); | |
237 break; | 227 break; |
238 } | 228 } |
239 | 229 |
240 printf("Using DirectShow codec: %s\n", dllname); | 230 printf("Using DirectShow codec: %s\n", dllname); |
241 This->m_iState = 1; | 231 init++; |
242 break; | 232 break; |
243 } | 233 } |
244 | 234 |
245 if (This->m_iState != 1) | 235 if (!init) |
246 { | 236 { |
247 DS_Filter_Destroy(This); | 237 DS_Filter_Destroy(This); |
238 printf("Warning: DS_Filter() %s. (DLL=%.200s)\n", em, dllname); | |
248 This = 0; | 239 This = 0; |
249 } | 240 } |
250 return This; | 241 return This; |
251 } | 242 } |