comparison loader/dshow/outputpin.c @ 1545:da26060c81ef

big avifile sync - from now we have common code
author arpi
date Thu, 16 Aug 2001 00:50:02 +0000
parents 269780d31b51
children ce45cce7f7a5
comparison
equal deleted inserted replaced
1544:558c1b03b8d0 1545:da26060c81ef
1
2 #include <cstdio>
3 #include <cstring>
4 //#include <string>
5
6 #include "outputpin.h" 1 #include "outputpin.h"
7 #include "allocator.h" 2 #include "allocator.h"
8 #include "iunk.h" 3 #include "iunk.h"
9 4 #include <wine/winerror.h>
10 #define E_NOTIMPL 0x80004001 5 #include <cstdio>
6 #include <cstring>
7
11 /* 8 /*
12 An object beyond interface IEnumMediaTypes. 9 An object beyond interface IEnumMediaTypes.
13 Returned by COutputPin through call IPin::EnumMediaTypes(). 10 Returned by COutputPin through call IPin::EnumMediaTypes().
14 */ 11 */
15 12
16 using namespace std; 13 using namespace std;
17 14
18 class CEnumMediaTypes: public IEnumMediaTypes 15 class CEnumMediaTypes: public IEnumMediaTypes
19 { 16 {
17 public:
20 AM_MEDIA_TYPE type; 18 AM_MEDIA_TYPE type;
21 static GUID interfaces[]; 19 static GUID interfaces[];
22 DECLARE_IUNKNOWN(CEnumMediaTypes) 20 DECLARE_IUNKNOWN(CEnumMediaTypes)
23 public:
24 CEnumMediaTypes(const AM_MEDIA_TYPE&); 21 CEnumMediaTypes(const AM_MEDIA_TYPE&);
25 ~CEnumMediaTypes(){delete vt;} 22 ~CEnumMediaTypes() {delete vt;}
26 static HRESULT STDCALL Next (
27 IEnumMediaTypes * This,
28 /* [in] */ ULONG cMediaTypes,
29 /* [size_is][out] */ AM_MEDIA_TYPE **ppMediaTypes,
30 /* [out] */ ULONG *pcFetched);
31
32 static HRESULT STDCALL Skip (
33 IEnumMediaTypes * This,
34 /* [in] */ ULONG cMediaTypes);
35
36 static HRESULT STDCALL Reset (
37 IEnumMediaTypes * This);
38
39 static HRESULT STDCALL Clone (
40 IEnumMediaTypes * This,
41 /* [out] */ IEnumMediaTypes **ppEnum);
42
43 }; 23 };
24
44 GUID CEnumMediaTypes::interfaces[]= 25 GUID CEnumMediaTypes::interfaces[]=
45 { 26 {
46 IID_IUnknown, 27 IID_IUnknown,
47 IID_IEnumMediaTypes, 28 IID_IEnumMediaTypes,
48 }; 29 };
30
31 // IPin->IUnknown methods
49 IMPLEMENT_IUNKNOWN(CEnumMediaTypes) 32 IMPLEMENT_IUNKNOWN(CEnumMediaTypes)
50 CEnumMediaTypes::CEnumMediaTypes(const AM_MEDIA_TYPE& type) 33
51 :refcount(1) 34
52 { 35 static HRESULT STDCALL CEnumMediaTypes_Next(IEnumMediaTypes * This,
53 this->type=type; 36 /* [in] */ ULONG cMediaTypes,
54 vt=new IEnumMediaTypes_vt; 37 /* [size_is][out] */ AM_MEDIA_TYPE **ppMediaTypes,
38 /* [out] */ ULONG *pcFetched)
39 {
40 AM_MEDIA_TYPE& type=((CEnumMediaTypes*)This)->type;
41 Debug printf("CEnumMediaTypes::Next() called\n");
42 if (!ppMediaTypes)
43 return E_INVALIDARG;
44 if (!pcFetched && (cMediaTypes!=1))
45 return E_INVALIDARG;
46 if (cMediaTypes <= 0)
47 return 0;
48
49 if (pcFetched)
50 *pcFetched=1;
51 ppMediaTypes[0] = (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
52 memcpy(*ppMediaTypes, &type, sizeof(AM_MEDIA_TYPE));
53 if (ppMediaTypes[0]->pbFormat)
54 {
55 ppMediaTypes[0]->pbFormat=(char *)CoTaskMemAlloc(ppMediaTypes[0]->cbFormat);
56 memcpy(ppMediaTypes[0]->pbFormat, type.pbFormat, ppMediaTypes[0]->cbFormat);
57 }
58 if (cMediaTypes == 1)
59 return 0;
60 return 1;
61 }
62
63 /* I expect that these methods are unused. */
64 static HRESULT STDCALL CEnumMediaTypes_Skip(IEnumMediaTypes * This,
65 /* [in] */ ULONG cMediaTypes)
66 {
67 Debug printf("CEnumMediaTypes::Skip() called\n");
68 return E_NOTIMPL;
69 }
70
71 static HRESULT STDCALL CEnumMediaTypes_Reset(IEnumMediaTypes * This)
72 {
73 Debug printf("CEnumMediaTypes::Reset() called\n");
74 return 0;
75 }
76
77 static HRESULT STDCALL CEnumMediaTypes_Clone(IEnumMediaTypes * This,
78 /* [out] */ IEnumMediaTypes **ppEnum)
79 {
80 Debug printf("CEnumMediaTypes::Clone() called\n");
81 return E_NOTIMPL;
82 }
83
84
85 CEnumMediaTypes::CEnumMediaTypes(const AM_MEDIA_TYPE& amtype)
86 {
87 refcount = 1;
88 type = amtype;
89
90 vt = new IEnumMediaTypes_vt;
55 vt->QueryInterface = QueryInterface; 91 vt->QueryInterface = QueryInterface;
56 vt->AddRef = AddRef; 92 vt->AddRef = AddRef;
57 vt->Release = Release; 93 vt->Release = Release;
58 vt->Next = Next; 94 vt->Next = CEnumMediaTypes_Next;
59 vt->Skip = Skip; 95 vt->Skip = CEnumMediaTypes_Skip;
60 vt->Reset = Reset; 96 vt->Reset = CEnumMediaTypes_Reset;
61 vt->Clone = Clone; 97 vt->Clone = CEnumMediaTypes_Clone;
62 } 98 }
63 99
64 HRESULT STDCALL CEnumMediaTypes::Next ( 100
65 IEnumMediaTypes * This, 101 static HRESULT STDCALL COutputPin_AddRef(IUnknown* This)
66 /* [in] */ ULONG cMediaTypes, 102 {
67 /* [size_is][out] */ AM_MEDIA_TYPE **ppMediaTypes, 103 Debug printf("COutputPin_AddRef(%p) called (%d)\n",
68 /* [out] */ ULONG *pcFetched) 104 This, ((COutputPin*)This)->refcount);
69 { 105 ((COutputPin*)This)->refcount++;
70 AM_MEDIA_TYPE& type=((CEnumMediaTypes*)This)->type; 106 return 0;
71 Debug printf("CEnumMediaTypes::Next() called\n"); 107 }
72 if(!ppMediaTypes)return 0x80004003; 108
73 if(!pcFetched && (cMediaTypes!=1))return 0x80004003; 109 static HRESULT STDCALL COutputPin_Release(IUnknown* This)
74 if(cMediaTypes<=0)return 0; 110 {
75 111 Debug printf("COutputPin_Release(%p) called (%d)\n",
76 if(pcFetched)*pcFetched=1; 112 This, ((COutputPin*)This)->refcount);
77 ppMediaTypes[0]=(AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); 113 if (--((COutputPin*)This)->refcount<=0)
78 memcpy(*ppMediaTypes, &type, sizeof(AM_MEDIA_TYPE)); 114 delete (COutputPin*)This;
79 if(ppMediaTypes[0]->pbFormat) 115
80 { 116 return 0;
81 ppMediaTypes[0]->pbFormat=(char *)CoTaskMemAlloc(ppMediaTypes[0]->cbFormat); 117 }
82 memcpy(ppMediaTypes[0]->pbFormat, type.pbFormat, ppMediaTypes[0]->cbFormat); 118
83 } 119 static HRESULT STDCALL COutputPin_M_AddRef(IUnknown* This)
84 if(cMediaTypes==1)return 0; 120 {
85 return 1; 121 COutputMemPin* p = (COutputMemPin*) This;
86 } 122 Debug printf("COutputPin_MAddRef(%p) called (%p, %d)\n",
87 /* 123 p, p->parent, p->parent->refcount);
88 I expect that these methods are unused. 124 p->parent->refcount++;
89 */ 125 return 0;
90 HRESULT STDCALL CEnumMediaTypes::Skip ( 126 }
91 IEnumMediaTypes * This, 127
92 /* [in] */ ULONG cMediaTypes) 128 static HRESULT STDCALL COutputPin_M_Release(IUnknown* This)
93 { 129 {
94 Debug printf("CEnumMediaTypes::Skip() called\n"); 130 COutputMemPin* p = (COutputMemPin*) This;
95 return E_NOTIMPL; 131 Debug printf("COutputPin_MRelease(%p) called (%p, %d)\n",
96 } 132 p, p->parent, p->parent->refcount);
97 133 if (--p->parent->refcount <= 0)
98 HRESULT STDCALL CEnumMediaTypes::Reset ( 134 delete p->parent;
99 IEnumMediaTypes * This) 135 return 0;
100 { 136 }
101 Debug printf("CEnumMediaTypes::Reset() called\n"); 137
102 return 0; 138 /* Implementation of output pin object. */
103 }
104
105 HRESULT STDCALL CEnumMediaTypes::Clone (
106 IEnumMediaTypes * This,
107 /* [out] */ IEnumMediaTypes **ppEnum)
108 {
109 Debug printf("CEnumMediaTypes::Clone() called\n");
110 return E_NOTIMPL;
111 }
112
113 /*
114 Implementation of output pin object.
115 */
116
117 // Constructor 139 // Constructor
118 140
119 COutputPin::COutputPin(const AM_MEDIA_TYPE& vh) :refcount(1), type(vh), remote(0), frame_pointer(0), frame_size_pointer(0) 141
120 { 142 static HRESULT STDCALL COutputPin_QueryInterface(IUnknown* This, GUID* iid, void** ppv)
121 IPin::vt = new IPin_vt; 143 {
122 IPin::vt->QueryInterface = QueryInterface; 144 Debug printf("COutputPin_QueryInterface(%p) called\n", This);
123 IPin::vt->AddRef = AddRef; 145 if (!ppv)
124 IPin::vt->Release = Release; 146 return E_INVALIDARG;
125 IPin::vt->Connect = Connect; 147
126 IPin::vt->ReceiveConnection = ReceiveConnection; 148 COutputPin* p = (COutputPin*) This;
127 IPin::vt->Disconnect=Disconnect; 149
128 IPin::vt->ConnectedTo = ConnectedTo; 150 if (memcmp(iid, &IID_IUnknown, 16) == 0)
129 IPin::vt->ConnectionMediaType = ConnectionMediaType; 151 {
130 IPin::vt->QueryPinInfo = QueryPinInfo; 152 *ppv = p;
131 IPin::vt->QueryDirection = QueryDirection; 153 p->vt->AddRef(This);
132 IPin::vt->QueryId = QueryId; 154 return 0;
133 IPin::vt->QueryAccept = QueryAccept; 155 }
134 IPin::vt->EnumMediaTypes = EnumMediaTypes; 156 if (memcmp(iid, &IID_IMemInputPin, 16) == 0)
135 IPin::vt->QueryInternalConnections = QueryInternalConnections; 157 {
136 IPin::vt->EndOfStream = EndOfStream; 158 *ppv = p->mempin;
137 IPin::vt->BeginFlush = BeginFlush; 159 p->mempin->vt->AddRef((IUnknown*)*ppv);
138 IPin::vt->EndFlush = EndFlush;
139 IPin::vt->NewSegment = NewSegment;
140
141 IMemInputPin::vt=new IMemInputPin_vt;
142 IMemInputPin::vt->QueryInterface = M_QueryInterface;
143 IMemInputPin::vt->AddRef = M_AddRef;
144 IMemInputPin::vt->Release = M_Release;
145 IMemInputPin::vt->GetAllocator = GetAllocator;
146 IMemInputPin::vt->NotifyAllocator = NotifyAllocator;
147 IMemInputPin::vt->GetAllocatorRequirements = GetAllocatorRequirements;
148 IMemInputPin::vt->Receive = Receive;
149 IMemInputPin::vt->ReceiveMultiple = ReceiveMultiple;
150 IMemInputPin::vt->ReceiveCanBlock = ReceiveCanBlock;
151
152 pAllocator = 0;
153 frame_pointer = 0;
154 }
155
156 COutputPin::~COutputPin()
157 {
158 delete IPin::vt;
159 delete IMemInputPin::vt;
160 }
161
162 // IPin->IUnknown methods
163
164 HRESULT STDCALL COutputPin::QueryInterface(IUnknown* This, GUID* iid, void** ppv)
165 {
166 Debug printf("COutputPin::QueryInterface() called\n");
167 if(!ppv)return 0x80004003;
168 if(!memcmp(iid, &IID_IUnknown, 16))
169 {
170 *ppv=(void*)This;
171 This->vt->AddRef(This);
172 return 0;
173 }
174 if(!memcmp(iid, &IID_IMemInputPin, 16))
175 {
176 *ppv=(void*)(This+1);
177 This->vt->AddRef(This);
178 return 0; 160 return 0;
179 } 161 }
180 162
181 Debug printf("Unknown interface : %08x-%04x-%04x-%02x%02x-" \ 163 Debug printf("Unknown interface : %08x-%04x-%04x-%02x%02x-" \
182 "%02x%02x%02x%02x%02x%02x\n", 164 "%02x%02x%02x%02x%02x%02x\n",
183 iid->f1, iid->f2, iid->f3, 165 iid->f1, iid->f2, iid->f3,
184 (unsigned char)iid->f4[1], (unsigned char)iid->f4[0], 166 (unsigned char)iid->f4[1], (unsigned char)iid->f4[0],
185 (unsigned char)iid->f4[2], (unsigned char)iid->f4[3], 167 (unsigned char)iid->f4[2], (unsigned char)iid->f4[3],
186 (unsigned char)iid->f4[4], (unsigned char)iid->f4[5], 168 (unsigned char)iid->f4[4], (unsigned char)iid->f4[5],
187 (unsigned char)iid->f4[6], (unsigned char)iid->f4[7]); 169 (unsigned char)iid->f4[6], (unsigned char)iid->f4[7]);
188 return 0x80004002; 170 return E_NOINTERFACE;
189 }
190
191 HRESULT STDCALL COutputPin::AddRef(IUnknown* This)
192 {
193 Debug printf("COutputPin::AddRef() called\n");
194 ((COutputPin*)This)->refcount++;
195 return 0;
196 }
197
198 HRESULT STDCALL COutputPin::Release(IUnknown* This)
199 {
200 Debug printf("COutputPin::Release() called\n");
201 if(--((COutputPin*)This)->refcount==0)
202 delete (COutputPin*)This;
203 return 0;
204 } 171 }
205 172
206 // IPin methods 173 // IPin methods
207 174 static HRESULT STDCALL COutputPin_Connect(IPin * This,
208 HRESULT STDCALL COutputPin::Connect ( 175 /* [in] */ IPin *pReceivePin,
209 IPin * This, 176 /* [in] */ /* const */ AM_MEDIA_TYPE *pmt)
210 /* [in] */ IPin *pReceivePin, 177 {
211 /* [in] */ /* const */ AM_MEDIA_TYPE *pmt) 178 Debug printf("COutputPin_Connect() called\n");
212 {
213 Debug printf("COutputPin::Connect() called\n");
214 /* 179 /*
215 *pmt=((COutputPin*)This)->type; 180 *pmt=((COutputPin*)This)->type;
216 if(pmt->cbFormat>0) 181 if(pmt->cbFormat>0)
217 { 182 {
218 pmt->pbFormat=CoTaskMemAlloc(pmt->cbFormat); 183 pmt->pbFormat=CoTaskMemAlloc(pmt->cbFormat);
219 memcpy(pmt->pbFormat, ((COutputPin*)This)->type.pbFormat, pmt->cbFormat); 184 memcpy(pmt->pbFormat, ((COutputPin*)This)->type.pbFormat, pmt->cbFormat);
220 } 185 }
221 */ 186 */
222 return E_NOTIMPL; 187 //return E_NOTIMPL;
188 return 0;// XXXXXXXXXXXXX CHECKME XXXXXXXXXXXXXXX
223 // if I put return 0; here, it crashes 189 // if I put return 0; here, it crashes
224 } 190 }
225 191
226 HRESULT STDCALL COutputPin::ReceiveConnection ( 192 static HRESULT STDCALL COutputPin_ReceiveConnection(IPin * This,
227 IPin * This, 193 /* [in] */ IPin *pConnector,
228 /* [in] */ IPin *pConnector, 194 /* [in] */ const AM_MEDIA_TYPE *pmt)
229 /* [in] */ const AM_MEDIA_TYPE *pmt) 195 {
230 { 196 Debug printf("COutputPin_ReceiveConnection() called\n");
231 Debug printf("COutputPin::ReceiveConnection() called\n");
232 ((COutputPin*)This)->remote=pConnector; 197 ((COutputPin*)This)->remote=pConnector;
233 return 0; 198 return 0;
234 } 199 }
235 200
236 HRESULT STDCALL COutputPin::Disconnect ( 201 static HRESULT STDCALL COutputPin_Disconnect(IPin * This)
237 IPin * This) 202 {
238 { 203 Debug printf("COutputPin_Disconnect() called\n");
239 Debug printf("COutputPin::Disconnect() called\n");
240 return 1; 204 return 1;
241 } 205 }
242 206
243 207 static HRESULT STDCALL COutputPin_ConnectedTo(IPin * This,
244 HRESULT STDCALL COutputPin::ConnectedTo ( 208 /* [out] */ IPin **pPin)
245 IPin * This, 209 {
246 /* [out] */ IPin **pPin) 210 Debug printf("COutputPin_ConnectedTo() called\n");
247 { 211 if (!pPin)
248 Debug printf("COutputPin::ConnectedTo() called\n"); 212 return E_INVALIDARG;
249 if(!pPin)return 0x80004003; 213 *pPin = ((COutputPin*)This)->remote;
250 *pPin=((COutputPin*)This)->remote; 214 return 0;
251 return 0; 215 }
252 } 216
253 217 static HRESULT STDCALL COutputPin_ConnectionMediaType(IPin * This,
254 218 /* [out] */ AM_MEDIA_TYPE *pmt)
255
256 HRESULT STDCALL COutputPin::ConnectionMediaType (
257 IPin * This,
258 /* [out] */ AM_MEDIA_TYPE *pmt)
259 { 219 {
260 Debug printf("CInputPin::ConnectionMediaType() called\n"); 220 Debug printf("CInputPin::ConnectionMediaType() called\n");
261 if(!pmt)return 0x80004003; 221 if (!pmt)
262 *pmt=((COutputPin*)This)->type; 222 return E_INVALIDARG;
263 if(pmt->cbFormat>0) 223 *pmt = ((COutputPin*)This)->type;
224 if (pmt->cbFormat>0)
264 { 225 {
265 pmt->pbFormat=(char *)CoTaskMemAlloc(pmt->cbFormat); 226 pmt->pbFormat=(char *)CoTaskMemAlloc(pmt->cbFormat);
266 memcpy(pmt->pbFormat, ((COutputPin*)This)->type.pbFormat, pmt->cbFormat); 227 memcpy(pmt->pbFormat, ((COutputPin*)This)->type.pbFormat, pmt->cbFormat);
267 } 228 }
268 return 0; 229 return 0;
269 } 230 }
270 231
271 HRESULT STDCALL COutputPin::QueryPinInfo ( 232 static HRESULT STDCALL COutputPin_QueryPinInfo(IPin * This,
272 IPin * This, 233 /* [out] */ PIN_INFO *pInfo)
273 /* [out] */ PIN_INFO *pInfo) 234 {
274 { 235 Debug printf("COutputPin_QueryPinInfo() called\n");
275 Debug printf("COutputPin::QueryPinInfo() called\n"); 236 return E_NOTIMPL;
276 return E_NOTIMPL; 237 }
277 } 238
278 239 static HRESULT STDCALL COutputPin_QueryDirection(IPin * This,
279 240 /* [out] */ PIN_DIRECTION *pPinDir)
280 HRESULT STDCALL COutputPin::QueryDirection ( 241 {
281 IPin * This, 242 Debug printf("COutputPin_QueryDirection() called\n");
282 /* [out] */ PIN_DIRECTION *pPinDir) 243 if (!pPinDir)
283 { 244 return E_INVALIDARG;
284 Debug printf("COutputPin::QueryDirection() called\n"); 245 *pPinDir = PINDIR_INPUT;
285 if(!pPinDir)return -1; 246 return 0;
286 *pPinDir=PINDIR_INPUT; 247 }
287 return 0; 248
288 } 249 static HRESULT STDCALL COutputPin_QueryId(IPin * This,
289 250 /* [out] */ LPWSTR *Id)
290 251 {
291 HRESULT STDCALL COutputPin::QueryId ( 252 Debug printf("COutputPin_QueryId() called\n");
292 IPin * This, 253 return E_NOTIMPL;
293 /* [out] */ LPWSTR *Id) 254 }
294 { 255
295 Debug printf("COutputPin::QueryId() called\n"); 256 static HRESULT STDCALL COutputPin_QueryAccept(IPin * This,
296 return E_NOTIMPL; 257 /* [in] */ const AM_MEDIA_TYPE *pmt)
297 } 258 {
298 259 Debug printf("COutputPin_QueryAccept() called\n");
299 HRESULT STDCALL COutputPin::QueryAccept ( 260 return E_NOTIMPL;
300 IPin * This, 261 }
301 /* [in] */ const AM_MEDIA_TYPE *pmt) 262
302 { 263 static HRESULT STDCALL COutputPin_EnumMediaTypes(IPin * This,
303 Debug printf("COutputPin::QueryAccept() called\n"); 264 /* [out] */ IEnumMediaTypes **ppEnum)
304 return E_NOTIMPL; 265 {
305 } 266 Debug printf("COutputPin_EnumMediaTypes() called\n");
306 267 if (!ppEnum)
307 268 return E_INVALIDARG;
308 HRESULT STDCALL COutputPin::EnumMediaTypes (
309 IPin * This,
310 /* [out] */ IEnumMediaTypes **ppEnum)
311 {
312 Debug printf("COutputPin::EnumMediaTypes() called\n");
313 if(!ppEnum)return 0x80004003;
314 *ppEnum=new CEnumMediaTypes(((COutputPin*)This)->type); 269 *ppEnum=new CEnumMediaTypes(((COutputPin*)This)->type);
315 return 0; 270 return 0;
316 } 271 }
317 272
318 273 static HRESULT STDCALL COutputPin_QueryInternalConnections(IPin * This,
319 HRESULT STDCALL COutputPin::QueryInternalConnections ( 274 /* [out] */ IPin **apPin,
320 IPin * This, 275 /* [out][in] */ ULONG *nPin)
321 /* [out] */ IPin **apPin, 276 {
322 /* [out][in] */ ULONG *nPin) 277 Debug printf("COutputPin_QueryInternalConnections() called\n");
323 { 278 return E_NOTIMPL;
324 Debug printf("COutputPin::QueryInternalConnections() called\n"); 279 }
325 return E_NOTIMPL; 280
326 } 281 static HRESULT STDCALL COutputPin_EndOfStream(IPin * This)
327 282 {
328 HRESULT STDCALL COutputPin::EndOfStream ( 283 Debug printf("COutputPin_EndOfStream() called\n");
329 IPin * This) 284 return E_NOTIMPL;
330 { 285 }
331 Debug printf("COutputPin::EndOfStream() called\n"); 286
332 return E_NOTIMPL; 287 static HRESULT STDCALL COutputPin_BeginFlush(IPin * This)
333 } 288 {
334 289 Debug printf("COutputPin_BeginFlush() called\n");
335 290 return E_NOTIMPL;
336 HRESULT STDCALL COutputPin::BeginFlush ( 291 }
337 IPin * This) 292
338 { 293 static HRESULT STDCALL COutputPin_EndFlush(IPin * This)
339 Debug printf("COutputPin::BeginFlush() called\n"); 294 {
340 return E_NOTIMPL; 295 Debug printf("COutputPin_EndFlush() called\n");
341 } 296 return E_NOTIMPL;
342 297 }
343 298
344 HRESULT STDCALL COutputPin::EndFlush ( 299 static HRESULT STDCALL COutputPin_NewSegment(IPin * This,
345 IPin * This) 300 /* [in] */ REFERENCE_TIME tStart,
346 { 301 /* [in] */ REFERENCE_TIME tStop,
347 Debug printf("COutputPin::EndFlush() called\n"); 302 /* [in] */ double dRate)
348 return E_NOTIMPL; 303 {
349 } 304 Debug printf("COutputPin_NewSegment(%ld,%ld,%f) called\n",
350 305 tStart, tStop, dRate);
351 HRESULT STDCALL COutputPin::NewSegment ( 306 return 0;
352 IPin * This, 307 }
353 /* [in] */ REFERENCE_TIME tStart,
354 /* [in] */ REFERENCE_TIME tStop,
355 /* [in] */ double dRate)
356 {
357 Debug printf("COutputPin::NewSegment(%ld,%ld,%f) called\n",tStart,tStop,dRate);
358 return 0;
359 }
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375 308
376 309
377 310
378 // IMemInputPin->IUnknown methods 311 // IMemInputPin->IUnknown methods
379 312
380 HRESULT STDCALL COutputPin::M_QueryInterface(IUnknown* This, GUID* iid, void** ppv) 313 static HRESULT STDCALL COutputPin_M_QueryInterface(IUnknown* This, GUID* iid, void** ppv)
381 { 314 {
382 Debug printf("COutputPin::QueryInterface() called\n"); 315 Debug printf("COutputPin_M_QueryInterface() called\n");
383 if(!ppv)return 0x80004003; 316 if (!ppv)
317 return E_INVALIDARG;
318
319 COutputPin* p = (COutputPin*)This;
384 if(!memcmp(iid, &IID_IUnknown, 16)) 320 if(!memcmp(iid, &IID_IUnknown, 16))
321 {
322 *ppv=p;
323 p->vt->AddRef(This);
324 return 0;
325 }
326 /*if(!memcmp(iid, &IID_IPin, 16))
385 { 327 {
386 COutputPin* ptr=(COutputPin*)(This-1); 328 COutputPin* ptr=(COutputPin*)(This-1);
387 *ppv=(void*)ptr; 329 *ppv=(void*)ptr;
388 AddRef((IUnknown*)ptr); 330 AddRef((IUnknown*)ptr);
389 return 0; 331 return 0;
390 }
391 /* if(!memcmp(iid, &IID_IPin, 16))
392 {
393 COutputPin* ptr=(COutputPin*)(This-1);
394 *ppv=(void*)ptr;
395 AddRef((IUnknown*)ptr);
396 return 0;
397 }*/ 332 }*/
398 if(!memcmp(iid, &IID_IMemInputPin, 16)) 333 if(!memcmp(iid, &IID_IMemInputPin, 16))
399 { 334 {
400 *ppv=(void*)This; 335 *ppv=p->mempin;
401 This->vt->AddRef(This); 336 p->mempin->vt->AddRef(This);
402 return 0; 337 return 0;
403 } 338 }
404 Debug printf("Unknown interface : %08x-%04x-%04x-%02x%02x-" \ 339 Debug printf("Unknown interface : %08x-%04x-%04x-%02x%02x-" \
405 "%02x%02x%02x%02x%02x%02x\n", 340 "%02x%02x%02x%02x%02x%02x\n",
406 iid->f1, iid->f2, iid->f3, 341 iid->f1, iid->f2, iid->f3,
407 (unsigned char)iid->f4[1], (unsigned char)iid->f4[0], 342 (unsigned char)iid->f4[1], (unsigned char)iid->f4[0],
408 (unsigned char)iid->f4[2],(unsigned char)iid->f4[3],(unsigned char)iid->f4[4], 343 (unsigned char)iid->f4[2], (unsigned char)iid->f4[3],
409 (unsigned char)iid->f4[5],(unsigned char)iid->f4[6],(unsigned char)iid->f4[7]); 344 (unsigned char)iid->f4[4], (unsigned char)iid->f4[5],
410 return 0x80004002; 345 (unsigned char)iid->f4[6], (unsigned char)iid->f4[7]);
411 } 346 return E_NOINTERFACE;
412 HRESULT STDCALL COutputPin::M_AddRef(IUnknown* This) 347 }
413 {
414 Debug printf("COutputPin::AddRef() called\n");
415 ((COutputPin*)(This-1))->refcount++;
416 return 0;
417 }
418 HRESULT STDCALL COutputPin::M_Release(IUnknown* This)
419 {
420 Debug printf("COutputPin::Release() called\n");
421 if(--((COutputPin*)(This-1))->refcount==0)
422 delete (COutputPin*)This;
423 return 0;
424 }
425
426
427
428 348
429 // IMemInputPin methods 349 // IMemInputPin methods
430 350
431 HRESULT STDCALL COutputPin::GetAllocator( 351 static HRESULT STDCALL COutputPin_GetAllocator(IMemInputPin * This,
432 IMemInputPin * This, 352 /* [out] */ IMemAllocator **ppAllocator)
433 /* [out] */ IMemAllocator **ppAllocator) 353 {
434 { 354 Debug printf("COutputPin_GetAllocator(%p, %p) called\n", This->vt, ppAllocator);
435 Debug printf("COutputPin::GetAllocator(%x,%x) called\n",This->vt,ppAllocator);
436 *ppAllocator=new MemAllocator; 355 *ppAllocator=new MemAllocator;
437 return 0; 356 return 0;
438 } 357 }
439 358
440 HRESULT STDCALL COutputPin::NotifyAllocator( 359 static HRESULT STDCALL COutputPin_NotifyAllocator(IMemInputPin * This,
441 IMemInputPin * This, 360 /* [in] */ IMemAllocator *pAllocator,
442 /* [in] */ IMemAllocator *pAllocator, 361 /* [in] */ int bReadOnly)
443 /* [in] */ int bReadOnly) 362 {
444 { 363 Debug printf("COutputPin_NotifyAllocator(%p, %p) called\n", This, pAllocator);
445 Debug printf("COutputPin::NotifyAllocator() called\n"); 364 ((COutputMemPin*)This)->pAllocator = (MemAllocator*) pAllocator;
446 COutputPin* pPin=(COutputPin*)This; 365 return 0;
447 pPin->pAllocator=(MemAllocator*)pAllocator; 366 }
448 return 0; 367
449 } 368 static HRESULT STDCALL COutputPin_GetAllocatorRequirements(IMemInputPin * This,
450 369 /* [out] */ ALLOCATOR_PROPERTIES *pProps)
451 HRESULT STDCALL COutputPin::GetAllocatorRequirements( 370 {
452 IMemInputPin * This, 371 Debug printf("COutputPin_GetAllocatorRequirements() called\n");
453 /* [out] */ ALLOCATOR_PROPERTIES *pProps) 372 return E_NOTIMPL;
454 { 373 }
455 Debug printf("COutputPin::GetAllocatorRequirements() called\n"); 374
456 return E_NOTIMPL; 375 static HRESULT STDCALL COutputPin_Receive(IMemInputPin * This,
457 } 376 /* [in] */ IMediaSample *pSample)
458 377 {
459 HRESULT STDCALL COutputPin::Receive( 378 Debug printf("COutputPin_Receive(%p) called\n", This);
460 IMemInputPin * This, 379 if (!pSample)
461 /* [in] */ IMediaSample *pSample) 380 return E_INVALIDARG;
462 {
463 Debug printf("COutputPin::Receive() called\n");
464 COutputPin& me=*(COutputPin*)This;
465 if(!pSample)return 0x80004003;
466 char* pointer; 381 char* pointer;
467 if(pSample->vt->GetPointer(pSample, (BYTE **)&pointer)) 382 if (pSample->vt->GetPointer(pSample, (BYTE **)&pointer))
468 return -1; 383 return -1;
469 int len=pSample->vt->GetActualDataLength(pSample); 384 int len = pSample->vt->GetActualDataLength(pSample);
470 if(len==0)len=pSample->vt->GetSize(pSample);//for iv50 385 if (len == 0)
386 len = pSample->vt->GetSize(pSample);//for iv50
471 //if(me.frame_pointer)memcpy(me.frame_pointer, pointer, len); 387 //if(me.frame_pointer)memcpy(me.frame_pointer, pointer, len);
472 if(me.frame_pointer) 388
473 *me.frame_pointer=pointer; 389 COutputMemPin* mp= (COutputMemPin*)This;
474 if(me.frame_size_pointer)*me.frame_size_pointer=len; 390 if (mp->frame_pointer)
391 *(mp->frame_pointer) = pointer;
392 if (mp->frame_size_pointer)
393 *(mp->frame_size_pointer) = len;
475 /* 394 /*
476 FILE* file=fopen("./uncompr.bmp", "wb"); 395 FILE* file=fopen("./uncompr.bmp", "wb");
477 char head[14]={0x42, 0x4D, 0x36, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00}; 396 char head[14]={0x42, 0x4D, 0x36, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00};
478 *(int*)(&head[2])=len+0x36; 397 *(int*)(&head[2])=len+0x36;
479 fwrite(head, 14, 1, file); 398 fwrite(head, 14, 1, file);
483 */ 402 */
484 // pSample->vt->Release((IUnknown*)pSample); 403 // pSample->vt->Release((IUnknown*)pSample);
485 return 0; 404 return 0;
486 } 405 }
487 406
488 HRESULT STDCALL COutputPin::ReceiveMultiple( 407 static HRESULT STDCALL COutputPin_ReceiveMultiple(IMemInputPin * This,
489 IMemInputPin * This, 408 /* [size_is][in] */ IMediaSample **pSamples,
490 /* [size_is][in] */ IMediaSample **pSamples, 409 /* [in] */ long nSamples,
491 /* [in] */ long nSamples, 410 /* [out] */ long *nSamplesProcessed)
492 /* [out] */ long *nSamplesProcessed) 411 {
493 { 412 Debug printf("COutputPin_ReceiveMultiple() called (UNIMPLEMENTED)\n");
494 Debug printf("COutputPin::ReceiveMultiple() called\n"); 413 return E_NOTIMPL;
495 return E_NOTIMPL; 414 }
496 } 415
497 416 static HRESULT STDCALL COutputPin_ReceiveCanBlock(IMemInputPin * This)
498 HRESULT STDCALL COutputPin::ReceiveCanBlock( 417 {
499 IMemInputPin * This) 418 Debug printf("COutputPin_ReceiveCanBlock() called (UNIMPLEMENTED)\n");
500 { 419 return E_NOTIMPL;
501 Debug printf("COutputPin::ReceiveCanBlock() called\n"); 420 }
502 return E_NOTIMPL; 421
503 } 422 COutputPin::COutputPin(const AM_MEDIA_TYPE& vh)
423 :refcount(1), type(vh), remote(0)
424 {
425 vt = new IPin_vt;
426 vt->QueryInterface = COutputPin_QueryInterface;
427 vt->AddRef = COutputPin_AddRef;
428 vt->Release = COutputPin_Release;
429 vt->Connect = COutputPin_Connect;
430 vt->ReceiveConnection = COutputPin_ReceiveConnection;
431 vt->Disconnect = COutputPin_Disconnect;
432 vt->ConnectedTo = COutputPin_ConnectedTo;
433 vt->ConnectionMediaType = COutputPin_ConnectionMediaType;
434 vt->QueryPinInfo = COutputPin_QueryPinInfo;
435 vt->QueryDirection = COutputPin_QueryDirection;
436 vt->QueryId = COutputPin_QueryId;
437 vt->QueryAccept = COutputPin_QueryAccept;
438 vt->EnumMediaTypes = COutputPin_EnumMediaTypes;
439 vt->QueryInternalConnections = COutputPin_QueryInternalConnections;
440 vt->EndOfStream = COutputPin_EndOfStream;
441 vt->BeginFlush = COutputPin_BeginFlush;
442 vt->EndFlush = COutputPin_EndFlush;
443 vt->NewSegment = COutputPin_NewSegment;
444
445 mempin = new COutputMemPin;
446 mempin->vt = new IMemInputPin_vt;
447 mempin->vt->QueryInterface = COutputPin_M_QueryInterface;
448 mempin->vt->AddRef = COutputPin_M_AddRef;
449 mempin->vt->Release = COutputPin_M_Release;
450 mempin->vt->GetAllocator = COutputPin_GetAllocator;
451 mempin->vt->NotifyAllocator = COutputPin_NotifyAllocator;
452 mempin->vt->GetAllocatorRequirements = COutputPin_GetAllocatorRequirements;
453 mempin->vt->Receive = COutputPin_Receive;
454 mempin->vt->ReceiveMultiple = COutputPin_ReceiveMultiple;
455 mempin->vt->ReceiveCanBlock = COutputPin_ReceiveCanBlock;
456
457 mempin->frame_size_pointer = 0;
458 mempin->frame_pointer = 0;
459 mempin->pAllocator = 0;
460 mempin->parent = this;
461 }
462
463 COutputPin::~COutputPin()
464 {
465 delete vt;
466 delete mempin->vt;
467 }