ReactOS  0.4.14-dev-358-gbef841c
node.cpp
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS WDM Streaming ActiveMovie Proxy
4  * FILE: dll/directx/ksproxy/node.cpp
5  * PURPOSE: Control Node
6  *
7  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8  */
9 #include "precomp.h"
10 
11 class CKsNode : public IKsControl
12 {
13 public:
15 
17  {
19  return m_Ref;
20  }
22  {
24 
25  if (!m_Ref)
26  {
27  delete this;
28  return 0;
29  }
30  return m_Ref;
31  }
32 
33  //IKsControl
37 
38  CKsNode(IUnknown * pUnkOuter, HANDLE Handle) : m_Ref(0), m_pUnkOuter(pUnkOuter), m_Handle(Handle){};
39  virtual ~CKsNode()
40  {
42  };
43 
44 protected:
45  LONG m_Ref;
48 };
49 
50 HRESULT
53  IN REFIID refiid,
54  OUT PVOID* Output)
55 {
56  if (IsEqualGUID(refiid, IID_IUnknown) ||
57  IsEqualGUID(refiid, IID_IKsControl))
58  {
59  *Output = PVOID(this);
60  reinterpret_cast<IUnknown*>(*Output)->AddRef();
61  return NOERROR;
62  }
63 
64  return E_NOINTERFACE;
65 }
66 
67 //-------------------------------------------------------------------
68 // IKsControl
69 //
70 HRESULT
74  ULONG PropertyLength,
75  LPVOID PropertyData,
78 {
79  assert(m_Handle != 0);
81 }
82 
83 HRESULT
86  PKSMETHOD Method,
87  ULONG MethodLength,
88  LPVOID MethodData,
91 {
92  assert(m_Handle != 0);
93  return KsSynchronousDeviceControl(m_Handle, IOCTL_KS_METHOD, (PVOID)Method, MethodLength, (PVOID)MethodData, DataLength, BytesReturned);
94 }
95 
96 HRESULT
100  ULONG EventLength,
101  LPVOID EventData,
104 {
105  assert(m_Handle != 0);
106 
107  if (EventLength)
109  else
111 }
112 
113 HRESULT
114 WINAPI
116  IUnknown * pUnkOuter,
117  HANDLE ParentHandle,
118  ULONG NodeId,
120  REFIID riid,
121  LPVOID * ppv)
122 {
123  HRESULT hr;
124  HANDLE handle;
126 
127 #ifdef KSPROXY_TRACE
128  OutputDebugStringW(L"CKsNode_Constructor\n");
129 #endif
130 
131  //setup request
133  NodeCreate.Node = NodeId;
134 
136  if (hr != NOERROR)
137  {
138  OutputDebugString("CKsNode_Constructor failed to open device\n");
140  }
141 
142  CKsNode * quality = new CKsNode(pUnkOuter, handle);
143 
144  if (!quality)
145  {
146  // free clock handle
148  return E_OUTOFMEMORY;
149  }
150 
151  if (FAILED(quality->QueryInterface(riid, ppv)))
152  {
153  /* not supported */
154  delete quality;
155  return E_NOINTERFACE;
156  }
157 
158  return NOERROR;
159 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define IN
Definition: typedefs.h:38
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define REFIID
Definition: guiddef.h:118
#define CloseHandle
Definition: compat.h:406
#define E_NOINTERFACE
Definition: winerror.h:2364
#define IOCTL_KS_DISABLE_EVENT
Definition: ks.h:133
STDMETHODIMP_(ULONG) AddRef()
Definition: node.cpp:16
HRESULT hr
Definition: shlfolder.c:183
const GUID IID_IKsControl
Definition: filter.c:44
#define NOERROR
Definition: winerror.h:2354
_In_ PKSNODE_CREATE NodeCreate
Definition: ks.h:4546
HRESULT STDMETHODCALLTYPE KsMethod(PKSMETHOD Method, ULONG MethodLength, LPVOID MethodData, ULONG DataLength, ULONG *BytesReturned)
Definition: node.cpp:85
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define assert(x)
Definition: debug.h:53
KSDDKAPI HRESULT WINAPI KsSynchronousDeviceControl(HANDLE Handle, ULONG IoControl, PVOID InBuffer, ULONG InLength, PVOID OutBuffer, ULONG OutLength, PULONG BytesReturned)
Definition: ksproxy.cpp:34
Definition: node.cpp:11
#define OutputDebugString
Definition: winbase.h:3714
IUnknown * m_pUnkOuter
Definition: node.cpp:46
LONG m_Ref
Definition: node.cpp:42
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
HRESULT STDMETHODCALLTYPE KsProperty(PKSPROPERTY Property, ULONG PropertyLength, LPVOID PropertyData, ULONG DataLength, ULONG *BytesReturned)
Definition: node.cpp:72
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
#define STDMETHODIMP
Definition: basetyps.h:43
ULONG Release()
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
KSDDKAPI DWORD NTAPI KsCreateTopologyNode(HANDLE ParentHandle, PKSNODE_CREATE NodeCreate, IN ACCESS_MASK DesiredAccess, OUT PHANDLE NodeHandle)
Definition: ksuser.c:240
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
#define IOCTL_KS_METHOD
Definition: ks.h:136
HRESULT WINAPI CKsNode_Constructor(IUnknown *pUnkOuter, HANDLE ParentHandle, ULONG NodeId, ACCESS_MASK DesiredAccess, REFIID riid, LPVOID *ppv)
Definition: node.cpp:115
_In_ HANDLE Handle
Definition: extypes.h:390
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
ULONG Node
Definition: ks.h:2094
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
int quality
Definition: jpeglib.h:991
CKsNode(IUnknown *pUnkOuter, HANDLE Handle)
Definition: node.cpp:38
#define SEVERITY_ERROR
Definition: winerror.h:65
STDMETHODIMP_(ULONG) Release()
Definition: node.cpp:21
ULONG AddRef()
static const WCHAR L[]
Definition: oid.c:1250
#define InterlockedDecrement
Definition: armddk.h:52
#define IOCTL_KS_ENABLE_EVENT
Definition: ks.h:130
Definition: arc.h:85
HRESULT STDMETHODCALLTYPE KsEvent(PKSEVENT Event, ULONG EventLength, LPVOID EventData, ULONG DataLength, ULONG *BytesReturned)
Definition: node.cpp:98
#define FACILITY_WIN32
Definition: winerror.h:27
#define InterlockedIncrement
Definition: armddk.h:53
HANDLE m_Handle
Definition: node.cpp:47
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
virtual ~CKsNode()
Definition: node.cpp:39
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: node.cpp:52
ULONG CreateFlags
Definition: ks.h:2093
ULONG ACCESS_MASK
Definition: nt_native.h:40