2010-02-23 17:40:34 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS BDA Proxy
|
|
|
|
* FILE: dll/directx/bdaplgin/classfactory.cpp
|
|
|
|
* PURPOSE: ClassFactory interface
|
|
|
|
*
|
|
|
|
* PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
#ifndef _MSC_VER
|
2010-03-01 15:28:28 +00:00
|
|
|
const GUID KSPROPSETID_BdaPinControl = {0x0ded49d5, 0xa8b7, 0x4d5d, {0x97, 0xa1, 0x12, 0xb0, 0xc1, 0x95, 0x87, 0x4d}};
|
2010-03-24 16:04:44 +00:00
|
|
|
const GUID IID_IBDA_PinControl = {0x0DED49D5, 0xA8B7, 0x4d5d, {0x97, 0xA1, 0x12, 0xB0, 0xC1, 0x95, 0x87, 0x4D}};
|
2010-02-25 16:14:54 +00:00
|
|
|
const GUID IID_IPin = {0x56a86891, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
|
2010-03-24 16:04:44 +00:00
|
|
|
#endif
|
|
|
|
|
2010-02-23 17:40:34 +00:00
|
|
|
|
|
|
|
class CBDAPinControl : public IBDA_PinControl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
|
|
|
|
|
|
|
|
STDMETHODIMP_(ULONG) AddRef()
|
|
|
|
{
|
|
|
|
InterlockedIncrement(&m_Ref);
|
|
|
|
return m_Ref;
|
|
|
|
}
|
|
|
|
STDMETHODIMP_(ULONG) Release()
|
|
|
|
{
|
|
|
|
InterlockedDecrement(&m_Ref);
|
|
|
|
if (!m_Ref)
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return m_Ref;
|
|
|
|
}
|
|
|
|
// IBDA_PinControl methods
|
|
|
|
HRESULT STDMETHODCALLTYPE GetPinID(ULONG *pulPinID);
|
|
|
|
HRESULT STDMETHODCALLTYPE GetPinType(ULONG *pulPinType);
|
|
|
|
HRESULT STDMETHODCALLTYPE RegistrationContext(ULONG *pulRegistrationCtx);
|
|
|
|
|
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
CBDAPinControl(HANDLE hFile, IBDA_NetworkProvider * pProvider, IPin * pConnectedPin, ULONG RegistrationCtx) : m_Ref(0), m_Handle(hFile), m_pProvider(pProvider), m_pConnectedPin(pConnectedPin), m_RegistrationCtx(RegistrationCtx){};
|
2010-03-01 15:28:28 +00:00
|
|
|
virtual ~CBDAPinControl()
|
|
|
|
{
|
|
|
|
//m_pConnectedPin->Release();
|
|
|
|
//m_pProvider->Release();
|
|
|
|
};
|
2010-02-23 17:40:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
LONG m_Ref;
|
|
|
|
HANDLE m_Handle;
|
2010-02-25 16:14:54 +00:00
|
|
|
IBDA_NetworkProvider * m_pProvider;
|
|
|
|
IPin * m_pConnectedPin;
|
2010-03-24 16:04:44 +00:00
|
|
|
ULONG m_RegistrationCtx;
|
2010-02-23 17:40:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CBDAPinControl::QueryInterface(
|
|
|
|
IN REFIID refiid,
|
|
|
|
OUT PVOID* Output)
|
|
|
|
{
|
2010-03-02 20:18:29 +00:00
|
|
|
*Output = NULL;
|
2010-02-23 17:40:34 +00:00
|
|
|
if (IsEqualGUID(refiid, IID_IUnknown))
|
|
|
|
{
|
|
|
|
*Output = PVOID(this);
|
|
|
|
reinterpret_cast<IUnknown*>(*Output)->AddRef();
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
if (IsEqualGUID(refiid, IID_IBDA_PinControl))
|
|
|
|
{
|
|
|
|
*Output = (IBDA_PinControl*)(this);
|
|
|
|
reinterpret_cast<IBDA_PinControl*>(*Output)->AddRef();
|
|
|
|
return NOERROR;
|
|
|
|
}
|
2010-03-26 11:43:52 +00:00
|
|
|
DebugBreak();
|
2010-02-23 17:40:34 +00:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
// IBDA_PinControl methods
|
|
|
|
//
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CBDAPinControl::GetPinID(ULONG *pulPinID)
|
|
|
|
{
|
2010-03-01 15:28:28 +00:00
|
|
|
KSPROPERTY Property;
|
|
|
|
ULONG BytesReturned;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
// setup request
|
|
|
|
Property.Set = KSPROPSETID_BdaPinControl;
|
|
|
|
Property.Id = KSPROPERTY_BDA_PIN_ID;
|
|
|
|
Property.Flags = KSPROPERTY_TYPE_GET;
|
|
|
|
|
|
|
|
// perform request
|
|
|
|
hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), pulPinID, sizeof(ULONG), &BytesReturned);
|
|
|
|
|
[BDAPLGIN]
- Add macro to enable/disable debug output
- Query the BaseFilter for the target control pin in order to query for IKsObject interface, which is used to retrieve the real pin handle.
- Pass the NodeId to constructors of IBDA_FrequencyFilter, IBDA_SignalStatistics, IBDA_LNBInfo, IBDA_DigitalDemodulator
- Implement IBDA_DigitalDemodulator::put_ModulationType, IBDA_DigitalDemodulator::put_InnerFECMethod, IBDADigitalDemodulator::put_InnerFECRate, IBDADigitalDemodulator::put_OuterFECMethod, IBDADigitalDemodulator::put_OuterFECRate, IBDADigitalDemodulator::put_SymbolRate, IBDADigitalDemodulator::put_SpectralInversion
- Implement IBDAFrequencyFilter::put_Frequency, IBDAFrequencyFilter::put_Polarity, IBDAFrequencyFilter::put_Range, IBDAFrequencyFilter::put_Bandwidth, IBDAFrequencyFilter::put_FrequencyMultiplier
- Implement IBDALNBInfo::put_LocalOscilatorFrequencyLowBand, IBDALNBInfo::put_LocalOscilatorFrequencyHighBand, IBDALNBInfo::put_HighLowSwitchFrequency
- Implement IBDASignalStatistics::get_SignalStrength, IBDASignalStatistics::get_SignalQuality, IBDASignalStatistics::get_SignalPresent, IBDASignalStatistics::get_SignalLocked, IBDASignalStatistics::put_SampleTime, IBDASignalStatistics::get_SampleTime
- Implement IBDA_DeviceControl::StartChanges, IBDA_DeviceControl::CheckChanges, IBDA_DeviceControl::CommitChanges, IBDA_DeviceControl::GetChangeState
- IBDA_DeviceControl interface now works with SageDvbRecorder(Windows XP SP3)
svn path=/trunk/; revision=45684
2010-02-26 01:53:48 +00:00
|
|
|
#ifdef BDAPLGIN_TRACE
|
2010-03-01 15:28:28 +00:00
|
|
|
WCHAR Buffer[100];
|
|
|
|
swprintf(Buffer, L"CBDAPinControl::GetPinID: hr %lx pulPinID %lu BytesReturned %lx\n", hr, *pulPinID, BytesReturned);
|
|
|
|
OutputDebugStringW(Buffer);
|
[BDAPLGIN]
- Add macro to enable/disable debug output
- Query the BaseFilter for the target control pin in order to query for IKsObject interface, which is used to retrieve the real pin handle.
- Pass the NodeId to constructors of IBDA_FrequencyFilter, IBDA_SignalStatistics, IBDA_LNBInfo, IBDA_DigitalDemodulator
- Implement IBDA_DigitalDemodulator::put_ModulationType, IBDA_DigitalDemodulator::put_InnerFECMethod, IBDADigitalDemodulator::put_InnerFECRate, IBDADigitalDemodulator::put_OuterFECMethod, IBDADigitalDemodulator::put_OuterFECRate, IBDADigitalDemodulator::put_SymbolRate, IBDADigitalDemodulator::put_SpectralInversion
- Implement IBDAFrequencyFilter::put_Frequency, IBDAFrequencyFilter::put_Polarity, IBDAFrequencyFilter::put_Range, IBDAFrequencyFilter::put_Bandwidth, IBDAFrequencyFilter::put_FrequencyMultiplier
- Implement IBDALNBInfo::put_LocalOscilatorFrequencyLowBand, IBDALNBInfo::put_LocalOscilatorFrequencyHighBand, IBDALNBInfo::put_HighLowSwitchFrequency
- Implement IBDASignalStatistics::get_SignalStrength, IBDASignalStatistics::get_SignalQuality, IBDASignalStatistics::get_SignalPresent, IBDASignalStatistics::get_SignalLocked, IBDASignalStatistics::put_SampleTime, IBDASignalStatistics::get_SampleTime
- Implement IBDA_DeviceControl::StartChanges, IBDA_DeviceControl::CheckChanges, IBDA_DeviceControl::CommitChanges, IBDA_DeviceControl::GetChangeState
- IBDA_DeviceControl interface now works with SageDvbRecorder(Windows XP SP3)
svn path=/trunk/; revision=45684
2010-02-26 01:53:48 +00:00
|
|
|
#endif
|
|
|
|
|
2010-03-01 15:28:28 +00:00
|
|
|
return hr;
|
2010-02-23 17:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CBDAPinControl::GetPinType(ULONG *pulPinType)
|
|
|
|
{
|
2010-03-01 15:28:28 +00:00
|
|
|
KSPROPERTY Property;
|
|
|
|
ULONG BytesReturned;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
// setup request
|
|
|
|
Property.Set = KSPROPSETID_BdaPinControl;
|
|
|
|
Property.Id = KSPROPERTY_BDA_PIN_TYPE;
|
|
|
|
Property.Flags = KSPROPERTY_TYPE_GET;
|
|
|
|
|
|
|
|
// perform request
|
|
|
|
hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), pulPinType, sizeof(ULONG), &BytesReturned);
|
|
|
|
|
[BDAPLGIN]
- Add macro to enable/disable debug output
- Query the BaseFilter for the target control pin in order to query for IKsObject interface, which is used to retrieve the real pin handle.
- Pass the NodeId to constructors of IBDA_FrequencyFilter, IBDA_SignalStatistics, IBDA_LNBInfo, IBDA_DigitalDemodulator
- Implement IBDA_DigitalDemodulator::put_ModulationType, IBDA_DigitalDemodulator::put_InnerFECMethod, IBDADigitalDemodulator::put_InnerFECRate, IBDADigitalDemodulator::put_OuterFECMethod, IBDADigitalDemodulator::put_OuterFECRate, IBDADigitalDemodulator::put_SymbolRate, IBDADigitalDemodulator::put_SpectralInversion
- Implement IBDAFrequencyFilter::put_Frequency, IBDAFrequencyFilter::put_Polarity, IBDAFrequencyFilter::put_Range, IBDAFrequencyFilter::put_Bandwidth, IBDAFrequencyFilter::put_FrequencyMultiplier
- Implement IBDALNBInfo::put_LocalOscilatorFrequencyLowBand, IBDALNBInfo::put_LocalOscilatorFrequencyHighBand, IBDALNBInfo::put_HighLowSwitchFrequency
- Implement IBDASignalStatistics::get_SignalStrength, IBDASignalStatistics::get_SignalQuality, IBDASignalStatistics::get_SignalPresent, IBDASignalStatistics::get_SignalLocked, IBDASignalStatistics::put_SampleTime, IBDASignalStatistics::get_SampleTime
- Implement IBDA_DeviceControl::StartChanges, IBDA_DeviceControl::CheckChanges, IBDA_DeviceControl::CommitChanges, IBDA_DeviceControl::GetChangeState
- IBDA_DeviceControl interface now works with SageDvbRecorder(Windows XP SP3)
svn path=/trunk/; revision=45684
2010-02-26 01:53:48 +00:00
|
|
|
#ifdef BDAPLGIN_TRACE
|
2010-03-01 15:28:28 +00:00
|
|
|
WCHAR Buffer[100];
|
|
|
|
swprintf(Buffer, L"CBDAPinControl::GetPinType: hr %lx pulPinType %lu BytesReturned %lx\n", hr, *pulPinType, BytesReturned);
|
|
|
|
OutputDebugStringW(Buffer);
|
[BDAPLGIN]
- Add macro to enable/disable debug output
- Query the BaseFilter for the target control pin in order to query for IKsObject interface, which is used to retrieve the real pin handle.
- Pass the NodeId to constructors of IBDA_FrequencyFilter, IBDA_SignalStatistics, IBDA_LNBInfo, IBDA_DigitalDemodulator
- Implement IBDA_DigitalDemodulator::put_ModulationType, IBDA_DigitalDemodulator::put_InnerFECMethod, IBDADigitalDemodulator::put_InnerFECRate, IBDADigitalDemodulator::put_OuterFECMethod, IBDADigitalDemodulator::put_OuterFECRate, IBDADigitalDemodulator::put_SymbolRate, IBDADigitalDemodulator::put_SpectralInversion
- Implement IBDAFrequencyFilter::put_Frequency, IBDAFrequencyFilter::put_Polarity, IBDAFrequencyFilter::put_Range, IBDAFrequencyFilter::put_Bandwidth, IBDAFrequencyFilter::put_FrequencyMultiplier
- Implement IBDALNBInfo::put_LocalOscilatorFrequencyLowBand, IBDALNBInfo::put_LocalOscilatorFrequencyHighBand, IBDALNBInfo::put_HighLowSwitchFrequency
- Implement IBDASignalStatistics::get_SignalStrength, IBDASignalStatistics::get_SignalQuality, IBDASignalStatistics::get_SignalPresent, IBDASignalStatistics::get_SignalLocked, IBDASignalStatistics::put_SampleTime, IBDASignalStatistics::get_SampleTime
- Implement IBDA_DeviceControl::StartChanges, IBDA_DeviceControl::CheckChanges, IBDA_DeviceControl::CommitChanges, IBDA_DeviceControl::GetChangeState
- IBDA_DeviceControl interface now works with SageDvbRecorder(Windows XP SP3)
svn path=/trunk/; revision=45684
2010-02-26 01:53:48 +00:00
|
|
|
#endif
|
|
|
|
|
2010-03-01 15:28:28 +00:00
|
|
|
return hr;
|
2010-02-23 17:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
STDMETHODCALLTYPE
|
|
|
|
CBDAPinControl::RegistrationContext(ULONG *pulRegistrationCtx)
|
|
|
|
{
|
[BDAPLGIN]
- Add macro to enable/disable debug output
- Query the BaseFilter for the target control pin in order to query for IKsObject interface, which is used to retrieve the real pin handle.
- Pass the NodeId to constructors of IBDA_FrequencyFilter, IBDA_SignalStatistics, IBDA_LNBInfo, IBDA_DigitalDemodulator
- Implement IBDA_DigitalDemodulator::put_ModulationType, IBDA_DigitalDemodulator::put_InnerFECMethod, IBDADigitalDemodulator::put_InnerFECRate, IBDADigitalDemodulator::put_OuterFECMethod, IBDADigitalDemodulator::put_OuterFECRate, IBDADigitalDemodulator::put_SymbolRate, IBDADigitalDemodulator::put_SpectralInversion
- Implement IBDAFrequencyFilter::put_Frequency, IBDAFrequencyFilter::put_Polarity, IBDAFrequencyFilter::put_Range, IBDAFrequencyFilter::put_Bandwidth, IBDAFrequencyFilter::put_FrequencyMultiplier
- Implement IBDALNBInfo::put_LocalOscilatorFrequencyLowBand, IBDALNBInfo::put_LocalOscilatorFrequencyHighBand, IBDALNBInfo::put_HighLowSwitchFrequency
- Implement IBDASignalStatistics::get_SignalStrength, IBDASignalStatistics::get_SignalQuality, IBDASignalStatistics::get_SignalPresent, IBDASignalStatistics::get_SignalLocked, IBDASignalStatistics::put_SampleTime, IBDASignalStatistics::get_SampleTime
- Implement IBDA_DeviceControl::StartChanges, IBDA_DeviceControl::CheckChanges, IBDA_DeviceControl::CommitChanges, IBDA_DeviceControl::GetChangeState
- IBDA_DeviceControl interface now works with SageDvbRecorder(Windows XP SP3)
svn path=/trunk/; revision=45684
2010-02-26 01:53:48 +00:00
|
|
|
#ifdef BDAPLGIN_TRACE
|
2010-03-24 16:04:44 +00:00
|
|
|
OutputDebugStringW(L"CBDAPinControl::RegistrationContext\n");
|
[BDAPLGIN]
- Add macro to enable/disable debug output
- Query the BaseFilter for the target control pin in order to query for IKsObject interface, which is used to retrieve the real pin handle.
- Pass the NodeId to constructors of IBDA_FrequencyFilter, IBDA_SignalStatistics, IBDA_LNBInfo, IBDA_DigitalDemodulator
- Implement IBDA_DigitalDemodulator::put_ModulationType, IBDA_DigitalDemodulator::put_InnerFECMethod, IBDADigitalDemodulator::put_InnerFECRate, IBDADigitalDemodulator::put_OuterFECMethod, IBDADigitalDemodulator::put_OuterFECRate, IBDADigitalDemodulator::put_SymbolRate, IBDADigitalDemodulator::put_SpectralInversion
- Implement IBDAFrequencyFilter::put_Frequency, IBDAFrequencyFilter::put_Polarity, IBDAFrequencyFilter::put_Range, IBDAFrequencyFilter::put_Bandwidth, IBDAFrequencyFilter::put_FrequencyMultiplier
- Implement IBDALNBInfo::put_LocalOscilatorFrequencyLowBand, IBDALNBInfo::put_LocalOscilatorFrequencyHighBand, IBDALNBInfo::put_HighLowSwitchFrequency
- Implement IBDASignalStatistics::get_SignalStrength, IBDASignalStatistics::get_SignalQuality, IBDASignalStatistics::get_SignalPresent, IBDASignalStatistics::get_SignalLocked, IBDASignalStatistics::put_SampleTime, IBDASignalStatistics::get_SampleTime
- Implement IBDA_DeviceControl::StartChanges, IBDA_DeviceControl::CheckChanges, IBDA_DeviceControl::CommitChanges, IBDA_DeviceControl::GetChangeState
- IBDA_DeviceControl interface now works with SageDvbRecorder(Windows XP SP3)
svn path=/trunk/; revision=45684
2010-02-26 01:53:48 +00:00
|
|
|
#endif
|
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
if (!pulRegistrationCtx)
|
|
|
|
{
|
|
|
|
// invalid argument
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_RegistrationCtx)
|
|
|
|
{
|
|
|
|
// is registered
|
|
|
|
*pulRegistrationCtx = m_RegistrationCtx;
|
|
|
|
return NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
//pin not registered
|
|
|
|
return E_FAIL;
|
2010-02-23 17:40:34 +00:00
|
|
|
}
|
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
//-------------------------------------------------------------------
|
2010-02-23 17:40:34 +00:00
|
|
|
HRESULT
|
2010-03-24 16:04:44 +00:00
|
|
|
GetNetworkProviderFromGraph(
|
|
|
|
IFilterGraph * pGraph,
|
|
|
|
IBDA_NetworkProvider ** pOutNetworkProvider)
|
|
|
|
{
|
|
|
|
IEnumFilters *pEnumFilters = NULL;
|
|
|
|
IBaseFilter * ppFilter[1];
|
|
|
|
IBDA_NetworkProvider * pNetworkProvider = NULL;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
// get IEnumFilters interface
|
|
|
|
hr = pGraph->EnumFilters(&pEnumFilters);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
//clean up
|
|
|
|
*pOutNetworkProvider = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(pEnumFilters->Next(1, ppFilter, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
// check if that filter supports the IBDA_NetworkProvider interface
|
|
|
|
hr = ppFilter[0]->QueryInterface(IID_IBDA_NetworkProvider, (void**)&pNetworkProvider);
|
|
|
|
|
|
|
|
// release IBaseFilter
|
|
|
|
ppFilter[0]->Release();
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// release IEnumFilters interface
|
|
|
|
pEnumFilters->Release();
|
|
|
|
|
|
|
|
//store result
|
|
|
|
*pOutNetworkProvider = pNetworkProvider;
|
|
|
|
|
|
|
|
if (pNetworkProvider)
|
|
|
|
return S_OK;
|
|
|
|
else
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
CBDAPinControl_RealConstructor(
|
|
|
|
HANDLE hPin,
|
|
|
|
IBDA_NetworkProvider *pNetworkProvider,
|
|
|
|
IPin * pConnectedPin,
|
|
|
|
ULONG RegistrationCtx,
|
2010-02-23 17:40:34 +00:00
|
|
|
IUnknown * pUnkOuter,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppv)
|
|
|
|
{
|
2010-03-24 16:04:44 +00:00
|
|
|
CBDAPinControl * handler = new CBDAPinControl(hPin, pNetworkProvider, pConnectedPin, RegistrationCtx);
|
2010-03-01 15:28:28 +00:00
|
|
|
|
|
|
|
#ifdef BDAPLGIN_TRACE
|
2010-03-24 16:04:44 +00:00
|
|
|
OutputDebugStringW(L"CBDAPinControl_fnConstructor\n");
|
2010-03-01 15:28:28 +00:00
|
|
|
#endif
|
2010-03-24 16:04:44 +00:00
|
|
|
|
|
|
|
if (!handler)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(handler->QueryInterface(riid, ppv)))
|
|
|
|
{
|
|
|
|
/* not supported */
|
|
|
|
delete handler;
|
|
|
|
return E_NOINTERFACE;
|
2010-03-01 15:28:28 +00:00
|
|
|
}
|
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
return NOERROR;
|
|
|
|
}
|
2010-03-01 15:28:28 +00:00
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
HRESULT
|
|
|
|
WINAPI
|
|
|
|
CBDAPinControl_fnConstructor(
|
|
|
|
IUnknown * pUnkOuter,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID * ppv)
|
|
|
|
{
|
|
|
|
IPin * pConnectedPin = NULL;
|
|
|
|
IBDA_NetworkProvider * pNetworkProvider = NULL;
|
|
|
|
HANDLE hFile = INVALID_HANDLE_VALUE;
|
2010-02-25 16:14:54 +00:00
|
|
|
HRESULT hr;
|
|
|
|
IKsObject * pObject = NULL;
|
2010-03-01 15:28:28 +00:00
|
|
|
IPin * pPin = NULL;
|
2010-03-24 16:04:44 +00:00
|
|
|
IUnknown * pUnknown = NULL;
|
2010-02-25 16:14:54 +00:00
|
|
|
PIN_INFO PinInfo;
|
|
|
|
FILTER_INFO FilterInfo;
|
2010-03-24 16:04:44 +00:00
|
|
|
ULONG RegistrationCtx = 0;
|
2010-02-25 16:14:54 +00:00
|
|
|
|
|
|
|
if (!pUnkOuter)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2010-03-26 11:43:52 +00:00
|
|
|
OutputDebugStringW(L"CBDAPinControl_fnConstructor\n");
|
|
|
|
//DebugBreak();
|
|
|
|
|
2010-02-25 16:14:54 +00:00
|
|
|
// query for IKsObject interface
|
|
|
|
hr = pUnkOuter->QueryInterface(IID_IKsObject, (void**)&pObject);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
// query for IPin interface
|
|
|
|
hr = pObject->QueryInterface(IID_IPin, (void**)&pPin);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
//clean up
|
|
|
|
pObject->Release();
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get pin info
|
|
|
|
hr = pPin->QueryPinInfo(&PinInfo);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
//clean up
|
|
|
|
pObject->Release();
|
|
|
|
pPin->Release();
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
if (!PinInfo.pFilter)
|
|
|
|
{
|
|
|
|
//clean up
|
|
|
|
pObject->Release();
|
|
|
|
pPin->Release();
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-02-25 16:14:54 +00:00
|
|
|
// sanity checks
|
|
|
|
assert(PinInfo.pFilter != NULL);
|
|
|
|
|
|
|
|
// query filter info
|
|
|
|
hr = PinInfo.pFilter->QueryFilterInfo(&FilterInfo);
|
|
|
|
|
|
|
|
// sanity check
|
|
|
|
assert(FilterInfo.pGraph != NULL);
|
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
// get network provider interface
|
|
|
|
hr = GetNetworkProviderFromGraph(FilterInfo.pGraph, &pNetworkProvider);
|
2010-02-25 16:14:54 +00:00
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
if (SUCCEEDED(hr))
|
2010-02-25 16:14:54 +00:00
|
|
|
{
|
2010-03-24 16:04:44 +00:00
|
|
|
if (PinInfo.dir == PINDIR_OUTPUT)
|
|
|
|
{
|
|
|
|
// get connected pin handle
|
|
|
|
hr = pPin->ConnectedTo(&pConnectedPin);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
// get file handle
|
|
|
|
hFile = pObject->KsGetObjectHandle();
|
|
|
|
if (hFile)
|
|
|
|
{
|
|
|
|
hr = CBDAPinControl_RealConstructor(hFile, pNetworkProvider, pConnectedPin, 0, pUnkOuter, riid, ppv);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
// set to null to prevent releasing
|
|
|
|
pNetworkProvider = NULL;
|
|
|
|
pConnectedPin = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// expected file handle
|
|
|
|
hr = E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// get IUnknown from base filter
|
|
|
|
hr = PinInfo.pFilter->QueryInterface(IID_IUnknown, (void**)&pUnknown);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
// register device filter
|
2010-04-15 11:08:19 +00:00
|
|
|
OutputDebugStringW(L"CBDAPinControl_fnConstructor registering device filter with network provider\n");
|
2010-03-24 16:04:44 +00:00
|
|
|
hr = pNetworkProvider->RegisterDeviceFilter(pUnknown, &RegistrationCtx);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
// get file handle
|
|
|
|
hFile = pObject->KsGetObjectHandle();
|
|
|
|
if (hFile)
|
|
|
|
{
|
|
|
|
hr = CBDAPinControl_RealConstructor(hFile, pNetworkProvider, NULL, RegistrationCtx, pUnkOuter, riid, ppv);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
// set to null to prevent releasing
|
|
|
|
pNetworkProvider = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// expected file handle
|
|
|
|
hr = E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
}
|
2010-03-26 11:43:52 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
WCHAR Buffer[100];
|
|
|
|
swprintf(Buffer, L"CBDAPinControl_fnConstructor failed to register filter with %lx\n", hr);
|
|
|
|
OutputDebugStringW(Buffer);
|
|
|
|
}
|
2010-03-24 16:04:44 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-25 16:14:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// release IFilterGraph interface
|
|
|
|
FilterInfo.pGraph->Release();
|
|
|
|
|
|
|
|
// release IBaseFilter interface
|
|
|
|
PinInfo.pFilter->Release();
|
|
|
|
|
|
|
|
// release IPin
|
|
|
|
pPin->Release();
|
|
|
|
|
|
|
|
// release IKsObject
|
|
|
|
pObject->Release();
|
|
|
|
|
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
if (pNetworkProvider)
|
2010-02-25 16:14:54 +00:00
|
|
|
{
|
2010-03-24 16:04:44 +00:00
|
|
|
// release network provider
|
|
|
|
pNetworkProvider->Release();
|
2010-02-25 16:14:54 +00:00
|
|
|
}
|
2010-02-23 17:40:34 +00:00
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
if (pConnectedPin)
|
|
|
|
{
|
|
|
|
// release connected pin
|
|
|
|
pConnectedPin->Release();
|
|
|
|
}
|
2010-02-23 17:40:34 +00:00
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
if (pUnknown)
|
2010-02-23 17:40:34 +00:00
|
|
|
{
|
2010-03-24 16:04:44 +00:00
|
|
|
// release filter
|
|
|
|
pUnknown->Release();
|
2010-02-23 17:40:34 +00:00
|
|
|
}
|
|
|
|
|
2010-03-24 16:04:44 +00:00
|
|
|
return hr;
|
2010-02-25 16:14:54 +00:00
|
|
|
}
|