[ros-diffs] [janderwald] 45759: [KSPROXY] - Implement IPersistPropertyBag interface - Implement IKsObject interface - Implement enumerating supported property/method/event set from driver and loading the corresponding ksproxy plugins

janderwald at svn.reactos.org janderwald at svn.reactos.org
Tue Mar 2 17:27:50 CET 2010


Author: janderwald
Date: Tue Mar  2 17:27:50 2010
New Revision: 45759

URL: http://svn.reactos.org/svn/reactos?rev=45759&view=rev
Log:
[KSPROXY]
- Implement IPersistPropertyBag interface
- Implement IKsObject interface
- Implement enumerating supported property/method/event set from driver and loading the corresponding ksproxy plugins

Modified:
    trunk/reactos/dll/directx/ksproxy/basicaudio.cpp
    trunk/reactos/dll/directx/ksproxy/clockforward.cpp
    trunk/reactos/dll/directx/ksproxy/cvpconfig.cpp
    trunk/reactos/dll/directx/ksproxy/cvpvbiconfig.cpp
    trunk/reactos/dll/directx/ksproxy/datatype.cpp
    trunk/reactos/dll/directx/ksproxy/interface.cpp
    trunk/reactos/dll/directx/ksproxy/ksproxy.rbuild
    trunk/reactos/dll/directx/ksproxy/precomp.h
    trunk/reactos/dll/directx/ksproxy/proxy.cpp
    trunk/reactos/dll/directx/ksproxy/qualityforward.cpp

Modified: trunk/reactos/dll/directx/ksproxy/basicaudio.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ksproxy/basicaudio.cpp?rev=45759&r1=45758&r2=45759&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ksproxy/basicaudio.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ksproxy/basicaudio.cpp [iso-8859-1] Tue Mar  2 17:27:50 2010
@@ -8,8 +8,6 @@
  */
 #include "precomp.h"
 
-const GUID IID_IBasicAudio = {0x56a868b3, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
-
 class CKsBasicAudio : public IBasicAudio,
                       public IDistributorNotify
 {
@@ -99,7 +97,7 @@
 STDMETHODCALLTYPE
 CKsBasicAudio::Stop()
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -107,7 +105,7 @@
 STDMETHODCALLTYPE
 CKsBasicAudio::Pause()
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -116,7 +114,7 @@
 CKsBasicAudio::Run(
     REFERENCE_TIME tStart)
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -125,7 +123,7 @@
 CKsBasicAudio::SetSyncSource(
     IReferenceClock *pClock)
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -133,7 +131,7 @@
 STDMETHODCALLTYPE
 CKsBasicAudio::NotifyGraphChange()
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -146,7 +144,7 @@
 CKsBasicAudio::GetTypeInfoCount(
     UINT *pctinfo)
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -157,7 +155,7 @@
     LCID lcid,
     ITypeInfo **ppTInfo)
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -170,7 +168,7 @@
     LCID lcid,
     DISPID *rgDispId)
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -186,7 +184,7 @@
     EXCEPINFO *pExcepInfo,
     UINT *puArgErr)
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -199,7 +197,7 @@
 CKsBasicAudio::put_Volume(
     long lVolume)
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -209,7 +207,7 @@
 CKsBasicAudio::get_Volume(
     long *plVolume)
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -219,7 +217,7 @@
 CKsBasicAudio::put_Balance(
     long lBalance)
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -229,7 +227,7 @@
 CKsBasicAudio::get_Balance(
     long *plBalance)
 {
-    OutputDebugString("UNIMPLEMENTED\n");
+    OutputDebugStringW(L"UNIMPLEMENTED\n");
     return E_NOTIMPL;
 }
 
