annotate loader/dshow/DS_Filter.c @ 16647:e26e80f3031c

synced with 1.30
author gabrov
date Mon, 03 Oct 2005 12:00:28 +0000
parents f5537cc95b02
children 0783dd397f74
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15166
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 9967
diff changeset
1 /*
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 9967
diff changeset
2 * Modified for use with MPlayer, detailed CVS changelog at
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 9967
diff changeset
3 * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 9967
diff changeset
4 * $Id$
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 9967
diff changeset
5 */
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 9967
diff changeset
6
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
7 #include "config.h"
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
8 #include "DS_Filter.h"
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
9 #include "driver.h"
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
10 #include "com.h"
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
11 #include <stdio.h>
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
12 #include <string.h>
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
13 #include <stdlib.h>
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
14 #include "win32.h" // printf macro
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
15
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
16 typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**);
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
17
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
18 #ifndef WIN32_LOADER
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
19 const GUID IID_IUnknown =
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
20 {
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
21 0x00000000, 0x0000, 0x0000,
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
22 {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
23 };
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
24 const GUID IID_IClassFactory =
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
25 {
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
26 0x00000001, 0x0000, 0x0000,
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
27 {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
28 };
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
29
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
30 HRESULT STDCALL CoInitialize(LPVOID pvReserved);
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
31 void STDCALL CoUninitialize(void);
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
32 #endif
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
33
8292
9533c26c0806 avifile sync (mostly cosmetics)
arpi
parents: 7472
diff changeset
34 //void trapbug();
244
1c3029be6713 Setup_FS fix for directshow
arpi_esp
parents: 168
diff changeset
35
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
36 static void DS_Filter_Start(DS_Filter* This)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
37 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
38 HRESULT hr;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
39
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
40 if (This->m_pAll)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
41 return;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
42
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
43 //Debug printf("DS_Filter_Start(%p)\n", This);
8292
9533c26c0806 avifile sync (mostly cosmetics)
arpi
parents: 7472
diff changeset
44 hr = This->m_pFilter->vt->Run(This->m_pFilter, (REFERENCE_TIME)0);
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
45 if (hr != 0)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
46 {
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
47 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
48 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
49 hr = This->m_pImp->vt->GetAllocator(This->m_pImp, &This->m_pAll);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
50
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
51 if (hr || !This->m_pAll)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
52 {
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
53 Debug printf("WARNING: error getting IMemAllocator interface %x\n", (int)hr);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
54 This->m_pImp->vt->Release((IUnknown*)This->m_pImp);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
55 return;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
56 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
57 This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
58 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
59
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
60 static void DS_Filter_Stop(DS_Filter* This)
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
61 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
62 if (This->m_pAll)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
63 {
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
64 //Debug printf("DS_Filter_Stop(%p)\n", This);
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
65 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
66 This->m_pAll->vt->Release((IUnknown*)This->m_pAll);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
67 This->m_pAll = 0;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
68 }
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
69 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
70
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
71 void DS_Filter_Destroy(DS_Filter* This)
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
72 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
73 This->Stop(This);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
74
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
75 if (This->m_pOurInput)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
76 This->m_pOurInput->vt->Release((IUnknown*)This->m_pOurInput);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
77 if (This->m_pInputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
78 This->m_pInputPin->vt->Disconnect(This->m_pInputPin);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
79 if (This->m_pOutputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
80 This->m_pOutputPin->vt->Disconnect(This->m_pOutputPin);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
81 if (This->m_pFilter)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
82 This->m_pFilter->vt->Release((IUnknown*)This->m_pFilter);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
83 if (This->m_pOutputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
84 This->m_pOutputPin->vt->Release((IUnknown*)This->m_pOutputPin);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
85 if (This->m_pInputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
86 This->m_pInputPin->vt->Release((IUnknown*)This->m_pInputPin);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
87 if (This->m_pImp)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
88 This->m_pImp->vt->Release((IUnknown*)This->m_pImp);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
89
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
90 if (This->m_pOurOutput)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
91 This->m_pOurOutput->vt->Release((IUnknown*)This->m_pOurOutput);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
92 if (This->m_pParentFilter)
3130
623cdb771e97 avifile sync. seems to some bugs fixed...
arpi
parents: 3056
diff changeset
93 This->m_pParentFilter->vt->Release((IUnknown*)This->m_pParentFilter);
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
94 if (This->m_pSrcFilter)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
95 This->m_pSrcFilter->vt->Release((IUnknown*)This->m_pSrcFilter);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
96
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
97 // FIXME - we are still leaving few things allocated!
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
98 if (This->m_iHandle)
8292
9533c26c0806 avifile sync (mostly cosmetics)
arpi
parents: 7472
diff changeset
99 FreeLibrary((unsigned)This->m_iHandle);
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
100
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
101 free(This);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
102
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
103 #ifdef WIN32_LOADER
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
104 CodecRelease();
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
105 #else
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
106 CoUninitialize();
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
107 #endif
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
108 }
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
109
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
110 DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
111 AM_MEDIA_TYPE* in_fmt,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
112 AM_MEDIA_TYPE* out_fmt)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
113 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
114 int init = 0;
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7386
diff changeset
115 // char eb[250];
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
116 const char* em = NULL;
8292
9533c26c0806 avifile sync (mostly cosmetics)
arpi
parents: 7472
diff changeset
117 HRESULT result;
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
118 DS_Filter* This = (DS_Filter*) malloc(sizeof(DS_Filter));
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
119 if (!This)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
120 return NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
121
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
122 #ifdef WIN32_LOADER
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
123 CodecAlloc();
9967
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
124 #else
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
125 CoInitialize(0L);
b0d1b415320c cygwin support patch by Sascha Sommer and some fixes by me
alex
parents: 8292
diff changeset
126 #endif
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
127
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
128 This->m_pFilter = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
129 This->m_pInputPin = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
130 This->m_pOutputPin = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
131 This->m_pSrcFilter = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
132 This->m_pParentFilter = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
133 This->m_pOurInput = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
134 This->m_pOurOutput = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
135 This->m_pAll = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
136 This->m_pImp = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
137
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
138 This->Start = DS_Filter_Start;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
139 This->Stop = DS_Filter_Stop;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
140
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
141 for (;;)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
142 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
143 GETCLASS func;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
144 struct IClassFactory* factory = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
145 struct IUnknown* object = NULL;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
146 IEnumPins* enum_pins = 0;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
147 IPin* array[256];
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
148 ULONG fetched;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
149 unsigned int i;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
150
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
151 This->m_iHandle = LoadLibraryA(dllname);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
152 if (!This->m_iHandle)
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
153 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
154 em = "could not open DirectShow DLL";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
155 break;
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
156 }
8292
9533c26c0806 avifile sync (mostly cosmetics)
arpi
parents: 7472
diff changeset
157 func = (GETCLASS)GetProcAddress((unsigned)This->m_iHandle, "DllGetClassObject");
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
158 if (!func)
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
159 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
160 em = "illegal or corrupt DirectShow DLL";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
161 break;
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
162 }
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
163 result = func(id, &IID_IClassFactory, (void**)&factory);
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
164 if (result || !factory)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
165 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
166 em = "no such class object";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
167 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
168 }
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
169 result = factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
170 factory->vt->Release((IUnknown*)factory);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
171 if (result || !object)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
172 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
173 em = "class factory failure";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
174 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
175 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
176 result = object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&This->m_pFilter);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
177 object->vt->Release((IUnknown*)object);
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
178 if (result || !This->m_pFilter)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
179 {
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
180 em = "object does not provide IBaseFilter interface";
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 // enumerate pins
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
184 result = This->m_pFilter->vt->EnumPins(This->m_pFilter, &enum_pins);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
185 if (result || !enum_pins)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
186 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
187 em = "could not enumerate pins";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
188 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
189 }
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
190
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
191 enum_pins->vt->Reset(enum_pins);
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
192 result = enum_pins->vt->Next(enum_pins, (ULONG)256, (IPin**)array, &fetched);
8292
9533c26c0806 avifile sync (mostly cosmetics)
arpi
parents: 7472
diff changeset
193 Debug printf("Pins enumeration returned %ld pins, error is %x\n", fetched, (int)result);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
194
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
195 for (i = 0; i < fetched; i++)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
196 {
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
197 int direction = -1;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
198 array[i]->vt->QueryDirection(array[i], (PIN_DIRECTION*)&direction);
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
199 if (!This->m_pInputPin && direction == 0)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
200 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
201 This->m_pInputPin = array[i];
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
202 This->m_pInputPin->vt->AddRef((IUnknown*)This->m_pInputPin);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
203 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
204 if (!This->m_pOutputPin && direction == 1)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
205 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
206 This->m_pOutputPin = array[i];
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
207 This->m_pOutputPin->vt->AddRef((IUnknown*)This->m_pOutputPin);
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
208 }
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
209 array[i]->vt->Release((IUnknown*)(array[i]));
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
210 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
211 if (!This->m_pInputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
212 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
213 em = "could not find input pin";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
214 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
215 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
216 if (!This->m_pOutputPin)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
217 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
218 em = "could not find output pin";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
219 break;
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_pInputPin->vt->QueryInterface((IUnknown*)This->m_pInputPin,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
222 &IID_IMemInputPin,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
223 (void**)&This->m_pImp);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
224 if (result)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
225 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
226 em = "could not get IMemInputPin interface";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
227 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
228 }
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
229
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
230 This->m_pOurType = in_fmt;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
231 This->m_pDestType = out_fmt;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
232 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
233 if (result)
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
234 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
235 em = "source format is not accepted";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
236 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
237 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
238 This->m_pParentFilter = CBaseFilter2Create();
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
239 This->m_pSrcFilter = CBaseFilterCreate(This->m_pOurType, This->m_pParentFilter);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
240 This->m_pOurInput = This->m_pSrcFilter->GetPin(This->m_pSrcFilter);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
241 This->m_pOurInput->vt->AddRef((IUnknown*)This->m_pOurInput);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
242
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
243 result = This->m_pInputPin->vt->ReceiveConnection(This->m_pInputPin,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
244 This->m_pOurInput,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
245 This->m_pOurType);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
246 if (result)
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
247 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
248 em = "could not connect to input pin";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
249 break;
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
250 }
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
251
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
252 This->m_pOurOutput = COutputPinCreate(This->m_pDestType);
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
253
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
254 result = This->m_pOutputPin->vt->ReceiveConnection(This->m_pOutputPin,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
255 (IPin*) This->m_pOurOutput,
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
256 This->m_pDestType);
713
9355b2ae634e avifile-0.6-CVS merge
arpi_esp
parents: 342
diff changeset
257 if (result)
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
258 {
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
259 em = "could not connect to output pin";
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
260 break;
1545
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
261 }
da26060c81ef big avifile sync - from now we have common code
arpi
parents: 1525
diff changeset
262
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
263 init++;
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
264 break;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
265 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
266
3467
e3bbf44dbab2 avifile sync
arpi
parents: 3130
diff changeset
267 if (!init)
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
268 {
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
269 DS_Filter_Destroy(This);
8292
9533c26c0806 avifile sync (mostly cosmetics)
arpi
parents: 7472
diff changeset
270 printf("Warning: DS_Filter() %s. (DLL=%.200s, r=0x%x)\n", em, dllname, result);
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
271 This = 0;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
272 }
3056
213b35f84cf3 C++ -> C (import from avifile cvs)
arpi
parents: 2580
diff changeset
273 return This;
168
bdc4a8fc04d8 Initial revision
arpi_esp
parents:
diff changeset
274 }