2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS BDA Proxy
4 * FILE: dll/directx/bdaplgin/classfactory.cpp
5 * PURPOSE: ClassFactory interface
7 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
12 const GUID CLSID_DVBTNetworkProvider
= {0x216c62df, 0x6d7f, 0x4e9a, {0x85, 0x71, 0x5, 0xf1, 0x4e, 0xdb, 0x76, 0x6a}};
13 const GUID IID_IAC3Filter
= {0xe4539501, 0xc609, 0x46ea, {0xad, 0x2a, 0x0e, 0x97, 0x00, 0x24, 0x56, 0x83}};
14 const GUID IID_IAsyncReader
= {0x56A868AA, 0x0AD4, 0x11CE, {0xB0, 0x3A, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70}};
15 const GUID IID_IMatrixMixer
= {0xafc57835, 0x2fd1, 0x4541, {0xa6, 0xd9, 0x0d, 0xb7, 0x18, 0x56, 0xe5, 0x89}};
16 const GUID IID_IBDA_NetworkProvider
= {0xfd501041, 0x8ebe, 0x11ce, {0x81, 0x83, 0x00, 0xaa, 0x00, 0x57, 0x7d, 0xa2}};
17 const GUID IID_IAMOpenProgress
= {0x8E1C39A1, 0xDE53, 0x11cf, {0xAA, 0x63, 0x00, 0x80, 0xC7, 0x44, 0x52, 0x8D}};
18 const GUID IID_IDistributorNotify
= {0x56a868af, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
19 const GUID IID_IBDA_DeviceControl
= {0xFD0A5AF3, 0xB41D, 0x11d2, {0x9C, 0x95, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}};
20 const GUID IID_IBDA_Topology
= {0x79B56888, 0x7FEA, 0x4690, {0xB4, 0x5D, 0x38, 0xFD, 0x3C, 0x78, 0x49, 0xBE}};
21 const GUID IID_IKsObject
= {0x423c13a2, 0x2070, 0x11d0, {0x9e, 0xf7, 0x00, 0xaa, 0x00, 0xa2, 0x16, 0xa1}};
22 const GUID KSPROPSETID_BdaTopology
= {0xa14ee835, 0x0a23, 0x11d3, {0x9c, 0xc7, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
23 const GUID KSMETHODSETID_BdaDeviceConfiguration
= {0x71985f45, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
24 const GUID IID_IBaseFilter
= {0x56a86895, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
25 const GUID KSMETHODSETID_BdaChangeSync
= {0xfd0a5af3, 0xb41d, 0x11d2, {0x9c, 0x95, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
27 class CBDADeviceControl
: public IBDA_DeviceControl
,
31 STDMETHODIMP
QueryInterface( REFIID InterfaceId
, PVOID
* Interface
);
33 STDMETHODIMP_(ULONG
) AddRef()
35 InterlockedIncrement(&m_Ref
);
38 STDMETHODIMP_(ULONG
) Release()
40 InterlockedDecrement(&m_Ref
);
49 // IBDA_DeviceControl methods
50 HRESULT STDMETHODCALLTYPE
StartChanges( void);
51 HRESULT STDMETHODCALLTYPE
CheckChanges( void);
52 HRESULT STDMETHODCALLTYPE
CommitChanges( void);
53 HRESULT STDMETHODCALLTYPE
GetChangeState(ULONG
*pState
);
55 // IBDA_Topology methods
56 HRESULT STDMETHODCALLTYPE
GetNodeTypes(ULONG
*pulcNodeTypes
, ULONG ulcNodeTypesMax
, ULONG
* rgulNodeTypes
);
57 HRESULT STDMETHODCALLTYPE
GetNodeDescriptors(ULONG
*ulcNodeDescriptors
, ULONG ulcNodeDescriptorsMax
, BDANODE_DESCRIPTOR
* rgNodeDescriptors
);
58 HRESULT STDMETHODCALLTYPE
GetNodeInterfaces(ULONG ulNodeType
, ULONG
*pulcInterfaces
, ULONG ulcInterfacesMax
, GUID
* rgguidInterfaces
);
59 HRESULT STDMETHODCALLTYPE
GetPinTypes(ULONG
*pulcPinTypes
, ULONG ulcPinTypesMax
, ULONG
*rgulPinTypes
);
60 HRESULT STDMETHODCALLTYPE
GetTemplateConnections(ULONG
*pulcConnections
, ULONG ulcConnectionsMax
, BDA_TEMPLATE_CONNECTION
* rgConnections
);
61 HRESULT STDMETHODCALLTYPE
CreatePin(ULONG ulPinType
, ULONG
*pulPinId
);
62 HRESULT STDMETHODCALLTYPE
DeletePin(ULONG ulPinId
);
63 HRESULT STDMETHODCALLTYPE
SetMediaType(ULONG ulPinId
, AM_MEDIA_TYPE
*pMediaType
);
64 HRESULT STDMETHODCALLTYPE
SetMedium(ULONG ulPinId
, REGPINMEDIUM
*pMedium
);
65 HRESULT STDMETHODCALLTYPE
CreateTopology(ULONG ulInputPinId
, ULONG ulOutputPinId
);
66 HRESULT STDMETHODCALLTYPE
GetControlNode(ULONG ulInputPinId
, ULONG ulOutputPinId
, ULONG ulNodeType
, IUnknown
**ppControlNode
);
68 CBDADeviceControl(IUnknown
* pUnkOuter
, IBaseFilter
*pFilter
, HANDLE hFile
) : m_Ref(0), m_pUnkOuter(pUnkOuter
), m_Handle(hFile
), m_pFilter(pFilter
){};
69 virtual ~CBDADeviceControl(){};
73 IUnknown
* m_pUnkOuter
;
75 IBaseFilter
* m_pFilter
;
80 CBDADeviceControl::QueryInterface(
86 if (IsEqualGUID(refiid
, IID_IUnknown
))
88 *Output
= PVOID(this);
89 reinterpret_cast<IUnknown
*>(*Output
)->AddRef();
92 if (IsEqualGUID(refiid
, IID_IBDA_DeviceControl
))
94 *Output
= (IBDA_DeviceControl
*)(this);
95 reinterpret_cast<IBDA_DeviceControl
*>(*Output
)->AddRef();
99 if (IsEqualGUID(refiid
, IID_IBDA_Topology
))
101 *Output
= (IBDA_Topology
*)(this);
102 reinterpret_cast<IBDA_Topology
*>(*Output
)->AddRef();
106 return E_NOINTERFACE
;
110 //-------------------------------------------------------------------
111 // IBDA_DeviceControl methods
115 CBDADeviceControl::StartChanges( void)
122 Method
.Set
= KSMETHODSETID_BdaChangeSync
;
123 Method
.Id
= KSMETHOD_BDA_START_CHANGES
;
124 Method
.Flags
= KSMETHOD_TYPE_NONE
;
126 /* execute request */
127 hr
= KsSynchronousDeviceControl(m_Handle
, IOCTL_KS_METHOD
, (PVOID
)&Method
, sizeof(KSMETHOD
), NULL
, 0, &BytesReturned
);
129 #ifdef BDAPLGIN_TRACE
131 swprintf(Buffer
, L
"CBDADeviceControl::StartChanges: hr %lx, BytesReturned %lu\n", hr
, BytesReturned
);
132 OutputDebugStringW(Buffer
);
141 CBDADeviceControl::CheckChanges( void)
148 Method
.Set
= KSMETHODSETID_BdaChangeSync
;
149 Method
.Id
= KSMETHOD_BDA_CHECK_CHANGES
;
150 Method
.Flags
= KSMETHOD_TYPE_NONE
;
152 /* execute request */
153 hr
= KsSynchronousDeviceControl(m_Handle
, IOCTL_KS_METHOD
, (PVOID
)&Method
, sizeof(KSMETHOD
), NULL
, 0, &BytesReturned
);
155 #ifdef BDAPLGIN_TRACE
157 swprintf(Buffer
, L
"CBDADeviceControl::CheckChanges: hr %lx, BytesReturned %lu\n", hr
, BytesReturned
);
158 OutputDebugStringW(Buffer
);
167 CBDADeviceControl::CommitChanges( void)
174 Method
.Set
= KSMETHODSETID_BdaChangeSync
;
175 Method
.Id
= KSMETHOD_BDA_COMMIT_CHANGES
;
176 Method
.Flags
= KSMETHOD_TYPE_NONE
;
178 /* execute request */
179 hr
= KsSynchronousDeviceControl(m_Handle
, IOCTL_KS_METHOD
, (PVOID
)&Method
, sizeof(KSMETHOD
), NULL
, 0, &BytesReturned
);
181 #ifdef BDAPLGIN_TRACE
183 swprintf(Buffer
, L
"CBDADeviceControl::CommitChanges: hr %lx, BytesReturned %lu\n", hr
, BytesReturned
);
184 OutputDebugStringW(Buffer
);
192 CBDADeviceControl::GetChangeState(ULONG
*pState
)
196 *pState
= BDA_CHANGES_COMPLETE
;
205 //-------------------------------------------------------------------
206 // IBDA_Topology methods
210 CBDADeviceControl::GetNodeTypes(ULONG
*pulcNodeTypes
, ULONG ulcNodeTypesMax
, ULONG
* rgulNodeTypes
)
217 Property
.Set
= KSPROPSETID_BdaTopology
;
218 Property
.Id
= KSPROPERTY_BDA_NODE_TYPES
;
219 Property
.Flags
= KSPROPERTY_TYPE_GET
;
222 hr
= KsSynchronousDeviceControl(m_Handle
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSPROPERTY
), rgulNodeTypes
, sizeof(ULONG
) * ulcNodeTypesMax
, &BytesReturned
);
224 *pulcNodeTypes
= (BytesReturned
/ sizeof(ULONG
));
226 #ifdef BDAPLGIN_TRACE
228 swprintf(Buffer
, L
"CBDADeviceControl::GetNodeTypes: hr %lx, BytesReturned %lu\n", hr
, BytesReturned
);
229 OutputDebugStringW(Buffer
);
233 for(ULONG Index
= 0; Index
< *pulcNodeTypes
; Index
++)
235 swprintf(Buffer
, L
"CBDADeviceControl::GetPinTypes: Index %lu Value %lx\n", Index
, rgulNodeTypes
[Index
]);
236 OutputDebugStringW(Buffer
);
246 CBDADeviceControl::GetNodeDescriptors(ULONG
*ulcNodeDescriptors
, ULONG ulcNodeDescriptorsMax
, BDANODE_DESCRIPTOR
* rgNodeDescriptors
)
254 Property
.Set
= KSPROPSETID_BdaTopology
;
255 Property
.Id
= KSPROPERTY_BDA_NODE_DESCRIPTORS
;
256 Property
.Flags
= KSPROPERTY_TYPE_GET
;
259 hr
= KsSynchronousDeviceControl(m_Handle
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSPROPERTY
), rgNodeDescriptors
, sizeof(BDANODE_DESCRIPTOR
) * ulcNodeDescriptorsMax
, &BytesReturned
);
261 *ulcNodeDescriptors
= (BytesReturned
/ sizeof(BDANODE_DESCRIPTOR
));
263 #ifdef BDAPLGIN_TRACE
265 swprintf(Buffer
, L
"CBDADeviceControl::GetNodeDescriptors: hr %lx, BytesReturned %lu\n", hr
, BytesReturned
);
266 OutputDebugStringW(Buffer
);
271 for(ULONG Index
= 0; Index
< min(*ulcNodeDescriptors
, ulcNodeDescriptorsMax
); Index
++)
273 LPOLESTR pGUIDFunction
, pGUIDName
;
275 StringFromCLSID(rgNodeDescriptors
[Index
].guidFunction
, &pGUIDFunction
);
276 StringFromCLSID(rgNodeDescriptors
[Index
].guidName
, &pGUIDName
);
278 swprintf(Buffer
, L
"CBDADeviceControl::GetPinTypes: Index %lu Value %lx\nFunction %s\n Name %s\n-----\n", Index
, rgNodeDescriptors
[Index
].ulBdaNodeType
, pGUIDFunction
, pGUIDName
);
279 OutputDebugStringW(Buffer
);
290 CBDADeviceControl::GetNodeInterfaces(ULONG ulNodeType
, ULONG
*pulcInterfaces
, ULONG ulcInterfacesMax
, GUID
* rgguidInterfaces
)
298 Property
.Property
.Set
= KSPROPSETID_BdaTopology
;
299 Property
.Property
.Id
= KSPROPERTY_BDA_NODE_PROPERTIES
;
300 Property
.Property
.Flags
= KSPROPERTY_TYPE_GET
;
301 Property
.NodeId
= ulNodeType
;
302 Property
.Reserved
= 0;
305 hr
= KsSynchronousDeviceControl(m_Handle
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSP_NODE
), rgguidInterfaces
, sizeof(GUID
) * ulcInterfacesMax
, &BytesReturned
);
307 *pulcInterfaces
= (BytesReturned
/ sizeof(GUID
));
309 #ifdef BDAPLGIN_TRACE
311 swprintf(Buffer
, L
"CBDADeviceControl::GetNodeInterfaces: hr %lx, BytesReturned %lu ulNodeType %lu\n", hr
, BytesReturned
, ulNodeType
);
312 OutputDebugStringW(Buffer
);
316 for(ULONG Index
= 0; Index
< min(*pulcInterfaces
, ulcInterfacesMax
); Index
++)
320 StringFromCLSID(rgguidInterfaces
[Index
], &pstr
);
322 swprintf(Buffer
, L
"CBDADeviceControl::GetNodeInterfaces: Index %lu Name %s\n", Index
, pstr
);
323 OutputDebugStringW(Buffer
);
333 CBDADeviceControl::GetPinTypes(ULONG
*pulcPinTypes
, ULONG ulcPinTypesMax
, ULONG
*rgulPinTypes
)
340 Property
.Set
= KSPROPSETID_BdaTopology
;
341 Property
.Id
= KSPROPERTY_BDA_PIN_TYPES
;
342 Property
.Flags
= KSPROPERTY_TYPE_GET
;
345 hr
= KsSynchronousDeviceControl(m_Handle
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSPROPERTY
), rgulPinTypes
, sizeof(ULONG
) * ulcPinTypesMax
, &BytesReturned
);
347 *pulcPinTypes
= (BytesReturned
/ sizeof(ULONG
));
349 #ifdef BDAPLGIN_TRACE
351 swprintf(Buffer
, L
"CBDADeviceControl::GetPinTypes: hr %lx, BytesReturned %lu\n", hr
, BytesReturned
);
352 OutputDebugStringW(Buffer
);
356 for(ULONG Index
= 0; Index
< *pulcPinTypes
; Index
++)
358 swprintf(Buffer
, L
"CBDADeviceControl::GetPinTypes: Index %lu Value %lx\n", Index
, rgulPinTypes
[Index
]);
359 OutputDebugStringW(Buffer
);
369 CBDADeviceControl::GetTemplateConnections(ULONG
*pulcConnections
, ULONG ulcConnectionsMax
, BDA_TEMPLATE_CONNECTION
* rgConnections
)
371 #ifdef BDAPLGIN_TRACE
372 OutputDebugStringW(L
"CBDADeviceControl::GetTemplateConnections: NotImplemented\n");
380 CBDADeviceControl::CreatePin(ULONG ulPinType
, ULONG
*pulPinId
)
382 #ifdef BDAPLGIN_TRACE
383 OutputDebugStringW(L
"CBDADeviceControl::CreatePin: NotImplemented\n");
391 CBDADeviceControl::DeletePin(ULONG ulPinId
)
393 #ifdef BDAPLGIN_TRACE
394 OutputDebugStringW(L
"CBDADeviceControl::DeletePin: NotImplemented\n");
402 CBDADeviceControl::SetMediaType(ULONG ulPinId
, AM_MEDIA_TYPE
*pMediaType
)
404 #ifdef BDAPLGIN_TRACE
405 OutputDebugStringW(L
"CBDADeviceControl::SetMediaType: NotImplemented\n");
413 CBDADeviceControl::SetMedium(ULONG ulPinId
, REGPINMEDIUM
*pMedium
)
415 #ifdef BDAPLGIN_TRACE
416 OutputDebugStringW(L
"CBDADeviceControl::SetMedium: NotImplemented\n");
424 CBDADeviceControl::CreateTopology(ULONG ulInputPinId
, ULONG ulOutputPinId
)
426 KSM_BDA_PIN_PAIR Method
;
428 ULONG BytesReturned
= 0;
430 Method
.Method
.Flags
= KSMETHOD_TYPE_NONE
;
431 Method
.Method
.Id
= KSMETHOD_BDA_CREATE_TOPOLOGY
;
432 Method
.Method
.Set
= KSMETHODSETID_BdaDeviceConfiguration
;
433 Method
.InputPinId
= ulInputPinId
;
434 Method
.OutputPinId
= ulOutputPinId
;
436 hr
= KsSynchronousDeviceControl(m_Handle
, IOCTL_KS_METHOD
, (PVOID
)&Method
, sizeof(KSM_BDA_PIN_PAIR
), NULL
, 0, &BytesReturned
);
438 #ifdef BDAPLGIN_TRACE
440 swprintf(Buffer
, L
"CBDADeviceControl::CreateTopology: hr %lx, BytesReturned %lu\n", hr
, BytesReturned
);
441 OutputDebugStringW(Buffer
);
449 CBDADeviceControl::GetControlNode(ULONG ulInputPinId
, ULONG ulOutputPinId
, ULONG ulNodeType
, IUnknown
**ppControlNode
)
454 KSP_BDA_NODE_PIN Property
;
457 Property
.Property
.Set
= KSPROPSETID_BdaTopology
;
458 Property
.Property
.Id
= KSPROPERTY_BDA_CONTROLLING_PIN_ID
;
459 Property
.Property
.Flags
= KSPROPERTY_TYPE_GET
;
460 Property
.ulInputPinId
= ulInputPinId
;
461 Property
.ulOutputPinId
= ulOutputPinId
;
462 Property
.ulNodeType
= ulNodeType
;
465 // WinXP SP3 expects minimum sizeof(KSP_BDA_NODE_PIN) + sizeof(ULONG)
466 // seems a driver to be a driver bug
468 hr
= KsSynchronousDeviceControl(m_Handle
, IOCTL_KS_PROPERTY
, (PVOID
)&Property
, sizeof(KSP_BDA_NODE_PIN
) + sizeof(ULONG
), &PinId
, sizeof(ULONG
), &BytesReturned
);
470 #ifdef BDAPLGIN_TRACE
472 swprintf(Buffer
, L
"CBDADeviceControl::GetControlNode: hr %lx, BytesReturned %lu PinId %lu\n", hr
, BytesReturned
, PinId
);
473 OutputDebugStringW(Buffer
);
479 hr
= CControlNode_fnConstructor(m_Handle
, m_pFilter
, ulNodeType
, PinId
, IID_IUnknown
, (LPVOID
*)ppControlNode
);
481 #ifdef BDAPLGIN_TRACE
482 swprintf(Buffer
, L
"CBDADeviceControl::GetControlNode: hr %lx\n", hr
);
483 OutputDebugStringW(Buffer
);
491 CBDADeviceControl_fnConstructor(
492 IUnknown
* pUnkOuter
,
497 IKsObject
*pObject
= NULL
;
498 IBaseFilter
*pFilter
= NULL
;
501 #ifdef BDAPLGIN_TRACE
502 OutputDebugStringW(L
"CBDADeviceControl_fnConstructor\n");
510 // query for IKsObject
511 hr
= pUnkOuter
->QueryInterface(IID_IKsObject
, (void**)&pObject
);
514 return E_NOINTERFACE
;
517 assert(hr
== NOERROR
);
519 // query for IBaseFilter interface support
520 hr
= pUnkOuter
->QueryInterface(IID_IBaseFilter
, (void**)&pFilter
);
526 return E_NOINTERFACE
;
529 // another sanity check
530 assert(pObject
!= NULL
);
533 hFile
= pObject
->KsGetObjectHandle();
535 // one more sanity check
536 assert(hFile
!= NULL
&& hFile
!= INVALID_HANDLE_VALUE
);
538 // release IKsObject interface
544 // construct device control
545 CBDADeviceControl
* handler
= new CBDADeviceControl(pUnkOuter
, pFilter
, hFile
);
548 return E_OUTOFMEMORY
;
550 if (FAILED(handler
->QueryInterface(riid
, ppv
)))
554 return E_NOINTERFACE
;