@@ -240,6 +238,8 @@
     REFIID riid,
     LPVOID * ppv)
 {
+    OutputDebugStringW(L"CKsBasicAudio_Constructor\n");
+
     CKsBasicAudio * handler = new CKsBasicAudio();
 
     if (!handler)

Modified: trunk/reactos/dll/directx/ksproxy/clockforward.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ksproxy/clockforward.cpp?rev=45759&r1=45758&r2=45759&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ksproxy/clockforward.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ksproxy/clockforward.cpp [iso-8859-1] Tue Mar  2 17:27:50 2010
@@ -8,7 +8,6 @@
  */
 #include "precomp.h"
 
-const GUID IID_IDistributorNotify = {0x56a868af, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
 const GUID KSCATEGORY_CLOCK       = {0x53172480, 0x4791, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
 
 class CKsClockForwarder : public IDistributorNotify,
@@ -158,6 +157,8 @@
     HRESULT hr;
     HANDLE handle;
 
+    OutputDebugStringW(L"CKsClockForwarder_Constructor\n");
+
     // open default clock
     hr = KsOpenDefaultDevice(KSCATEGORY_CLOCK, GENERIC_READ | GENERIC_WRITE, &handle);
 

Modified: trunk/reactos/dll/directx/ksproxy/cvpconfig.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ksproxy/cvpconfig.cpp?rev=45759&r1=45758&r2=45759&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ksproxy/cvpconfig.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ksproxy/cvpconfig.cpp [iso-8859-1] Tue Mar  2 17:27:50 2010
@@ -7,8 +7,6 @@
  * PROGRAMMERS:     Johannes Anderwald (janderwald at reactos.org)
  */
 #include "precomp.h"
-
-const GUID IID_IVPConfig = {0xbc29a660, 0x30e3, 0x11d0, {0x9e, 0x69, 0x0, 0xc0, 0x4f, 0xd7, 0xc1, 0x5b}};
 
 class CVPConfig : public IVPConfig,
                   public IDistributorNotify
@@ -302,6 +300,8 @@
     REFIID riid,
     LPVOID * ppv)
 {
+    OutputDebugStringW(L"CVPConfig_Constructor\n");
+
     CVPConfig * handler = new CVPConfig();
 
     if (!handler)

Modified: trunk/reactos/dll/directx/ksproxy/cvpvbiconfig.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ksproxy/cvpvbiconfig.cpp?rev=45759&r1=45758&r2=45759&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ksproxy/cvpvbiconfig.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ksproxy/cvpvbiconfig.cpp [iso-8859-1] Tue Mar  2 17:27:50 2010
@@ -7,8 +7,6 @@
  * PROGRAMMERS:     Johannes Anderwald (janderwald at reactos.org)
  */
 #include "precomp.h"
-
-const GUID IID_IVPVBIConfig = {0xec529b00, 0x1a1f, 0x11d1, {0xba, 0xd9, 0x0, 0x60, 0x97, 0x44, 0x11, 0x1a}};
 
 class CVPVBIConfig : public IVPVBIConfig,
                      public IDistributorNotify
@@ -274,6 +272,8 @@
     REFIID riid,
     LPVOID * ppv)
 {
+    OutputDebugStringW(L"CVPVBIConfig_Constructor\n");
+
     CVPVBIConfig * handler = new CVPVBIConfig();
 
     if (!handler)

Modified: trunk/reactos/dll/directx/ksproxy/datatype.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ksproxy/datatype.cpp?rev=45759&r1=45758&r2=45759&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ksproxy/datatype.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ksproxy/datatype.cpp [iso-8859-1] Tue Mar  2 17:27:50 2010
@@ -11,9 +11,6 @@
 /* FIXME guid mess */
 const GUID IID_IUnknown           = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
 const GUID IID_IClassFactory      = {0x00000001, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
-const GUID IID_IKsDataTypeHandler = {0x5FFBAA02, 0x49A3, 0x11D0, {0x9F, 0x36, 0x00, 0xAA, 0x00, 0xA2, 0x16, 0xA1}};
-const GUID MEDIATYPE_Audio        = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-
 
 class CKsDataTypeHandler : public IKsDataTypeHandler
 {
@@ -138,6 +135,8 @@
     REFIID riid,
     LPVOID * ppv)
 {
+    OutputDebugStringW(L"CKsDataTypeHandler_Constructor\n");
+
     CKsDataTypeHandler * handler = new CKsDataTypeHandler();
 
     if (!handler)

Modified: trunk/reactos/dll/directx/ksproxy/interface.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ksproxy/interface.cpp?rev=45759&r1=45758&r2=45759&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ksproxy/interface.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ksproxy/interface.cpp [iso-8859-1] Tue Mar  2 17:27:50 2010
@@ -8,7 +8,6 @@
  */
 #include "precomp.h"
 
-const GUID IID_IKsInterfaceHandler = {0xD3ABC7E0, 0x9A61, 0x11D0, {0xA4, 0x0D, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
 const GUID IID_IKsObject           = {0x423c13a2, 0x2070, 0x11d0, {0x9e, 0xf7, 0x00, 0xaa, 0x00, 0xa2, 0x16, 0xa1}};
 
 class CKsInterfaceHandler : public IKsInterfaceHandler
@@ -119,6 +118,8 @@
     REFIID riid,
     LPVOID * ppv)
 {
+    OutputDebugStringW(L"CKsInterfaceHandler_Constructor\n");
+
     CKsInterfaceHandler * handler = new CKsInterfaceHandler();
 
     if (!handler)

Modified: trunk/reactos/dll/directx/ksproxy/ksproxy.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ksproxy/ksproxy.rbuild?rev=45759&r1=45758&r2=45759&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ksproxy/ksproxy.rbuild [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ksproxy/ksproxy.rbuild [iso-8859-1] Tue Mar  2 17:27:50 2010
@@ -10,7 +10,7 @@
 	<library>ole32</library>
 	<library>setupapi</library>
 	<library>msvcrt</library>
-
+	<library>strmiids</library>
 	<group compilerset="gcc">
 		<compilerflag compiler="cxx">-fno-exceptions</compilerflag>
 		<compilerflag compiler="cxx">-fno-rtti</compilerflag>

Modified: trunk/reactos/dll/directx/ksproxy/precomp.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ksproxy/precomp.h?rev=45759&r1=45758&r2=45759&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ksproxy/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ksproxy/precomp.h [iso-8859-1] Tue Mar  2 17:27:50 2010
@@ -1,5 +1,6 @@
 #pragma once
 
+#define _FORCENAMELESSUNION
 #define BUILDING_KS
 #define _KSDDK_
 #include <dshow.h>
@@ -14,8 +15,8 @@
 #include <dvp.h>
 #include <vptype.h>
 #include <vpconfig.h>
-
 #include <setupapi.h>
+#include <vector>
 //#include <debug.h>
 
 typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);

Modified: trunk/reactos/dll/directx/ksproxy/proxy.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ksproxy/proxy.cpp?rev=45759&r1=45758&r2=45759&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ksproxy/proxy.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ksproxy/proxy.cpp [iso-8859-1] Tue Mar  2 17:27:50 2010
@@ -8,15 +8,20 @@
  */
 #include "precomp.h"
 
+const GUID IID_IPersistPropertyBag = {0x37D84F60, 0x42CB, 0x11CE, {0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51}};
+const GUID GUID_NULL                     = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
+
 /*
     Needs IKsClock, IKsNotifyEvent
 */
 
 class CKsProxy : public IBaseFilter,
                  public IAMovieSetup,
+                 public IPersistPropertyBag,
+                 public IKsObject
+/*
                  public IPersistStream,
                  public ISpecifyPropertyPages,
-                 public IPersistPropertyBag,
                  public IReferenceClock,
                  public IMediaSeeking,
                  public IKsObject,
@@ -27,12 +32,490 @@
                  public IKsTopology,
                  public IKsAggregateControl,
                  public IAMDeviceRemoval
-{
-
-
+*/
+{
+public:
+    typedef std::vector<IUnknown *>ProxyPluginVector;
+
+    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;
+    }
+
+    // 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);
+
+    // IPersistPropertyBag methods
+    HRESULT STDMETHODCALLTYPE InitNew( void);
+    HRESULT STDMETHODCALLTYPE Load(IPropertyBag *pPropBag, IErrorLog *pErrorLog);
+    HRESULT STDMETHODCALLTYPE Save(IPropertyBag *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties);
+
+    // IKsObject
+    HANDLE STDMETHODCALLTYPE KsGetObjectHandle();
+
+    CKsProxy() : m_Ref(0), m_pGraph(0), m_ReferenceClock(0), m_FilterState(State_Stopped), m_hDevice(0), m_Plugins(0) {};
+    virtual ~CKsProxy()
+    {
+        if (m_hDevice)
+            CloseHandle(m_hDevice);
+    };
+
+    HRESULT STDMETHODCALLTYPE GetSupportedSets(LPGUID * pOutGuid, PULONG NumGuids);
+    HRESULT STDMETHODCALLTYPE LoadProxyPlugins(LPGUID pGuids, ULONG NumGuids);
+
+protected:
+    LONG m_Ref;
+    IFilterGraph *m_pGraph;
+    IReferenceClock * m_ReferenceClock;
+    FILTER_STATE m_FilterState;
+    HANDLE m_hDevice;
+    ProxyPluginVector m_Plugins;
 };
 
-
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::QueryInterface(
+    IN  REFIID refiid,
+    OUT PVOID* Output)
+{
+    *Output = NULL;
+
+    if (IsEqualGUID(refiid, IID_IUnknown) ||
+        IsEqualGUID(refiid, IID_IBaseFilter))
+    {
+        *Output = PVOID(this);
+        reinterpret_cast<IUnknown*>(*Output)->AddRef();
+        return NOERROR;
+    }
+    else if (IsEqualGUID(refiid, IID_IPersistPropertyBag))
+    {
+        *Output = (IPersistPropertyBag*)(this);
+        reinterpret_cast<IPersistPropertyBag*>(*Output)->AddRef();
+        return NOERROR;
+    }
+    if (IsEqualGUID(refiid, IID_IKsObject))
+    {
+        *Output = (IKsObject*)(this);
+        reinterpret_cast<IKsObject*>(*Output)->AddRef();
+        return NOERROR;
+    }
+
+    WCHAR Buffer[MAX_PATH];
+    LPOLESTR lpstr;
+    StringFromCLSID(refiid, &lpstr);
+    swprintf(Buffer, L"CKsProxy::QueryInterface: NoInterface for %s !!!\n", lpstr);
+    OutputDebugStringW(Buffer);
+    CoTaskMemFree(lpstr);
+
+
+    return E_NOINTERFACE;
+}
+
+//-------------------------------------------------------------------
+// IKsObject interface
+//
+
+HANDLE
+STDMETHODCALLTYPE
+CKsProxy::KsGetObjectHandle()
+{
+    return m_hDevice;
+}
+
+//-------------------------------------------------------------------
+// IPersistPropertyBag interface
+//
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::InitNew( void)
+{
+    return S_OK;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::GetSupportedSets(
+    LPGUID * pOutGuid,
+    PULONG NumGuids)
+{
+    KSPROPERTY Property;
+    LPGUID pGuid;
+    ULONG NumProperty = 0;
+    ULONG NumMethods = 0;
+    ULONG NumEvents = 0;
+    ULONG Length;
+    ULONG BytesReturned;
+    HRESULT hr;
+
+    Property.Set = GUID_NULL;
+    Property.Id = 0;
+    Property.Flags = KSPROPERTY_TYPE_SETSUPPORT;
+
+    KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), NULL, 0, &NumProperty);
+    KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_METHOD, (PVOID)&Property, sizeof(KSPROPERTY), NULL, 0, &NumMethods);
+    KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_ENABLE_EVENT, (PVOID)&Property, sizeof(KSPROPERTY), NULL, 0, &NumEvents);
+
+    Length = NumProperty + NumMethods + NumEvents;
+
+    // allocate guid buffer
+    pGuid = (LPGUID)CoTaskMemAlloc(Length);
+    if (!pGuid)
+    {
+        // failed
+        return E_OUTOFMEMORY;
+    }
+
+    NumProperty /= sizeof(GUID);
+    NumMethods /= sizeof(GUID);
+    NumEvents /= sizeof(GUID);
+
+    // get all properties
+    hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)pGuid, Length, &BytesReturned);
+    if (FAILED(hr))
+    {
+        CoTaskMemFree(pGuid);
+        return E_FAIL;
+    }
+    Length -= BytesReturned;
+
+    // get all methods
+    if (Length)
+    {
+        hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_METHOD, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&pGuid[NumProperty], Length, &BytesReturned);
+        if (FAILED(hr))
+        {
+            CoTaskMemFree(pGuid);
+            return E_FAIL;
+        }
+        Length -= BytesReturned;
+    }
+
+    // get all events
+    if (Length)
+    {
+        hr = KsSynchronousDeviceControl(m_hDevice, IOCTL_KS_ENABLE_EVENT, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&pGuid[NumProperty+NumMethods], Length, &BytesReturned);
+        if (FAILED(hr))
+        {
+            CoTaskMemFree(pGuid);
+            return E_FAIL;
+        }
+        Length -= BytesReturned;
+    }
+
+#ifdef KSPROXY_TRACE
+    WCHAR Buffer[200];
+    swprintf(Buffer, L"NumProperty %lu NumMethods %lu NumEvents %lu\n", NumProperty, NumMethods, NumEvents);
+    OutputDebugStringW(Buffer);
+#endif
+
+    *pOutGuid = pGuid;
+    *NumGuids = NumProperty+NumEvents+NumMethods;
+    return S_OK;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::LoadProxyPlugins(
+    LPGUID pGuids,
+    ULONG NumGuids)
+{
+    ULONG Index;
+    LPOLESTR pStr;
+    HKEY hKey, hSubKey;
+    HRESULT hr;
+    IUnknown * pUnknown;
+
+    if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\MediaInterfaces", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
+    {
+        OutputDebugStringW(L"CKsProxy::LoadProxyPlugins failed to open MediaInterfaces key\n");
+        return E_FAIL;
+    }
+
+    // enumerate all sets
+    for(Index = 0; Index < NumGuids; Index++)
+    {
+        // convert to string
+        hr = StringFromCLSID(pGuids[Index], &pStr);
+        if (FAILED(hr))
+            return E_FAIL;
+
+        // now try open class key
+        if (RegOpenKeyExW(hKey, pStr, 0, KEY_READ, &hSubKey) != ERROR_SUCCESS)
+        {
+            // no plugin for that set exists
+            CoTaskMemFree(pStr);
+            continue;
+        }
+
+        // try load plugin
+        hr = CoCreateInstance(pGuids[Index], (IBaseFilter*)this, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&pUnknown);
+        if (SUCCEEDED(hr))
+        {
+            // store plugin
+            m_Plugins.push_back(pUnknown);
+        }
+        // close key
+        RegCloseKey(hSubKey);
+    }
+
+    // close media interfaces key
+    RegCloseKey(hKey);
+    return S_OK;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::Load(IPropertyBag *pPropBag, IErrorLog *pErrorLog)
+{
+    HRESULT hr;
+    WCHAR Buffer[100];
+    VARIANT varName;
+    LPGUID pGuid;
+    ULONG NumGuids = 0;
+
+    // read device path
+    varName.vt = VT_BSTR;
+    hr = pPropBag->Read(L"DevicePath", &varName, pErrorLog);
+
+    if (FAILED(hr))
+    {
+        swprintf(Buffer, L"CKsProxy::Load Read %lx\n", hr);
+        OutputDebugStringW(Buffer);
+        return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
+    }
+
+    // open device
+    m_hDevice = CreateFileW(varName.bstrVal, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
+
+    if (m_hDevice == INVALID_HANDLE_VALUE)
+    {
+        // failed to open device
+        swprintf(Buffer, L"CKsProxy:: failed to open device with %lx\n", GetLastError());
+        OutputDebugStringW(Buffer);
+
+        return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
+    }
+
+    // get all supported sets
+    hr = GetSupportedSets(&pGuid, &NumGuids);
+    if (FAILED(hr))
+    {
+        CloseHandle(m_hDevice);
+        m_hDevice = NULL;
+        return hr;
+    }
+
+    // load all proxy plugins
+    hr = LoadProxyPlugins(pGuid, NumGuids);
+
+    CloseHandle(m_hDevice);
+    m_hDevice = NULL;
+
+
+    return hr;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::Save(IPropertyBag *pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
+{
+    return E_NOTIMPL;
+}
+
+//-------------------------------------------------------------------
+// IBaseFilter interface
+//
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::GetClassID(
+    CLSID *pClassID)
+{
+    OutputDebugStringW(L"CKsProxy::GetClassID : NotImplemented\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::Stop()
+{
+    OutputDebugStringW(L"CKsProxy::Stop : NotImplemented\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::Pause()
+{
+    OutputDebugStringW(L"CKsProxy::Pause : NotImplemented\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::Run(
+    REFERENCE_TIME tStart)
+{
+    OutputDebugStringW(L"CKsProxy::Run : NotImplemented\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::GetState(
+    DWORD dwMilliSecsTimeout,
+    FILTER_STATE *State)
+{
+    *State = m_FilterState;
+    return S_OK;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::SetSyncSource(
+    IReferenceClock *pClock)
+{
+    if (pClock)
+    {
+        pClock->AddRef();
+    }
+
+    if (m_ReferenceClock)
+    {
+        m_ReferenceClock->Release();
+    }
+
+    m_ReferenceClock = pClock;
+    return S_OK;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::GetSyncSource(
+    IReferenceClock **pClock)
+{
+    if (!pClock)
+        return E_POINTER;
+
+    if (m_ReferenceClock)
+        m_ReferenceClock->AddRef();
+
+    *pClock = m_ReferenceClock;
+    return S_OK;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::EnumPins(
+    IEnumPins **ppEnum)
+{
+    OutputDebugStringW(L"CKsProxy::EnumPins : NotImplemented\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::FindPin(
+    LPCWSTR Id, IPin **ppPin)
+{
+    OutputDebugStringW(L"CKsProxy::FindPin : NotImplemented\n");
+    return E_NOTIMPL;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::QueryFilterInfo(
+    FILTER_INFO *pInfo)
+{
+    if (!pInfo)
+        return E_POINTER;
+
+    pInfo->achName[0] = L'\0';
+    pInfo->pGraph = m_pGraph;
+
+    return S_OK;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::JoinFilterGraph(
+    IFilterGraph *pGraph,
+    LPCWSTR pName)
+{
+    if (pGraph)
+    {
+        // joining filter graph
+        m_pGraph = pGraph;
+    }
+    else
+    {
+        // leaving graph
+        m_pGraph = 0;
+    }
+
+    OutputDebugStringW(L"CKsProxy::JoinFilterGraph\n");
+    return S_OK;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::QueryVendorInfo(
+    LPWSTR *pVendorInfo)
+{
+    OutputDebugStringW(L"CKsProxy::QueryVendorInfo : NotImplemented\n");
+    return E_NOTIMPL;
+}
+
+//-------------------------------------------------------------------
+// IAMovieSetup interface
+//
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::Register()
+{
+    OutputDebugStringW(L"CKsProxy::Register : NotImplemented\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsProxy::Unregister()
+{
+    OutputDebugStringW(L"CKsProxy::Unregister : NotImplemented\n");
+    return E_NOTIMPL;
+}
 
 HRESULT
 WINAPI
@@ -41,6 +524,23 @@
     REFIID riid,
     LPVOID * ppv)
 {
-    OutputDebugString("CKsProxy_Constructor UNIMPLEMENTED\n");
-    return E_NOTIMPL;
-}
+    WCHAR Buffer[100];
+    LPOLESTR pstr;
+    StringFromCLSID(riid, &pstr);
+    swprintf(Buffer, L"CKsProxy_Constructor pUnkOuter %p riid %s\n", pUnkOuter, pstr);
+    OutputDebugStringW(Buffer);
+
+    CKsProxy * handler = new CKsProxy();
+
+    if (!handler)
+        return E_OUTOFMEMORY;
+
+    if (FAILED(handler->QueryInterface(riid, ppv)))
+    {
+        /* not supported */
+        delete handler;
+        return E_NOINTERFACE;
+    }
+
+    return S_OK;
+}

Modified: trunk/reactos/dll/directx/ksproxy/qualityforward.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ksproxy/qualityforward.cpp?rev=45759&r1=45758&r2=45759&view=diff
==============================================================================
--- trunk/reactos/dll/directx/ksproxy/qualityforward.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ksproxy/qualityforward.cpp [iso-8859-1] Tue Mar  2 17:27:50 2010
@@ -87,8 +87,6 @@
     OutputDebugString("UNIMPLEMENTED\n");
 }
 
-
-
 HRESULT
 WINAPI
 CKsQualityForwarder_Constructor(
@@ -98,6 +96,8 @@
 {
     HRESULT hr;
     HANDLE handle;
+
+    OutputDebugStringW(L"CKsQualityForwarder_Constructor\n");
 
     // open default clock
     hr = KsOpenDefaultDevice(KSCATEGORY_QUALITY, GENERIC_READ | GENERIC_WRITE, &handle);




More information about the Ros-diffs mailing list