2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WDM Streaming ActiveMovie Proxy
4 * FILE: dll/directx/ksproxy/input_cpp.cpp
5 * PURPOSE: InputPin of Proxy Filter
7 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
11 const GUID IID_IKsPinEx
= {0x7bb38260L
, 0xd19c, 0x11d2, {0xb3, 0x8a, 0x00, 0xa0, 0xc9, 0x5e, 0xc2, 0x2e}};
12 const GUID KSPROPSETID_Connection
= {0x1D58C920L
, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
14 KSPIN_INTERFACE StandardPinInterface
=
16 {STATIC_KSINTERFACESETID_Standard
},
17 KSINTERFACE_STANDARD_STREAMING
,
21 KSPIN_MEDIUM StandardPinMedium
=
23 {STATIC_KSMEDIUMSETID_Standard
},
24 KSMEDIUM_TYPE_ANYINSTANCE
,
29 class CInputPin
: public IPin
,
30 public IKsPropertySet
,
36 public IQualityControl,
38 public ISpecifyPropertyPages,
39 public IStreamBuilder,
41 public IKsAggregateControl
45 STDMETHODIMP
QueryInterface( REFIID InterfaceId
, PVOID
* Interface
);
47 STDMETHODIMP_(ULONG
) AddRef()
49 InterlockedIncrement(&m_Ref
);
52 STDMETHODIMP_(ULONG
) Release()
54 InterlockedDecrement(&m_Ref
);
64 HRESULT STDMETHODCALLTYPE
Connect(IPin
*pReceivePin
, const AM_MEDIA_TYPE
*pmt
);
65 HRESULT STDMETHODCALLTYPE
ReceiveConnection(IPin
*pConnector
, const AM_MEDIA_TYPE
*pmt
);
66 HRESULT STDMETHODCALLTYPE
Disconnect();
67 HRESULT STDMETHODCALLTYPE
ConnectedTo(IPin
**pPin
);
68 HRESULT STDMETHODCALLTYPE
ConnectionMediaType(AM_MEDIA_TYPE
*pmt
);
69 HRESULT STDMETHODCALLTYPE
QueryPinInfo(PIN_INFO
*pInfo
);
70 HRESULT STDMETHODCALLTYPE
QueryDirection(PIN_DIRECTION
*pPinDir
);
71 HRESULT STDMETHODCALLTYPE
QueryId(LPWSTR
*Id
);
72 HRESULT STDMETHODCALLTYPE
QueryAccept(const AM_MEDIA_TYPE
*pmt
);
73 HRESULT STDMETHODCALLTYPE
EnumMediaTypes(IEnumMediaTypes
**ppEnum
);
74 HRESULT STDMETHODCALLTYPE
QueryInternalConnections(IPin
**apPin
, ULONG
*nPin
);
75 HRESULT STDMETHODCALLTYPE
EndOfStream();
76 HRESULT STDMETHODCALLTYPE
BeginFlush();
77 HRESULT STDMETHODCALLTYPE
EndFlush();
78 HRESULT STDMETHODCALLTYPE
NewSegment(REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, double dRate
);
81 HANDLE STDMETHODCALLTYPE
KsGetObjectHandle();
84 HRESULT STDMETHODCALLTYPE
Set(REFGUID guidPropSet
, DWORD dwPropID
, LPVOID pInstanceData
, DWORD cbInstanceData
, LPVOID pPropData
, DWORD cbPropData
);
85 HRESULT STDMETHODCALLTYPE
Get(REFGUID guidPropSet
, DWORD dwPropID
, LPVOID pInstanceData
, DWORD cbInstanceData
, LPVOID pPropData
, DWORD cbPropData
, DWORD
*pcbReturned
);
86 HRESULT STDMETHODCALLTYPE
QuerySupported(REFGUID guidPropSet
, DWORD dwPropID
, DWORD
*pTypeSupport
);
89 HRESULT STDMETHODCALLTYPE
KsProperty(PKSPROPERTY Property
, ULONG PropertyLength
, LPVOID PropertyData
, ULONG DataLength
, ULONG
* BytesReturned
);
90 HRESULT STDMETHODCALLTYPE
KsMethod(PKSMETHOD Method
, ULONG MethodLength
, LPVOID MethodData
, ULONG DataLength
, ULONG
* BytesReturned
);
91 HRESULT STDMETHODCALLTYPE
KsEvent(PKSEVENT Event
, ULONG EventLength
, LPVOID EventData
, ULONG DataLength
, ULONG
* BytesReturned
);
94 HRESULT STDMETHODCALLTYPE
KsQueryMediums(PKSMULTIPLE_ITEM
* MediumList
);
95 HRESULT STDMETHODCALLTYPE
KsQueryInterfaces(PKSMULTIPLE_ITEM
* InterfaceList
);
96 HRESULT STDMETHODCALLTYPE
KsCreateSinkPinHandle(KSPIN_INTERFACE
& Interface
, KSPIN_MEDIUM
& Medium
);
97 HRESULT STDMETHODCALLTYPE
KsGetCurrentCommunication(KSPIN_COMMUNICATION
*Communication
, KSPIN_INTERFACE
*Interface
, KSPIN_MEDIUM
*Medium
);
98 HRESULT STDMETHODCALLTYPE
KsPropagateAcquire();
99 HRESULT STDMETHODCALLTYPE
KsDeliver(IMediaSample
* Sample
, ULONG Flags
);
100 HRESULT STDMETHODCALLTYPE
KsMediaSamplesCompleted(PKSSTREAM_SEGMENT StreamSegment
);
101 IMemAllocator
* STDMETHODCALLTYPE
KsPeekAllocator(KSPEEKOPERATION Operation
);
102 HRESULT STDMETHODCALLTYPE
KsReceiveAllocator(IMemAllocator
*MemAllocator
);
103 HRESULT STDMETHODCALLTYPE
KsRenegotiateAllocator();
104 LONG STDMETHODCALLTYPE
KsIncrementPendingIoCount();
105 LONG STDMETHODCALLTYPE
KsDecrementPendingIoCount();
106 HRESULT STDMETHODCALLTYPE
KsQualityNotify(ULONG Proportion
, REFERENCE_TIME TimeDelta
);
108 VOID STDMETHODCALLTYPE
KsNotifyError(IMediaSample
* Sample
, HRESULT hr
);
111 HRESULT STDMETHODCALLTYPE
GetAllocator(IMemAllocator
**ppAllocator
);
112 HRESULT STDMETHODCALLTYPE
NotifyAllocator(IMemAllocator
*pAllocator
, BOOL bReadOnly
);
113 HRESULT STDMETHODCALLTYPE
GetAllocatorRequirements(ALLOCATOR_PROPERTIES
*pProps
);
114 HRESULT STDMETHODCALLTYPE
Receive(IMediaSample
*pSample
);
115 HRESULT STDMETHODCALLTYPE
ReceiveMultiple(IMediaSample
**pSamples
, long nSamples
, long *nSamplesProcessed
);
116 HRESULT STDMETHODCALLTYPE
ReceiveCanBlock( void);
118 //---------------------------------------------------------------
119 HRESULT STDMETHODCALLTYPE
CheckFormat(const AM_MEDIA_TYPE
*pmt
);
120 HRESULT STDMETHODCALLTYPE
CreatePin();
121 HRESULT STDMETHODCALLTYPE
CreatePinHandle(PKSPIN_MEDIUM Medium
, PKSPIN_INTERFACE Interface
, PKSDATAFORMAT DataFormat
);
122 CInputPin(IBaseFilter
* ParentFilter
, LPCWSTR PinName
, HANDLE hFilter
, ULONG PinId
, KSPIN_COMMUNICATION Communication
) : m_Ref(0), m_ParentFilter(ParentFilter
), m_PinName(PinName
), m_hFilter(hFilter
), m_hPin(0), m_PinId(PinId
), m_MemAllocator(0), m_IoCount(0), m_Communication(Communication
), m_Pin(0){};
123 virtual ~CInputPin(){};
127 IBaseFilter
* m_ParentFilter
;
132 IMemAllocator
* m_MemAllocator
;
134 KSPIN_COMMUNICATION m_Communication
;
135 KSPIN_INTERFACE m_Interface
;
136 KSPIN_MEDIUM m_Medium
;
142 CInputPin::QueryInterface(
148 if (IsEqualGUID(refiid
, IID_IUnknown
) ||
149 IsEqualGUID(refiid
, IID_IPin
))
151 *Output
= PVOID(this);
152 reinterpret_cast<IUnknown
*>(*Output
)->AddRef();
155 else if (IsEqualGUID(refiid
, IID_IMemInputPin
))
157 *Output
= (IMemInputPin
*)(this);
158 reinterpret_cast<IMemInputPin
*>(*Output
)->AddRef();
161 else if (IsEqualGUID(refiid
, IID_IKsObject
))
165 HRESULT hr
= CreatePin();
170 *Output
= (IKsObject
*)(this);
171 reinterpret_cast<IKsObject
*>(*Output
)->AddRef();
174 else if (IsEqualGUID(refiid
, IID_IKsPropertySet
))
178 HRESULT hr
= CreatePin();
183 *Output
= (IKsPropertySet
*)(this);
184 reinterpret_cast<IKsPropertySet
*>(*Output
)->AddRef();
187 else if (IsEqualGUID(refiid
, IID_IKsControl
))
191 HRESULT hr
= CreatePin();
196 *Output
= (IKsControl
*)(this);
197 reinterpret_cast<IKsControl
*>(*Output
)->AddRef();
200 else if (IsEqualGUID(refiid
, IID_IKsPin
) ||
201 IsEqualGUID(refiid
, IID_IKsPinEx
))
205 HRESULT hr
= CreatePin();
210 *Output
= (IKsPinEx
*)(this);
211 reinterpret_cast<IKsPinEx
*>(*Output
)->AddRef();
216 WCHAR Buffer
[MAX_PATH
];
218 StringFromCLSID(refiid
, &lpstr
);
219 swprintf(Buffer
, L
"CInputPin::QueryInterface: NoInterface for %s\n", lpstr
);
220 OutputDebugStringW(Buffer
);
221 CoTaskMemFree(lpstr
);
223 return E_NOINTERFACE
;
226 //-------------------------------------------------------------------
233 CInputPin::GetAllocator(IMemAllocator
**ppAllocator
)
235 OutputDebugStringW(L
"CInputPin::GetAllocator\n");
236 return VFW_E_NO_ALLOCATOR
;
241 CInputPin::NotifyAllocator(IMemAllocator
*pAllocator
, BOOL bReadOnly
)
245 pAllocator
->AddRef();
250 m_MemAllocator
->Release();
253 m_MemAllocator
= pAllocator
;
259 CInputPin::GetAllocatorRequirements(ALLOCATOR_PROPERTIES
*pProps
)
261 KSALLOCATOR_FRAMING Framing
;
266 Property
.Set
= KSPROPSETID_Connection
;
267 Property
.Id
= KSPROPERTY_CONNECTION_ALLOCATORFRAMING
;
268 Property
.Flags
= KSPROPERTY_TYPE_SET
;
270 hr
= KsProperty(&Property
, sizeof(KSPROPERTY
), (PVOID
)&Framing
, sizeof(KSALLOCATOR_FRAMING
), &BytesReturned
);
273 pProps
->cBuffers
= Framing
.Frames
;
274 pProps
->cbBuffer
= Framing
.FrameSize
;
275 pProps
->cbAlign
= Framing
.FileAlignment
;
276 pProps
->cbPrefix
= 0;
285 CInputPin::Receive(IMediaSample
*pSample
)
287 OutputDebugStringW(L
"CInputPin::Receive NotImplemented\n");
293 CInputPin::ReceiveMultiple(IMediaSample
**pSamples
, long nSamples
, long *nSamplesProcessed
)
295 OutputDebugStringW(L
"CInputPin::ReceiveMultiple NotImplemented\n");
301 CInputPin::ReceiveCanBlock( void)
303 OutputDebugStringW(L
"CInputPin::ReceiveCanBlock NotImplemented\n");
308 //-------------------------------------------------------------------
314 CInputPin::KsQueryMediums(
315 PKSMULTIPLE_ITEM
* MediumList
)
317 return KsGetMultiplePinFactoryItems(m_hFilter
, m_PinId
, KSPROPERTY_PIN_MEDIUMS
, (PVOID
*)MediumList
);
322 CInputPin::KsQueryInterfaces(
323 PKSMULTIPLE_ITEM
* InterfaceList
)
325 return KsGetMultiplePinFactoryItems(m_hFilter
, m_PinId
, KSPROPERTY_PIN_INTERFACES
, (PVOID
*)InterfaceList
);
330 CInputPin::KsCreateSinkPinHandle(
331 KSPIN_INTERFACE
& Interface
,
332 KSPIN_MEDIUM
& Medium
)
334 OutputDebugStringW(L
"CInputPin::KsCreateSinkPinHandle NotImplemented\n");
340 CInputPin::KsGetCurrentCommunication(
341 KSPIN_COMMUNICATION
*Communication
,
342 KSPIN_INTERFACE
*Interface
,
343 KSPIN_MEDIUM
*Medium
)
347 *Communication
= m_Communication
;
353 return VFW_E_NOT_CONNECTED
;
355 CopyMemory(Interface
, &m_Interface
, sizeof(KSPIN_INTERFACE
));
361 return VFW_E_NOT_CONNECTED
;
363 CopyMemory(Medium
, &m_Medium
, sizeof(KSPIN_MEDIUM
));
370 CInputPin::KsPropagateAcquire()
372 OutputDebugStringW(L
"CInputPin::KsPropagateAcquire NotImplemented\n");
378 CInputPin::KsDeliver(
379 IMediaSample
* Sample
,
387 CInputPin::KsMediaSamplesCompleted(PKSSTREAM_SEGMENT StreamSegment
)
394 CInputPin::KsPeekAllocator(KSPEEKOPERATION Operation
)
396 if (Operation
== KsPeekOperation_AddRef
)
398 // add reference on allocator
399 m_MemAllocator
->AddRef();
402 return m_MemAllocator
;
407 CInputPin::KsReceiveAllocator(IMemAllocator
*MemAllocator
)
411 MemAllocator
->AddRef();
416 m_MemAllocator
->Release();
419 m_MemAllocator
= MemAllocator
;
425 CInputPin::KsRenegotiateAllocator()
432 CInputPin::KsIncrementPendingIoCount()
434 return InterlockedIncrement((volatile LONG
*)&m_IoCount
);
439 CInputPin::KsDecrementPendingIoCount()
441 return InterlockedDecrement((volatile LONG
*)&m_IoCount
);
446 CInputPin::KsQualityNotify(
448 REFERENCE_TIME TimeDelta
)
450 OutputDebugStringW(L
"CInputPin::KsQualityNotify NotImplemented\n");
454 //-------------------------------------------------------------------
460 CInputPin::KsNotifyError(
461 IMediaSample
* Sample
,
464 OutputDebugStringW(L
"CInputPin::KsNotifyError NotImplemented\n");
468 //-------------------------------------------------------------------
473 CInputPin::KsProperty(
474 PKSPROPERTY Property
,
475 ULONG PropertyLength
,
478 ULONG
* BytesReturned
)
480 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_PROPERTY
, (PVOID
)Property
, PropertyLength
, (PVOID
)PropertyData
, DataLength
, BytesReturned
);
490 ULONG
* BytesReturned
)
492 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_METHOD
, (PVOID
)Method
, MethodLength
, (PVOID
)MethodData
, DataLength
, BytesReturned
);
502 ULONG
* BytesReturned
)
505 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_ENABLE_EVENT
, (PVOID
)Event
, EventLength
, (PVOID
)EventData
, DataLength
, BytesReturned
);
507 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_DISABLE_EVENT
, (PVOID
)Event
, EventLength
, NULL
, 0, BytesReturned
);
511 //-------------------------------------------------------------------
519 LPVOID pInstanceData
,
520 DWORD cbInstanceData
,
528 PKSPROPERTY Property
= (PKSPROPERTY
)CoTaskMemAlloc(sizeof(KSPROPERTY
) + cbInstanceData
);
530 return E_OUTOFMEMORY
;
532 Property
->Set
= guidPropSet
;
533 Property
->Id
= dwPropID
;
534 Property
->Flags
= KSPROPERTY_TYPE_SET
;
536 CopyMemory((Property
+1), pInstanceData
, cbInstanceData
);
538 HRESULT hr
= KsProperty(Property
, sizeof(KSPROPERTY
) + cbInstanceData
, pPropData
, cbPropData
, &BytesReturned
);
539 CoTaskMemFree(Property
);
546 Property
.Set
= guidPropSet
;
547 Property
.Id
= dwPropID
;
548 Property
.Flags
= KSPROPERTY_TYPE_SET
;
550 HRESULT hr
= KsProperty(&Property
, sizeof(KSPROPERTY
), pPropData
, cbPropData
, &BytesReturned
);
560 LPVOID pInstanceData
,
561 DWORD cbInstanceData
,
570 PKSPROPERTY Property
= (PKSPROPERTY
)CoTaskMemAlloc(sizeof(KSPROPERTY
) + cbInstanceData
);
572 return E_OUTOFMEMORY
;
574 Property
->Set
= guidPropSet
;
575 Property
->Id
= dwPropID
;
576 Property
->Flags
= KSPROPERTY_TYPE_GET
;
578 CopyMemory((Property
+1), pInstanceData
, cbInstanceData
);
580 HRESULT hr
= KsProperty(Property
, sizeof(KSPROPERTY
) + cbInstanceData
, pPropData
, cbPropData
, &BytesReturned
);
581 CoTaskMemFree(Property
);
588 Property
.Set
= guidPropSet
;
589 Property
.Id
= dwPropID
;
590 Property
.Flags
= KSPROPERTY_TYPE_GET
;
592 HRESULT hr
= KsProperty(&Property
, sizeof(KSPROPERTY
), pPropData
, cbPropData
, &BytesReturned
);
599 CInputPin::QuerySupported(
607 Property
.Set
= guidPropSet
;
608 Property
.Id
= dwPropID
;
609 Property
.Flags
= KSPROPERTY_TYPE_SETSUPPORT
;
611 return KsProperty(&Property
, sizeof(KSPROPERTY
), pTypeSupport
, sizeof(DWORD
), &BytesReturned
);
615 //-------------------------------------------------------------------
620 CInputPin::KsGetObjectHandle()
622 OutputDebugStringW(L
"CInputPin::KsGetObjectHandle CALLED\n");
629 //-------------------------------------------------------------------
634 CInputPin::Connect(IPin
*pReceivePin
, const AM_MEDIA_TYPE
*pmt
)
636 OutputDebugStringW(L
"CInputPin::Connect NotImplemented\n");
642 CInputPin::ReceiveConnection(IPin
*pConnector
, const AM_MEDIA_TYPE
*pmt
)
648 OutputDebugStringW(L
"CInputPin::ReceiveConnection already connected\n");
649 return VFW_E_ALREADY_CONNECTED
;
652 // first check format
653 hr
= CheckFormat(pmt
);
657 if (FAILED(CheckFormat(pmt
)))
664 OutputDebugStringW(L
"CInputPin::ReceiveConnection NotImplemented\n");
669 CInputPin::Disconnect( void)
671 OutputDebugStringW(L
"CInputPin::Disconnect NotImplemented\n");
676 CInputPin::ConnectedTo(IPin
**pPin
)
683 // increment reference count
690 return VFW_E_NOT_CONNECTED
;
694 CInputPin::ConnectionMediaType(AM_MEDIA_TYPE
*pmt
)
696 OutputDebugStringW(L
"CInputPin::ConnectionMediaType NotImplemented\n");
701 CInputPin::QueryPinInfo(PIN_INFO
*pInfo
)
703 wcscpy(pInfo
->achName
, m_PinName
);
704 pInfo
->dir
= PINDIR_INPUT
;
705 pInfo
->pFilter
= m_ParentFilter
;
706 m_ParentFilter
->AddRef();
712 CInputPin::QueryDirection(PIN_DIRECTION
*pPinDir
)
716 *pPinDir
= PINDIR_INPUT
;
724 CInputPin::QueryId(LPWSTR
*Id
)
726 *Id
= (LPWSTR
)CoTaskMemAlloc((wcslen(m_PinName
)+1)*sizeof(WCHAR
));
728 return E_OUTOFMEMORY
;
730 wcscpy(*Id
, m_PinName
);
736 CInputPin::QueryAccept(
737 const AM_MEDIA_TYPE
*pmt
)
739 return CheckFormat(pmt
);
743 CInputPin::EnumMediaTypes(IEnumMediaTypes
**ppEnum
)
745 return CEnumMediaTypes_fnConstructor(0, NULL
, IID_IEnumMediaTypes
, (void**)ppEnum
);
749 CInputPin::QueryInternalConnections(IPin
**apPin
, ULONG
*nPin
)
751 OutputDebugStringW(L
"CInputPin::QueryInternalConnections NotImplemented\n");
756 CInputPin::EndOfStream( void)
758 OutputDebugStringW(L
"CInputPin::EndOfStream NotImplemented\n");
763 CInputPin::BeginFlush( void)
765 OutputDebugStringW(L
"CInputPin::BeginFlush NotImplemented\n");
770 CInputPin::EndFlush( void)
772 OutputDebugStringW(L
"CInputPin::EndFlush NotImplemented\n");
777 CInputPin::NewSegment(REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, double dRate
)
779 OutputDebugStringW(L
"CInputPin::NewSegment NotImplemented\n");
783 //-------------------------------------------------------------------
786 CInputPin::CheckFormat(
787 const AM_MEDIA_TYPE
*pmt
)
790 PKSMULTIPLE_ITEM MultipleItem
;
791 PKSDATAFORMAT DataFormat
;
796 Property
.Property
.Set
= KSPROPSETID_Pin
;
797 Property
.Property
.Id
= KSPROPERTY_PIN_DATARANGES
;
798 Property
.Property
.Flags
= KSPROPERTY_TYPE_GET
;
799 Property
.PinId
= m_PinId
;
800 Property
.Reserved
= 0;
802 // query for size of dataranges
803 hr
= KsSynchronousDeviceControl(m_hFilter
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSP_PIN
), NULL
, 0, &BytesReturned
);
805 if (hr
== MAKE_HRESULT(SEVERITY_ERROR
, FACILITY_WIN32
, ERROR_MORE_DATA
))
807 // allocate dataranges buffer
808 MultipleItem
= (PKSMULTIPLE_ITEM
)CoTaskMemAlloc(BytesReturned
);
811 return E_OUTOFMEMORY
;
814 hr
= KsSynchronousDeviceControl(m_hFilter
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSP_PIN
), (PVOID
)MultipleItem
, BytesReturned
, &BytesReturned
);
818 // failed to query data ranges
819 CoTaskMemFree(MultipleItem
);
823 DataFormat
= (PKSDATAFORMAT
)(MultipleItem
+ 1);
824 for(ULONG Index
= 0; Index
< MultipleItem
->Count
; Index
++)
826 if (IsEqualGUID(pmt
->majortype
, DataFormat
->MajorFormat
) &&
827 IsEqualGUID(pmt
->subtype
, DataFormat
->SubFormat
) &&
828 IsEqualGUID(pmt
->formattype
, DataFormat
->Specifier
))
830 // format is supported
831 CoTaskMemFree(MultipleItem
);
832 OutputDebugStringW(L
"CInputPin::CheckFormat format OK\n");
835 DataFormat
= (PKSDATAFORMAT
)((ULONG_PTR
)DataFormat
+ DataFormat
->FormatSize
);
837 //format is not supported
838 CoTaskMemFree(MultipleItem
);
845 CInputPin::CreatePin()
847 PKSMULTIPLE_ITEM MediumList
;
848 PKSMULTIPLE_ITEM InterfaceList
;
849 PKSMULTIPLE_ITEM DataFormatList
= NULL
;
850 PKSPIN_MEDIUM Medium
;
851 PKSDATAFORMAT DataFormat
;
852 PKSPIN_INTERFACE Interface
;
855 // query for pin medium
856 hr
= KsQueryMediums(&MediumList
);
860 // query for pin interface
861 hr
= KsQueryInterfaces(&InterfaceList
);
865 CoTaskMemFree(MediumList
);
870 hr
= KsGetMultiplePinFactoryItems(m_hFilter
, m_PinId
, KSPROPERTY_PIN_DATARANGES
, (PVOID
*)&DataFormatList
);
871 if (FAILED(hr
) || DataFormatList
->Count
== 0)
874 CoTaskMemFree(MediumList
);
875 CoTaskMemFree(InterfaceList
);
877 CoTaskMemFree(DataFormatList
);
882 if (MediumList
->Count
)
884 //use first available medium
885 Medium
= (PKSPIN_MEDIUM
)(MediumList
+ 1);
889 // default to standard medium
890 Medium
= &StandardPinMedium
;
893 if (InterfaceList
->Count
)
895 //use first available interface
896 Interface
= (PKSPIN_INTERFACE
)(InterfaceList
+ 1);
900 // default to standard interface
901 Interface
= &StandardPinInterface
;
904 //FIXME determine format
905 // use first available format
906 DataFormat
= (PKSDATAFORMAT
) (DataFormatList
+ 1);
909 hr
= CreatePinHandle(Medium
, Interface
, DataFormat
);
911 // free medium / interface / dataformat
912 CoTaskMemFree(DataFormatList
);
913 CoTaskMemFree(MediumList
);
914 CoTaskMemFree(InterfaceList
);
921 CInputPin::CreatePinHandle(
922 PKSPIN_MEDIUM Medium
,
923 PKSPIN_INTERFACE Interface
,
924 PKSDATAFORMAT DataFormat
)
926 PKSPIN_CONNECT PinConnect
;
931 Length
= sizeof(KSPIN_CONNECT
) + DataFormat
->FormatSize
;
933 // allocate pin connect
934 PinConnect
= (PKSPIN_CONNECT
)CoTaskMemAlloc(Length
);
938 return E_OUTOFMEMORY
;
942 CopyMemory(&PinConnect
->Interface
, Interface
, sizeof(KSPIN_INTERFACE
));
943 CopyMemory(&PinConnect
->Medium
, Medium
, sizeof(KSPIN_MEDIUM
));
944 PinConnect
->PinId
= m_PinId
;
945 PinConnect
->PinToHandle
= NULL
;
946 PinConnect
->Priority
.PriorityClass
= KSPRIORITY_NORMAL
;
947 PinConnect
->Priority
.PrioritySubClass
= KSPRIORITY_NORMAL
;
948 CopyMemory((PinConnect
+ 1), DataFormat
, DataFormat
->FormatSize
);
951 hr
= KsCreatePin(m_hFilter
, PinConnect
, GENERIC_WRITE
, &m_hPin
);
954 CoTaskMemFree(PinConnect
);
961 CInputPin_Constructor(
962 IBaseFilter
* ParentFilter
,
966 KSPIN_COMMUNICATION Communication
,
970 CInputPin
* handler
= new CInputPin(ParentFilter
, PinName
, hFilter
, PinId
, Communication
);
973 return E_OUTOFMEMORY
;
975 if (FAILED(handler
->QueryInterface(riid
, ppv
)))
979 return E_NOINTERFACE
;