[KSPROXY]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Thu, 18 Feb 2010 15:24:29 +0000 (15:24 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Thu, 18 Feb 2010 15:24:29 +0000 (15:24 +0000)
- Stub interfaces for CBasicAudio, CKsClockForwarder, CVPConfig, CVPVBIConfig, CKsDataTypeHandler, CKsInterfaceHandler, CKsProxy, CKsQualityForwarder
- Implement KsSynchronousDeviceControl, KsOpenDefaultDevice, KsGetMultiplePinFactoryItems, KsGetMediaTypeCount, DllGetClassObject

svn path=/trunk/; revision=45608

13 files changed:
reactos/dll/directx/ksproxy/basicaudio.cpp [new file with mode: 0644]
reactos/dll/directx/ksproxy/classfactory.cpp [new file with mode: 0644]
reactos/dll/directx/ksproxy/clockforward.cpp [new file with mode: 0644]
reactos/dll/directx/ksproxy/cvpconfig.cpp [new file with mode: 0644]
reactos/dll/directx/ksproxy/cvpvbiconfig.cpp [new file with mode: 0644]
reactos/dll/directx/ksproxy/datatype.cpp [new file with mode: 0644]
reactos/dll/directx/ksproxy/interface.cpp [new file with mode: 0644]
reactos/dll/directx/ksproxy/ksproxy.c [deleted file]
reactos/dll/directx/ksproxy/ksproxy.cpp [new file with mode: 0644]
reactos/dll/directx/ksproxy/ksproxy.rbuild
reactos/dll/directx/ksproxy/precomp.h [new file with mode: 0644]
reactos/dll/directx/ksproxy/proxy.cpp [new file with mode: 0644]
reactos/dll/directx/ksproxy/qualityforward.cpp [new file with mode: 0644]

diff --git a/reactos/dll/directx/ksproxy/basicaudio.cpp b/reactos/dll/directx/ksproxy/basicaudio.cpp
new file mode 100644 (file)
index 0000000..f0a872c
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS WDM Streaming ActiveMovie Proxy
+ * FILE:            dll/directx/ksproxy/cvpvbiconfig.cpp
+ * PURPOSE:         CVPVBIConfig interface
+ *
+ * PROGRAMMERS:     Johannes Anderwald (janderwald@reactos.org)
+ */
+#include "precomp.h"
+
+const GUID IID_IBasicAudio = {0x56a868b3, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
+
+class CKsBasicAudio : public IBasicAudio,
+                      public IDistributorNotify
+{
+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;
+    }
+
+    // IDistributorNotify methods
+    HRESULT STDMETHODCALLTYPE Stop();
+    HRESULT STDMETHODCALLTYPE Pause();
+    HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart);
+    HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock);
+    HRESULT STDMETHODCALLTYPE NotifyGraphChange();
+
+    // IDispatch methods
+    HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo);
+    HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
+    HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
+    HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
+
+
+    // IBasicAudio methods
+    HRESULT STDMETHODCALLTYPE put_Volume(long lVolume);
+    HRESULT STDMETHODCALLTYPE get_Volume(long *plVolume);
+    HRESULT STDMETHODCALLTYPE put_Balance(long lBalance);
+    HRESULT STDMETHODCALLTYPE get_Balance(long *plBalance);
+
+
+    CKsBasicAudio() : m_Ref(0){}
+    virtual ~CKsBasicAudio(){}
+
+protected:
+    LONG m_Ref;
+};
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::QueryInterface(
+    IN  REFIID refiid,
+    OUT PVOID* Output)
+{
+    if (IsEqualGUID(refiid, IID_IUnknown))
+    {
+        *Output = PVOID(this);
+        reinterpret_cast<IUnknown*>(*Output)->AddRef();
+        return NOERROR;
+    }
+    if (IsEqualGUID(refiid, IID_IDistributorNotify))
+    {
+        *Output = (IDistributorNotify*)(this);
+        reinterpret_cast<IDistributorNotify*>(*Output)->AddRef();
+        return NOERROR;
+    }
+
+    if (IsEqualGUID(refiid, IID_IBasicAudio))
+    {
+        *Output = (IBasicAudio*)(this);
+        reinterpret_cast<IBasicAudio*>(*Output)->AddRef();
+        return NOERROR;
+    }
+
+    return E_NOINTERFACE;
+}
+
+//-------------------------------------------------------------------
+// IDistributorNotify interface
+//
+
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::Stop()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::Pause()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::Run(
+    REFERENCE_TIME tStart)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::SetSyncSource(
+    IReferenceClock *pClock)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::NotifyGraphChange()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+//-------------------------------------------------------------------
+// IDispatch interface
+//
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::GetTypeInfoCount(
+    UINT *pctinfo)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::GetTypeInfo(
+    UINT iTInfo,
+    LCID lcid,
+    ITypeInfo **ppTInfo)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::GetIDsOfNames(
+    REFIID riid,
+    LPOLESTR *rgszNames,
+    UINT cNames,
+    LCID lcid,
+    DISPID *rgDispId)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::Invoke(
+    DISPID dispIdMember,
+    REFIID riid,
+    LCID lcid,
+    WORD wFlags,
+    DISPPARAMS *pDispParams,
+    VARIANT *pVarResult,
+    EXCEPINFO *pExcepInfo,
+    UINT *puArgErr)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+//-------------------------------------------------------------------
+// IBasicAudio interface
+//
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::put_Volume(
+    long lVolume)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::get_Volume(
+    long *plVolume)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::put_Balance(
+    long lBalance)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CKsBasicAudio::get_Balance(
+    long *plBalance)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+WINAPI
+CKsBasicAudio_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv)
+{
+    CKsBasicAudio * handler = new CKsBasicAudio();
+
+    if (!handler)
+        return E_OUTOFMEMORY;
+
+    if (FAILED(handler->QueryInterface(riid, ppv)))
+    {
+        /* not supported */
+        delete handler;
+        return E_NOINTERFACE;
+    }
+
+    return NOERROR;
+}
diff --git a/reactos/dll/directx/ksproxy/classfactory.cpp b/reactos/dll/directx/ksproxy/classfactory.cpp
new file mode 100644 (file)
index 0000000..98dacc6
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS WDM Streaming ActiveMovie Proxy
+ * FILE:            dll/directx/ksproxy/classfactory.cpp
+ * PURPOSE:         ClassFactory interface
+ *
+ * PROGRAMMERS:     Johannes Anderwald (janderwald@reactos.org)
+ */
+#include "precomp.h"
+
+class CClassFactory : public IClassFactory
+{
+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;
+    }
+
+    HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObject);
+    HRESULT WINAPI LockServer(BOOL fLock);
+
+    CClassFactory(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst) : m_Ref(1), m_lpfnCI(lpfnCI), m_IID(riidInst)
+    {};
+
+    virtual ~CClassFactory(){};
+
+protected:
+    LONG m_Ref;
+    LPFNCREATEINSTANCE m_lpfnCI;
+    IID * m_IID;
+};
+
+HRESULT
+WINAPI
+CClassFactory::QueryInterface(
+    REFIID riid,
+    LPVOID *ppvObj)
+{
+    *ppvObj = NULL;
+    if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
+    {
+        *ppvObj = PVOID(this);
+        InterlockedIncrement(&m_Ref);
+        return S_OK;
+    }
+    return E_NOINTERFACE;
+}
+
+HRESULT
+WINAPI
+CClassFactory::CreateInstance(
+    LPUNKNOWN pUnkOuter,
+    REFIID riid,
+    LPVOID *ppvObject)
+{
+    *ppvObject = NULL;
+
+    if ( m_IID == NULL || IsEqualCLSID(riid, *m_IID) || IsEqualCLSID(riid, IID_IUnknown))
+    {
+        return m_lpfnCI(pUnkOuter, riid, ppvObject);
+    }
+
+    return E_NOINTERFACE;
+}
+
+HRESULT
+WINAPI
+CClassFactory::LockServer(
+    BOOL fLock)
+{
+    return E_NOTIMPL;
+}
+
+IClassFactory * 
+CClassFactory_fnConstructor(
+    LPFNCREATEINSTANCE lpfnCI, 
+    PLONG pcRefDll, 
+    IID * riidInst)
+{
+    CClassFactory* factory = new CClassFactory(lpfnCI, pcRefDll, riidInst);
+
+    if (!factory)
+        return NULL;
+
+    if (pcRefDll)
+        InterlockedIncrement(pcRefDll);
+
+    return (LPCLASSFACTORY)factory;
+}
diff --git a/reactos/dll/directx/ksproxy/clockforward.cpp b/reactos/dll/directx/ksproxy/clockforward.cpp
new file mode 100644 (file)
index 0000000..a588938
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS WDM Streaming ActiveMovie Proxy
+ * FILE:            dll/directx/ksproxy/clockforward.cpp
+ * PURPOSE:         IKsClockForwarder interface
+ *
+ * PROGRAMMERS:     Johannes Anderwald (janderwald@reactos.org)
+ */
+#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,
+                          public IKsObject
+{
+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;
+    }
+
+    // IDistributorNotify interface
+    HRESULT STDMETHODCALLTYPE Stop();
+    HRESULT STDMETHODCALLTYPE Pause();
+    HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart);
+    HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock);
+    HRESULT STDMETHODCALLTYPE NotifyGraphChange();
+
+    // IKsObject interface
+    HANDLE STDMETHODCALLTYPE KsGetObjectHandle();
+
+    CKsClockForwarder(HANDLE handle) : m_Ref(0), m_Handle(handle){}
+    virtual ~CKsClockForwarder(){ if (m_Handle) CloseHandle(m_Handle);}
+
+protected:
+    LONG m_Ref;
+    HANDLE m_Handle;
+};
+
+HRESULT
+STDMETHODCALLTYPE
+CKsClockForwarder::QueryInterface(
+    IN  REFIID refiid,
+    OUT PVOID* Output)
+{
+    if (IsEqualGUID(refiid, IID_IUnknown))
+    {
+        *Output = PVOID(this);
+        reinterpret_cast<IUnknown*>(*Output)->AddRef();
+        return NOERROR;
+    }
+    if (IsEqualGUID(refiid, IID_IKsObject))
+    {
+        *Output = (IKsObject*)(this);
+        reinterpret_cast<IKsObject*>(*Output)->AddRef();
+        return NOERROR;
+    }
+
+    if (IsEqualGUID(refiid, IID_IDistributorNotify))
+    {
+        *Output = (IDistributorNotify*)(this);
+        reinterpret_cast<IDistributorNotify*>(*Output)->AddRef();
+        return NOERROR;
+    }
+
+#if 0
+    if (IsEqualGUID(refiid, IID_IKsClockForwarder))
+    {
+        *Output = PVOID(this);
+        reinterpret_cast<IKsObject*>(*Output)->AddRef();
+        return NOERROR;
+    }
+#endif
+
+    return E_NOINTERFACE;
+}
+
+//-------------------------------------------------------------------
+// IDistributorNotify interface
+//
+
+
+HRESULT
+STDMETHODCALLTYPE
+CKsClockForwarder::Stop()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsClockForwarder::Pause()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsClockForwarder::Run(
+    REFERENCE_TIME tStart)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsClockForwarder::SetSyncSource(
+    IReferenceClock *pClock)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsClockForwarder::NotifyGraphChange()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+//-------------------------------------------------------------------
+// IKsObject interface
+//
+
+HANDLE
+STDMETHODCALLTYPE
+CKsClockForwarder::KsGetObjectHandle()
+{
+    return m_Handle;
+}
+
+HRESULT
+WINAPI
+CKsClockForwarder_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv)
+{
+    HRESULT hr;
+    HANDLE handle;
+
+    // open default clock
+    hr = KsOpenDefaultDevice(KSCATEGORY_CLOCK, GENERIC_READ | GENERIC_WRITE, &handle);
+
+    if (hr != NOERROR)
+    {
+         OutputDebugString("CKsClockForwarder_Constructor failed to open device\n");
+         return hr;
+    }
+
+    CKsClockForwarder * clock = new CKsClockForwarder(handle);
+
+    if (!clock)
+    {
+        // free clock handle
+        CloseHandle(handle);
+        return E_OUTOFMEMORY;
+    }
+
+    if (FAILED(clock->QueryInterface(riid, ppv)))
+    {
+        /* not supported */
+        delete clock;
+        return E_NOINTERFACE;
+    }
+
+    return NOERROR;
+}
diff --git a/reactos/dll/directx/ksproxy/cvpconfig.cpp b/reactos/dll/directx/ksproxy/cvpconfig.cpp
new file mode 100644 (file)
index 0000000..ffe4fc7
--- /dev/null
@@ -0,0 +1,319 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS WDM Streaming ActiveMovie Proxy
+ * FILE:            dll/directx/ksproxy/cvpconfig.cpp
+ * PURPOSE:         IVPConfig interface
+ *
+ * PROGRAMMERS:     Johannes Anderwald (janderwald@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
+{
+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;
+    }
+
+    // IDistributorNotify interface
+    HRESULT STDMETHODCALLTYPE Stop();
+    HRESULT STDMETHODCALLTYPE Pause();
+    HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart);
+    HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock);
+    HRESULT STDMETHODCALLTYPE NotifyGraphChange();
+
+    // IVPBaseConfig
+    HRESULT STDMETHODCALLTYPE GetConnectInfo(LPDWORD pdwNumConnectInfo, IN OUT LPDDVIDEOPORTCONNECT pddVPConnectInfo);
+    HRESULT STDMETHODCALLTYPE SetConnectInfo(DWORD dwChosenEntry);
+    HRESULT STDMETHODCALLTYPE GetVPDataInfo(LPAMVPDATAINFO pamvpDataInfo);
+    HRESULT STDMETHODCALLTYPE GetMaxPixelRate(LPAMVPSIZE pamvpSize, OUT LPDWORD pdwMaxPixelsPerSecond);
+    HRESULT STDMETHODCALLTYPE InformVPInputFormats(DWORD dwNumFormats, IN LPDDPIXELFORMAT pDDPixelFormats);
+    HRESULT STDMETHODCALLTYPE GetVideoFormats(LPDWORD pdwNumFormats, IN OUT LPDDPIXELFORMAT pddPixelFormats);
+    HRESULT STDMETHODCALLTYPE SetVideoFormat(DWORD dwChosenEntry);
+    HRESULT STDMETHODCALLTYPE SetInvertPolarity();
+    HRESULT STDMETHODCALLTYPE GetOverlaySurface(LPDIRECTDRAWSURFACE* ppddOverlaySurface);
+    HRESULT STDMETHODCALLTYPE SetDirectDrawKernelHandle(ULONG_PTR dwDDKernelHandle);
+    HRESULT STDMETHODCALLTYPE SetVideoPortID(IN DWORD dwVideoPortID);
+    HRESULT STDMETHODCALLTYPE SetDDSurfaceKernelHandles(DWORD cHandles, IN ULONG_PTR *rgDDKernelHandles);
+    HRESULT STDMETHODCALLTYPE SetSurfaceParameters(DWORD dwPitch, IN DWORD dwXOrigin, IN DWORD dwYOrigin);
+    // IVPConfig
+    HRESULT STDMETHODCALLTYPE IsVPDecimationAllowed(LPBOOL pbIsDecimationAllowed);
+    HRESULT STDMETHODCALLTYPE SetScalingFactors(LPAMVPSIZE pamvpSize);
+
+    CVPConfig() : m_Ref(0){}
+    virtual ~CVPConfig(){}
+
+protected:
+    LONG m_Ref;
+};
+
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::QueryInterface(
+    IN  REFIID refiid,
+    OUT PVOID* Output)
+{
+    if (IsEqualGUID(refiid, IID_IUnknown))
+    {
+        *Output = PVOID(this);
+        reinterpret_cast<IUnknown*>(*Output)->AddRef();
+        return NOERROR;
+    }
+    if (IsEqualGUID(refiid, IID_IDistributorNotify))
+    {
+        *Output = (IDistributorNotify*)(this);
+        reinterpret_cast<IDistributorNotify*>(*Output)->AddRef();
+        return NOERROR;
+    }
+
+    if (IsEqualGUID(refiid, IID_IVPConfig))
+    {
+        *Output = (IVPConfig*)(this);
+        reinterpret_cast<IVPConfig*>(*Output)->AddRef();
+        return NOERROR;
+    }
+
+    return E_NOINTERFACE;
+}
+
+//-------------------------------------------------------------------
+// IDistributorNotify interface
+//
+
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::Stop()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::Pause()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::Run(
+    REFERENCE_TIME tStart)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::SetSyncSource(
+    IReferenceClock *pClock)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::NotifyGraphChange()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+//-------------------------------------------------------------------
+// IVPBaseConfig
+//
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::GetConnectInfo(
+    LPDWORD pdwNumConnectInfo, 
+    IN OUT LPDDVIDEOPORTCONNECT pddVPConnectInfo)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::SetConnectInfo(
+    DWORD dwChosenEntry)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::GetVPDataInfo(
+    LPAMVPDATAINFO pamvpDataInfo)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::GetMaxPixelRate(
+    LPAMVPSIZE pamvpSize,
+    OUT LPDWORD pdwMaxPixelsPerSecond)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::InformVPInputFormats(
+    DWORD dwNumFormats,
+    IN LPDDPIXELFORMAT pDDPixelFormats)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::GetVideoFormats(
+    LPDWORD pdwNumFormats, 
+    IN OUT LPDDPIXELFORMAT pddPixelFormats)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::SetVideoFormat(
+    DWORD dwChosenEntry)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::SetInvertPolarity()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::GetOverlaySurface(
+    LPDIRECTDRAWSURFACE* ppddOverlaySurface)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::SetDirectDrawKernelHandle(
+    ULONG_PTR dwDDKernelHandle)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::SetVideoPortID(
+    IN DWORD dwVideoPortID)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::SetDDSurfaceKernelHandles(
+    DWORD cHandles,
+    IN ULONG_PTR *rgDDKernelHandles)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::SetSurfaceParameters(
+    DWORD dwPitch,
+    IN DWORD dwXOrigin,
+    IN DWORD dwYOrigin)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+//-------------------------------------------------------------------
+// IVPConfig
+//
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::IsVPDecimationAllowed(
+    LPBOOL pbIsDecimationAllowed)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPConfig::SetScalingFactors(
+    LPAMVPSIZE pamvpSize)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+
+
+
+HRESULT
+WINAPI
+CVPConfig_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv)
+{
+    CVPConfig * handler = new CVPConfig();
+
+    if (!handler)
+        return E_OUTOFMEMORY;
+
+    if (FAILED(handler->QueryInterface(riid, ppv)))
+    {
+        /* not supported */
+        delete handler;
+        return E_NOINTERFACE;
+    }
+
+    return NOERROR;
+}
+
diff --git a/reactos/dll/directx/ksproxy/cvpvbiconfig.cpp b/reactos/dll/directx/ksproxy/cvpvbiconfig.cpp
new file mode 100644 (file)
index 0000000..061d332
--- /dev/null
@@ -0,0 +1,290 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS WDM Streaming ActiveMovie Proxy
+ * FILE:            dll/directx/ksproxy/cvpvbiconfig.cpp
+ * PURPOSE:         CVPVBIConfig interface
+ *
+ * PROGRAMMERS:     Johannes Anderwald (janderwald@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
+{
+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;
+    }
+
+    // IDistributorNotify interface
+    HRESULT STDMETHODCALLTYPE Stop();
+    HRESULT STDMETHODCALLTYPE Pause();
+    HRESULT STDMETHODCALLTYPE Run(REFERENCE_TIME tStart);
+    HRESULT STDMETHODCALLTYPE SetSyncSource(IReferenceClock *pClock);
+    HRESULT STDMETHODCALLTYPE NotifyGraphChange();
+
+    // IVPBaseConfig
+    HRESULT STDMETHODCALLTYPE GetConnectInfo(LPDWORD pdwNumConnectInfo, IN OUT LPDDVIDEOPORTCONNECT pddVPConnectInfo);
+    HRESULT STDMETHODCALLTYPE SetConnectInfo(DWORD dwChosenEntry);
+    HRESULT STDMETHODCALLTYPE GetVPDataInfo(LPAMVPDATAINFO pamvpDataInfo);
+    HRESULT STDMETHODCALLTYPE GetMaxPixelRate(LPAMVPSIZE pamvpSize, OUT LPDWORD pdwMaxPixelsPerSecond);
+    HRESULT STDMETHODCALLTYPE InformVPInputFormats(DWORD dwNumFormats, IN LPDDPIXELFORMAT pDDPixelFormats);
+    HRESULT STDMETHODCALLTYPE GetVideoFormats(LPDWORD pdwNumFormats, IN OUT LPDDPIXELFORMAT pddPixelFormats);
+    HRESULT STDMETHODCALLTYPE SetVideoFormat(DWORD dwChosenEntry);
+    HRESULT STDMETHODCALLTYPE SetInvertPolarity();
+    HRESULT STDMETHODCALLTYPE GetOverlaySurface(LPDIRECTDRAWSURFACE* ppddOverlaySurface);
+    HRESULT STDMETHODCALLTYPE SetDirectDrawKernelHandle(ULONG_PTR dwDDKernelHandle);
+    HRESULT STDMETHODCALLTYPE SetVideoPortID(IN DWORD dwVideoPortID);
+    HRESULT STDMETHODCALLTYPE SetDDSurfaceKernelHandles(DWORD cHandles, IN ULONG_PTR *rgDDKernelHandles);
+    HRESULT STDMETHODCALLTYPE SetSurfaceParameters(DWORD dwPitch, IN DWORD dwXOrigin, IN DWORD dwYOrigin);
+
+    CVPVBIConfig() : m_Ref(0){}
+    virtual ~CVPVBIConfig(){}
+
+protected:
+    LONG m_Ref;
+};
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::QueryInterface(
+    IN  REFIID refiid,
+    OUT PVOID* Output)
+{
+    if (IsEqualGUID(refiid, IID_IUnknown))
+    {
+        *Output = PVOID(this);
+        reinterpret_cast<IUnknown*>(*Output)->AddRef();
+        return NOERROR;
+    }
+    if (IsEqualGUID(refiid, IID_IDistributorNotify))
+    {
+        *Output = (IDistributorNotify*)(this);
+        reinterpret_cast<IDistributorNotify*>(*Output)->AddRef();
+        return NOERROR;
+    }
+
+    if (IsEqualGUID(refiid, IID_IVPVBIConfig))
+    {
+        *Output = (IVPConfig*)(this);
+        reinterpret_cast<IVPConfig*>(*Output)->AddRef();
+        return NOERROR;
+    }
+
+    return E_NOINTERFACE;
+}
+
+//-------------------------------------------------------------------
+// IDistributorNotify interface
+//
+
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::Stop()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::Pause()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::Run(
+    REFERENCE_TIME tStart)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::SetSyncSource(
+    IReferenceClock *pClock)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::NotifyGraphChange()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+//-------------------------------------------------------------------
+// IVPBaseConfig
+//
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::GetConnectInfo(
+    LPDWORD pdwNumConnectInfo, 
+    IN OUT LPDDVIDEOPORTCONNECT pddVPConnectInfo)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::SetConnectInfo(
+    DWORD dwChosenEntry)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::GetVPDataInfo(
+    LPAMVPDATAINFO pamvpDataInfo)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::GetMaxPixelRate(
+    LPAMVPSIZE pamvpSize,
+    OUT LPDWORD pdwMaxPixelsPerSecond)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::InformVPInputFormats(
+    DWORD dwNumFormats,
+    IN LPDDPIXELFORMAT pDDPixelFormats)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::GetVideoFormats(
+    LPDWORD pdwNumFormats, 
+    IN OUT LPDDPIXELFORMAT pddPixelFormats)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::SetVideoFormat(
+    DWORD dwChosenEntry)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::SetInvertPolarity()
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::GetOverlaySurface(
+    LPDIRECTDRAWSURFACE* ppddOverlaySurface)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::SetDirectDrawKernelHandle(
+    ULONG_PTR dwDDKernelHandle)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::SetVideoPortID(
+    IN DWORD dwVideoPortID)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::SetDDSurfaceKernelHandles(
+    DWORD cHandles,
+    IN ULONG_PTR *rgDDKernelHandles)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CVPVBIConfig::SetSurfaceParameters(
+    DWORD dwPitch,
+    IN DWORD dwXOrigin,
+    IN DWORD dwYOrigin)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+
+HRESULT
+WINAPI
+CVPVBIConfig_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv)
+{
+    CVPVBIConfig * handler = new CVPVBIConfig();
+
+    if (!handler)
+        return E_OUTOFMEMORY;
+
+    if (FAILED(handler->QueryInterface(riid, ppv)))
+    {
+        /* not supported */
+        delete handler;
+        return E_NOINTERFACE;
+    }
+
+    return NOERROR;
+}
diff --git a/reactos/dll/directx/ksproxy/datatype.cpp b/reactos/dll/directx/ksproxy/datatype.cpp
new file mode 100644 (file)
index 0000000..c946805
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS WDM Streaming ActiveMovie Proxy
+ * FILE:            dll/directx/ksproxy/ksproxy.c
+ * PURPOSE:         IKsDataTypeHandler interface
+ *
+ * PROGRAMMERS:     Johannes Anderwald (janderwald@reactos.org)
+ */
+#include "precomp.h"
+
+/* FIXME guid mess */
+const GUID IID_IUnknown           = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0xC0, 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
+{
+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;
+    }
+
+    HRESULT STDMETHODCALLTYPE KsCompleteIoOperation(IN OUT IMediaSample *Sample, IN OUT PVOID StreamHeader, IN KSIOOPERATION IoOperation, IN BOOL Cancelled);
+    HRESULT STDMETHODCALLTYPE KsIsMediaTypeInRanges(IN PVOID DataRanges);
+    HRESULT STDMETHODCALLTYPE KsPrepareIoOperation(IN OUT IMediaSample *Sample, IN OUT PVOID StreamHeader, IN KSIOOPERATION IoOperation);
+    HRESULT STDMETHODCALLTYPE KsQueryExtendedSize(OUT ULONG* ExtendedSize);
+    HRESULT STDMETHODCALLTYPE KsSetMediaType(IN const AM_MEDIA_TYPE* AmMediaType);
+
+    CKsDataTypeHandler() : m_Ref(0){};
+    virtual ~CKsDataTypeHandler(){};
+
+protected:
+    //CMediaType * m_Type;
+    LONG m_Ref;
+};
+
+
+HRESULT
+STDMETHODCALLTYPE
+CKsDataTypeHandler::QueryInterface(
+    IN  REFIID refiid,
+    OUT PVOID* Output)
+{
+    if (IsEqualGUID(refiid, IID_IUnknown) ||
+        IsEqualGUID(refiid, IID_IKsDataTypeHandler))
+    {
+        *Output = PVOID(this);
+        reinterpret_cast<IUnknown*>(*Output)->AddRef();
+        return NOERROR;
+    }
+    return E_NOINTERFACE;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CKsDataTypeHandler::KsCompleteIoOperation(
+    IN OUT IMediaSample *Sample,
+    IN OUT PVOID StreamHeader,
+    IN KSIOOPERATION IoOperation,
+    IN BOOL Cancelled)
+{
+    return NOERROR;
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CKsDataTypeHandler::KsIsMediaTypeInRanges(
+    IN PVOID DataRanges)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsDataTypeHandler::KsPrepareIoOperation(
+    IN OUT IMediaSample *Sample,
+    IN OUT PVOID StreamHeader,
+    IN KSIOOPERATION IoOperation)
+{
+    return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsDataTypeHandler::KsQueryExtendedSize(
+    OUT ULONG* ExtendedSize)
+{
+    /* no header extension required */
+    *ExtendedSize = 0;
+
+    return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsDataTypeHandler::KsSetMediaType(
+    IN const AM_MEDIA_TYPE* AmMediaType)
+{
+#if 0
+    if (m_Type)
+    {
+        /* media type can only be set once */
+        return E_FAIL;
+    }
+#endif
+
+    /*
+     * TODO: allocate CMediaType and copy parameters
+     */
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+WINAPI
+CKsDataTypeHandler_Constructor (
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv)
+{
+    CKsDataTypeHandler * handler = new CKsDataTypeHandler();
+
+    if (!handler)
+        return E_OUTOFMEMORY;
+
+    if (FAILED(handler->QueryInterface(riid, ppv)))
+    {
+        /* not supported */
+        delete handler;
+        return E_NOINTERFACE;
+    }
+
+    return NOERROR;
+}
diff --git a/reactos/dll/directx/ksproxy/interface.cpp b/reactos/dll/directx/ksproxy/interface.cpp
new file mode 100644 (file)
index 0000000..cd8dc80
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS WDM Streaming ActiveMovie Proxy
+ * FILE:            dll/directx/ksproxy/interface.cpp
+ * PURPOSE:         IKsInterfaceHandler interface
+ *
+ * PROGRAMMERS:     Johannes Anderwald (janderwald@reactos.org)
+ */
+#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
+{
+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;
+    }
+    HRESULT STDMETHODCALLTYPE KsSetPin(IKsPin *KsPin);
+    HRESULT STDMETHODCALLTYPE KsProcessMediaSamples(IKsDataTypeHandler *KsDataTypeHandler, IMediaSample** SampleList, PLONG SampleCount, KSIOOPERATION IoOperation, PKSSTREAM_SEGMENT *StreamSegment);
+    HRESULT STDMETHODCALLTYPE KsCompleteIo(PKSSTREAM_SEGMENT StreamSegment);
+
+    CKsInterfaceHandler() : m_Ref(0), m_Handle(NULL){};
+    virtual ~CKsInterfaceHandler(){};
+
+protected:
+    LONG m_Ref;
+    HANDLE m_Handle;
+};
+
+HRESULT
+STDMETHODCALLTYPE
+CKsInterfaceHandler::QueryInterface(
+    IN  REFIID refiid,
+    OUT PVOID* Output)
+{
+    if (IsEqualGUID(refiid, IID_IUnknown) ||
+        IsEqualGUID(refiid, IID_IKsInterfaceHandler))
+    {
+        *Output = PVOID(this);
+        reinterpret_cast<IUnknown*>(*Output)->AddRef();
+        return NOERROR;
+    }
+    return E_NOINTERFACE;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsInterfaceHandler::KsSetPin(
+    IKsPin *KsPin)
+{
+    HRESULT hr;
+    IKsObject * KsObject;
+
+    // check if IKsObject is supported
+    hr = KsPin->QueryInterface(IID_IKsObject, (void**)&KsObject);
+
+    if (SUCCEEDED(hr))
+    {
+        // get pin handle
+        m_Handle = KsObject->KsGetObjectHandle();
+
+        // release IKsObject interface
+        KsObject->Release();
+
+        if (!m_Handle)
+        {
+            // expected a file handle
+            return E_UNEXPECTED;
+        }
+    }
+
+    // done
+    return hr;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsInterfaceHandler::KsProcessMediaSamples(
+     IKsDataTypeHandler *KsDataTypeHandler,
+     IMediaSample** SampleList,
+     PLONG SampleCount,
+     KSIOOPERATION IoOperation,
+     PKSSTREAM_SEGMENT *StreamSegment)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CKsInterfaceHandler::KsCompleteIo(
+    PKSSTREAM_SEGMENT StreamSegment)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
+
+HRESULT
+WINAPI
+CKsInterfaceHandler_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv)
+{
+    CKsInterfaceHandler * handler = new CKsInterfaceHandler();
+
+    if (!handler)
+        return E_OUTOFMEMORY;
+
+    if (FAILED(handler->QueryInterface(riid, ppv)))
+    {
+        /* not supported */
+        delete handler;
+        return E_NOINTERFACE;
+    }
+
+    return NOERROR;
+}
diff --git a/reactos/dll/directx/ksproxy/ksproxy.c b/reactos/dll/directx/ksproxy/ksproxy.c
deleted file mode 100644 (file)
index bb89957..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * KSPROXY.AX - ReactOS WDM Streaming ActiveMovie Proxy
- *
- * Copyright 2008 Dmitry Chapyshev
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include <windows.h>
-#include <stdio.h>
-#include <wchar.h>
-#include <tchar.h>
-#include <ks.h>
-#include <dshow.h>
-
-HRESULT WINAPI
-KsSynchronousDeviceControl(
-    HANDLE     Handle,
-    ULONG      IoControl,
-    PVOID      InBuffer,
-    ULONG      InLength,
-    PVOID      OutBuffer,
-    ULONG      OutLength,
-    PULONG     BytesReturned)
-{
-    return NOERROR;
-}
-
-HRESULT WINAPI
-KsResolveRequiredAttributes(
-    PKSDATARANGE     DataRange,
-    KSMULTIPLE_ITEM  *Attributes OPTIONAL)
-{
-    return NOERROR;
-}
-
-HRESULT WINAPI
-KsOpenDefaultDevice(
-    REFGUID      Category,
-    ACCESS_MASK  Access,
-    PHANDLE      DeviceHandle)
-{
-    return NOERROR;
-}
-
-HRESULT WINAPI
-KsGetMultiplePinFactoryItems(
-    HANDLE  FilterHandle,
-    ULONG   PinFactoryId,
-    ULONG   PropertyId,
-    PVOID   *Items)
-{
-    return NOERROR;
-}
-
-HRESULT WINAPI
-KsGetMediaTypeCount(
-    HANDLE  FilterHandle,
-    ULONG   PinFactoryId,
-    ULONG   *MediaTypeCount)
-{
-    return NOERROR;
-}
-
-HRESULT WINAPI
-KsGetMediaType(
-    int  Position,
-    AM_MEDIA_TYPE  *AmMediaType,
-    HANDLE         FilterHandle,
-    ULONG          PinFactoryId)
-{
-    return NOERROR;
-}
-
-HRESULT WINAPI
-DllUnregisterServer(void)
-{
-    return S_OK;
-}
-
-HRESULT WINAPI
-DllRegisterServer(void)
-{
-    return S_OK;
-}
-
-HRESULT WINAPI
-DllGetClassObject(
-       REFCLSID rclsid,
-       REFIID riid,
-       LPVOID *ppv)
-{
-    return S_OK;
-}
-
-HRESULT WINAPI
-DllCanUnloadNow(void)
-{
-    return S_OK;
-}
-
diff --git a/reactos/dll/directx/ksproxy/ksproxy.cpp b/reactos/dll/directx/ksproxy/ksproxy.cpp
new file mode 100644 (file)
index 0000000..1a80119
--- /dev/null
@@ -0,0 +1,327 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS WDM Streaming ActiveMovie Proxy
+ * FILE:            dll/directx/ksproxy/ksproxy.c
+ * PURPOSE:         ActiveMovie Proxy functions
+ *
+ * PROGRAMMERS:     Dmitry Chapyshev
+                    Johannes Anderwald (janderwald@reactos.org)
+ */
+
+#include "precomp.h"
+
+const GUID KSPROPSETID_Pin                     = {0x8C134960, 0x51AD, 0x11CF, {0x87, 0x8A, 0x94, 0xF8, 0x01, 0xC1, 0x00, 0x00}};
+const GUID KSINTERFACESETID_Standard           = {STATIC_KSINTERFACESETID_Standard};
+const GUID CLSID_KsClockForwarder              = {0x877e4351, 0x6fea, 0x11d0, {0xb8, 0x63, 0x00, 0xaa, 0x00, 0xa2, 0x16, 0xa1}};
+const GUID CLSID_KsQualityForwarder            = {0xe05592e4, 0xc0b5, 0x11d0, {0xa4, 0x39, 0x00, 0xa0, 0xc9, 0x22, 0x31, 0x96}};
+const GUID CLSID_KsIBasicAudioInterfaceHandler = {0xb9f8ac3e, 0x0f71, 0x11d2, {0xb7, 0x2c, 0x00, 0xc0, 0x4f, 0xb6, 0xbd, 0x3d}};
+const GUID CLSID_Proxy                         = {0x17CCA71B, 0xECD7, 0x11D0, {0xB9, 0x08, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
+
+
+static INTERFACE_TABLE InterfaceTable[] =
+{
+    {&MEDIATYPE_Audio, CKsDataTypeHandler_Constructor},
+    {&KSINTERFACESETID_Standard, CKsInterfaceHandler_Constructor},
+    {&CLSID_KsClockForwarder, CKsClockForwarder_Constructor},
+    {&CLSID_KsQualityForwarder, CKsQualityForwarder_Constructor},
+    {&IID_IVPConfig, CVPConfig_Constructor},
+    {&IID_IVPVBIConfig, CVPVBIConfig_Constructor},
+    {&CLSID_KsIBasicAudioInterfaceHandler, CKsBasicAudio_Constructor},
+    {&CLSID_Proxy, CKsProxy_Constructor},
+    {NULL, NULL}
+};
+
+KSDDKAPI
+HRESULT
+WINAPI
+KsSynchronousDeviceControl(
+    HANDLE     Handle,
+    ULONG      IoControl,
+    PVOID      InBuffer,
+    ULONG      InLength,
+    PVOID      OutBuffer,
+    ULONG      OutLength,
+    PULONG     BytesReturned)
+{
+    OVERLAPPED Overlapped;
+    DWORD Transferred;
+
+    /* zero overlapped */
+    RtlZeroMemory(&Overlapped, sizeof(OVERLAPPED));
+
+    /* create notification event */
+    Overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
+
+    if (!Overlapped.hEvent)
+    {
+        /* failed */
+        return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
+    }
+
+    if (!DeviceIoControl(Handle, IoControl, InBuffer, InLength, OutBuffer, OutLength, BytesReturned, &Overlapped))
+    {
+        /* operation failed */
+        if (GetLastError() != ERROR_IO_PENDING)
+        {
+            /* failed */
+            CloseHandle(Overlapped.hEvent);
+            return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
+        }
+    }
+
+    /* get result of pending operation */
+    if (!GetOverlappedResult(Handle, &Overlapped, &Transferred, TRUE))
+    {
+        /* failed */
+        CloseHandle(Overlapped.hEvent);
+        return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
+    }
+
+    /* store number of bytes transferred */
+    *BytesReturned = Transferred;
+
+    /* close event object */
+    CloseHandle(Overlapped.hEvent);
+
+    /* done */
+    return NOERROR;
+}
+
+KSDDKAPI
+HRESULT
+WINAPI
+KsResolveRequiredAttributes(
+    PKSDATARANGE     DataRange,
+    KSMULTIPLE_ITEM  *Attributes OPTIONAL)
+{
+    //UNIMPLEMENTED
+    return NOERROR;
+}
+
+KSDDKAPI
+HRESULT
+WINAPI
+KsOpenDefaultDevice(
+    REFGUID      Category,
+    ACCESS_MASK  Access,
+    PHANDLE      DeviceHandle)
+{
+    HDEVINFO hList;
+    SP_DEVINFO_DATA DeviceInfoData;
+    SP_DEVICE_INTERFACE_DATA DeviceInterfaceData;
+    PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData;
+    WCHAR Path[MAX_PATH+sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W)];
+
+    /* open device list */
+    hList = SetupDiGetClassDevsW(&Category, NULL, NULL, DIGCF_DEVICEINTERFACE  /* | DIGCF_PRESENT*/);
+
+    if (hList == INVALID_HANDLE_VALUE)
+    {
+        /* failed */
+        return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
+    }
+
+    /* setup parameters */
+    DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
+    DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
+
+    if (SetupDiEnumDeviceInterfaces(hList, &DeviceInfoData, &Category, 0, &DeviceInterfaceData))
+    {
+        /* setup interface data struct */
+        DeviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA_W)Path;
+        DeviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
+
+        /* get device interface details */
+        if (SetupDiGetDeviceInterfaceDetailW(hList, &DeviceInterfaceData, DeviceInterfaceDetailData, sizeof(Path), NULL, NULL))
+        {
+            /* open device */
+            *DeviceHandle = CreateFileW(DeviceInterfaceDetailData->DevicePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_ATTRIBUTE_NORMAL, NULL);
+
+            if (*DeviceHandle != INVALID_HANDLE_VALUE)
+            {
+                /* operation succeeded */
+                SetupDiDestroyDeviceInfoList(hList);
+                return NOERROR;
+            }
+        }
+    }
+
+    /* free device list */
+    SetupDiDestroyDeviceInfoList(hList);
+
+    /* failed */
+    return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, GetLastError());
+}
+
+KSDDKAPI
+HRESULT
+WINAPI
+KsGetMultiplePinFactoryItems(
+    HANDLE  FilterHandle,
+    ULONG   PinFactoryId,
+    ULONG   PropertyId,
+    PVOID   *Items)
+{
+    KSP_PIN Property;
+    ULONG BytesReturned, NumData;
+    HRESULT hResult;
+
+    /* zero pin property */
+    RtlZeroMemory(&Property, sizeof(KSP_PIN));
+    Property.Property.Set = KSPROPSETID_Pin;
+    Property.Property.Id = PropertyId;
+    Property.Property.Flags = KSPROPERTY_TYPE_GET;
+    Property.PinId = PinFactoryId;
+
+    /* query pin factory */
+    hResult = KsSynchronousDeviceControl(FilterHandle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), NULL, 0, &BytesReturned);
+
+    if (hResult == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INSUFFICIENT_BUFFER))
+    {
+        /* buffer too small */
+        hResult = KsSynchronousDeviceControl(FilterHandle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), (PVOID)&NumData, sizeof(ULONG), &BytesReturned);
+
+        if (SUCCEEDED(hResult))
+        {
+            /* store required data size */
+            BytesReturned = NumData;
+            hResult = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_MORE_DATA);
+        }
+    }
+
+    if (hResult == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_MORE_DATA))
+    {
+        /* allocate data */
+        *Items = CoTaskMemAlloc(BytesReturned);
+
+        if (!*Items)
+        {
+            /* no memory */
+            return E_OUTOFMEMORY;
+        }
+
+        /* retry querying property */
+        hResult = KsSynchronousDeviceControl(FilterHandle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_PIN), (PVOID)*Items, BytesReturned, &BytesReturned);
+
+        /* check for success */
+        if (FAILED(hResult))
+        {
+            /* free memory */
+            CoTaskMemFree(*Items);
+        }
+    }
+
+    /* done */
+    return hResult;
+}
+
+KSDDKAPI
+HRESULT
+WINAPI
+KsGetMediaTypeCount(
+    HANDLE  FilterHandle,
+    ULONG   PinFactoryId,
+    ULONG   *MediaTypeCount)
+{
+    PKSMULTIPLE_ITEM MultipleItem;
+    HRESULT hr;
+
+    /* try get contrained data ranges */
+    hr = KsGetMultiplePinFactoryItems(FilterHandle, PinFactoryId, KSPROPERTY_PIN_CONSTRAINEDDATARANGES, (PVOID*)&MultipleItem);
+
+    /* check for failure*/
+    if (FAILED(hr))
+    {
+        /* try getting default data ranges */
+        hr = KsGetMultiplePinFactoryItems(FilterHandle, PinFactoryId, KSPROPERTY_PIN_DATARANGES, (PVOID*)&MultipleItem);
+    }
+
+    if (SUCCEEDED(hr))
+    {
+        /* store number of media types */
+        *MediaTypeCount = MultipleItem->Count;
+
+        /* free memory */
+        CoTaskMemFree(MultipleItem);
+    }
+
+    /* done */
+    return hr;
+}
+
+KSDDKAPI
+HRESULT
+WINAPI
+KsGetMediaType(
+    int  Position,
+    AM_MEDIA_TYPE  *AmMediaType,
+    HANDLE         FilterHandle,
+    ULONG          PinFactoryId)
+{
+    //UNIMPLEMENTED
+    return NOERROR;
+}
+
+extern "C"
+KSDDKAPI
+HRESULT
+WINAPI
+DllUnregisterServer(void)
+{
+    return S_OK;
+}
+
+extern "C"
+KSDDKAPI
+HRESULT
+WINAPI
+DllRegisterServer(void)
+{
+    return S_OK;
+}
+
+KSDDKAPI
+HRESULT
+WINAPI
+DllGetClassObject(
+    REFCLSID rclsid,
+    REFIID riid,
+    LPVOID *ppv)
+{
+    UINT i;
+    HRESULT hres = E_OUTOFMEMORY;
+    IClassFactory * pcf = NULL;        
+
+    if (!ppv)
+        return E_INVALIDARG;
+
+    *ppv = NULL;
+
+    for (i = 0; InterfaceTable[i].riid; i++) 
+    {
+        if (IsEqualIID(InterfaceTable[i].riid, rclsid)) 
+        {
+            pcf = CClassFactory_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL);
+            break;
+        }
+    }
+
+    if (!pcf) 
+    {
+        return CLASS_E_CLASSNOTAVAILABLE;
+    }
+
+    hres = pcf->QueryInterface(riid, ppv);
+    pcf->Release();
+
+    return hres;
+}
+
+KSDDKAPI
+HRESULT
+WINAPI
+DllCanUnloadNow(void)
+{
+    return S_OK;
+}
+
index c4c177b..f7a0bbd 100644 (file)
@@ -4,9 +4,32 @@
 <module name="ksproxy" type="win32dll" entrypoint="0" baseaddress="${BASEADDRESS_KSPROXY}" installbase="system32" installname="ksproxy.ax">
        <importlibrary definition="ksproxy.spec" />
        <include base="ksproxy">.</include>
