ReactOS 0.4.15-dev-7674-gc0b4db1
networkprovider.cpp
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Network Provider for MPEG2 based networks
4 * FILE: dll/directx/msdvbnp/networkprovider.cpp
5 * PURPOSE: IBDA_NetworkProvider interface
6 *
7 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8 */
9#include "precomp.h"
10
11#define DEVICE_FILTER_MASK (0x80000000)
12
14 public IAMovieSetup,
16{
17public:
18 typedef std::vector<IUnknown*>DeviceFilterStack;
19
21
23 {
25 return m_Ref;
26 }
28 {
30 if (!m_Ref)
31 {
32 delete this;
33 return 0;
34 }
35 return m_Ref;
36 }
37
38 // IBaseFilter methods
51
52 //IAMovieSetup methods
55
56 //IBDA_NetworkProvider methods
62 HRESULT STDMETHODCALLTYPE RegisterDeviceFilter(IUnknown *pUnkFilterControl, ULONG *ppvRegistrationContext);
64
66 virtual ~CNetworkProvider(){};
67
68protected:
80};
81
85 IN REFIID refiid,
87{
89 HRESULT hr;
90
91 *Output = NULL;
92
93 if (IsEqualGUID(refiid, IID_IUnknown))
94 {
95 *Output = PVOID(this);
96 reinterpret_cast<IUnknown*>(*Output)->AddRef();
97 return NOERROR;
98 }
99 if (IsEqualGUID(refiid, IID_IBaseFilter))
100 {
101 *Output = (IBaseFilter*)(this);
102 reinterpret_cast<IBaseFilter*>(*Output)->AddRef();
103 return NOERROR;
104 }
105
106 if (IsEqualGUID(refiid, IID_ITuner) ||
107 IsEqualGUID(refiid, IID_IScanningTuner))
108 {
109 // construct scanning tuner
110 if (!m_Tuner)
111 {
113 if (FAILED(hr))
114 return hr;
115 }
116 m_Tuner->AddRef();
118
119 return NOERROR;
120 }
121
122 if (IsEqualGUID(refiid, IID_IBDA_IPV6Filter))
123 {
124 // construct scanning tuner
125 if (!m_IPV6Filter)
126 {
128 if (FAILED(hr))
129 return hr;
130 }
133
134 return NOERROR;
135 }
136
137 if (IsEqualGUID(refiid, IID_IBDA_IPV4Filter))
138 {
139 // construct scanning tuner
140 if (!m_IPV4Filter)
141 {
143 if (FAILED(hr))
144 return hr;
145 }
148
149 return NOERROR;
150 }
151
152 if (IsEqualGUID(refiid, IID_IBDA_EthernetFilter))
153 {
154 // construct scanning tuner
155 if (!m_EthernetFilter)
156 {
158 if (FAILED(hr))
159 return hr;
160 }
163
164 return NOERROR;
165 }
166
168 {
169 *Output = (IBDA_NetworkProvider*)(this);
170 reinterpret_cast<IBDA_NetworkProvider*>(*Output)->AddRef();
171 return NOERROR;
172 }
173
174 for(Index = 0; Index < m_DeviceFilters.size(); Index++)
175 {
176 // get device filter
177 IUnknown *pFilter = m_DeviceFilters[Index];
178
179 if (!pFilter)
180 continue;
181
182 // query for requested interface
183 hr = pFilter->QueryInterface(refiid, Output);
184 if (SUCCEEDED(hr))
185 {
186#ifdef MSDVBNP_TRACE
189 StringFromCLSID(refiid, &lpstr);
190 swprintf(Buffer, L"CNetworkProvider::QueryInterface: DeviceFilter %lu supports %s !!!\n", Index, lpstr);
193#endif
194 return hr;
195 }
196 }
197
200 StringFromCLSID(refiid, &lpstr);
201 swprintf(Buffer, L"CNetworkProvider::QueryInterface: NoInterface for %s !!!\n", lpstr);
204
205 return E_NOINTERFACE;
206}
207
209 m_pGraph(0),
210 m_ReferenceClock(0),
211 m_FilterState(State_Stopped),
212 m_DeviceFilters(),
213 m_Tuner(0),
214 m_IPV6Filter(0),
215 m_IPV4Filter(0),
216 m_EthernetFilter(0)
217{
218 m_Pins[0] = 0;
219
220 CopyMemory(&m_ClassID, ClassID, sizeof(GUID));
221};
222
223//-------------------------------------------------------------------
224// IBaseFilter interface
225//
226
230 CLSID *pClassID)
231{
232 OutputDebugStringW(L"CNetworkProvider::GetClassID\n");
233 CopyMemory(&pClassID, &m_ClassID, sizeof(GUID));
234
235 return S_OK;
236}
237
241{
242 OutputDebugStringW(L"CNetworkProvider::Stop\n");
244 return S_OK;
245}
246
250{
251 OutputDebugStringW(L"CNetworkProvider::Pause\n");
252
254 return S_OK;
255}
256
260 REFERENCE_TIME tStart)
261{
262 OutputDebugStringW(L"CNetworkProvider::Run\n");
263
265 return S_OK;
266}
267
271 DWORD dwMilliSecsTimeout,
273{
275 return S_OK;
276}
277
281 IReferenceClock *pClock)
282{
283 if (pClock)
284 {
285 pClock->AddRef();
286
287 }
289 {
291 }
292
293 m_ReferenceClock = pClock;
294 return S_OK;
295}
296
300 IReferenceClock **pClock)
301{
302 if (!pClock)
303 return E_POINTER;
304
307
308 *pClock = m_ReferenceClock;
309 return S_OK;
310}
311
315 IEnumPins **ppEnum)
316{
317 if (m_Pins[0] == 0)
318 {
320 if (FAILED(hr))
321 return hr;
322 }
323
324 return CEnumPins_fnConstructor(NULL, 1, m_Pins, IID_IEnumPins, (void**)ppEnum);
325}
326
330 LPCWSTR Id, IPin **ppPin)
331{
332 OutputDebugStringW(L"CNetworkProvider::FindPin : NotImplemented\n");
333 return E_NOTIMPL;
334}
335
336
340 FILTER_INFO *pInfo)
341{
342 if (!pInfo)
343 return E_POINTER;
344
345 pInfo->achName[0] = L'\0';
346 pInfo->pGraph = m_pGraph;
347
348 if (m_pGraph)
349 m_pGraph->AddRef();
350
351 return S_OK;
352}
353
357 IFilterGraph *pGraph,
359{
360 if (pGraph)
361 {
362 // joining filter graph
363 m_pGraph = pGraph;
364 }
365 else
366 {
367 // leaving graph
368 m_pGraph = 0;
369 }
370
371 OutputDebugStringW(L"CNetworkProvider::JoinFilterGraph\n");
372 return S_OK;
373}
374
375
379 LPWSTR *pVendorInfo)
380{
381 return E_NOTIMPL;
382}
383
384//-------------------------------------------------------------------
385// IAMovieSetup interface
386//
387
391{
392 OutputDebugStringW(L"CNetworkProvider::Register : NotImplemented\n");
393 return E_NOTIMPL;
394}
395
399{
400 OutputDebugStringW(L"CNetworkProvider::Unregister : NotImplemented\n");
401 return E_NOTIMPL;
402}
403
404//-------------------------------------------------------------------
405// IBDA_NetworkProvider interface
406//
407
411 ULONG ulSignalSource)
412{
413 OutputDebugStringW(L"CNetworkProvider::PutSignalSource : NotImplemented\n");
414 return E_NOTIMPL;
415}
416
420 ULONG *pulSignalSource)
421{
422 OutputDebugStringW(L"CNetworkProvider::GetSignalSource : NotImplemented\n");
423 return E_NOTIMPL;
424}
425
429 GUID *pguidNetworkType)
430{
431 OutputDebugStringW(L"CNetworkProvider::GetNetworkType : NotImplemented\n");
432 return E_NOTIMPL;
433}
434
438 REFGUID guidTuningSpace)
439{
440 OutputDebugStringW(L"CNetworkProvider::PutTuningSpace : NotImplemented\n");
441 return E_NOTIMPL;
442}
443
447 GUID *pguidTuingSpace)
448{
449 OutputDebugStringW(L"CNetworkProvider::GetTuningSpace : NotImplemented\n");
450 return E_NOTIMPL;
451}
452
456 IUnknown *pUnkFilterControl,
457 ULONG *ppvRegistrationContext)
458{
459 HRESULT hr;
460 IBDA_DeviceControl * pDeviceControl = NULL;
461 IBDA_Topology *pTopology = NULL;
462
463 OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter\n");
464
465 if (!pUnkFilterControl || !ppvRegistrationContext)
466 {
467 //invalid argument
468 return E_POINTER;
469 }
470
471 // the filter must support IBDA_DeviceControl and IBDA_Topology
472 hr = pUnkFilterControl->QueryInterface(IID_IBDA_DeviceControl, (void**)&pDeviceControl);
473 if (FAILED(hr))
474 {
475 OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter Filter does not support IBDA_DeviceControl\n");
476 return hr;
477 }
478
479 hr = pUnkFilterControl->QueryInterface(IID_IBDA_Topology, (void**)&pTopology);
480 if (FAILED(hr))
481 {
482 pDeviceControl->Release();
483 OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter Filter does not support IID_IBDA_Topology\n");
484 return hr;
485 }
486
487 //TODO
488 // analyize device filter
489
490 // increment reference
491 pUnkFilterControl->AddRef();
492
493 // release IBDA_DeviceControl interface
494 pDeviceControl->Release();
495
496 // release IBDA_Topology interface
497 pTopology->Release();
498
499 // store registration ctx
500 *ppvRegistrationContext = (m_DeviceFilters.size() | DEVICE_FILTER_MASK);
501
502 // store filter
503 m_DeviceFilters.push_back(pUnkFilterControl);
504
505 OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter complete\n");
506
507 return S_OK;
508}
509
513{
514 ULONG Index;
516
517 OutputDebugStringW(L"CNetworkProvider::UnRegisterDeviceFilter\n");
518
519 if (!(pvRegistrationContext & DEVICE_FILTER_MASK))
520 {
521 // invalid argument
522 return E_INVALIDARG;
523 }
524
525 // get real index
526 Index = pvRegistrationContext & ~DEVICE_FILTER_MASK;
527
528 if (Index >= m_DeviceFilters.size())
529 {
530 // invalid argument
531 return E_INVALIDARG;
532 }
533
535 if (!pUnknown)
536 {
537 // filter was already de-registered
538 return E_INVALIDARG;
539 }
540
541 // remove from vector
543
544 // release extra reference
545 pUnknown->Release();
546
547 return NOERROR;
548}
549
551WINAPI
554 REFIID riid,
555 LPVOID * ppv)
556{
558
559#ifdef MSDVBNP_TRACE
563 swprintf(Buffer, L"CNetworkProvider_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown);
565#endif
566
567 if (!handler)
568 return E_OUTOFMEMORY;
569
570 if (FAILED(handler->QueryInterface(riid, ppv)))
571 {
572 /* not supported */
573 delete handler;
574 return E_NOINTERFACE;
575 }
576 return NOERROR;
577}
DWORD Id
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define STDMETHODIMP
Definition: basetyps.h:43
const GUID IID_IUnknown
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
Definition: bufpool.h:45
HRESULT STDMETHODCALLTYPE Stop(void)
HRESULT STDMETHODCALLTYPE UnRegisterDeviceFilter(ULONG pvRegistrationContext)
HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID)
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins **ppEnum)
std::vector< IUnknown * > DeviceFilterStack
HRESULT STDMETHODCALLTYPE Pause(void)
virtual ~CNetworkProvider()
IBDA_EthernetFilter * m_EthernetFilter
HRESULT STDMETHODCALLTYPE GetTuningSpace(GUID *pguidTuingSpace)
HRESULT STDMETHODCALLTYPE RegisterDeviceFilter(IUnknown *pUnkFilterControl, ULONG *ppvRegistrationContext)
HRESULT STDMETHODCALLTYPE PutSignalSource(ULONG ulSignalSource)
IFilterGraph * m_pGraph
HRESULT STDMETHODCALLTYPE GetSignalSource(ULONG *pulSignalSource)
HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart)
DeviceFilterStack m_DeviceFilters
HRESULT STDMETHODCALLTYPE GetNetworkType(GUID *pguidNetworkType)
IReferenceClock * m_ReferenceClock
HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin **ppPin)
IBDA_IPV4Filter * m_IPV4Filter
HRESULT STDMETHODCALLTYPE Register(void)
HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO *pInfo)
STDMETHODIMP_(ULONG) Release()
HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock **pClock)
FILTER_STATE m_FilterState
HRESULT STDMETHODCALLTYPE Unregister(void)
IScanningTuner * m_Tuner
HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR *pVendorInfo)
STDMETHODIMP_(ULONG) AddRef()
IBDA_IPV6Filter * m_IPV6Filter
HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State)
HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName)
HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock)
CNetworkProvider(LPCGUID ClassID)
HRESULT STDMETHODCALLTYPE PutTuningSpace(REFGUID guidTuningSpace)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
const GUID IID_IBaseFilter
const GUID CLSID_DVBTNetworkProvider
const GUID IID_IBDA_DeviceControl
const GUID IID_IBDA_NetworkProvider
const GUID IID_IBDA_Topology
#define NULL
Definition: types.h:112
HRESULT WINAPI CScanningTunner_fnConstructor(std::vector< IUnknown * > &m_DeviceFilter, REFIID riid, LPVOID *ppv)
#define MAX_PATH
Definition: compat.h:34
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7482
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
#define swprintf
Definition: precomp.h:40
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
unsigned long DWORD
Definition: ntddk_ex.h:95
return pTarget GetState()
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
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
struct IBaseFilter::_FilterInfo FILTER_INFO
enum IMediaFilter::_FilterState FILTER_STATE
Definition: axcore.idl:92
ULONG AddRef()
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT WINAPI CIPV4Filter_fnConstructor(IBDA_NetworkProvider *pNetworkProvider, REFIID riid, LPVOID *ppv)
Definition: ipv4.cpp:152
HRESULT WINAPI CIPV6Filter_fnConstructor(IBDA_NetworkProvider *pNetworkProvider, REFIID riid, LPVOID *ppv)
Definition: ipv6.cpp:149
HRESULT WINAPI CEnumPins_fnConstructor(std::vector< IPin * > Pins, REFIID riid, LPVOID *ppv)
Definition: enumpins.cpp:151
static LPSTR pName
Definition: security.c:75
static LPCSTR lpstr
Definition: font.c:51
static LPOLESTR
Definition: stg_prop.c:27
#define DEVICE_FILTER_MASK
HRESULT WINAPI CNetworkProvider_fnConstructor(IUnknown *pUnknown, REFIID riid, LPVOID *ppv)
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
HRESULT WINAPI CPin_fnConstructor(IUnknown *pUnknown, IBaseFilter *ParentFilter, REFIID riid, LPVOID *ppv)
Definition: pin.cpp:318
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
@ Output
Definition: arc.h:85
HRESULT hr
Definition: shlfolder.c:183
IFilterGraph * pGraph
Definition: axcore.idl:303
WCHAR achName[MAX_FILTER_NAME]
Definition: axcore.idl:302
Definition: scsiwmi.h:51
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
struct tagRun Run
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
#define CopyMemory
Definition: winbase.h:1710
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
#define NOERROR
Definition: winerror.h:2354
#define E_POINTER
Definition: winerror.h:2365
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185