comparison loader/dshow/inputpin.c @ 168:bdc4a8fc04d8

Initial revision
author arpi_esp
date Tue, 20 Mar 2001 00:05:27 +0000
parents
children da26060c81ef
comparison
equal deleted inserted replaced
167:53f289e99102 168:bdc4a8fc04d8
1 #include "inputpin.h"
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #define E_NOTIMPL 0x80004001
6 GUID CInputPin::interfaces[]=
7 {
8 IID_IUnknown,
9 };
10 IMPLEMENT_IUNKNOWN(CInputPin)
11
12 GUID CRemotePin::interfaces[]=
13 {
14 IID_IUnknown,
15 };
16 IMPLEMENT_IUNKNOWN(CRemotePin)
17
18 GUID CRemotePin2::interfaces[]=
19 {
20 IID_IUnknown,
21 };
22 IMPLEMENT_IUNKNOWN(CRemotePin2)
23
24 GUID CBaseFilter::interfaces[]=
25 {
26 IID_IUnknown,
27 IID_IBaseFilter,
28 };
29 IMPLEMENT_IUNKNOWN(CBaseFilter)
30
31 GUID CBaseFilter2::interfaces[]=
32 {
33 IID_IUnknown,
34 IID_IBaseFilter,
35 {0x76c61a30, 0xebe1, 0x11cf, {0x89, 0xf9, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb}},
36 {0xaae7e4e2, 0x6388, 0x11d1, {0x8d, 0x93, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}},
37 {0x02ef04dd, 0x7580, 0x11d1, {0xbe, 0xce, 0x00, 0xc0, 0x4f, 0xb6, 0xe9, 0x37}},
38 };
39 IMPLEMENT_IUNKNOWN(CBaseFilter2)
40
41 class CEnumPins: public IEnumPins
42 {
43 IPin* pin1;
44 IPin* pin2;
45 int counter;
46 static GUID interfaces[];
47 DECLARE_IUNKNOWN(CEnumPins)
48 public:
49 CEnumPins(IPin*, IPin* =0);
50 ~CEnumPins(){delete vt;}
51 static long STDCALL Next (
52 IEnumPins * This,
53 /* [in] */ unsigned long cMediaTypes,
54 /* [size_is][out] */ IPin **ppMediaTypes,
55 /* [out] */ unsigned long *pcFetched);
56
57 static long STDCALL Skip (
58 IEnumPins * This,
59 /* [in] */ unsigned long cMediaTypes);
60
61 static long STDCALL Reset (
62 IEnumPins * This);
63
64 static long STDCALL Clone (
65 IEnumPins * This,
66 /* [out] */ IEnumPins **ppEnum);
67
68 };
69 GUID CEnumPins::interfaces[]=
70 {
71 IID_IUnknown,
72 IID_IEnumPins,
73 };
74 IMPLEMENT_IUNKNOWN(CEnumPins)
75
76 CEnumPins::CEnumPins(IPin* p, IPin* pp): pin1(p), pin2(pp), counter(0), refcount(1)
77 {
78 vt=new IEnumPins_vt;
79 vt->QueryInterface = QueryInterface;
80 vt->AddRef = AddRef;
81 vt->Release = Release;
82 vt->Next = Next;
83 vt->Skip = Skip;
84 vt->Reset = Reset;
85 vt->Clone = Clone;
86 }
87
88 long STDCALL CEnumPins::Next (
89 IEnumPins * This,
90 /* [in] */ unsigned long cMediaTypes,
91 /* [size_is][out] */ IPin **ppMediaTypes,
92 /* [out] */ unsigned long *pcFetched)
93 {
94 IPin* pin1=((CEnumPins*)This)->pin1;
95 IPin* pin2=((CEnumPins*)This)->pin2;
96 Debug printf("CEnumPins::Next() called\n");
97 if(!ppMediaTypes)return 0x80004003;
98 if(!pcFetched && (cMediaTypes!=1))return 0x80004003;
99 if(cMediaTypes<=0)return 0;
100 int& counter=((CEnumPins*)This)->counter;
101 if(((counter==2) && pin2) || ((counter==1) && !pin2))
102 {
103 if(pcFetched)*pcFetched=0;
104 return 1;
105 }
106
107 if(pcFetched)*pcFetched=1;
108 if(counter==0)
109 {
110 *ppMediaTypes=pin1;
111 pin1->vt->AddRef((IUnknown*)pin1);
112 }
113 else
114 {
115 *ppMediaTypes=pin2;
116 pin2->vt->AddRef((IUnknown*)pin2);
117 }
118 counter++;
119 if(cMediaTypes==1)return 0;
120 return 1;
121 }
122
123 long STDCALL CEnumPins::Skip (
124 IEnumPins * This,
125 /* [in] */ unsigned long cMediaTypes)
126 {
127 Debug printf("CEnumPins::Skip() called\n");
128 return E_NOTIMPL;
129 }
130
131 long STDCALL CEnumPins::Reset (
132 IEnumPins * This)
133 {
134 Debug printf("CEnumPins::Reset() called\n");
135 ((CEnumPins*)This)->counter=0;
136 return 0;
137 }
138
139 long STDCALL CEnumPins::Clone (
140 IEnumPins * This,
141 /* [out] */ IEnumPins **ppEnum)
142 {
143 Debug printf("CEnumPins::Clone() called\n");
144 return E_NOTIMPL;
145 }
146
147 CInputPin::CInputPin(CBaseFilter* p, const AM_MEDIA_TYPE& vh)
148 : refcount(1), type(vh), parent(p)
149 {
150 vt=new IPin_vt;
151 vt->QueryInterface = QueryInterface;
152 vt->AddRef = AddRef;
153 vt->Release = Release;
154 vt->Connect = Connect;
155 vt->ReceiveConnection = ReceiveConnection;
156 vt->Disconnect=Disconnect;
157 vt->ConnectedTo = ConnectedTo;
158 vt->ConnectionMediaType = ConnectionMediaType;
159 vt->QueryPinInfo = QueryPinInfo;
160 vt->QueryDirection = QueryDirection;
161 vt->QueryId = QueryId;
162 vt->QueryAccept = QueryAccept;
163 vt->EnumMediaTypes = EnumMediaTypes;
164 vt->QueryInternalConnections = QueryInternalConnections;
165 vt->EndOfStream = EndOfStream;
166 vt->BeginFlush = BeginFlush;
167 vt->EndFlush = EndFlush;
168 vt->NewSegment = NewSegment;
169 }
170
171 long STDCALL CInputPin::Connect (
172 IPin * This,
173 /* [in] */ IPin *pReceivePin,
174 /* [in] */ AM_MEDIA_TYPE *pmt)
175 {
176 Debug printf("CInputPin::Connect() called\n");
177 return E_NOTIMPL;
178 }
179
180 long STDCALL CInputPin::ReceiveConnection (
181 IPin * This,
182 /* [in] */ IPin *pConnector,
183 /* [in] */ const AM_MEDIA_TYPE *pmt)
184 {
185 Debug printf("CInputPin::ReceiveConnection() called\n");
186 return E_NOTIMPL;
187 }
188
189 long STDCALL CInputPin::Disconnect (
190 IPin * This)
191 {
192 Debug printf("CInputPin::Disconnect() called\n");
193 return E_NOTIMPL;
194 }
195
196
197 long STDCALL CInputPin::ConnectedTo (
198 IPin * This,
199 /* [out] */ IPin **pPin)
200 {
201 Debug printf("CInputPin::ConnectedTo() called\n");
202 return E_NOTIMPL;
203 }
204
205
206 long STDCALL CInputPin::ConnectionMediaType (
207 IPin * This,
208 /* [out] */ AM_MEDIA_TYPE *pmt)
209 {
210 Debug printf("CInputPin::ConnectionMediaType() called\n");
211 if(!pmt)return 0x80004003;
212 *pmt=((CInputPin*)This)->type;
213 if(pmt->cbFormat>0)
214 {
215 pmt->pbFormat=(char *)CoTaskMemAlloc(pmt->cbFormat);
216 memcpy(pmt->pbFormat, ((CInputPin*)This)->type.pbFormat, pmt->cbFormat);
217 }
218 return 0;
219 }
220
221 long STDCALL CInputPin::QueryPinInfo (
222 IPin * This,
223 /* [out] */ PIN_INFO *pInfo)
224 {
225 Debug printf("CInputPin::QueryPinInfo() called\n");
226 pInfo->dir=PINDIR_OUTPUT;
227 CBaseFilter* parent=((CInputPin*)This)->parent;
228 pInfo->pFilter=parent;
229 parent->vt->AddRef((IUnknown*)parent);
230 pInfo->achName[0]=0;
231 return 0;
232 }
233
234
235 long STDCALL CInputPin::QueryDirection (
236 IPin * This,
237 /* [out] */ PIN_DIRECTION *pPinDir)
238 {
239 *pPinDir=PINDIR_OUTPUT;
240 Debug printf("CInputPin::QueryDirection() called\n");
241 return 0;
242 }
243
244
245 long STDCALL CInputPin::QueryId (
246 IPin * This,
247 /* [out] */ unsigned short* *Id)
248 {
249 Debug printf("CInputPin::QueryId() called\n");
250 return E_NOTIMPL;
251 }
252
253
254 long STDCALL CInputPin::QueryAccept (
255 IPin * This,
256 /* [in] */ const AM_MEDIA_TYPE *pmt)
257 {
258 Debug printf("CInputPin::QueryAccept() called\n");
259 return E_NOTIMPL;
260 }
261
262
263 long STDCALL CInputPin::EnumMediaTypes (
264 IPin * This,
265 /* [out] */ IEnumMediaTypes **ppEnum)
266 {
267 Debug printf("CInputPin::EnumMediaTypes() called\n");
268 return E_NOTIMPL;
269 }
270
271
272 long STDCALL CInputPin::QueryInternalConnections (
273 IPin * This,
274 /* [out] */ IPin **apPin,
275 /* [out][in] */ unsigned long *nPin)
276 {
277 Debug printf("CInputPin::QueryInternalConnections() called\n");
278 return E_NOTIMPL;
279 }
280
281 long STDCALL CInputPin::EndOfStream (
282 IPin * This)
283 {
284 Debug printf("CInputPin::EndOfStream() called\n");
285 return E_NOTIMPL;
286 }
287
288
289 long STDCALL CInputPin::BeginFlush (
290 IPin * This)
291 {
292 Debug printf("CInputPin::BeginFlush() called\n");
293 return E_NOTIMPL;
294 }
295
296
297 long STDCALL CInputPin::EndFlush (
298 IPin * This)
299 {
300 Debug printf("CInputPin::EndFlush() called\n");
301 return E_NOTIMPL;
302 }
303
304 long STDCALL CInputPin::NewSegment (
305 IPin * This,
306 /* [in] */ REFERENCE_TIME tStart,
307 /* [in] */ REFERENCE_TIME tStop,
308 /* [in] */ double dRate)
309 {
310 Debug printf("CInputPin::NewSegment() called\n");
311 return E_NOTIMPL;
312 }
313
314
315
316
317
318
319 CBaseFilter::CBaseFilter(const AM_MEDIA_TYPE& type, CBaseFilter2* parent)
320 : refcount(1)
321 {
322 pin=new CInputPin(this, type);
323 unused_pin=new CRemotePin(this, parent->GetPin());
324 vt=new IBaseFilter_vt;
325 vt->QueryInterface = QueryInterface;
326 vt->AddRef = AddRef;
327 vt->Release = Release;
328 vt->GetClassID = GetClassID;
329 vt->Stop = Stop;
330 vt->Pause = Pause;
331 vt->Run = Run;
332 vt->GetState = GetState;
333 vt->SetSyncSource = SetSyncSource;
334 vt->GetSyncSource = GetSyncSource;
335 vt->EnumPins = EnumPins;
336 vt->FindPin = FindPin;
337 vt->QueryFilterInfo = QueryFilterInfo;
338 vt->JoinFilterGraph = JoinFilterGraph;
339 vt->QueryVendorInfo = QueryVendorInfo;
340 }
341
342 long STDCALL CBaseFilter::GetClassID (
343 IBaseFilter * This,
344 /* [out] */ CLSID *pClassID)
345 {
346 Debug printf("CBaseFilter::GetClassID() called\n");
347 return E_NOTIMPL;
348 }
349
350 long STDCALL CBaseFilter::Stop (
351 IBaseFilter * This)
352 {
353 Debug printf("CBaseFilter::Stop() called\n");
354 return E_NOTIMPL;
355 }
356
357
358 long STDCALL CBaseFilter::Pause (
359 IBaseFilter * This)
360 {
361 Debug printf("CBaseFilter::Pause() called\n");
362 return E_NOTIMPL;
363 }
364
365 long STDCALL CBaseFilter::Run (
366 IBaseFilter * This,
367 REFERENCE_TIME tStart)
368 {
369 Debug printf("CBaseFilter::Run() called\n");
370 return E_NOTIMPL;
371 }
372
373
374 long STDCALL CBaseFilter::GetState (
375 IBaseFilter * This,
376 /* [in] */ unsigned long dwMilliSecsTimeout,
377 // /* [out] */ FILTER_STATE *State)
378 void* State)
379 {
380 Debug printf("CBaseFilter::GetState() called\n");
381 return E_NOTIMPL;
382 }
383
384
385 long STDCALL CBaseFilter::SetSyncSource (
386 IBaseFilter * This,
387 /* [in] */ IReferenceClock *pClock)
388 {
389 Debug printf("CBaseFilter::SetSyncSource() called\n");
390 return E_NOTIMPL;
391 }
392
393
394 long STDCALL CBaseFilter::GetSyncSource (
395 IBaseFilter * This,
396 /* [out] */ IReferenceClock **pClock)
397 {
398 Debug printf("CBaseFilter::GetSyncSource() called\n");
399 return E_NOTIMPL;
400 }
401
402
403 long STDCALL CBaseFilter::EnumPins (
404 IBaseFilter * This,
405 /* [out] */ IEnumPins **ppEnum)
406 {
407 Debug printf("CBaseFilter::EnumPins() called\n");
408 *ppEnum=new CEnumPins(((CBaseFilter*)This)->pin, ((CBaseFilter*)This)->unused_pin);
409 return 0;
410 }
411
412
413 long STDCALL CBaseFilter::FindPin (
414 IBaseFilter * This,
415 /* [string][in] */ const unsigned short* Id,
416 /* [out] */ IPin **ppPin)
417 {
418 Debug printf("CBaseFilter::FindPin() called\n");
419 return E_NOTIMPL;
420 }
421
422
423 long STDCALL CBaseFilter::QueryFilterInfo (
424 IBaseFilter * This,
425 // /* [out] */ FILTER_INFO *pInfo)
426 void* pInfo)
427 {
428 Debug printf("CBaseFilter::QueryFilterInfo() called\n");
429 return E_NOTIMPL;
430 }
431
432
433 long STDCALL CBaseFilter::JoinFilterGraph (
434 IBaseFilter * This,
435 /* [in] */ IFilterGraph *pGraph,
436 /* [string][in] */ const unsigned short* pName)
437 {
438 Debug printf("CBaseFilter::JoinFilterGraph() called\n");
439 return E_NOTIMPL;
440 }
441
442
443 long STDCALL CBaseFilter::QueryVendorInfo (
444 IBaseFilter * This,
445 /* [string][out] */ unsigned short* *pVendorInfo)
446 {
447 Debug printf("CBaseFilter::QueryVendorInfo() called\n");
448 return E_NOTIMPL;
449 }
450
451
452 CBaseFilter2::CBaseFilter2() : refcount(1)
453 {
454 pin=new CRemotePin2(this);
455 vt=new IBaseFilter_vt;
456 memset(vt, 0, sizeof (IBaseFilter_vt));
457 vt->QueryInterface = QueryInterface;
458 vt->AddRef = AddRef;
459 vt->Release = Release;
460 vt->GetClassID = GetClassID;
461 vt->Stop = Stop;
462 vt->Pause = Pause;
463 vt->Run = Run;
464 vt->GetState = GetState;
465 vt->SetSyncSource = SetSyncSource;
466 vt->GetSyncSource = GetSyncSource;
467 vt->EnumPins = EnumPins;
468 vt->FindPin = FindPin;
469 vt->QueryFilterInfo = QueryFilterInfo;
470 vt->JoinFilterGraph = JoinFilterGraph;
471 vt->QueryVendorInfo = QueryVendorInfo;
472 }
473 CRemotePin2::CRemotePin2(CBaseFilter2* p):parent(p),
474 refcount(1)
475 {
476 vt=new IPin_vt;
477 memset(vt, 0, sizeof (IPin_vt));
478 vt->QueryInterface = QueryInterface;
479 vt->AddRef = AddRef;
480 vt->Release = Release;
481 vt->QueryPinInfo=QueryPinInfo;
482 }
483 CRemotePin::CRemotePin(CBaseFilter* pt, IPin* rpin): parent(pt), remote_pin(rpin),
484 refcount(1)
485 {
486 vt=new IPin_vt;
487 memset(vt, 0, sizeof (IPin_vt));
488 vt->QueryInterface = QueryInterface;
489 vt->AddRef = AddRef;
490 vt->Release = Release;
491 vt->QueryDirection = QueryDirection;
492 vt->ConnectedTo = ConnectedTo;
493 vt->ConnectionMediaType = ConnectionMediaType;
494 vt->QueryPinInfo = QueryPinInfo;
495 }
496
497
498
499
500
501
502
503
504
505
506
507
508 long STDCALL CBaseFilter2::GetClassID (
509 IBaseFilter * This,
510 /* [out] */ CLSID *pClassID)
511 {
512 Debug printf("CBaseFilter2::GetClassID() called\n");
513 return E_NOTIMPL;
514 }
515
516 long STDCALL CBaseFilter2::Stop (
517 IBaseFilter * This)
518 {
519 Debug printf("CBaseFilter2::Stop() called\n");
520 return E_NOTIMPL;
521 }
522
523
524 long STDCALL CBaseFilter2::Pause (
525 IBaseFilter * This)
526 {
527 Debug printf("CBaseFilter2::Pause() called\n");
528 return E_NOTIMPL;
529 }
530
531 long STDCALL CBaseFilter2::Run (
532 IBaseFilter * This,
533 REFERENCE_TIME tStart)
534 {
535 Debug printf("CBaseFilter2::Run() called\n");
536 return E_NOTIMPL;
537 }
538
539
540 long STDCALL CBaseFilter2::GetState (
541 IBaseFilter * This,
542 /* [in] */ unsigned long dwMilliSecsTimeout,
543 // /* [out] */ FILTER_STATE *State)
544 void* State)
545 {
546 Debug printf("CBaseFilter2::GetState() called\n");
547 return E_NOTIMPL;
548 }
549
550
551 long STDCALL CBaseFilter2::SetSyncSource (
552 IBaseFilter * This,
553 /* [in] */ IReferenceClock *pClock)
554 {
555 Debug printf("CBaseFilter2::SetSyncSource() called\n");
556 return E_NOTIMPL;
557 }
558
559
560 long STDCALL CBaseFilter2::GetSyncSource (
561 IBaseFilter * This,
562 /* [out] */ IReferenceClock **pClock)
563 {
564 Debug printf("CBaseFilter2::GetSyncSource() called\n");
565 return E_NOTIMPL;
566 }
567
568
569 long STDCALL CBaseFilter2::EnumPins (
570 IBaseFilter * This,
571 /* [out] */ IEnumPins **ppEnum)
572 {
573 Debug printf("CBaseFilter2::EnumPins() called\n");
574 *ppEnum=new CEnumPins(((CBaseFilter2*)This)->pin);
575 return 0;
576 }
577
578
579 long STDCALL CBaseFilter2::FindPin (
580 IBaseFilter * This,
581 /* [string][in] */ const unsigned short* Id,
582 /* [out] */ IPin **ppPin)
583 {
584 Debug printf("CBaseFilter2::FindPin() called\n");
585 return E_NOTIMPL;
586 }
587
588
589 long STDCALL CBaseFilter2::QueryFilterInfo (
590 IBaseFilter * This,
591 // /* [out] */ FILTER_INFO *pInfo)
592 void* pInfo)
593 {
594 Debug printf("CBaseFilter2::QueryFilterInfo() called\n");
595 return E_NOTIMPL;
596 }
597
598
599 long STDCALL CBaseFilter2::JoinFilterGraph (
600 IBaseFilter * This,
601 /* [in] */ IFilterGraph *pGraph,
602 /* [string][in] */ const unsigned short* pName)
603 {
604 Debug printf("CBaseFilter2::JoinFilterGraph() called\n");
605 return E_NOTIMPL;
606 }
607
608
609 long STDCALL CBaseFilter2::QueryVendorInfo (
610 IBaseFilter * This,
611 /* [string][out] */ unsigned short* *pVendorInfo)
612 {
613 Debug printf("CBaseFilter2::QueryVendorInfo() called\n");
614 return E_NOTIMPL;
615 }
616
617 long STDCALL CRemotePin::ConnectionMediaType (
618 IPin * This,
619 /* [out] */ AM_MEDIA_TYPE *pmt)
620 {
621 Debug printf("CRemotePin::ConnectionMediaType() called\n");
622 return E_NOTIMPL;
623 }
624
625 long STDCALL CRemotePin::QueryPinInfo (
626 IPin * This,
627 /* [out] */ PIN_INFO *pInfo)
628 {
629 Debug printf("CRemotePin::QueryPinInfo() called\n");
630 pInfo->dir=PINDIR_INPUT;
631 CBaseFilter* parent=((CRemotePin*)This)->parent;
632 pInfo->pFilter=parent;
633 parent->vt->AddRef((IUnknown*)parent);
634 pInfo->achName[0]=0;
635 return 0;
636 }
637 long STDCALL CRemotePin2::QueryPinInfo (
638 IPin * This,
639 /* [out] */ PIN_INFO *pInfo)
640 {
641 Debug printf("CRemotePin2::QueryPinInfo called\n");
642 CBaseFilter2* parent=((CRemotePin2*)This)->parent;
643 pInfo->pFilter=(IBaseFilter*)parent;
644 parent->vt->AddRef((IUnknown*)parent);
645 pInfo->dir=PINDIR_OUTPUT;
646 pInfo->achName[0]=0;
647 return 0;
648 }
649 long STDCALL CRemotePin::ConnectedTo (
650 IPin * This,
651 /* [out] */ IPin **pPin)
652 {
653 Debug printf("CRemotePin::ConnectedTo called\n");
654 if(!pPin)return 0x80004003;
655 *pPin=((CRemotePin*)This)->remote_pin;
656 (*pPin)->vt->AddRef((IUnknown*)(*pPin));
657 return 0;
658 }
659 long STDCALL CRemotePin::QueryDirection (
660 IPin * This,
661 /* [out] */ PIN_DIRECTION *pPinDir)
662 {
663 Debug printf("CRemotePin::QueryDirection called\n");
664 if(!pPinDir)return 0x80004003;
665 *pPinDir=PINDIR_INPUT;
666 return 0;
667 }