-       <library>advapi32</library>
        <library>ntdll</library>
-       <file>ksproxy.c</file>
+       <library>kernel32</library>
+       <library>advapi32</library>
+       <library>ole32</library>
+       <library>setupapi</library>
+       <library>msvcrt</library>
+
+       <group compilerset="gcc">
+               <compilerflag compiler="cxx">-fno-exceptions</compilerflag>
+               <compilerflag compiler="cxx">-fno-rtti</compilerflag>
+       </group>
+
+       <group compilerset="msc">
+               <compilerflag compiler="cxx">/GR-</compilerflag>
+       </group>
+
+       <file>basicaudio.cpp</file>
+       <file>classfactory.cpp</file>
+       <file>clockforward.cpp</file>
+       <file>cvpconfig.cpp</file>
+       <file>cvpvbiconfig.cpp</file>
+       <file>datatype.cpp</file>
+       <file>interface.cpp</file>
+       <file>ksproxy.cpp</file>
        <file>ksproxy.rc</file>
+       <file>proxy.cpp</file>
+       <file>qualityforward.cpp</file>
 </module>
 </group>
diff --git a/reactos/dll/directx/ksproxy/precomp.h b/reactos/dll/directx/ksproxy/precomp.h
new file mode 100644 (file)
index 0000000..d566249
--- /dev/null
@@ -0,0 +1,101 @@
+#ifndef PRECOMP_H_
+#define PRECOMP_H_
+
+#define BUILDING_KS
+#define _KSDDK_
+#include <dshow.h>
+//#include <streams.h>
+#include <ks.h>
+#define __STREAMS__
+#include <ksproxy.h>
+#include <stdio.h>
+#include <wchar.h>
+#include <tchar.h>
+#include <uuids.h>
+#include <dvp.h>
+#include <vptype.h>
+#include <vpconfig.h>
+
+#include <setupapi.h>
+#include <debug.h>
+
+typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);
+
+typedef struct {
+    const GUID* riid;
+    LPFNCREATEINSTANCE lpfnCI;
+} INTERFACE_TABLE;
+
+/* classfactory.cpp */
+
+IClassFactory *
+CClassFactory_fnConstructor(
+    LPFNCREATEINSTANCE lpfnCI, 
+    PLONG pcRefDll,
+    IID * riidInst);
+
+/* datatype.cpp */
+HRESULT
+WINAPI
+CKsDataTypeHandler_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv);
+
+/* interface.cpp */
+HRESULT
+WINAPI
+CKsInterfaceHandler_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv);
+
+/* clockforward.cpp */
+HRESULT
+WINAPI
+CKsClockForwarder_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv);
+
+/* qualityforward.cpp */
+HRESULT
+WINAPI
+CKsQualityForwarder_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv);
+
+/* cvpconfig.cpp */
+HRESULT
+WINAPI
+CVPConfig_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv);
+
+/* cvpvbiconfig.cpp */
+HRESULT
+WINAPI
+CVPVBIConfig_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv);
+
+/* basicaudio.cpp */
+HRESULT
+WINAPI
+CKsBasicAudio_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv);
+
+/* proxy.cpp */
+HRESULT
+WINAPI
+CKsProxy_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv);
+
+#endif
diff --git a/reactos/dll/directx/ksproxy/proxy.cpp b/reactos/dll/directx/ksproxy/proxy.cpp
new file mode 100644 (file)
index 0000000..a6d8245
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS WDM Streaming ActiveMovie Proxy
+ * FILE:            dll/directx/ksproxy/proxy.cpp
+ * PURPOSE:         IKsProxy interface
+ *
+ * PROGRAMMERS:     Johannes Anderwald (janderwald@reactos.org)
+ */
+#include "precomp.h"
+
+/*
+    Needs IKsClock, IKsNotifyEvent
+*/
+
+class CKsProxy : public IBaseFilter,
+                 public IAMovieSetup,
+                 public IPersistStream,
+                 public ISpecifyPropertyPages,
+                 public IPersistPropertyBag,
+                 public IReferenceClock,
+                 public IMediaSeeking,
+                 public IKsObject,
+                 public IKsPropertySet,
+                 public IKsClockPropertySet,
+                 public IAMFilterMiscFlags,
+                 public IKsControl,
+                 public IKsTopology,
+                 public IKsAggregateControl,
+                 public IAMDeviceRemoval
+{
+
+
+};
+
+
+
+HRESULT
+WINAPI
+CKsProxy_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv)
+{
+    OutputDebugString("CKsProxy_Constructor UNIMPLEMENTED\n");
+    return E_NOTIMPL;
+}
diff --git a/reactos/dll/directx/ksproxy/qualityforward.cpp b/reactos/dll/directx/ksproxy/qualityforward.cpp
new file mode 100644 (file)
index 0000000..45f8f34
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS WDM Streaming ActiveMovie Proxy
+ * FILE:            dll/directx/ksproxy/clockforward.cpp
+ * PURPOSE:         IKsClockForwarder interface
+ *
+ * PROGRAMMERS:     Johannes Anderwald (janderwald@reactos.org)
+ */
+#include "precomp.h"
+
+const GUID KSCATEGORY_QUALITY = {0x97EBAACB, 0x95BD, 0x11D0, {0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
+
+class CKsQualityForwarder : public IKsQualityForwarder
+{
+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;
+    }
+
+    // IKsObject interface
+    HANDLE STDMETHODCALLTYPE KsGetObjectHandle();
+
+    // IKsQualityForwarder
+    VOID STDMETHODCALLTYPE KsFlushClient(IN IKsPin  *Pin); 
+
+    CKsQualityForwarder(HANDLE handle) : m_Ref(0), m_Handle(handle){}
+    virtual ~CKsQualityForwarder(){ if (m_Handle) CloseHandle(m_Handle);}
+
+protected:
+    LONG m_Ref;
+    HANDLE m_Handle;
+
+
+};
+
+HRESULT
+STDMETHODCALLTYPE
+CKsQualityForwarder::QueryInterface(
+    IN  REFIID refiid,
+    OUT PVOID* Output)
+{
+    if (IsEqualGUID(refiid, IID_IUnknown) ||
+        IsEqualGUID(refiid, IID_IKsQualityForwarder))
+    {
+        *Output = PVOID(this);
+        reinterpret_cast<IUnknown*>(*Output)->AddRef();
+        return NOERROR;
+    }
+
+    return E_NOINTERFACE;
+}
+
+//-------------------------------------------------------------------
+// IKsObject interface
+//
+
+HANDLE
+STDMETHODCALLTYPE
+CKsQualityForwarder::KsGetObjectHandle()
+{
+    return m_Handle;
+}
+
+//-------------------------------------------------------------------
+// IKsQualityForwarder interface
+//
+VOID
+STDMETHODCALLTYPE
+CKsQualityForwarder::KsFlushClient(
+    IN IKsPin  *Pin)
+{
+    OutputDebugString("UNIMPLEMENTED\n");
+}
+
+
+
+HRESULT
+WINAPI
+CKsQualityForwarder_Constructor(
+    IUnknown * pUnkOuter,
+    REFIID riid,
+    LPVOID * ppv)
+{
+    HRESULT hr;
+    HANDLE handle;
+
+    // open default clock
+    hr = KsOpenDefaultDevice(KSCATEGORY_QUALITY, GENERIC_READ | GENERIC_WRITE, &handle);
+
+    if (hr != NOERROR)
+    {
+         OutputDebugString("CKsClockForwarder_Constructor failed to open device\n");
+         return hr;
+    }
+
+    CKsQualityForwarder * quality = new CKsQualityForwarder(handle);
+
+    if (!quality)
+    {
+        // free clock handle
+        CloseHandle(handle);
+        return E_OUTOFMEMORY;
+    }
+
+    if (FAILED(quality->QueryInterface(riid, ppv)))
+    {
+        /* not supported */
+        delete quality;
+        return E_NOINTERFACE;
+    }
+
+    return NOERROR;
+}