2010-03-01 15:28:28 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Network Provider for MPEG2 based networks
|
|
|
|
* FILE: dll/directx/msdvbnp/networkprovider.cpp
|
|
|
|
* PURPOSE: IBDA_NetworkProvider interface
|
|
|
|
*
|
2013-09-15 13:06:05 +00:00
|
|
|
* PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
|
2010-03-01 15:28:28 +00:00
|
|
|
*/
|
|
|
|
#include "precomp.h"
|
|
|
|
|
2010-03-26 17:51:54 +00:00
|
|
|
#define DEVICE_FILTER_MASK (0x80000000)
|
|
|
|
|
2010-03-01 15:28:28 +00:00
|
|
|
class CNetworkProvider : public IBaseFilter,
|
|
|
|
public IAMovieSetup,
|
|
|
|
public IBDA_NetworkProvider
|
|
|
|
{
|
|
|
|
public:
|
2010-03-26 17:51:54 +00:00
|
|
|
typedef std::vector<IUnknown*>DeviceFilterStack;
|
|
|
|
|
2010-03-01 15:28:28 +00:00
|
|
|
STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
|
|
|
|
|
|
|
|
STDMETHODIMP_(ULONG) AddRef()
|
|
|
|
{
|
|
|
|
InterlockedIncrement(&m_Ref);
|
|
|
|
return m_Ref;
|
|
|
|
}
|
|
|
|
STDMETHODIMP_(ULONG) Release()
|
|
|
|
{
|
|
|
|
InterlockedDecrement(&m_Ref);
|
|
|
|
if (!m_Ref)
|
|
|
|
{
|
2010-03-02 20:18:29 +00:00
|
|
|
delete this;
|
2010-03-01 15:28:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return m_Ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
// IBaseFilter methods
|
|
|
|
HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pClassID);
|
|
|
|
HRESULT STDMETHODCALLTYPE Stop( void);
|
|
|
|
HRESULT STDMETHODCALLTYPE Pause( void);
|
|
|
|
HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart);
|
|
|
|
HRESULT STDMETHODCALLTYPE GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *State);
|
|
|
|
HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock);
|
|
|
|
HRESULT STDMETHODCALLTYPE GetSyncSource(IReferenceClock **pClock);
|
|
|
|
HRESULT STDMETHODCALLTYPE EnumPins(IEnumPins **ppEnum);
|
|
|
|
HRESULT STDMETHODCALLTYPE FindPin(LPCWSTR Id, IPin **ppPin);
|
|
|
|
HRESULT STDMETHODCALLTYPE QueryFilterInfo(FILTER_INFO *pInfo);
|
|
|
|
HRESULT STDMETHODCALLTYPE JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName);
|
|
|
|
HRESULT STDMETHODCALLTYPE QueryVendorInfo(LPWSTR *pVendorInfo);
|
|
|
|
|
|
|
|
//IAMovieSetup methods
|
|
|
|
HRESULT STDMETHODCALLTYPE Register( void);
|
|
|
|
HRESULT STDMETHODCALLTYPE Unregister( void);
|
|
|
|
|
|
|
|
//IBDA_NetworkProvider methods
|
|
|
|
HRESULT STDMETHODCALLTYPE PutSignalSource(ULONG ulSignalSource);
|
|
|
|
HRESULT STDMETHODCALLTYPE GetSignalSource(ULONG *pulSignalSource);
|
|
|
|
HRESULT STDMETHODCALLTYPE GetNetworkType(GUID *pguidNetworkType);
|
|
|
|
HRESULT STDMETHODCALLTYPE PutTuningSpace(REFGUID guidTuningSpace);
|
|
|
|
HRESULT STDMETHODCALLTYPE GetTuningSpace(GUID *pguidTuingSpace);
|
2016-11-12 21:53:33 +00:00
|
|
|
HRESULT STDMETHODCALLTYPE RegisterDeviceFilter(IUnknown *pUnkFilterControl, ULONG *ppvRegistrationContext);
|
2010-03-01 15:28:28 +00:00
|
|
|
HRESULT STDMETHODCALLTYPE UnRegisterDeviceFilter(ULONG pvRegistrationContext);
|
|
|
|
|
2010-03-26 17:51:54 +00:00
|
|
|
CNetworkProvider(LPCGUID ClassID);
|
2010-03-01 15:28:28 +00:00
|
|
|
virtual ~CNetworkProvider(){};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
LONG m_Ref;
|
|
|
|
IFilterGraph *m_pGraph;
|
2010-03-01 18:59:42 +00:00
|
|
|
IReferenceClock * m_ReferenceClock;
|
|
|
|
FILTER_STATE m_FilterState;
|
|
|
|
IPin * m_Pins[1];
|
2010-03-26 17:51:54 +00:00
|
|
|
GUID m_ClassID;
|
|
|
|
DeviceFilterStack m_DeviceFilters;
|
|
|
|
IScanningTuner * m_Tuner;
|
2010-03-29 13:12:16 +00:00
|
|
|
IBDA_IPV6Filter * m_IPV6Filter;
|
|
|
|
IBDA_IPV4Filter * m_IPV4Filter;
|
|
|
|
IBDA_EthernetFilter * m_EthernetFilter;
|
2010-03-01 15:28:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::QueryInterface(
|
|
|
|
IN REFIID refiid,
|
|
|
|
OUT PVOID* Output)
|
|
|
|
{
|
2010-03-26 17:51:54 +00:00
|
|
|
ULONG Index;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2010-03-01 20:00:26 +00:00
|
|
|
*Output = NULL;
|
|
|
|
|
2010-03-01 15:28:28 +00:00
|
|
|
if (IsEqualGUID(refiid, IID_IUnknown))
|
|
|
|
{
|
|
|
|
*Output = PVOID(this);
|
|
|
|
reinterpret_cast<IUnknown*>(*Output)->AddRef();
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
if (IsEqualGUID(refiid, IID_IBaseFilter))
|
|
|
|
{
|
|
|
|
*Output = (IBaseFilter*)(this);
|
|
|
|
reinterpret_cast<IBaseFilter*>(*Output)->AddRef();
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsEqualGUID(refiid, IID_ITuner) ||
|
|
|
|
IsEqualGUID(refiid, IID_IScanningTuner))
|
|
|
|
{
|
|
|
|
// construct scanning tuner
|
2010-03-26 17:51:54 +00:00
|
|
|
if (!m_Tuner)
|
|
|
|
{
|
|
|
|
HRESULT hr = CScanningTunner_fnConstructor(m_DeviceFilters, refiid, (void**)&m_Tuner);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
m_Tuner->AddRef();
|
|
|
|
*Output = (IUnknown*)m_Tuner;
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
2010-03-29 13:12:16 +00:00
|
|
|
if (IsEqualGUID(refiid, IID_IBDA_IPV6Filter))
|
|
|
|
{
|
|
|
|
// construct scanning tuner
|
|
|
|
if (!m_IPV6Filter)
|
|
|
|
{
|
|
|
|
HRESULT hr = CIPV6Filter_fnConstructor((IBDA_NetworkProvider*)this, refiid, (void**)&m_IPV6Filter);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
m_IPV6Filter->AddRef();
|
|
|
|
*Output = (IUnknown*)m_IPV6Filter;
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsEqualGUID(refiid, IID_IBDA_IPV4Filter))
|
|
|
|
{
|
|
|
|
// construct scanning tuner
|
|
|
|
if (!m_IPV4Filter)
|
|
|
|
{
|
|
|
|
HRESULT hr = CIPV4Filter_fnConstructor((IBDA_NetworkProvider*)this, refiid, (void**)&m_IPV4Filter);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
m_IPV4Filter->AddRef();
|
|
|
|
*Output = (IUnknown*)m_IPV4Filter;
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsEqualGUID(refiid, IID_IBDA_EthernetFilter))
|
|
|
|
{
|
|
|
|
// construct scanning tuner
|
|
|
|
if (!m_EthernetFilter)
|
|
|
|
{
|
|
|
|
HRESULT hr = CIPV4Filter_fnConstructor((IBDA_NetworkProvider*)this, refiid, (void**)&m_EthernetFilter);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
m_EthernetFilter->AddRef();
|
|
|
|
*Output = (IUnknown*)m_EthernetFilter;
|
|
|
|
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
2010-03-26 17:51:54 +00:00
|
|
|
if (IsEqualGUID(refiid, IID_IBDA_NetworkProvider))
|
|
|
|
{
|
|
|
|
*Output = (IBDA_NetworkProvider*)(this);
|
|
|
|
reinterpret_cast<IBDA_NetworkProvider*>(*Output)->AddRef();
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(Index = 0; Index < m_DeviceFilters.size(); Index++)
|
|
|
|
{
|
|
|
|
// get device filter
|
|
|
|
IUnknown *pFilter = m_DeviceFilters[Index];
|
|
|
|
|
|
|
|
if (!pFilter)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// query for requested interface
|
|
|
|
hr = pFilter->QueryInterface(refiid, Output);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
#ifdef MSDVBNP_TRACE
|
|
|
|
WCHAR Buffer[MAX_PATH];
|
|
|
|
LPOLESTR lpstr;
|
|
|
|
StringFromCLSID(refiid, &lpstr);
|
|
|
|
swprintf(Buffer, L"CNetworkProvider::QueryInterface: DeviceFilter %lu supports %s !!!\n", Index, lpstr);
|
|
|
|
OutputDebugStringW(Buffer);
|
|
|
|
CoTaskMemFree(lpstr);
|
|
|
|
#endif
|
|
|
|
return hr;
|
|
|
|
}
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WCHAR Buffer[MAX_PATH];
|
|
|
|
LPOLESTR lpstr;
|
|
|
|
StringFromCLSID(refiid, &lpstr);
|
2010-03-01 18:59:42 +00:00
|
|
|
swprintf(Buffer, L"CNetworkProvider::QueryInterface: NoInterface for %s !!!\n", lpstr);
|
2010-03-01 15:28:28 +00:00
|
|
|
OutputDebugStringW(Buffer);
|
|
|
|
CoTaskMemFree(lpstr);
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2010-03-26 17:51:54 +00:00
|
|
|
CNetworkProvider::CNetworkProvider(LPCGUID ClassID) : m_Ref(0),
|
|
|
|
m_pGraph(0),
|
|
|
|
m_ReferenceClock(0),
|
|
|
|
m_FilterState(State_Stopped),
|
|
|
|
m_DeviceFilters(),
|
2010-03-29 13:12:16 +00:00
|
|
|
m_Tuner(0),
|
|
|
|
m_IPV6Filter(0),
|
|
|
|
m_IPV4Filter(0),
|
|
|
|
m_EthernetFilter(0)
|
2010-03-26 17:51:54 +00:00
|
|
|
{
|
|
|
|
m_Pins[0] = 0;
|
|
|
|
|
|
|
|
CopyMemory(&m_ClassID, ClassID, sizeof(GUID));
|
|
|
|
};
|
|
|
|
|
2010-03-01 15:28:28 +00:00
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// IBaseFilter interface
|
|
|
|
//
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::GetClassID(
|
|
|
|
CLSID *pClassID)
|
|
|
|
{
|
2010-03-26 17:51:54 +00:00
|
|
|
OutputDebugStringW(L"CNetworkProvider::GetClassID\n");
|
|
|
|
CopyMemory(&pClassID, &m_ClassID, sizeof(GUID));
|
|
|
|
|
|
|
|
return S_OK;
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::Stop()
|
|
|
|
{
|
2010-03-26 17:51:54 +00:00
|
|
|
OutputDebugStringW(L"CNetworkProvider::Stop\n");
|
|
|
|
m_FilterState = State_Stopped;
|
|
|
|
return S_OK;
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::Pause()
|
|
|
|
{
|
2010-03-26 17:51:54 +00:00
|
|
|
OutputDebugStringW(L"CNetworkProvider::Pause\n");
|
|
|
|
|
|
|
|
m_FilterState = State_Paused;
|
|
|
|
return S_OK;
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::Run(
|
|
|
|
REFERENCE_TIME tStart)
|
|
|
|
{
|
2010-03-26 17:51:54 +00:00
|
|
|
OutputDebugStringW(L"CNetworkProvider::Run\n");
|
|
|
|
|
|
|
|
m_FilterState = State_Running;
|
|
|
|
return S_OK;
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::GetState(
|
|
|
|
DWORD dwMilliSecsTimeout,
|
|
|
|
FILTER_STATE *State)
|
|
|
|
{
|
2010-03-01 18:59:42 +00:00
|
|
|
*State = m_FilterState;
|
|
|
|
return S_OK;
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::SetSyncSource(
|
|
|
|
IReferenceClock *pClock)
|
|
|
|
{
|
2010-03-01 18:59:42 +00:00
|
|
|
if (pClock)
|
|
|
|
{
|
|
|
|
pClock->AddRef();
|
|
|
|
|
|
|
|
}
|
|
|
|
if (m_ReferenceClock)
|
|
|
|
{
|
|
|
|
m_ReferenceClock->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ReferenceClock = pClock;
|
|
|
|
return S_OK;
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::GetSyncSource(
|
|
|
|
IReferenceClock **pClock)
|
|
|
|
{
|
2010-03-01 18:59:42 +00:00
|
|
|
if (!pClock)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if (m_ReferenceClock)
|
|
|
|
m_ReferenceClock->AddRef();
|
|
|
|
|
|
|
|
*pClock = m_ReferenceClock;
|
|
|
|
return S_OK;
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::EnumPins(
|
|
|
|
IEnumPins **ppEnum)
|
|
|
|
{
|
2010-03-01 18:59:42 +00:00
|
|
|
if (m_Pins[0] == 0)
|
|
|
|
{
|
|
|
|
HRESULT hr = CPin_fnConstructor(NULL, (IBaseFilter*)this, IID_IUnknown, (void**)&m_Pins[0]);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CEnumPins_fnConstructor(NULL, 1, m_Pins, IID_IEnumPins, (void**)ppEnum);
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::FindPin(
|
|
|
|
LPCWSTR Id, IPin **ppPin)
|
|
|
|
{
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::FindPin : NotImplemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::QueryFilterInfo(
|
|
|
|
FILTER_INFO *pInfo)
|
|
|
|
{
|
2010-03-01 18:59:42 +00:00
|
|
|
if (!pInfo)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
pInfo->achName[0] = L'\0';
|
|
|
|
pInfo->pGraph = m_pGraph;
|
|
|
|
|
2010-03-26 17:51:54 +00:00
|
|
|
if (m_pGraph)
|
|
|
|
m_pGraph->AddRef();
|
|
|
|
|
2010-03-01 18:59:42 +00:00
|
|
|
return S_OK;
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::JoinFilterGraph(
|
|
|
|
IFilterGraph *pGraph,
|
|
|
|
LPCWSTR pName)
|
|
|
|
{
|
|
|
|
if (pGraph)
|
|
|
|
{
|
|
|
|
// joining filter graph
|
|
|
|
m_pGraph = pGraph;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// leaving graph
|
|
|
|
m_pGraph = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::JoinFilterGraph\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::QueryVendorInfo(
|
|
|
|
LPWSTR *pVendorInfo)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// IAMovieSetup interface
|
|
|
|
//
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::Register()
|
|
|
|
{
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::Register : NotImplemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::Unregister()
|
|
|
|
{
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::Unregister : NotImplemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// IBDA_NetworkProvider interface
|
|
|
|
//
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::PutSignalSource(
|
|
|
|
ULONG ulSignalSource)
|
|
|
|
{
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::PutSignalSource : NotImplemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::GetSignalSource(
|
|
|
|
ULONG *pulSignalSource)
|
|
|
|
{
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::GetSignalSource : NotImplemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::GetNetworkType(
|
|
|
|
GUID *pguidNetworkType)
|
|
|
|
{
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::GetNetworkType : NotImplemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::PutTuningSpace(
|
|
|
|
REFGUID guidTuningSpace)
|
|
|
|
{
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::PutTuningSpace : NotImplemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::GetTuningSpace(
|
|
|
|
GUID *pguidTuingSpace)
|
|
|
|
{
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::GetTuningSpace : NotImplemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::RegisterDeviceFilter(
|
|
|
|
IUnknown *pUnkFilterControl,
|
2016-11-12 21:53:33 +00:00
|
|
|
ULONG *ppvRegistrationContext)
|
2010-03-01 15:28:28 +00:00
|
|
|
{
|
2010-03-26 17:51:54 +00:00
|
|
|
HRESULT hr;
|
|
|
|
IBDA_DeviceControl * pDeviceControl = NULL;
|
|
|
|
IBDA_Topology *pTopology = NULL;
|
|
|
|
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter\n");
|
|
|
|
|
2016-11-12 21:53:33 +00:00
|
|
|
if (!pUnkFilterControl || !ppvRegistrationContext)
|
2010-03-26 17:51:54 +00:00
|
|
|
{
|
|
|
|
//invalid argument
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
// the filter must support IBDA_DeviceControl and IBDA_Topology
|
|
|
|
hr = pUnkFilterControl->QueryInterface(IID_IBDA_DeviceControl, (void**)&pDeviceControl);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter Filter does not support IBDA_DeviceControl\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = pUnkFilterControl->QueryInterface(IID_IBDA_Topology, (void**)&pTopology);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
pDeviceControl->Release();
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter Filter does not support IID_IBDA_Topology\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
// analyize device filter
|
|
|
|
|
|
|
|
// increment reference
|
|
|
|
pUnkFilterControl->AddRef();
|
|
|
|
|
|
|
|
// release IBDA_DeviceControl interface
|
|
|
|
pDeviceControl->Release();
|
|
|
|
|
|
|
|
// release IBDA_Topology interface
|
|
|
|
pTopology->Release();
|
|
|
|
|
|
|
|
// store registration ctx
|
2016-11-12 21:53:33 +00:00
|
|
|
*ppvRegistrationContext = (m_DeviceFilters.size() | DEVICE_FILTER_MASK);
|
2010-03-26 17:51:54 +00:00
|
|
|
|
|
|
|
// store filter
|
|
|
|
m_DeviceFilters.push_back(pUnkFilterControl);
|
|
|
|
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter complete\n");
|
|
|
|
|
|
|
|
return S_OK;
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CNetworkProvider::UnRegisterDeviceFilter(ULONG pvRegistrationContext)
|
|
|
|
{
|
2010-03-26 17:51:54 +00:00
|
|
|
ULONG Index;
|
|
|
|
IUnknown * pUnknown;
|
|
|
|
|
|
|
|
OutputDebugStringW(L"CNetworkProvider::UnRegisterDeviceFilter\n");
|
|
|
|
|
|
|
|
if (!(pvRegistrationContext & DEVICE_FILTER_MASK))
|
|
|
|
{
|
|
|
|
// invalid argument
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get real index
|
|
|
|
Index = pvRegistrationContext & ~DEVICE_FILTER_MASK;
|
|
|
|
|
|
|
|
if (Index >= m_DeviceFilters.size())
|
|
|
|
{
|
|
|
|
// invalid argument
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
pUnknown = m_DeviceFilters[Index];
|
|
|
|
if (!pUnknown)
|
|
|
|
{
|
|
|
|
// filter was already de-registered
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove from vector
|
|
|
|
m_DeviceFilters[Index] = NULL;
|
|
|
|
|
|
|
|
// release extra reference
|
|
|
|
pUnknown->Release();
|
|
|
|
|
|
|
|
return NOERROR;
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
WINAPI
|
|
|
|
CNetworkProvider_fnConstructor(
|
|
|
|
IUnknown *pUnknown,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppv)
|
|
|
|
{
|
2010-03-26 17:51:54 +00:00
|
|
|
CNetworkProvider * handler = new CNetworkProvider(&CLSID_DVBTNetworkProvider);
|
2010-03-01 15:28:28 +00:00
|
|
|
|
|
|
|
#ifdef MSDVBNP_TRACE
|
|
|
|
WCHAR Buffer[MAX_PATH];
|
|
|
|
LPOLESTR lpstr;
|
|
|
|
StringFromCLSID(riid, &lpstr);
|
2010-03-01 20:00:26 +00:00
|
|
|
swprintf(Buffer, L"CNetworkProvider_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown);
|
2010-03-01 15:28:28 +00:00
|
|
|
OutputDebugStringW(Buffer);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!handler)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(handler->QueryInterface(riid, ppv)))
|
|
|
|
{
|
|
|
|
/* not supported */
|
|
|
|
delete handler;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
return NOERROR;
|
|
|
|
}
|