annotate loader/dshow/DS_Filter.c @ 5692:8bfa2ecbcab9

Fix non-interactive install issue, based on report from Jens
author eyck
date Thu, 18 Apr 2002 22:34:45 +0000
parents e3bbf44dbab2
children 4b0dd1ff6a20
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
1 #include "DS_Filter.h"
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
2 #include "driver.h"
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
3 #include "com.h"
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
4 #include <stdio.h>
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
5 #include <string.h>
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
6
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
7 typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**);
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
8
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
9 //extern "C" STDCALL void* GetProcAddress(int, const char*); // STDCALL has to be first NetBSD
244
1c3029be6713 Setup_FS fix for directshow
arpi_esp
parents: 168
diff changeset
10
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
11 static void DS_Filter_Start(DS_Filter* This)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
12 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
13 HRESULT hr;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
14
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
15 if (This->m_pAll)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
16 return;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
17
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
18 //Debug printf("DS_Filter_Start(%p)\n", This);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
19 hr = This->m_pFilter->vt->Run(This->m_pFilter, 0);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
20 if (hr != 0)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
21 {
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
22 Debug printf("WARNING: m_Filter->Run() failed, error code %x\n", (int)hr);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
23 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
24 hr = This->m_pImp->vt->GetAllocator(This->m_pImp, &This->m_pAll);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
25
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
26 if (hr || !This->m_pAll)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
27 {
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
28 Debug printf("WARNING: error getting IMemAllocator interface %x\n", (int)hr);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
29 This->m_pImp->vt->Release((IUnknown*)This->m_pImp);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
30 return;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
31 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
32 This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
33 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
34
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
35 static void DS_Filter_Stop(DS_Filter* This)
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
36 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
37 if (This->m_pAll)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
38 {
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
39 //Debug printf("DS_Filter_Stop(%p)\n", This);
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
40 This->m_pFilter->vt->Stop(This->m_pFilter); // causes weird crash ??? FIXME
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
41 This->m_pAll->vt->Release((IUnknown*)This->m_pAll);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
42 This->m_pAll = 0;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
43 }
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
44 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
45
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
46 void DS_Filter_Destroy(DS_Filter* This)
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
47 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
48 This->Stop(This);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
49
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
50 if (This->m_pOurInput)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
51 This->m_pOurInput->vt->Release((IUnknown*)This->m_pOurInput);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
52 if (This->m_pInputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
53 This->m_pInputPin->vt->Disconnect(This->m_pInputPin);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
54 if (This->m_pOutputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
55 This->m_pOutputPin->vt->Disconnect(This->m_pOutputPin);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
56 if (This->m_pFilter)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
57 This->m_pFilter->vt->Release((IUnknown*)This->m_pFilter);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
58 if (This->m_pOutputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
59 This->m_pOutputPin->vt->Release((IUnknown*)This->m_pOutputPin);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
60 if (This->m_pInputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
61 This->m_pInputPin->vt->Release((IUnknown*)This->m_pInputPin);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
62 if (This->m_pImp)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
63 This->m_pImp->vt->Release((IUnknown*)This->m_pImp);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
64
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
65 if (This->m_pOurOutput)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
66 This->m_pOurOutput->vt->Release((IUnknown*)This->m_pOurOutput);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
67 if (This->m_pParentFilter)
3130
623cdb771e97 avifile sync. seems to some bugs fixed...
arpi
parents: 3056
diff changeset
68 This->m_pParentFilter->vt->Release((IUnknown*)This->m_pParentFilter);
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
69 if (This->m_pSrcFilter)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
70 This->m_pSrcFilter->vt->Release((IUnknown*)This->m_pSrcFilter);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
71
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
72 // FIXME - we are still leaving few things allocated!
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
73 if (This->m_iHandle)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
74 FreeLibrary(This->m_iHandle);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
75
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
76 free(This);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
77
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
78 CodecRelease();
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
79 }
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
80
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
81 DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
82 AM_MEDIA_TYPE* in_fmt,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
83 AM_MEDIA_TYPE* out_fmt)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
84 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
85 int init = 0;
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
86 char eb[250];
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
87 const char* em = NULL;
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
88 DS_Filter* This = (DS_Filter*) malloc(sizeof(DS_Filter));
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
89 if (!This)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
90 return NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
91
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
92 CodecAlloc();
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
93
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
94 This->m_pFilter = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
95 This->m_pInputPin = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
96 This->m_pOutputPin = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
97 This->m_pSrcFilter = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
98 This->m_pParentFilter = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
99 This->m_pOurInput = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
100 This->m_pOurOutput = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
101 This->m_pAll = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
102 This->m_pImp = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
103
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
104 This->Start = DS_Filter_Start;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
105 This->Stop = DS_Filter_Stop;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
106
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
107 for (;;)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
108 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
109 HRESULT result;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
110 GETCLASS func;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
111 struct IClassFactory* factory = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
112 struct IUnknown* object = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
113 IEnumPins* enum_pins = 0;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
114 IPin* array[256];
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
115 ULONG fetched;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
116 unsigned int i;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
117
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
118 This->m_iHandle = LoadLibraryA(dllname);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
119 if (!This->m_iHandle)
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
120 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
121 em = "could not open DirectShow DLL";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
122 break;
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
123 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
124 func = (GETCLASS)GetProcAddress(This->m_iHandle, "DllGetClassObject");
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
125 if (!func)
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
126 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
127 em = "illegal or corrupt DirectShow DLL";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
128 break;
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
129 }
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
130 result = func(id, &IID_IClassFactory, (void**)&factory);
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
131 if (result || !factory)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
132 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
133 em = "no such class object";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
134 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
135 }
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
136 result = factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
137 factory->vt->Release((IUnknown*)factory);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
138 if (result || !object)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
139 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
140 em = "class factory failure";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
141 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
142 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
143 result = object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&This->m_pFilter);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
144 object->vt->Release((IUnknown*)object);
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
145 if (result || !This->m_pFilter)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
146 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
147 em = "object does not have IBaseFilter interface";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
148 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
149 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
150 // enumerate pins
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
151 result = This->m_pFilter->vt->EnumPins(This->m_pFilter, &enum_pins);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
152 if (result || !enum_pins)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
153 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
154 em = "could not enumerate pins";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
155 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
156 }
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
157
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
158 enum_pins->vt->Reset(enum_pins);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
159 result = enum_pins->vt->Next(enum_pins, (ULONG)256, (IPin**)array, &fetched);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
160 Debug printf("Pins enumeration returned %ld pins, error is %x\n", fetched, (int)result);
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
161
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
162 for (i = 0; i < fetched; i++)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
163 {
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
164 int direction = -1;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
165 array[i]->vt->QueryDirection(array[i], (PIN_DIRECTION*)&direction);
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
166 if (!This->m_pInputPin && direction == 0)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
167 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
168 This->m_pInputPin = array[i];
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
169 This->m_pInputPin->vt->AddRef((IUnknown*)This->m_pInputPin);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
170 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
171 if (!This->m_pOutputPin && direction == 1)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
172 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
173 This->m_pOutputPin = array[i];
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
174 This->m_pOutputPin->vt->AddRef((IUnknown*)This->m_pOutputPin);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
175 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
176 array[i]->vt->Release((IUnknown*)(array[i]));
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
177 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
178 if (!This->m_pInputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
179 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
180 em = "could not find input pin";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
181 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
182 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
183 if (!This->m_pOutputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
184 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
185 em = "could not find output pin";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
186 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
187 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
188 result = This->m_pInputPin->vt->QueryInterface((IUnknown*)This->m_pInputPin,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
189 &IID_IMemInputPin,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
190 (void**)&This->m_pImp);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
191 if (result)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
192 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
193 em = "could not get IMemInputPin interface";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
194 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
195 }
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
196
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
197 This->m_pOurType = in_fmt;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
198 This->m_pDestType = out_fmt;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
199 result = This->m_pInputPin->vt->QueryAccept(This->m_pInputPin, This->m_pOurType);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
200 if (result)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
201 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
202 em = "source format is not accepted";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
203 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
204 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
205 This->m_pParentFilter = CBaseFilter2Create();
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
206 This->m_pSrcFilter = CBaseFilterCreate(This->m_pOurType, This->m_pParentFilter);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
207 This->m_pOurInput = This->m_pSrcFilter->GetPin(This->m_pSrcFilter);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
208 This->m_pOurInput->vt->AddRef((IUnknown*)This->m_pOurInput);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
209
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
210 result = This->m_pInputPin->vt->ReceiveConnection(This->m_pInputPin,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
211 This->m_pOurInput,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
212 This->m_pOurType);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
213 if (result)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
214 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
215 em = "could not connect to input pin";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
216 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
217 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
218
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
219 This->m_pOurOutput = COutputPinCreate(This->m_pDestType);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
220
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
221 result = This->m_pOutputPin->vt->ReceiveConnection(This->m_pOutputPin,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
222 (IPin*) This->m_pOurOutput,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
223 This->m_pDestType);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
224 if (result)
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
225 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
226 em = "could not connect to output pin";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
227 break;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
228 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
229
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
230 printf("Using DirectShow codec: %s\n", dllname);
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
231 init++;
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
232 break;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
233 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
234
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
235 if (!init)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
236 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
237 DS_Filter_Destroy(This);
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
238 printf("Warning: DS_Filter() %s. (DLL=%.200s)\n", em, dllname);
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
239 This = 0;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
240 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
241 return This;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
242 }