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}};
14 const GUID KSPROPSETID_Connection
= {0x1D58C920L
, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
18 KSPIN_INTERFACE StandardPinInterface
=
20 {STATIC_KSINTERFACESETID_Standard
},
21 KSINTERFACE_STANDARD_STREAMING
,
25 KSPIN_MEDIUM StandardPinMedium
=
27 {STATIC_KSMEDIUMSETID_Standard
},
28 KSMEDIUM_TYPE_ANYINSTANCE
,
34 KSPIN_INTERFACE StandardPinInterface
=
36 STATIC_KSINTERFACESETID_Standard
,
37 KSINTERFACE_STANDARD_STREAMING
,
41 KSPIN_MEDIUM StandardPinMedium
=
43 STATIC_KSMEDIUMSETID_Standard
,
44 KSMEDIUM_TYPE_ANYINSTANCE
,
50 class CInputPin
: public IPin
,
51 public IKsPropertySet
,
56 public ISpecifyPropertyPages
58 public IQualityControl,
60 public IStreamBuilder,
62 public IKsAggregateControl
66 STDMETHODIMP
QueryInterface( REFIID InterfaceId
, PVOID
* Interface
);
68 STDMETHODIMP_(ULONG
) AddRef()
70 InterlockedIncrement(&m_Ref
);
73 STDMETHODIMP_(ULONG
) Release()
75 InterlockedDecrement(&m_Ref
);
85 HRESULT STDMETHODCALLTYPE
Connect(IPin
*pReceivePin
, const AM_MEDIA_TYPE
*pmt
);
86 HRESULT STDMETHODCALLTYPE
ReceiveConnection(IPin
*pConnector
, const AM_MEDIA_TYPE
*pmt
);
87 HRESULT STDMETHODCALLTYPE
Disconnect();
88 HRESULT STDMETHODCALLTYPE
ConnectedTo(IPin
**pPin
);
89 HRESULT STDMETHODCALLTYPE
ConnectionMediaType(AM_MEDIA_TYPE
*pmt
);
90 HRESULT STDMETHODCALLTYPE
QueryPinInfo(PIN_INFO
*pInfo
);
91 HRESULT STDMETHODCALLTYPE
QueryDirection(PIN_DIRECTION
*pPinDir
);
92 HRESULT STDMETHODCALLTYPE
QueryId(LPWSTR
*Id
);
93 HRESULT STDMETHODCALLTYPE
QueryAccept(const AM_MEDIA_TYPE
*pmt
);
94 HRESULT STDMETHODCALLTYPE
EnumMediaTypes(IEnumMediaTypes
**ppEnum
);
95 HRESULT STDMETHODCALLTYPE
QueryInternalConnections(IPin
**apPin
, ULONG
*nPin
);
96 HRESULT STDMETHODCALLTYPE
EndOfStream();
97 HRESULT STDMETHODCALLTYPE
BeginFlush();
98 HRESULT STDMETHODCALLTYPE
EndFlush();
99 HRESULT STDMETHODCALLTYPE
NewSegment(REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, double dRate
);
101 // ISpecifyPropertyPages
102 HRESULT STDMETHODCALLTYPE
GetPages(CAUUID
*pPages
);
105 HANDLE STDMETHODCALLTYPE
KsGetObjectHandle();
108 HRESULT STDMETHODCALLTYPE
Set(REFGUID guidPropSet
, DWORD dwPropID
, LPVOID pInstanceData
, DWORD cbInstanceData
, LPVOID pPropData
, DWORD cbPropData
);
109 HRESULT STDMETHODCALLTYPE
Get(REFGUID guidPropSet
, DWORD dwPropID
, LPVOID pInstanceData
, DWORD cbInstanceData
, LPVOID pPropData
, DWORD cbPropData
, DWORD
*pcbReturned
);
110 HRESULT STDMETHODCALLTYPE
QuerySupported(REFGUID guidPropSet
, DWORD dwPropID
, DWORD
*pTypeSupport
);
113 HRESULT STDMETHODCALLTYPE
KsProperty(PKSPROPERTY Property
, ULONG PropertyLength
, LPVOID PropertyData
, ULONG DataLength
, ULONG
* BytesReturned
);
114 HRESULT STDMETHODCALLTYPE
KsMethod(PKSMETHOD Method
, ULONG MethodLength
, LPVOID MethodData
, ULONG DataLength
, ULONG
* BytesReturned
);
115 HRESULT STDMETHODCALLTYPE
KsEvent(PKSEVENT Event
, ULONG EventLength
, LPVOID EventData
, ULONG DataLength
, ULONG
* BytesReturned
);
118 HRESULT STDMETHODCALLTYPE
KsQueryMediums(PKSMULTIPLE_ITEM
* MediumList
);
119 HRESULT STDMETHODCALLTYPE
KsQueryInterfaces(PKSMULTIPLE_ITEM
* InterfaceList
);
120 HRESULT STDMETHODCALLTYPE
KsCreateSinkPinHandle(KSPIN_INTERFACE
& Interface
, KSPIN_MEDIUM
& Medium
);
121 HRESULT STDMETHODCALLTYPE
KsGetCurrentCommunication(KSPIN_COMMUNICATION
*Communication
, KSPIN_INTERFACE
*Interface
, KSPIN_MEDIUM
*Medium
);
122 HRESULT STDMETHODCALLTYPE
KsPropagateAcquire();
123 HRESULT STDMETHODCALLTYPE
KsDeliver(IMediaSample
* Sample
, ULONG Flags
);
124 HRESULT STDMETHODCALLTYPE
KsMediaSamplesCompleted(PKSSTREAM_SEGMENT StreamSegment
);
125 IMemAllocator
* STDMETHODCALLTYPE
KsPeekAllocator(KSPEEKOPERATION Operation
);
126 HRESULT STDMETHODCALLTYPE
KsReceiveAllocator(IMemAllocator
*MemAllocator
);
127 HRESULT STDMETHODCALLTYPE
KsRenegotiateAllocator();
128 LONG STDMETHODCALLTYPE
KsIncrementPendingIoCount();
129 LONG STDMETHODCALLTYPE
KsDecrementPendingIoCount();
130 HRESULT STDMETHODCALLTYPE
KsQualityNotify(ULONG Proportion
, REFERENCE_TIME TimeDelta
);
132 VOID STDMETHODCALLTYPE
KsNotifyError(IMediaSample
* Sample
, HRESULT hr
);
135 HRESULT STDMETHODCALLTYPE
GetAllocator(IMemAllocator
**ppAllocator
);
136 HRESULT STDMETHODCALLTYPE
NotifyAllocator(IMemAllocator
*pAllocator
, BOOL bReadOnly
);
137 HRESULT STDMETHODCALLTYPE
GetAllocatorRequirements(ALLOCATOR_PROPERTIES
*pProps
);
138 HRESULT STDMETHODCALLTYPE
Receive(IMediaSample
*pSample
);
139 HRESULT STDMETHODCALLTYPE
ReceiveMultiple(IMediaSample
**pSamples
, long nSamples
, long *nSamplesProcessed
);
140 HRESULT STDMETHODCALLTYPE
ReceiveCanBlock( void);
142 //---------------------------------------------------------------
143 HRESULT STDMETHODCALLTYPE
CheckFormat(const AM_MEDIA_TYPE
*pmt
);
144 HRESULT STDMETHODCALLTYPE
CreatePin(const AM_MEDIA_TYPE
*pmt
);
145 HRESULT STDMETHODCALLTYPE
CreatePinHandle(PKSPIN_MEDIUM Medium
, PKSPIN_INTERFACE Interface
, const AM_MEDIA_TYPE
*pmt
);
146 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(INVALID_HANDLE_VALUE
), m_PinId(PinId
), m_MemAllocator(0), m_IoCount(0), m_Communication(Communication
), m_Pin(0), m_ReadOnly(0){};
147 virtual ~CInputPin(){};
151 IBaseFilter
* m_ParentFilter
;
156 IMemAllocator
* m_MemAllocator
;
158 KSPIN_COMMUNICATION m_Communication
;
159 KSPIN_INTERFACE m_Interface
;
160 KSPIN_MEDIUM m_Medium
;
167 CInputPin::QueryInterface(
173 if (IsEqualGUID(refiid
, IID_IUnknown
) ||
174 IsEqualGUID(refiid
, IID_IPin
))
176 *Output
= PVOID(this);
177 reinterpret_cast<IUnknown
*>(*Output
)->AddRef();
180 else if (IsEqualGUID(refiid
, IID_IMemInputPin
))
182 *Output
= (IMemInputPin
*)(this);
183 reinterpret_cast<IMemInputPin
*>(*Output
)->AddRef();
186 else if (IsEqualGUID(refiid
, IID_IKsObject
))
188 *Output
= (IKsObject
*)(this);
189 reinterpret_cast<IKsObject
*>(*Output
)->AddRef();
192 else if (IsEqualGUID(refiid
, IID_IKsPropertySet
))
194 *Output
= (IKsPropertySet
*)(this);
195 reinterpret_cast<IKsPropertySet
*>(*Output
)->AddRef();
198 else if (IsEqualGUID(refiid
, IID_IKsControl
))
200 *Output
= (IKsControl
*)(this);
201 reinterpret_cast<IKsControl
*>(*Output
)->AddRef();
204 else if (IsEqualGUID(refiid
, IID_IKsPin
) ||
205 IsEqualGUID(refiid
, IID_IKsPinEx
))
207 *Output
= (IKsPinEx
*)(this);
208 reinterpret_cast<IKsPinEx
*>(*Output
)->AddRef();
211 else if (IsEqualGUID(refiid
, IID_ISpecifyPropertyPages
))
213 *Output
= (ISpecifyPropertyPages
*)(this);
214 reinterpret_cast<ISpecifyPropertyPages
*>(*Output
)->AddRef();
218 WCHAR Buffer
[MAX_PATH
];
220 StringFromCLSID(refiid
, &lpstr
);
221 swprintf(Buffer
, L
"CInputPin::QueryInterface: NoInterface for %s\n", lpstr
);
222 OutputDebugStringW(Buffer
);
223 CoTaskMemFree(lpstr
);
225 return E_NOINTERFACE
;
228 //-------------------------------------------------------------------
229 // ISpecifyPropertyPages
234 CInputPin::GetPages(CAUUID
*pPages
)
240 pPages
->pElems
= NULL
;
245 //-------------------------------------------------------------------
252 CInputPin::GetAllocator(IMemAllocator
**ppAllocator
)
254 OutputDebugStringW(L
"CInputPin::GetAllocator\n");
255 return VFW_E_NO_ALLOCATOR
;
260 CInputPin::NotifyAllocator(IMemAllocator
*pAllocator
, BOOL bReadOnly
)
264 pAllocator
->AddRef();
269 m_MemAllocator
->Release();
272 m_MemAllocator
= pAllocator
;
273 m_ReadOnly
= bReadOnly
;
279 CInputPin::GetAllocatorRequirements(ALLOCATOR_PROPERTIES
*pProps
)
281 KSALLOCATOR_FRAMING Framing
;
286 Property
.Set
= KSPROPSETID_Connection
;
287 Property
.Id
= KSPROPERTY_CONNECTION_ALLOCATORFRAMING
;
288 Property
.Flags
= KSPROPERTY_TYPE_SET
;
290 hr
= KsProperty(&Property
, sizeof(KSPROPERTY
), (PVOID
)&Framing
, sizeof(KSALLOCATOR_FRAMING
), &BytesReturned
);
293 pProps
->cBuffers
= Framing
.Frames
;
294 pProps
->cbBuffer
= Framing
.FrameSize
;
295 pProps
->cbAlign
= Framing
.FileAlignment
;
296 pProps
->cbPrefix
= 0;
305 CInputPin::Receive(IMediaSample
*pSample
)
307 OutputDebugStringW(L
"CInputPin::Receive NotImplemented\n");
313 CInputPin::ReceiveMultiple(IMediaSample
**pSamples
, long nSamples
, long *nSamplesProcessed
)
315 OutputDebugStringW(L
"CInputPin::ReceiveMultiple NotImplemented\n");
321 CInputPin::ReceiveCanBlock( void)
323 OutputDebugStringW(L
"CInputPin::ReceiveCanBlock NotImplemented\n");
328 //-------------------------------------------------------------------
334 CInputPin::KsQueryMediums(
335 PKSMULTIPLE_ITEM
* MediumList
)
337 return KsGetMultiplePinFactoryItems(m_hFilter
, m_PinId
, KSPROPERTY_PIN_MEDIUMS
, (PVOID
*)MediumList
);
342 CInputPin::KsQueryInterfaces(
343 PKSMULTIPLE_ITEM
* InterfaceList
)
345 return KsGetMultiplePinFactoryItems(m_hFilter
, m_PinId
, KSPROPERTY_PIN_INTERFACES
, (PVOID
*)InterfaceList
);
350 CInputPin::KsCreateSinkPinHandle(
351 KSPIN_INTERFACE
& Interface
,
352 KSPIN_MEDIUM
& Medium
)
354 OutputDebugStringW(L
"CInputPin::KsCreateSinkPinHandle NotImplemented\n");
360 CInputPin::KsGetCurrentCommunication(
361 KSPIN_COMMUNICATION
*Communication
,
362 KSPIN_INTERFACE
*Interface
,
363 KSPIN_MEDIUM
*Medium
)
367 *Communication
= m_Communication
;
373 return VFW_E_NOT_CONNECTED
;
375 CopyMemory(Interface
, &m_Interface
, sizeof(KSPIN_INTERFACE
));
381 return VFW_E_NOT_CONNECTED
;
383 CopyMemory(Medium
, &m_Medium
, sizeof(KSPIN_MEDIUM
));
390 CInputPin::KsPropagateAcquire()
392 OutputDebugStringW(L
"CInputPin::KsPropagateAcquire NotImplemented\n");
398 CInputPin::KsDeliver(
399 IMediaSample
* Sample
,
407 CInputPin::KsMediaSamplesCompleted(PKSSTREAM_SEGMENT StreamSegment
)
414 CInputPin::KsPeekAllocator(KSPEEKOPERATION Operation
)
416 if (Operation
== KsPeekOperation_AddRef
)
418 // add reference on allocator
419 m_MemAllocator
->AddRef();
422 return m_MemAllocator
;
427 CInputPin::KsReceiveAllocator(IMemAllocator
*MemAllocator
)
431 MemAllocator
->AddRef();
436 m_MemAllocator
->Release();
439 m_MemAllocator
= MemAllocator
;
445 CInputPin::KsRenegotiateAllocator()
452 CInputPin::KsIncrementPendingIoCount()
454 return InterlockedIncrement((volatile LONG
*)&m_IoCount
);
459 CInputPin::KsDecrementPendingIoCount()
461 return InterlockedDecrement((volatile LONG
*)&m_IoCount
);
466 CInputPin::KsQualityNotify(
468 REFERENCE_TIME TimeDelta
)
470 OutputDebugStringW(L
"CInputPin::KsQualityNotify NotImplemented\n");
474 //-------------------------------------------------------------------
480 CInputPin::KsNotifyError(
481 IMediaSample
* Sample
,
484 OutputDebugStringW(L
"CInputPin::KsNotifyError NotImplemented\n");
488 //-------------------------------------------------------------------
493 CInputPin::KsProperty(
494 PKSPROPERTY Property
,
495 ULONG PropertyLength
,
498 ULONG
* BytesReturned
)
501 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_PROPERTY
, (PVOID
)Property
, PropertyLength
, (PVOID
)PropertyData
, DataLength
, BytesReturned
);
511 ULONG
* BytesReturned
)
514 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_METHOD
, (PVOID
)Method
, MethodLength
, (PVOID
)MethodData
, DataLength
, BytesReturned
);
524 ULONG
* BytesReturned
)
529 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_ENABLE_EVENT
, (PVOID
)Event
, EventLength
, (PVOID
)EventData
, DataLength
, BytesReturned
);
531 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_DISABLE_EVENT
, (PVOID
)Event
, EventLength
, NULL
, 0, BytesReturned
);
535 //-------------------------------------------------------------------
543 LPVOID pInstanceData
,
544 DWORD cbInstanceData
,
552 PKSPROPERTY Property
= (PKSPROPERTY
)CoTaskMemAlloc(sizeof(KSPROPERTY
) + cbInstanceData
);
554 return E_OUTOFMEMORY
;
556 Property
->Set
= guidPropSet
;
557 Property
->Id
= dwPropID
;
558 Property
->Flags
= KSPROPERTY_TYPE_SET
;
560 CopyMemory((Property
+1), pInstanceData
, cbInstanceData
);
562 HRESULT hr
= KsProperty(Property
, sizeof(KSPROPERTY
) + cbInstanceData
, pPropData
, cbPropData
, &BytesReturned
);
563 CoTaskMemFree(Property
);
570 Property
.Set
= guidPropSet
;
571 Property
.Id
= dwPropID
;
572 Property
.Flags
= KSPROPERTY_TYPE_SET
;
574 HRESULT hr
= KsProperty(&Property
, sizeof(KSPROPERTY
), pPropData
, cbPropData
, &BytesReturned
);
584 LPVOID pInstanceData
,
585 DWORD cbInstanceData
,
594 PKSPROPERTY Property
= (PKSPROPERTY
)CoTaskMemAlloc(sizeof(KSPROPERTY
) + cbInstanceData
);
596 return E_OUTOFMEMORY
;
598 Property
->Set
= guidPropSet
;
599 Property
->Id
= dwPropID
;
600 Property
->Flags
= KSPROPERTY_TYPE_GET
;
602 CopyMemory((Property
+1), pInstanceData
, cbInstanceData
);
604 HRESULT hr
= KsProperty(Property
, sizeof(KSPROPERTY
) + cbInstanceData
, pPropData
, cbPropData
, &BytesReturned
);
605 CoTaskMemFree(Property
);
612 Property
.Set
= guidPropSet
;
613 Property
.Id
= dwPropID
;
614 Property
.Flags
= KSPROPERTY_TYPE_GET
;
616 HRESULT hr
= KsProperty(&Property
, sizeof(KSPROPERTY
), pPropData
, cbPropData
, &BytesReturned
);
623 CInputPin::QuerySupported(
631 Property
.Set
= guidPropSet
;
632 Property
.Id
= dwPropID
;
633 Property
.Flags
= KSPROPERTY_TYPE_SETSUPPORT
;
635 return KsProperty(&Property
, sizeof(KSPROPERTY
), pTypeSupport
, sizeof(DWORD
), &BytesReturned
);
639 //-------------------------------------------------------------------
644 CInputPin::KsGetObjectHandle()
650 //-------------------------------------------------------------------
655 CInputPin::Connect(IPin
*pReceivePin
, const AM_MEDIA_TYPE
*pmt
)
657 OutputDebugStringW(L
"CInputPin::Connect NotImplemented\n");
663 CInputPin::ReceiveConnection(IPin
*pConnector
, const AM_MEDIA_TYPE
*pmt
)
669 return VFW_E_ALREADY_CONNECTED
;
672 // first check format
673 hr
= CheckFormat(pmt
);
677 if (FAILED(CheckFormat(pmt
)))
694 CInputPin::Disconnect( void)
698 // pin was not connected
703 //check if filter is active
708 OutputDebugStringW(L
"CInputPin::Disconnect\n");
713 CInputPin::ConnectedTo(IPin
**pPin
)
720 // increment reference count
727 return VFW_E_NOT_CONNECTED
;
731 CInputPin::ConnectionMediaType(AM_MEDIA_TYPE
*pmt
)
734 return VFW_E_NOT_CONNECTED
;
736 OutputDebugStringW(L
"CInputPin::ConnectionMediaType NotImplemented\n");
741 CInputPin::QueryPinInfo(PIN_INFO
*pInfo
)
743 wcscpy(pInfo
->achName
, m_PinName
);
744 pInfo
->dir
= PINDIR_INPUT
;
745 pInfo
->pFilter
= m_ParentFilter
;
746 m_ParentFilter
->AddRef();
752 CInputPin::QueryDirection(PIN_DIRECTION
*pPinDir
)
756 *pPinDir
= PINDIR_INPUT
;
764 CInputPin::QueryId(LPWSTR
*Id
)
766 *Id
= (LPWSTR
)CoTaskMemAlloc((wcslen(m_PinName
)+1)*sizeof(WCHAR
));
768 return E_OUTOFMEMORY
;
770 wcscpy(*Id
, m_PinName
);
776 CInputPin::QueryAccept(
777 const AM_MEDIA_TYPE
*pmt
)
779 return CheckFormat(pmt
);
783 CInputPin::EnumMediaTypes(IEnumMediaTypes
**ppEnum
)
786 ULONG MediaTypeCount
= 0, Index
;
787 AM_MEDIA_TYPE
* MediaTypes
;
789 // query media type count
790 hr
= KsGetMediaTypeCount(m_hFilter
, m_PinId
, &MediaTypeCount
);
791 if (FAILED(hr
) || !MediaTypeCount
)
794 // allocate media types
795 MediaTypes
= (AM_MEDIA_TYPE
*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE
) * MediaTypeCount
);
799 return E_OUTOFMEMORY
;
803 ZeroMemory(MediaTypes
, sizeof(AM_MEDIA_TYPE
) * MediaTypeCount
);
805 for(Index
= 0; Index
< MediaTypeCount
; Index
++)
808 hr
= KsGetMediaType(Index
, &MediaTypes
[Index
], m_hFilter
, m_PinId
);
812 CoTaskMemFree(MediaTypes
);
817 return CEnumMediaTypes_fnConstructor(MediaTypeCount
, MediaTypes
, IID_IEnumMediaTypes
, (void**)ppEnum
);
822 CInputPin::QueryInternalConnections(IPin
**apPin
, ULONG
*nPin
)
824 OutputDebugStringW(L
"CInputPin::QueryInternalConnections NotImplemented\n");
829 CInputPin::EndOfStream( void)
831 OutputDebugStringW(L
"CInputPin::EndOfStream NotImplemented\n");
836 CInputPin::BeginFlush( void)
838 OutputDebugStringW(L
"CInputPin::BeginFlush NotImplemented\n");
843 CInputPin::EndFlush( void)
845 OutputDebugStringW(L
"CInputPin::EndFlush NotImplemented\n");
850 CInputPin::NewSegment(REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, double dRate
)
852 OutputDebugStringW(L
"CInputPin::NewSegment NotImplemented\n");
856 //-------------------------------------------------------------------
859 CInputPin::CheckFormat(
860 const AM_MEDIA_TYPE
*pmt
)
863 PKSMULTIPLE_ITEM MultipleItem
;
864 PKSDATAFORMAT DataFormat
;
869 Property
.Property
.Set
= KSPROPSETID_Pin
;
870 Property
.Property
.Id
= KSPROPERTY_PIN_DATARANGES
;
871 Property
.Property
.Flags
= KSPROPERTY_TYPE_GET
;
872 Property
.PinId
= m_PinId
;
873 Property
.Reserved
= 0;
878 // query for size of dataranges
879 hr
= KsSynchronousDeviceControl(m_hFilter
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSP_PIN
), NULL
, 0, &BytesReturned
);
881 if (hr
== MAKE_HRESULT(SEVERITY_ERROR
, FACILITY_WIN32
, ERROR_MORE_DATA
))
883 // allocate dataranges buffer
884 MultipleItem
= (PKSMULTIPLE_ITEM
)CoTaskMemAlloc(BytesReturned
);
887 return E_OUTOFMEMORY
;
890 hr
= KsSynchronousDeviceControl(m_hFilter
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSP_PIN
), (PVOID
)MultipleItem
, BytesReturned
, &BytesReturned
);
894 // failed to query data ranges
895 CoTaskMemFree(MultipleItem
);
899 DataFormat
= (PKSDATAFORMAT
)(MultipleItem
+ 1);
900 for(ULONG Index
= 0; Index
< MultipleItem
->Count
; Index
++)
902 if (IsEqualGUID(pmt
->majortype
, DataFormat
->MajorFormat
) &&
903 IsEqualGUID(pmt
->subtype
, DataFormat
->SubFormat
) &&
904 IsEqualGUID(pmt
->formattype
, DataFormat
->Specifier
))
906 // format is supported
907 CoTaskMemFree(MultipleItem
);
908 OutputDebugStringW(L
"CInputPin::CheckFormat format OK\n");
911 DataFormat
= (PKSDATAFORMAT
)((ULONG_PTR
)DataFormat
+ DataFormat
->FormatSize
);
913 //format is not supported
914 CoTaskMemFree(MultipleItem
);
921 CInputPin::CreatePin(
922 const AM_MEDIA_TYPE
*pmt
)
924 PKSMULTIPLE_ITEM MediumList
;
925 PKSMULTIPLE_ITEM InterfaceList
;
926 PKSPIN_MEDIUM Medium
;
927 PKSPIN_INTERFACE Interface
;
930 // query for pin medium
931 hr
= KsQueryMediums(&MediumList
);
935 // query for pin interface
936 hr
= KsQueryInterfaces(&InterfaceList
);
940 CoTaskMemFree(MediumList
);
944 if (MediumList
->Count
)
946 //use first available medium
947 Medium
= (PKSPIN_MEDIUM
)(MediumList
+ 1);
951 // default to standard medium
952 Medium
= &StandardPinMedium
;
955 if (InterfaceList
->Count
)
957 //use first available interface
958 Interface
= (PKSPIN_INTERFACE
)(InterfaceList
+ 1);
962 // default to standard interface
963 Interface
= &StandardPinInterface
;
967 hr
= CreatePinHandle(Medium
, Interface
, pmt
);
969 // free medium / interface / dataformat
970 CoTaskMemFree(MediumList
);
971 CoTaskMemFree(InterfaceList
);
978 CInputPin::CreatePinHandle(
979 PKSPIN_MEDIUM Medium
,
980 PKSPIN_INTERFACE Interface
,
981 const AM_MEDIA_TYPE
*pmt
)
983 PKSPIN_CONNECT PinConnect
;
984 PKSDATAFORMAT DataFormat
;
989 Length
= sizeof(KSPIN_CONNECT
) + sizeof(KSDATAFORMAT
) + pmt
->cbFormat
;
991 // allocate pin connect
992 PinConnect
= (PKSPIN_CONNECT
)CoTaskMemAlloc(Length
);
996 return E_OUTOFMEMORY
;
1000 CopyMemory(&PinConnect
->Interface
, Interface
, sizeof(KSPIN_INTERFACE
));
1001 CopyMemory(&PinConnect
->Medium
, Medium
, sizeof(KSPIN_MEDIUM
));
1002 PinConnect
->PinId
= m_PinId
;
1003 PinConnect
->PinToHandle
= NULL
;
1004 PinConnect
->Priority
.PriorityClass
= KSPRIORITY_NORMAL
;
1005 PinConnect
->Priority
.PrioritySubClass
= KSPRIORITY_NORMAL
;
1007 // get dataformat offset
1008 DataFormat
= (PKSDATAFORMAT
)(PinConnect
+ 1);
1011 DataFormat
->FormatSize
= sizeof(KSDATAFORMAT
) + pmt
->cbFormat
;
1012 DataFormat
->Flags
= 0;
1013 DataFormat
->SampleSize
= pmt
->lSampleSize
;
1014 DataFormat
->Reserved
= 0;
1015 CopyMemory(&DataFormat
->MajorFormat
, &pmt
->majortype
, sizeof(GUID
));
1016 CopyMemory(&DataFormat
->SubFormat
, &pmt
->subtype
, sizeof(GUID
));
1017 CopyMemory(&DataFormat
->Specifier
, &pmt
->formattype
, sizeof(GUID
));
1021 // copy extended format
1022 CopyMemory((DataFormat
+ 1), pmt
->pbFormat
, pmt
->cbFormat
);
1026 hr
= KsCreatePin(m_hFilter
, PinConnect
, GENERIC_WRITE
, &m_hPin
);
1029 CoTaskMemFree(PinConnect
);
1036 CInputPin_Constructor(
1037 IBaseFilter
* ParentFilter
,
1041 KSPIN_COMMUNICATION Communication
,
1045 CInputPin
* handler
= new CInputPin(ParentFilter
, PinName
, hFilter
, PinId
, Communication
);
1048 return E_OUTOFMEMORY
;
1050 if (FAILED(handler
->QueryInterface(riid
, ppv
)))
1054 return E_NOINTERFACE
;