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
,
57 public IQualityControl,
59 public ISpecifyPropertyPages,
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
);
102 HANDLE STDMETHODCALLTYPE
KsGetObjectHandle();
105 HRESULT STDMETHODCALLTYPE
Set(REFGUID guidPropSet
, DWORD dwPropID
, LPVOID pInstanceData
, DWORD cbInstanceData
, LPVOID pPropData
, DWORD cbPropData
);
106 HRESULT STDMETHODCALLTYPE
Get(REFGUID guidPropSet
, DWORD dwPropID
, LPVOID pInstanceData
, DWORD cbInstanceData
, LPVOID pPropData
, DWORD cbPropData
, DWORD
*pcbReturned
);
107 HRESULT STDMETHODCALLTYPE
QuerySupported(REFGUID guidPropSet
, DWORD dwPropID
, DWORD
*pTypeSupport
);
110 HRESULT STDMETHODCALLTYPE
KsProperty(PKSPROPERTY Property
, ULONG PropertyLength
, LPVOID PropertyData
, ULONG DataLength
, ULONG
* BytesReturned
);
111 HRESULT STDMETHODCALLTYPE
KsMethod(PKSMETHOD Method
, ULONG MethodLength
, LPVOID MethodData
, ULONG DataLength
, ULONG
* BytesReturned
);
112 HRESULT STDMETHODCALLTYPE
KsEvent(PKSEVENT Event
, ULONG EventLength
, LPVOID EventData
, ULONG DataLength
, ULONG
* BytesReturned
);
115 HRESULT STDMETHODCALLTYPE
KsQueryMediums(PKSMULTIPLE_ITEM
* MediumList
);
116 HRESULT STDMETHODCALLTYPE
KsQueryInterfaces(PKSMULTIPLE_ITEM
* InterfaceList
);
117 HRESULT STDMETHODCALLTYPE
KsCreateSinkPinHandle(KSPIN_INTERFACE
& Interface
, KSPIN_MEDIUM
& Medium
);
118 HRESULT STDMETHODCALLTYPE
KsGetCurrentCommunication(KSPIN_COMMUNICATION
*Communication
, KSPIN_INTERFACE
*Interface
, KSPIN_MEDIUM
*Medium
);
119 HRESULT STDMETHODCALLTYPE
KsPropagateAcquire();
120 HRESULT STDMETHODCALLTYPE
KsDeliver(IMediaSample
* Sample
, ULONG Flags
);
121 HRESULT STDMETHODCALLTYPE
KsMediaSamplesCompleted(PKSSTREAM_SEGMENT StreamSegment
);
122 IMemAllocator
* STDMETHODCALLTYPE
KsPeekAllocator(KSPEEKOPERATION Operation
);
123 HRESULT STDMETHODCALLTYPE
KsReceiveAllocator(IMemAllocator
*MemAllocator
);
124 HRESULT STDMETHODCALLTYPE
KsRenegotiateAllocator();
125 LONG STDMETHODCALLTYPE
KsIncrementPendingIoCount();
126 LONG STDMETHODCALLTYPE
KsDecrementPendingIoCount();
127 HRESULT STDMETHODCALLTYPE
KsQualityNotify(ULONG Proportion
, REFERENCE_TIME TimeDelta
);
129 VOID STDMETHODCALLTYPE
KsNotifyError(IMediaSample
* Sample
, HRESULT hr
);
132 HRESULT STDMETHODCALLTYPE
GetAllocator(IMemAllocator
**ppAllocator
);
133 HRESULT STDMETHODCALLTYPE
NotifyAllocator(IMemAllocator
*pAllocator
, BOOL bReadOnly
);
134 HRESULT STDMETHODCALLTYPE
GetAllocatorRequirements(ALLOCATOR_PROPERTIES
*pProps
);
135 HRESULT STDMETHODCALLTYPE
Receive(IMediaSample
*pSample
);
136 HRESULT STDMETHODCALLTYPE
ReceiveMultiple(IMediaSample
**pSamples
, long nSamples
, long *nSamplesProcessed
);
137 HRESULT STDMETHODCALLTYPE
ReceiveCanBlock( void);
139 //---------------------------------------------------------------
140 HRESULT STDMETHODCALLTYPE
CheckFormat(const AM_MEDIA_TYPE
*pmt
);
141 HRESULT STDMETHODCALLTYPE
CreatePin(const AM_MEDIA_TYPE
*pmt
);
142 HRESULT STDMETHODCALLTYPE
CreatePinHandle(PKSPIN_MEDIUM Medium
, PKSPIN_INTERFACE Interface
, const AM_MEDIA_TYPE
*pmt
);
143 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), m_ReadOnly(0){};
144 virtual ~CInputPin(){};
148 IBaseFilter
* m_ParentFilter
;
153 IMemAllocator
* m_MemAllocator
;
155 KSPIN_COMMUNICATION m_Communication
;
156 KSPIN_INTERFACE m_Interface
;
157 KSPIN_MEDIUM m_Medium
;
164 CInputPin::QueryInterface(
170 if (IsEqualGUID(refiid
, IID_IUnknown
) ||
171 IsEqualGUID(refiid
, IID_IPin
))
173 *Output
= PVOID(this);
174 reinterpret_cast<IUnknown
*>(*Output
)->AddRef();
177 else if (IsEqualGUID(refiid
, IID_IMemInputPin
))
179 *Output
= (IMemInputPin
*)(this);
180 reinterpret_cast<IMemInputPin
*>(*Output
)->AddRef();
183 else if (IsEqualGUID(refiid
, IID_IKsObject
))
185 *Output
= (IKsObject
*)(this);
186 reinterpret_cast<IKsObject
*>(*Output
)->AddRef();
189 else if (IsEqualGUID(refiid
, IID_IKsPropertySet
))
191 *Output
= (IKsPropertySet
*)(this);
192 reinterpret_cast<IKsPropertySet
*>(*Output
)->AddRef();
195 else if (IsEqualGUID(refiid
, IID_IKsControl
))
197 *Output
= (IKsControl
*)(this);
198 reinterpret_cast<IKsControl
*>(*Output
)->AddRef();
201 else if (IsEqualGUID(refiid
, IID_IKsPin
) ||
202 IsEqualGUID(refiid
, IID_IKsPinEx
))
204 *Output
= (IKsPinEx
*)(this);
205 reinterpret_cast<IKsPinEx
*>(*Output
)->AddRef();
210 WCHAR Buffer
[MAX_PATH
];
212 StringFromCLSID(refiid
, &lpstr
);
213 swprintf(Buffer
, L
"CInputPin::QueryInterface: NoInterface for %s\n", lpstr
);
214 OutputDebugStringW(Buffer
);
215 CoTaskMemFree(lpstr
);
217 return E_NOINTERFACE
;
220 //-------------------------------------------------------------------
227 CInputPin::GetAllocator(IMemAllocator
**ppAllocator
)
229 OutputDebugStringW(L
"CInputPin::GetAllocator\n");
230 return VFW_E_NO_ALLOCATOR
;
235 CInputPin::NotifyAllocator(IMemAllocator
*pAllocator
, BOOL bReadOnly
)
239 pAllocator
->AddRef();
244 m_MemAllocator
->Release();
247 m_MemAllocator
= pAllocator
;
248 m_ReadOnly
= bReadOnly
;
254 CInputPin::GetAllocatorRequirements(ALLOCATOR_PROPERTIES
*pProps
)
256 KSALLOCATOR_FRAMING Framing
;
261 Property
.Set
= KSPROPSETID_Connection
;
262 Property
.Id
= KSPROPERTY_CONNECTION_ALLOCATORFRAMING
;
263 Property
.Flags
= KSPROPERTY_TYPE_SET
;
265 hr
= KsProperty(&Property
, sizeof(KSPROPERTY
), (PVOID
)&Framing
, sizeof(KSALLOCATOR_FRAMING
), &BytesReturned
);
268 pProps
->cBuffers
= Framing
.Frames
;
269 pProps
->cbBuffer
= Framing
.FrameSize
;
270 pProps
->cbAlign
= Framing
.FileAlignment
;
271 pProps
->cbPrefix
= 0;
280 CInputPin::Receive(IMediaSample
*pSample
)
282 OutputDebugStringW(L
"CInputPin::Receive NotImplemented\n");
288 CInputPin::ReceiveMultiple(IMediaSample
**pSamples
, long nSamples
, long *nSamplesProcessed
)
290 OutputDebugStringW(L
"CInputPin::ReceiveMultiple NotImplemented\n");
296 CInputPin::ReceiveCanBlock( void)
298 OutputDebugStringW(L
"CInputPin::ReceiveCanBlock NotImplemented\n");
303 //-------------------------------------------------------------------
309 CInputPin::KsQueryMediums(
310 PKSMULTIPLE_ITEM
* MediumList
)
312 return KsGetMultiplePinFactoryItems(m_hFilter
, m_PinId
, KSPROPERTY_PIN_MEDIUMS
, (PVOID
*)MediumList
);
317 CInputPin::KsQueryInterfaces(
318 PKSMULTIPLE_ITEM
* InterfaceList
)
320 return KsGetMultiplePinFactoryItems(m_hFilter
, m_PinId
, KSPROPERTY_PIN_INTERFACES
, (PVOID
*)InterfaceList
);
325 CInputPin::KsCreateSinkPinHandle(
326 KSPIN_INTERFACE
& Interface
,
327 KSPIN_MEDIUM
& Medium
)
329 OutputDebugStringW(L
"CInputPin::KsCreateSinkPinHandle NotImplemented\n");
335 CInputPin::KsGetCurrentCommunication(
336 KSPIN_COMMUNICATION
*Communication
,
337 KSPIN_INTERFACE
*Interface
,
338 KSPIN_MEDIUM
*Medium
)
342 *Communication
= m_Communication
;
348 return VFW_E_NOT_CONNECTED
;
350 CopyMemory(Interface
, &m_Interface
, sizeof(KSPIN_INTERFACE
));
356 return VFW_E_NOT_CONNECTED
;
358 CopyMemory(Medium
, &m_Medium
, sizeof(KSPIN_MEDIUM
));
365 CInputPin::KsPropagateAcquire()
367 OutputDebugStringW(L
"CInputPin::KsPropagateAcquire NotImplemented\n");
373 CInputPin::KsDeliver(
374 IMediaSample
* Sample
,
382 CInputPin::KsMediaSamplesCompleted(PKSSTREAM_SEGMENT StreamSegment
)
389 CInputPin::KsPeekAllocator(KSPEEKOPERATION Operation
)
391 if (Operation
== KsPeekOperation_AddRef
)
393 // add reference on allocator
394 m_MemAllocator
->AddRef();
397 return m_MemAllocator
;
402 CInputPin::KsReceiveAllocator(IMemAllocator
*MemAllocator
)
406 MemAllocator
->AddRef();
411 m_MemAllocator
->Release();
414 m_MemAllocator
= MemAllocator
;
420 CInputPin::KsRenegotiateAllocator()
427 CInputPin::KsIncrementPendingIoCount()
429 return InterlockedIncrement((volatile LONG
*)&m_IoCount
);
434 CInputPin::KsDecrementPendingIoCount()
436 return InterlockedDecrement((volatile LONG
*)&m_IoCount
);
441 CInputPin::KsQualityNotify(
443 REFERENCE_TIME TimeDelta
)
445 OutputDebugStringW(L
"CInputPin::KsQualityNotify NotImplemented\n");
449 //-------------------------------------------------------------------
455 CInputPin::KsNotifyError(
456 IMediaSample
* Sample
,
459 OutputDebugStringW(L
"CInputPin::KsNotifyError NotImplemented\n");
463 //-------------------------------------------------------------------
468 CInputPin::KsProperty(
469 PKSPROPERTY Property
,
470 ULONG PropertyLength
,
473 ULONG
* BytesReturned
)
476 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_PROPERTY
, (PVOID
)Property
, PropertyLength
, (PVOID
)PropertyData
, DataLength
, BytesReturned
);
486 ULONG
* BytesReturned
)
489 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_METHOD
, (PVOID
)Method
, MethodLength
, (PVOID
)MethodData
, DataLength
, BytesReturned
);
499 ULONG
* BytesReturned
)
504 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_ENABLE_EVENT
, (PVOID
)Event
, EventLength
, (PVOID
)EventData
, DataLength
, BytesReturned
);
506 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_DISABLE_EVENT
, (PVOID
)Event
, EventLength
, NULL
, 0, BytesReturned
);
510 //-------------------------------------------------------------------
518 LPVOID pInstanceData
,
519 DWORD cbInstanceData
,
527 PKSPROPERTY Property
= (PKSPROPERTY
)CoTaskMemAlloc(sizeof(KSPROPERTY
) + cbInstanceData
);
529 return E_OUTOFMEMORY
;
531 Property
->Set
= guidPropSet
;
532 Property
->Id
= dwPropID
;
533 Property
->Flags
= KSPROPERTY_TYPE_SET
;
535 CopyMemory((Property
+1), pInstanceData
, cbInstanceData
);
537 HRESULT hr
= KsProperty(Property
, sizeof(KSPROPERTY
) + cbInstanceData
, pPropData
, cbPropData
, &BytesReturned
);
538 CoTaskMemFree(Property
);
545 Property
.Set
= guidPropSet
;
546 Property
.Id
= dwPropID
;
547 Property
.Flags
= KSPROPERTY_TYPE_SET
;
549 HRESULT hr
= KsProperty(&Property
, sizeof(KSPROPERTY
), pPropData
, cbPropData
, &BytesReturned
);
559 LPVOID pInstanceData
,
560 DWORD cbInstanceData
,
569 PKSPROPERTY Property
= (PKSPROPERTY
)CoTaskMemAlloc(sizeof(KSPROPERTY
) + cbInstanceData
);
571 return E_OUTOFMEMORY
;
573 Property
->Set
= guidPropSet
;
574 Property
->Id
= dwPropID
;
575 Property
->Flags
= KSPROPERTY_TYPE_GET
;
577 CopyMemory((Property
+1), pInstanceData
, cbInstanceData
);
579 HRESULT hr
= KsProperty(Property
, sizeof(KSPROPERTY
) + cbInstanceData
, pPropData
, cbPropData
, &BytesReturned
);
580 CoTaskMemFree(Property
);
587 Property
.Set
= guidPropSet
;
588 Property
.Id
= dwPropID
;
589 Property
.Flags
= KSPROPERTY_TYPE_GET
;
591 HRESULT hr
= KsProperty(&Property
, sizeof(KSPROPERTY
), pPropData
, cbPropData
, &BytesReturned
);
598 CInputPin::QuerySupported(
606 Property
.Set
= guidPropSet
;
607 Property
.Id
= dwPropID
;
608 Property
.Flags
= KSPROPERTY_TYPE_SETSUPPORT
;
610 return KsProperty(&Property
, sizeof(KSPROPERTY
), pTypeSupport
, sizeof(DWORD
), &BytesReturned
);
614 //-------------------------------------------------------------------
619 CInputPin::KsGetObjectHandle()
625 //-------------------------------------------------------------------
630 CInputPin::Connect(IPin
*pReceivePin
, const AM_MEDIA_TYPE
*pmt
)
632 OutputDebugStringW(L
"CInputPin::Connect NotImplemented\n");
638 CInputPin::ReceiveConnection(IPin
*pConnector
, const AM_MEDIA_TYPE
*pmt
)
644 return VFW_E_ALREADY_CONNECTED
;
647 // first check format
648 hr
= CheckFormat(pmt
);
652 if (FAILED(CheckFormat(pmt
)))
669 CInputPin::Disconnect( void)
673 // pin was not connected
678 //check if filter is active
683 OutputDebugStringW(L
"CInputPin::Disconnect\n");
688 CInputPin::ConnectedTo(IPin
**pPin
)
695 // increment reference count
702 return VFW_E_NOT_CONNECTED
;
706 CInputPin::ConnectionMediaType(AM_MEDIA_TYPE
*pmt
)
709 return VFW_E_NOT_CONNECTED
;
711 OutputDebugStringW(L
"CInputPin::ConnectionMediaType NotImplemented\n");
716 CInputPin::QueryPinInfo(PIN_INFO
*pInfo
)
718 wcscpy(pInfo
->achName
, m_PinName
);
719 pInfo
->dir
= PINDIR_INPUT
;
720 pInfo
->pFilter
= m_ParentFilter
;
721 m_ParentFilter
->AddRef();
727 CInputPin::QueryDirection(PIN_DIRECTION
*pPinDir
)
731 *pPinDir
= PINDIR_INPUT
;
739 CInputPin::QueryId(LPWSTR
*Id
)
741 *Id
= (LPWSTR
)CoTaskMemAlloc((wcslen(m_PinName
)+1)*sizeof(WCHAR
));
743 return E_OUTOFMEMORY
;
745 wcscpy(*Id
, m_PinName
);
751 CInputPin::QueryAccept(
752 const AM_MEDIA_TYPE
*pmt
)
754 return CheckFormat(pmt
);
758 CInputPin::EnumMediaTypes(IEnumMediaTypes
**ppEnum
)
761 ULONG MediaTypeCount
= 0, Index
;
762 AM_MEDIA_TYPE
* MediaTypes
;
764 // query media type count
765 hr
= KsGetMediaTypeCount(m_hFilter
, m_PinId
, &MediaTypeCount
);
766 if (FAILED(hr
) || !MediaTypeCount
)
769 // allocate media types
770 MediaTypes
= (AM_MEDIA_TYPE
*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE
) * MediaTypeCount
);
774 return E_OUTOFMEMORY
;
778 ZeroMemory(MediaTypes
, sizeof(AM_MEDIA_TYPE
) * MediaTypeCount
);
780 for(Index
= 0; Index
< MediaTypeCount
; Index
++)
783 hr
= KsGetMediaType(Index
, &MediaTypes
[Index
], m_hFilter
, m_PinId
);
787 CoTaskMemFree(MediaTypes
);
792 return CEnumMediaTypes_fnConstructor(MediaTypeCount
, MediaTypes
, IID_IEnumMediaTypes
, (void**)ppEnum
);
797 CInputPin::QueryInternalConnections(IPin
**apPin
, ULONG
*nPin
)
799 OutputDebugStringW(L
"CInputPin::QueryInternalConnections NotImplemented\n");
804 CInputPin::EndOfStream( void)
806 OutputDebugStringW(L
"CInputPin::EndOfStream NotImplemented\n");
811 CInputPin::BeginFlush( void)
813 OutputDebugStringW(L
"CInputPin::BeginFlush NotImplemented\n");
818 CInputPin::EndFlush( void)
820 OutputDebugStringW(L
"CInputPin::EndFlush NotImplemented\n");
825 CInputPin::NewSegment(REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, double dRate
)
827 OutputDebugStringW(L
"CInputPin::NewSegment NotImplemented\n");
831 //-------------------------------------------------------------------
834 CInputPin::CheckFormat(
835 const AM_MEDIA_TYPE
*pmt
)
838 PKSMULTIPLE_ITEM MultipleItem
;
839 PKSDATAFORMAT DataFormat
;
844 Property
.Property
.Set
= KSPROPSETID_Pin
;
845 Property
.Property
.Id
= KSPROPERTY_PIN_DATARANGES
;
846 Property
.Property
.Flags
= KSPROPERTY_TYPE_GET
;
847 Property
.PinId
= m_PinId
;
848 Property
.Reserved
= 0;
853 // query for size of dataranges
854 hr
= KsSynchronousDeviceControl(m_hFilter
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSP_PIN
), NULL
, 0, &BytesReturned
);
856 if (hr
== MAKE_HRESULT(SEVERITY_ERROR
, FACILITY_WIN32
, ERROR_MORE_DATA
))
858 // allocate dataranges buffer
859 MultipleItem
= (PKSMULTIPLE_ITEM
)CoTaskMemAlloc(BytesReturned
);
862 return E_OUTOFMEMORY
;
865 hr
= KsSynchronousDeviceControl(m_hFilter
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSP_PIN
), (PVOID
)MultipleItem
, BytesReturned
, &BytesReturned
);
869 // failed to query data ranges
870 CoTaskMemFree(MultipleItem
);
874 DataFormat
= (PKSDATAFORMAT
)(MultipleItem
+ 1);
875 for(ULONG Index
= 0; Index
< MultipleItem
->Count
; Index
++)
877 if (IsEqualGUID(pmt
->majortype
, DataFormat
->MajorFormat
) &&
878 IsEqualGUID(pmt
->subtype
, DataFormat
->SubFormat
) &&
879 IsEqualGUID(pmt
->formattype
, DataFormat
->Specifier
))
881 // format is supported
882 CoTaskMemFree(MultipleItem
);
883 OutputDebugStringW(L
"CInputPin::CheckFormat format OK\n");
886 DataFormat
= (PKSDATAFORMAT
)((ULONG_PTR
)DataFormat
+ DataFormat
->FormatSize
);
888 //format is not supported
889 CoTaskMemFree(MultipleItem
);
896 CInputPin::CreatePin(
897 const AM_MEDIA_TYPE
*pmt
)
899 PKSMULTIPLE_ITEM MediumList
;
900 PKSMULTIPLE_ITEM InterfaceList
;
901 PKSPIN_MEDIUM Medium
;
902 PKSPIN_INTERFACE Interface
;
905 // query for pin medium
906 hr
= KsQueryMediums(&MediumList
);
910 // query for pin interface
911 hr
= KsQueryInterfaces(&InterfaceList
);
915 CoTaskMemFree(MediumList
);
919 if (MediumList
->Count
)
921 //use first available medium
922 Medium
= (PKSPIN_MEDIUM
)(MediumList
+ 1);
926 // default to standard medium
927 Medium
= &StandardPinMedium
;
930 if (InterfaceList
->Count
)
932 //use first available interface
933 Interface
= (PKSPIN_INTERFACE
)(InterfaceList
+ 1);
937 // default to standard interface
938 Interface
= &StandardPinInterface
;
942 hr
= CreatePinHandle(Medium
, Interface
, pmt
);
944 // free medium / interface / dataformat
945 CoTaskMemFree(MediumList
);
946 CoTaskMemFree(InterfaceList
);
953 CInputPin::CreatePinHandle(
954 PKSPIN_MEDIUM Medium
,
955 PKSPIN_INTERFACE Interface
,
956 const AM_MEDIA_TYPE
*pmt
)
958 PKSPIN_CONNECT PinConnect
;
959 PKSDATAFORMAT DataFormat
;
964 Length
= sizeof(KSPIN_CONNECT
) + sizeof(KSDATAFORMAT
) + pmt
->cbFormat
;
966 // allocate pin connect
967 PinConnect
= (PKSPIN_CONNECT
)CoTaskMemAlloc(Length
);
971 return E_OUTOFMEMORY
;
975 CopyMemory(&PinConnect
->Interface
, Interface
, sizeof(KSPIN_INTERFACE
));
976 CopyMemory(&PinConnect
->Medium
, Medium
, sizeof(KSPIN_MEDIUM
));
977 PinConnect
->PinId
= m_PinId
;
978 PinConnect
->PinToHandle
= NULL
;
979 PinConnect
->Priority
.PriorityClass
= KSPRIORITY_NORMAL
;
980 PinConnect
->Priority
.PrioritySubClass
= KSPRIORITY_NORMAL
;
982 // get dataformat offset
983 DataFormat
= (PKSDATAFORMAT
)(PinConnect
+ 1);
986 DataFormat
->FormatSize
= sizeof(KSDATAFORMAT
) + pmt
->cbFormat
;
987 DataFormat
->Flags
= 0;
988 DataFormat
->SampleSize
= pmt
->lSampleSize
;
989 DataFormat
->Reserved
= 0;
990 CopyMemory(&DataFormat
->MajorFormat
, &pmt
->majortype
, sizeof(GUID
));
991 CopyMemory(&DataFormat
->SubFormat
, &pmt
->subtype
, sizeof(GUID
));
992 CopyMemory(&DataFormat
->Specifier
, &pmt
->formattype
, sizeof(GUID
));
996 // copy extended format
997 CopyMemory((DataFormat
+ 1), pmt
->pbFormat
, pmt
->cbFormat
);
1001 hr
= KsCreatePin(m_hFilter
, PinConnect
, GENERIC_WRITE
, &m_hPin
);
1004 CoTaskMemFree(PinConnect
);
1011 CInputPin_Constructor(
1012 IBaseFilter
* ParentFilter
,
1016 KSPIN_COMMUNICATION Communication
,
1020 CInputPin
* handler
= new CInputPin(ParentFilter
, PinName
, hFilter
, PinId
, Communication
);
1023 return E_OUTOFMEMORY
;
1025 if (FAILED(handler
->QueryInterface(riid
, ppv
)))
1029 return E_NOINTERFACE
;