ReactOS 0.4.16-dev-297-gc569aee
pincontrol.cpp File Reference
#include "precomp.h"
Include dependency graph for pincontrol.cpp:

Go to the source code of this file.

Classes

class  CBDAPinControl
 

Functions

HRESULT GetNetworkProviderFromGraph (IFilterGraph *pGraph, IBDA_NetworkProvider **pOutNetworkProvider)
 
HRESULT CBDAPinControl_RealConstructor (HANDLE hPin, IBDA_NetworkProvider *pNetworkProvider, IPin *pConnectedPin, ULONG RegistrationCtx, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
 
HRESULT WINAPI CBDAPinControl_fnConstructor (IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
 

Variables

const GUID KSPROPSETID_BdaPinControl = {0x0ded49d5, 0xa8b7, 0x4d5d, {0x97, 0xa1, 0x12, 0xb0, 0xc1, 0x95, 0x87, 0x4d}}
 
const GUID IID_IBDA_PinControl = {0x0DED49D5, 0xA8B7, 0x4d5d, {0x97, 0xA1, 0x12, 0xB0, 0xC1, 0x95, 0x87, 0x4D}}
 
const GUID IID_IPin = {0x56a86891, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}
 

Function Documentation

◆ CBDAPinControl_fnConstructor()

HRESULT WINAPI CBDAPinControl_fnConstructor ( IUnknown pUnkOuter,
REFIID  riid,
LPVOID ppv 
)

Definition at line 236 of file pincontrol.cpp.

240{
241 IPin * pConnectedPin = NULL;
242 IBDA_NetworkProvider * pNetworkProvider = NULL;
244 HRESULT hr;
245 IKsObject * pObject = NULL;
246 IPin * pPin = NULL;
248 PIN_INFO PinInfo;
249 FILTER_INFO FilterInfo;
250 ULONG RegistrationCtx = 0;
251
252 if (!pUnkOuter)
253 return E_POINTER;
254
255 OutputDebugStringW(L"CBDAPinControl_fnConstructor\n");
256 //DebugBreak();
257
258 // query for IKsObject interface
259 hr = pUnkOuter->QueryInterface(IID_IKsObject, (void**)&pObject);
260
261 if (FAILED(hr))
262 return hr;
263
264 // query for IPin interface
265 hr = pObject->QueryInterface(IID_IPin, (void**)&pPin);
266
267 if (FAILED(hr))
268 {
269 //clean up
270 pObject->Release();
271 return hr;
272 }
273
274 // get pin info
275 hr = pPin->QueryPinInfo(&PinInfo);
276
277 if (FAILED(hr))
278 {
279 //clean up
280 pObject->Release();
281 pPin->Release();
282 return hr;
283 }
284
285 if (!PinInfo.pFilter)
286 {
287 //clean up
288 pObject->Release();
289 pPin->Release();
290 return hr;
291 }
292
293 // sanity checks
294 assert(PinInfo.pFilter != NULL);
295
296 // query filter info
297 hr = PinInfo.pFilter->QueryFilterInfo(&FilterInfo);
298
299 // sanity check
300 assert(FilterInfo.pGraph != NULL);
301
302 // get network provider interface
303 hr = GetNetworkProviderFromGraph(FilterInfo.pGraph, &pNetworkProvider);
304
305 if (SUCCEEDED(hr))
306 {
307 if (PinInfo.dir == PINDIR_OUTPUT)
308 {
309 // get connected pin handle
310 hr = pPin->ConnectedTo(&pConnectedPin);
311 if (SUCCEEDED(hr))
312 {
313 // get file handle
314 hFile = pObject->KsGetObjectHandle();
315 if (hFile)
316 {
317 hr = CBDAPinControl_RealConstructor(hFile, pNetworkProvider, pConnectedPin, 0, pUnkOuter, riid, ppv);
318 if (SUCCEEDED(hr))
319 {
320 // set to null to prevent releasing
321 pNetworkProvider = NULL;
322 pConnectedPin = NULL;
323 }
324 }
325 else
326 {
327 // expected file handle
329 }
330 }
331 }
332 else
333 {
334 // get IUnknown from base filter
335 hr = PinInfo.pFilter->QueryInterface(IID_IUnknown, (void**)&pUnknown);
336 if (SUCCEEDED(hr))
337 {
338 // register device filter
339 OutputDebugStringW(L"CBDAPinControl_fnConstructor registering device filter with network provider\n");
340 hr = pNetworkProvider->RegisterDeviceFilter(pUnknown, &RegistrationCtx);
341 if (SUCCEEDED(hr))
342 {
343 // get file handle
344 hFile = pObject->KsGetObjectHandle();
345 if (hFile)
346 {
347 hr = CBDAPinControl_RealConstructor(hFile, pNetworkProvider, NULL, RegistrationCtx, pUnkOuter, riid, ppv);
348 if (SUCCEEDED(hr))
349 {
350 // set to null to prevent releasing
351 pNetworkProvider = NULL;
352 }
353 }
354 else
355 {
356 // expected file handle
358 }
359 }
360 else
361 {
362 WCHAR Buffer[100];
363 swprintf(Buffer, L"CBDAPinControl_fnConstructor failed to register filter with %lx\n", hr);
365 }
366 }
367 }
368 }
369
370 // release IFilterGraph interface
371 FilterInfo.pGraph->Release();
372
373 // release IBaseFilter interface
374 PinInfo.pFilter->Release();
375
376 // release IPin
377 pPin->Release();
378
379 // release IKsObject
380 pObject->Release();
381
382
383 if (pNetworkProvider)
384 {
385 // release network provider
386 pNetworkProvider->Release();
387 }
388
389 if (pConnectedPin)
390 {
391 // release connected pin
392 pConnectedPin->Release();
393 }
394
395 if (pUnknown)
396 {
397 // release filter
398 pUnknown->Release();
399 }
400
401 return hr;
402}
@ PINDIR_OUTPUT
Definition: axcore.idl:42
const GUID IID_IUnknown
Definition: bufpool.h:45
virtual ULONG Release(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:853
virtual _Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
Definition: fxobject.cpp:255
const GUID IID_IKsObject
#define NULL
Definition: types.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define swprintf
Definition: precomp.h:40
#define assert(x)
Definition: debug.h:53
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
FxObject * pObject
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT RegisterDeviceFilter([in] IUnknown *pUnkFilterControl, [in, out] ULONG *ppvRegisitrationContext)
Definition: axcore.idl:92
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
nsrefcnt Release()
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
_In_ HANDLE hFile
Definition: mswsock.h:90
#define L(x)
Definition: ntvdm.h:50
HRESULT GetNetworkProviderFromGraph(IFilterGraph *pGraph, IBDA_NetworkProvider **pOutNetworkProvider)
Definition: pincontrol.cpp:162
HRESULT CBDAPinControl_RealConstructor(HANDLE hPin, IBDA_NetworkProvider *pNetworkProvider, IPin *pConnectedPin, ULONG RegistrationCtx, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
Definition: pincontrol.cpp:206
const GUID IID_IPin
Definition: pincontrol.cpp:15
HRESULT hr
Definition: shlfolder.c:183
uint32_t ULONG
Definition: typedefs.h:59
#define E_UNEXPECTED
Definition: winerror.h:2456
#define E_POINTER
Definition: winerror.h:2365
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ CBDAPinControl_RealConstructor()

HRESULT CBDAPinControl_RealConstructor ( HANDLE  hPin,
IBDA_NetworkProvider pNetworkProvider,
IPin pConnectedPin,
ULONG  RegistrationCtx,
IUnknown pUnkOuter,
REFIID  riid,
LPVOID ppv 
)

Definition at line 206 of file pincontrol.cpp.

214{
215 CBDAPinControl * handler = new CBDAPinControl(hPin, pNetworkProvider, pConnectedPin, RegistrationCtx);
216
217#ifdef BDAPLGIN_TRACE
218 OutputDebugStringW(L"CBDAPinControl_fnConstructor\n");
219#endif
220
221 if (!handler)
222 return E_OUTOFMEMORY;
223
224 if (FAILED(handler->QueryInterface(riid, ppv)))
225 {
226 /* not supported */
227 delete handler;
228 return E_NOINTERFACE;
229 }
230
231 return NOERROR;
232}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512
#define E_NOINTERFACE
Definition: winerror.h:2364
#define NOERROR
Definition: winerror.h:2354

Referenced by CBDAPinControl_fnConstructor().

◆ GetNetworkProviderFromGraph()

HRESULT GetNetworkProviderFromGraph ( IFilterGraph pGraph,
IBDA_NetworkProvider **  pOutNetworkProvider 
)

Definition at line 162 of file pincontrol.cpp.

165{
166 IEnumFilters *pEnumFilters = NULL;
167 IBaseFilter * ppFilter[1];
168 IBDA_NetworkProvider * pNetworkProvider = NULL;
169 HRESULT hr;
170
171 // get IEnumFilters interface
172 hr = pGraph->EnumFilters(&pEnumFilters);
173
174 if (FAILED(hr))
175 {
176 //clean up
177 *pOutNetworkProvider = NULL;
178 return hr;
179 }
180
181 while(pEnumFilters->Next(1, ppFilter, NULL) == S_OK)
182 {
183 // check if that filter supports the IBDA_NetworkProvider interface
184 hr = ppFilter[0]->QueryInterface(IID_IBDA_NetworkProvider, (void**)&pNetworkProvider);
185
186 // release IBaseFilter
187 ppFilter[0]->Release();
188
189 if (SUCCEEDED(hr))
190 break;
191 }
192
193 // release IEnumFilters interface
194 pEnumFilters->Release();
195
196 //store result
197 *pOutNetworkProvider = pNetworkProvider;
198
199 if (pNetworkProvider)
200 return S_OK;
201 else
202 return E_FAIL;
203}
#define E_FAIL
Definition: ddrawi.h:102
const GUID IID_IBDA_NetworkProvider
HRESULT Next([in] ULONG cFilters, [out] IBaseFilter **ppFilter, [out] ULONG *pcFetched)
HRESULT EnumFilters([out] IEnumFilters **ppEnum)
#define S_OK
Definition: intsafe.h:52

Referenced by CBDAPinControl_fnConstructor().

Variable Documentation

◆ IID_IBDA_PinControl

const GUID IID_IBDA_PinControl = {0x0DED49D5, 0xA8B7, 0x4d5d, {0x97, 0xA1, 0x12, 0xB0, 0xC1, 0x95, 0x87, 0x4D}}

Definition at line 14 of file pincontrol.cpp.

Referenced by CBDAPinControl::QueryInterface().

◆ IID_IPin

◆ KSPROPSETID_BdaPinControl

const GUID KSPROPSETID_BdaPinControl = {0x0ded49d5, 0xa8b7, 0x4d5d, {0x97, 0xa1, 0x12, 0xb0, 0xc1, 0x95, 0x87, 0x4d}}

Definition at line 13 of file pincontrol.cpp.

Referenced by CBDAPinControl::GetPinID(), and CBDAPinControl::GetPinType().