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 class CInputPin
: public IPin
,
12 public IKsPropertySet
,
16 public IQualityControl,
19 public ISpecifyPropertyPages,
20 public IStreamBuilder,
22 public IKsAggregateControl
26 STDMETHODIMP
QueryInterface( REFIID InterfaceId
, PVOID
* Interface
);
28 STDMETHODIMP_(ULONG
) AddRef()
30 InterlockedIncrement(&m_Ref
);
33 STDMETHODIMP_(ULONG
) Release()
35 InterlockedDecrement(&m_Ref
);
45 HRESULT STDMETHODCALLTYPE
Connect(IPin
*pReceivePin
, const AM_MEDIA_TYPE
*pmt
);
46 HRESULT STDMETHODCALLTYPE
ReceiveConnection(IPin
*pConnector
, const AM_MEDIA_TYPE
*pmt
);
47 HRESULT STDMETHODCALLTYPE
Disconnect();
48 HRESULT STDMETHODCALLTYPE
ConnectedTo(IPin
**pPin
);
49 HRESULT STDMETHODCALLTYPE
ConnectionMediaType(AM_MEDIA_TYPE
*pmt
);
50 HRESULT STDMETHODCALLTYPE
QueryPinInfo(PIN_INFO
*pInfo
);
51 HRESULT STDMETHODCALLTYPE
QueryDirection(PIN_DIRECTION
*pPinDir
);
52 HRESULT STDMETHODCALLTYPE
QueryId(LPWSTR
*Id
);
53 HRESULT STDMETHODCALLTYPE
QueryAccept(const AM_MEDIA_TYPE
*pmt
);
54 HRESULT STDMETHODCALLTYPE
EnumMediaTypes(IEnumMediaTypes
**ppEnum
);
55 HRESULT STDMETHODCALLTYPE
QueryInternalConnections(IPin
**apPin
, ULONG
*nPin
);
56 HRESULT STDMETHODCALLTYPE
EndOfStream();
57 HRESULT STDMETHODCALLTYPE
BeginFlush();
58 HRESULT STDMETHODCALLTYPE
EndFlush();
59 HRESULT STDMETHODCALLTYPE
NewSegment(REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, double dRate
);
62 HANDLE STDMETHODCALLTYPE
KsGetObjectHandle();
65 HRESULT STDMETHODCALLTYPE
Set(REFGUID guidPropSet
, DWORD dwPropID
, LPVOID pInstanceData
, DWORD cbInstanceData
, LPVOID pPropData
, DWORD cbPropData
);
66 HRESULT STDMETHODCALLTYPE
Get(REFGUID guidPropSet
, DWORD dwPropID
, LPVOID pInstanceData
, DWORD cbInstanceData
, LPVOID pPropData
, DWORD cbPropData
, DWORD
*pcbReturned
);
67 HRESULT STDMETHODCALLTYPE
QuerySupported(REFGUID guidPropSet
, DWORD dwPropID
, DWORD
*pTypeSupport
);
70 HRESULT STDMETHODCALLTYPE
KsProperty(PKSPROPERTY Property
, ULONG PropertyLength
, LPVOID PropertyData
, ULONG DataLength
, ULONG
* BytesReturned
);
71 HRESULT STDMETHODCALLTYPE
KsMethod(PKSMETHOD Method
, ULONG MethodLength
, LPVOID MethodData
, ULONG DataLength
, ULONG
* BytesReturned
);
72 HRESULT STDMETHODCALLTYPE
KsEvent(PKSEVENT Event
, ULONG EventLength
, LPVOID EventData
, ULONG DataLength
, ULONG
* BytesReturned
);
74 HRESULT STDMETHODCALLTYPE
CheckFormat(const AM_MEDIA_TYPE
*pmt
);
75 CInputPin(IBaseFilter
* ParentFilter
, LPCWSTR PinName
, HANDLE hFilter
, ULONG PinId
) : m_Ref(0), m_ParentFilter(ParentFilter
), m_PinName(PinName
), m_hFilter(hFilter
), m_hPin(0), m_PinId(PinId
){};
76 virtual ~CInputPin(){};
80 IBaseFilter
* m_ParentFilter
;
89 CInputPin::QueryInterface(
95 if (IsEqualGUID(refiid
, IID_IUnknown
) ||
96 IsEqualGUID(refiid
, IID_IPin
))
98 *Output
= PVOID(this);
99 reinterpret_cast<IUnknown
*>(*Output
)->AddRef();
102 else if (IsEqualGUID(refiid
, IID_IKsObject
))
106 OutputDebugStringW(L
"CInputPin::QueryInterface IID_IKsObject Create PIN!!!\n");
110 *Output
= (IKsObject
*)(this);
111 reinterpret_cast<IKsObject
*>(*Output
)->AddRef();
114 else if (IsEqualGUID(refiid
, IID_IKsPropertySet
))
118 OutputDebugStringW(L
"CInputPin::QueryInterface IID_IKsPropertySet Create PIN!!!\n");
122 *Output
= (IKsPropertySet
*)(this);
123 reinterpret_cast<IKsPropertySet
*>(*Output
)->AddRef();
126 else if (IsEqualGUID(refiid
, IID_IKsControl
))
130 OutputDebugStringW(L
"CInputPin::QueryInterface IID_IKsControl Create PIN!!!\n");
134 *Output
= (IKsControl
*)(this);
135 reinterpret_cast<IKsControl
*>(*Output
)->AddRef();
139 WCHAR Buffer
[MAX_PATH
];
141 StringFromCLSID(refiid
, &lpstr
);
142 swprintf(Buffer
, L
"CInputPin::QueryInterface: NoInterface for %s\n", lpstr
);
143 OutputDebugStringW(Buffer
);
144 CoTaskMemFree(lpstr
);
146 return E_NOINTERFACE
;
149 //-------------------------------------------------------------------
154 CInputPin::KsProperty(
155 PKSPROPERTY Property
,
156 ULONG PropertyLength
,
159 ULONG
* BytesReturned
)
161 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_PROPERTY
, (PVOID
)Property
, PropertyLength
, (PVOID
)PropertyData
, DataLength
, BytesReturned
);
171 ULONG
* BytesReturned
)
173 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_METHOD
, (PVOID
)Method
, MethodLength
, (PVOID
)MethodData
, DataLength
, BytesReturned
);
183 ULONG
* BytesReturned
)
186 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_ENABLE_EVENT
, (PVOID
)Event
, EventLength
, (PVOID
)EventData
, DataLength
, BytesReturned
);
188 return KsSynchronousDeviceControl(m_hPin
, IOCTL_KS_DISABLE_EVENT
, (PVOID
)Event
, EventLength
, NULL
, 0, BytesReturned
);
192 //-------------------------------------------------------------------
200 LPVOID pInstanceData
,
201 DWORD cbInstanceData
,
209 PKSPROPERTY Property
= (PKSPROPERTY
)CoTaskMemAlloc(sizeof(KSPROPERTY
) + cbInstanceData
);
211 return E_OUTOFMEMORY
;
213 Property
->Set
= guidPropSet
;
214 Property
->Id
= dwPropID
;
215 Property
->Flags
= KSPROPERTY_TYPE_SET
;
217 CopyMemory((Property
+1), pInstanceData
, cbInstanceData
);
219 HRESULT hr
= KsProperty(Property
, sizeof(KSPROPERTY
) + cbInstanceData
, pPropData
, cbPropData
, &BytesReturned
);
220 CoTaskMemFree(Property
);
227 Property
.Set
= guidPropSet
;
228 Property
.Id
= dwPropID
;
229 Property
.Flags
= KSPROPERTY_TYPE_SET
;
231 HRESULT hr
= KsProperty(&Property
, sizeof(KSPROPERTY
), pPropData
, cbPropData
, &BytesReturned
);
241 LPVOID pInstanceData
,
242 DWORD cbInstanceData
,
251 PKSPROPERTY Property
= (PKSPROPERTY
)CoTaskMemAlloc(sizeof(KSPROPERTY
) + cbInstanceData
);
253 return E_OUTOFMEMORY
;
255 Property
->Set
= guidPropSet
;
256 Property
->Id
= dwPropID
;
257 Property
->Flags
= KSPROPERTY_TYPE_GET
;
259 CopyMemory((Property
+1), pInstanceData
, cbInstanceData
);
261 HRESULT hr
= KsProperty(Property
, sizeof(KSPROPERTY
) + cbInstanceData
, pPropData
, cbPropData
, &BytesReturned
);
262 CoTaskMemFree(Property
);
269 Property
.Set
= guidPropSet
;
270 Property
.Id
= dwPropID
;
271 Property
.Flags
= KSPROPERTY_TYPE_GET
;
273 HRESULT hr
= KsProperty(&Property
, sizeof(KSPROPERTY
), pPropData
, cbPropData
, &BytesReturned
);
280 CInputPin::QuerySupported(
288 Property
.Set
= guidPropSet
;
289 Property
.Id
= dwPropID
;
290 Property
.Flags
= KSPROPERTY_TYPE_SETSUPPORT
;
292 return KsProperty(&Property
, sizeof(KSPROPERTY
), pTypeSupport
, sizeof(DWORD
), &BytesReturned
);
296 //-------------------------------------------------------------------
301 CInputPin::KsGetObjectHandle()
303 OutputDebugStringW(L
"CInputPin::KsGetObjectHandle CALLED\n");
310 //-------------------------------------------------------------------
315 CInputPin::Connect(IPin
*pReceivePin
, const AM_MEDIA_TYPE
*pmt
)
317 //MajorFormat: KSDATAFORMAT_TYPE_BDA_ANTENNA
318 //SubType: MEDIASUBTYPE_None
319 //FormatType: FORMAT_None
320 //bFixedSizeSamples 1 bTemporalCompression 0 lSampleSize 1 pUnk 00000000 cbFormat 0 pbFormat 00000000
322 //KSPROPSETID_Connection KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT
323 //PriorityClass = KSPRIORITY_NORMAL PrioritySubClass = KSPRIORITY_NORMAL
326 OutputDebugStringW(L
"CInputPin::Connect NotImplemented\n");
332 CInputPin::ReceiveConnection(IPin
*pConnector
, const AM_MEDIA_TYPE
*pmt
)
334 OutputDebugStringW(L
"CInputPin::ReceiveConnection NotImplemented\n");
339 CInputPin::Disconnect( void)
341 OutputDebugStringW(L
"CInputPin::Disconnect NotImplemented\n");
346 CInputPin::ConnectedTo(IPin
**pPin
)
349 OutputDebugStringW(L
"CInputPin::ConnectedTo NotImplemented\n");
350 return VFW_E_NOT_CONNECTED
;
354 CInputPin::ConnectionMediaType(AM_MEDIA_TYPE
*pmt
)
356 OutputDebugStringW(L
"CInputPin::ConnectionMediaType NotImplemented\n");
361 CInputPin::QueryPinInfo(PIN_INFO
*pInfo
)
363 wcscpy(pInfo
->achName
, m_PinName
);
364 pInfo
->dir
= PINDIR_INPUT
;
365 pInfo
->pFilter
= m_ParentFilter
;
366 m_ParentFilter
->AddRef();
372 CInputPin::QueryDirection(PIN_DIRECTION
*pPinDir
)
376 *pPinDir
= PINDIR_INPUT
;
384 CInputPin::QueryId(LPWSTR
*Id
)
386 *Id
= (LPWSTR
)CoTaskMemAlloc((wcslen(m_PinName
)+1)*sizeof(WCHAR
));
388 return E_OUTOFMEMORY
;
390 wcscpy(*Id
, m_PinName
);
396 CInputPin::CheckFormat(
397 const AM_MEDIA_TYPE
*pmt
)
400 PKSMULTIPLE_ITEM MultipleItem
;
401 PKSDATAFORMAT DataFormat
;
406 Property
.Property
.Set
= KSPROPSETID_Pin
;
407 Property
.Property
.Id
= KSPROPERTY_PIN_DATARANGES
;
408 Property
.Property
.Flags
= KSPROPERTY_TYPE_GET
;
409 Property
.PinId
= m_PinId
;
410 Property
.Reserved
= 0;
412 // query for size of dataranges
413 hr
= KsSynchronousDeviceControl(m_hFilter
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSP_PIN
), NULL
, 0, &BytesReturned
);
415 if (hr
== MAKE_HRESULT(SEVERITY_ERROR
, FACILITY_WIN32
, ERROR_MORE_DATA
))
417 // allocate dataranges buffer
418 MultipleItem
= (PKSMULTIPLE_ITEM
)CoTaskMemAlloc(BytesReturned
);
421 return E_OUTOFMEMORY
;
424 hr
= KsSynchronousDeviceControl(m_hFilter
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSP_PIN
), (PVOID
)MultipleItem
, BytesReturned
, &BytesReturned
);
428 // failed to query data ranges
429 CoTaskMemFree(MultipleItem
);
433 DataFormat
= (PKSDATAFORMAT
)(MultipleItem
+ 1);
434 for(ULONG Index
= 0; Index
< MultipleItem
->Count
; Index
++)
436 if (IsEqualGUID(pmt
->majortype
, DataFormat
->MajorFormat
) &&
437 IsEqualGUID(pmt
->subtype
, DataFormat
->SubFormat
) &&
438 IsEqualGUID(pmt
->formattype
, DataFormat
->Specifier
))
440 // format is supported
441 CoTaskMemFree(MultipleItem
);
442 OutputDebugStringW(L
"CInputPin::CheckFormat format OK\n");
445 DataFormat
= (PKSDATAFORMAT
)((ULONG_PTR
)DataFormat
+ DataFormat
->FormatSize
);
447 //format is not supported
448 CoTaskMemFree(MultipleItem
);
455 CInputPin::QueryAccept(
456 const AM_MEDIA_TYPE
*pmt
)
458 return CheckFormat(pmt
);
462 CInputPin::EnumMediaTypes(IEnumMediaTypes
**ppEnum
)
464 return CEnumMediaTypes_fnConstructor(0, NULL
, IID_IEnumMediaTypes
, (void**)ppEnum
);
468 CInputPin::QueryInternalConnections(IPin
**apPin
, ULONG
*nPin
)
470 OutputDebugStringW(L
"CInputPin::QueryInternalConnections NotImplemented\n");
475 CInputPin::EndOfStream( void)
477 OutputDebugStringW(L
"CInputPin::EndOfStream NotImplemented\n");
482 CInputPin::BeginFlush( void)
484 OutputDebugStringW(L
"CInputPin::BeginFlush NotImplemented\n");
489 CInputPin::EndFlush( void)
491 OutputDebugStringW(L
"CInputPin::EndFlush NotImplemented\n");
496 CInputPin::NewSegment(REFERENCE_TIME tStart
, REFERENCE_TIME tStop
, double dRate
)
498 OutputDebugStringW(L
"CInputPin::NewSegment NotImplemented\n");
504 CInputPin_Constructor(
505 IBaseFilter
* ParentFilter
,
512 CInputPin
* handler
= new CInputPin(ParentFilter
, PinName
, hFilter
, PinId
);
515 return E_OUTOFMEMORY
;
517 if (FAILED(handler
->QueryInterface(riid
, ppv
)))
521 return E_NOINTERFACE
;