[BDAPLGIN]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Wed, 24 Mar 2010 16:04:44 +0000 (16:04 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Wed, 24 Mar 2010 16:04:44 +0000 (16:04 +0000)
- Fix compilation with msvc
- Implement IBDA_PinControl::RegistrationContext
- Register filter with IBDA_NetworkProvider when it is an input pin
- IBDA_PinControl is now working

svn path=/trunk/; revision=46398

reactos/dll/directx/bdaplgin/controlnode.cpp
reactos/dll/directx/bdaplgin/devicecontrol.cpp
reactos/dll/directx/bdaplgin/digitaldemo.cpp
reactos/dll/directx/bdaplgin/frequencyfilter.cpp
reactos/dll/directx/bdaplgin/lnbinfo.cpp
reactos/dll/directx/bdaplgin/pincontrol.cpp
reactos/dll/directx/bdaplgin/precomp.h
reactos/dll/directx/bdaplgin/signalstatistics.cpp

index 5cd98cc..b8b21c7 100644 (file)
@@ -9,7 +9,9 @@
 
 #include "precomp.h"
 
+#ifndef _MSC_VER
 const GUID IID_IKsPropertySet = {0x31efac30, 0x515c, 0x11d0, {0xa9,0xaa, 0x00,0xaa,0x00,0x61,0xbe,0x93}};
+#endif
 
 class CControlNode : public IUnknown
 {
@@ -88,7 +90,6 @@ CControlNode::QueryInterface(
 HRESULT
 WINAPI
 CControlNode_fnConstructor(
-    HANDLE hFile,
     IBaseFilter * pFilter,
     ULONG NodeType,
     ULONG PinId,
@@ -99,6 +100,7 @@ CControlNode_fnConstructor(
     HRESULT hr;
     IPin * pPin = NULL;
     IKsObject * pObject = NULL;
+    HANDLE hFile = INVALID_HANDLE_VALUE;
 
     // store pin id
     swprintf(Buffer, L"%u", PinId);
index 661eba5..693232c 100644 (file)
@@ -9,20 +9,24 @@
 
 #include "precomp.h"
 
-const GUID CLSID_DVBTNetworkProvider = {0x216c62df, 0x6d7f, 0x4e9a, {0x85, 0x71, 0x5, 0xf1, 0x4e, 0xdb, 0x76, 0x6a}};
-const GUID IID_IAC3Filter         = {0xe4539501, 0xc609, 0x46ea, {0xad, 0x2a, 0x0e, 0x97, 0x00, 0x24, 0x56, 0x83}};
-const GUID IID_IAsyncReader       = {0x56A868AA, 0x0AD4, 0x11CE, {0xB0, 0x3A, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70}};
-const GUID IID_IMatrixMixer       = {0xafc57835, 0x2fd1, 0x4541, {0xa6, 0xd9, 0x0d, 0xb7, 0x18, 0x56, 0xe5, 0x89}};
-const GUID IID_IBDA_NetworkProvider   = {0xfd501041, 0x8ebe, 0x11ce, {0x81, 0x83, 0x00, 0xaa, 0x00, 0x57, 0x7d, 0xa2}};
-const GUID IID_IAMOpenProgress    = {0x8E1C39A1, 0xDE53, 0x11cf, {0xAA, 0x63, 0x00, 0x80, 0xC7, 0x44, 0x52, 0x8D}};
-const GUID IID_IDistributorNotify = {0x56a868af, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-const GUID IID_IBDA_DeviceControl = {0xFD0A5AF3, 0xB41D, 0x11d2, {0x9C, 0x95, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}};
-const GUID IID_IBDA_Topology      = {0x79B56888, 0x7FEA, 0x4690, {0xB4, 0x5D, 0x38, 0xFD, 0x3C, 0x78, 0x49, 0xBE}};
 const GUID IID_IKsObject           = {0x423c13a2, 0x2070, 0x11d0, {0x9e, 0xf7, 0x00, 0xaa, 0x00, 0xa2, 0x16, 0xa1}};
+
+#ifndef _MSC_VER
+const GUID CLSID_DVBTNetworkProvider = {0x216c62df, 0x6d7f, 0x4e9a, {0x85, 0x71, 0x5, 0xf1, 0x4e, 0xdb, 0x76, 0x6a}};
+
 const GUID KSPROPSETID_BdaTopology = {0xa14ee835, 0x0a23, 0x11d3, {0x9c, 0xc7, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
 const GUID KSMETHODSETID_BdaDeviceConfiguration = {0x71985f45, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
-const GUID IID_IBaseFilter         = {0x56a86895, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
 const GUID KSMETHODSETID_BdaChangeSync = {0xfd0a5af3, 0xb41d, 0x11d2, {0x9c, 0x95, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
+const GUID IID_IBaseFilter         = {0x56a86895, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
+const GUID IID_IAsyncReader       = {0x56A868AA, 0x0AD4, 0x11CE, {0xB0, 0x3A, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70}};
+const GUID IID_IAMOpenProgress    = {0x8E1C39A1, 0xDE53, 0x11cf, {0xAA, 0x63, 0x00, 0x80, 0xC7, 0x44, 0x52, 0x8D}};
+const GUID IID_IBDA_Topology      = {0x79B56888, 0x7FEA, 0x4690, {0xB4, 0x5D, 0x38, 0xFD, 0x3C, 0x78, 0x49, 0xBE}};
+const GUID IID_IBDA_NetworkProvider   = {0xfd501041, 0x8ebe, 0x11ce, {0x81, 0x83, 0x00, 0xaa, 0x00, 0x57, 0x7d, 0xa2}};
+const GUID IID_IBDA_DeviceControl = {0xFD0A5AF3, 0xB41D, 0x11d2, {0x9C, 0x95, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}};
+
+const GUID IID_IDistributorNotify = {0x56a868af, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
+
+#endif
 
 class CBDADeviceControl : public IBDA_DeviceControl,
                           public IBDA_Topology
@@ -476,7 +480,7 @@ CBDADeviceControl::GetControlNode(ULONG ulInputPinId, ULONG ulOutputPinId, ULONG
     if (FAILED(hr))
         return hr;
 
-    hr = CControlNode_fnConstructor(m_Handle, m_pFilter, ulNodeType, PinId, IID_IUnknown, (LPVOID*)ppControlNode);
+    hr = CControlNode_fnConstructor(m_pFilter, ulNodeType, PinId, IID_IUnknown, (LPVOID*)ppControlNode);
 
 #ifdef BDAPLGIN_TRACE
     swprintf(Buffer, L"CBDADeviceControl::GetControlNode: hr %lx\n", hr);
index 2d1b7ed..d93a313 100644 (file)
@@ -9,8 +9,10 @@
 
 #include "precomp.h"
 
+#ifndef _MSC_VER
 const GUID IID_IBDA_DigitalDemodulator = {0xef30f379, 0x985b, 0x4d10, {0xb6, 0x40, 0xa7, 0x9d, 0x5e, 0x04, 0xe1, 0xe0}};
 const GUID KSPROPSETID_BdaDigitalDemodulator = {0xef30f379, 0x985b, 0x4d10, {0xb6, 0x40, 0xa7, 0x9d, 0x5e, 0x4, 0xe1, 0xe0}};
+#endif
 
 class CBDADigitalDemodulator : public IBDA_DigitalDemodulator
 {
index 90d1e6a..712fda0 100644 (file)
@@ -9,8 +9,10 @@
 
 #include "precomp.h"
 
+#ifndef _MSC_VER
 const GUID IID_IBDA_FrequencyFilter = {0x71985f47, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x00, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
 const GUID KSPROPSETID_BdaFrequencyFilter = {0x71985f47, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
+#endif
 
 class CBDAFrequencyFilter : public IBDA_FrequencyFilter
 {
index a663883..a3c175f 100644 (file)
@@ -9,8 +9,10 @@
 
 #include "precomp.h"
 
+#ifndef _MSC_VER
 const GUID IID_IBDA_LNBInfo = {0x992cf102, 0x49f9, 0x4719, {0xa6, 0x64,  0xc4, 0xf2, 0x3e, 0x24, 0x08, 0xf4}};
 const GUID KSPROPSETID_BdaLNBInfo = {0x992cf102, 0x49f9, 0x4719, {0xa6, 0x64, 0xc4, 0xf2, 0x3e, 0x24, 0x8, 0xf4}};
+#endif
 
 class CBDALNBInfo : public IBDA_LNBInfo
 {
index a5b9912..b4dc49b 100644 (file)
@@ -9,9 +9,12 @@
 
 #include "precomp.h"
 
-const GUID IID_IBDA_PinControl       = {0x0DED49D5, 0xA8B7, 0x4d5d, {0x97, 0xA1, 0x12, 0xB0, 0xC1, 0x95, 0x87, 0x4D}};
+#ifndef _MSC_VER
 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}};
+#endif
+
 
 class CBDAPinControl : public IBDA_PinControl
 {
@@ -39,7 +42,7 @@ public:
     HRESULT STDMETHODCALLTYPE RegistrationContext(ULONG *pulRegistrationCtx);
 
 
-    CBDAPinControl(HANDLE hFile, IBDA_NetworkProvider * pProvider, IPin * pConnectedPin) : m_Ref(0), m_Handle(hFile), m_pProvider(pProvider), m_pConnectedPin(pConnectedPin){};
+    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){};
     virtual ~CBDAPinControl()
     {
         //m_pConnectedPin->Release();
@@ -51,6 +54,7 @@ protected:
     HANDLE m_Handle;
     IBDA_NetworkProvider * m_pProvider;
     IPin * m_pConnectedPin;
+    ULONG m_RegistrationCtx;
 };
 
 HRESULT
@@ -73,15 +77,6 @@ CBDAPinControl::QueryInterface(
         return NOERROR;
     }
 
-#ifdef BDAPLGIN_TRACE
-    WCHAR Buffer[MAX_PATH];
-    LPOLESTR lpstr;
-    StringFromCLSID(refiid, &lpstr);
-    swprintf(Buffer, L"CBDAPinControl::QueryInterface: NoInterface for %s", lpstr);
-    OutputDebugStringW(Buffer);
-    CoTaskMemFree(lpstr);
-#endif
-
     return E_NOINTERFACE;
 }
 //-------------------------------------------------------------------
@@ -142,42 +137,117 @@ STDMETHODCALLTYPE
 CBDAPinControl::RegistrationContext(ULONG *pulRegistrationCtx)
 {
 #ifdef BDAPLGIN_TRACE
-    OutputDebugStringW(L"CBDAPinControl::RegistrationContext: NotImplemented\n");
+    OutputDebugStringW(L"CBDAPinControl::RegistrationContext\n");
 #endif
 
-    return E_NOTIMPL;
+    if (!pulRegistrationCtx)
+    {
+        // invalid argument
+        return E_POINTER;
+    }
+
+    if (m_RegistrationCtx)
+    {
+        // is registered
+        *pulRegistrationCtx = m_RegistrationCtx;
+        return NOERROR;
+    }
+
+    //pin not registered
+    return E_FAIL;
 }
 
+//-------------------------------------------------------------------
 HRESULT
-WINAPI
-CBDAPinControl_fnConstructor(
+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,
     IUnknown * pUnkOuter,
     REFIID riid,
     LPVOID * ppv)
 {
-    IPin * pConnectedPin = NULL;
-    IBDA_NetworkProvider * pNetworkProvider = NULL;
-    HANDLE hFile = INVALID_HANDLE_VALUE;
+    CBDAPinControl * handler = new CBDAPinControl(hPin, pNetworkProvider, pConnectedPin, RegistrationCtx);
 
-#if 0
-    if (!IsEqualGUID(riid, IID_IUnknown))
-    {
 #ifdef BDAPLGIN_TRACE
-    OutputDebugStringW(L"CBDAPinControl_fnConstructor: Expected IUnknown\n");
+    OutputDebugStringW(L"CBDAPinControl_fnConstructor\n");
 #endif
-        return REGDB_E_CLASSNOTREG;
+
+    if (!handler)
+        return E_OUTOFMEMORY;
+
+    if (FAILED(handler->QueryInterface(riid, ppv)))
+    {
+        /* not supported */
+        delete handler;
+        return E_NOINTERFACE;
     }
 
+    return NOERROR;
+}
 
+HRESULT
+WINAPI
+CBDAPinControl_fnConstructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv)
+{
+    IPin * pConnectedPin = NULL;
+    IBDA_NetworkProvider * pNetworkProvider = NULL;
+    HANDLE hFile = INVALID_HANDLE_VALUE;
     HRESULT hr;
     IKsObject * pObject = NULL;
     IPin * pPin = NULL;
-    IEnumFilters *pEnumFilters = NULL;
-
-    IBaseFilter * ppFilter[1];
+    IUnknown * pUnknown = NULL;
     PIN_INFO PinInfo;
     FILTER_INFO FilterInfo;
-
+    ULONG RegistrationCtx = 0;
 
     if (!pUnkOuter)
         return E_POINTER;
@@ -209,8 +279,15 @@ CBDAPinControl_fnConstructor(
        return hr;
     }
 
+    if (!PinInfo.pFilter)
+    {
+        //clean up
+       pObject->Release();
+       pPin->Release();
+       return hr;
+    }
+
     // sanity checks
-    assert(PinInfo.dir == PINDIR_OUTPUT);
     assert(PinInfo.pFilter != NULL);
 
     // query filter info
@@ -219,57 +296,73 @@ CBDAPinControl_fnConstructor(
     // sanity check
     assert(FilterInfo.pGraph != NULL);
 
-    // get IEnumFilters interface
-    hr = FilterInfo.pGraph->EnumFilters(&pEnumFilters);
+    // get network provider interface
+    hr = GetNetworkProviderFromGraph(FilterInfo.pGraph, &pNetworkProvider);
 
-    if (FAILED(hr))
+    if (SUCCEEDED(hr))
     {
-        //clean up
-       FilterInfo.pGraph->Release();
-       PinInfo.pFilter->Release();
-       pObject->Release();
-       pPin->Release();
-       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;
+        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
+                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;
+                    }
+                }
+            }
+        }
     }
 
-    // release IEnumFilters interface
-    pEnumFilters->Release();
-
     // release IFilterGraph interface
     FilterInfo.pGraph->Release();
 
     // release IBaseFilter interface
     PinInfo.pFilter->Release();
 
-    if (pNetworkProvider)
-    {
-        // get connected pin handle
-        hr = pPin->ConnectedTo(&pConnectedPin);
-
-        // get file handle
-        hFile = pObject->KsGetObjectHandle();
-
-        if (FAILED(hr) || hFile == INVALID_HANDLE_VALUE)
-        {
-            // pin not connected
-            pNetworkProvider->Release();
-            // set zero
-            pNetworkProvider = NULL;
-        }
-    }
-
     // release IPin 
     pPin->Release();
 
@@ -277,30 +370,23 @@ CBDAPinControl_fnConstructor(
     pObject->Release();
 
 
-    if (pNetworkProvider == NULL)
+    if (pNetworkProvider)
     {
-        // no network provider interface in graph
-        return E_NOINTERFACE;
+        // release network provider
+        pNetworkProvider->Release();
     }
-#endif
-
-    CBDAPinControl * handler = new CBDAPinControl(hFile, pNetworkProvider, pConnectedPin);
 
-#ifdef BDAPLGIN_TRACE
-    OutputDebugStringW(L"CBDAPinControl_fnConstructor");
-#endif
-
-    DebugBreak();
-
-    if (!handler)
-        return E_OUTOFMEMORY;
+    if (pConnectedPin)
+    {
+        // release connected pin
+        pConnectedPin->Release();
+    }
 
-    if (FAILED(handler->QueryInterface(riid, ppv)))
+    if (pUnknown)
     {
-        /* not supported */
-        delete handler;
-        return E_NOINTERFACE;
+        // release filter
+        pUnknown->Release();
     }
 
-    return NOERROR;
+    return hr;
 }
index 771a798..34c11ba 100644 (file)
@@ -9,6 +9,7 @@
 #include <ks.h>
 #define __STREAMS__
 #include <ksproxy.h>
+#include <ksmedia.h>
 #include <stdio.h>
 #include <wchar.h>
 #include <tchar.h>
@@ -55,7 +56,6 @@ CBDAPinControl_fnConstructor(
 HRESULT
 WINAPI
 CControlNode_fnConstructor(
-    HANDLE hFile,
     IBaseFilter * pFilter,
     ULONG NodeType,
     ULONG PinId,
@@ -101,4 +101,6 @@ CBDADigitalDemodulator_fnConstructor(
     REFIID riid,
     LPVOID * ppv);
 
+extern const GUID IID_IKsObject;
+
 #endif
index ae6079e..8c4aa3d 100644 (file)
@@ -9,8 +9,10 @@
 
 #include "precomp.h"
 
+#ifndef _MSC_VER
 const GUID IID_IBDA_SignalStatistics = {0x1347d106, 0xcf3a, 0x428a, {0xa5, 0xcb, 0xac, 0x0d, 0x9a, 0x2a, 0x43, 0x38}};
 const GUID KSPROPSETID_BdaSignalStats = {0x1347d106, 0xcf3a, 0x428a, {0xa5, 0xcb, 0xac, 0xd, 0x9a, 0x2a, 0x43, 0x38}};
+#endif
 
 class CBDASignalStatistics : public IBDA_SignalStatistics
 {