sync with trunk r46493
[reactos.git] / dll / directx / bdaplgin / signalstatistics.cpp
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS BDA Proxy
4 * FILE: dll/directx/bdaplgin/frequencyfilter.cpp
5 * PURPOSE: IBDA_FrequencyFilter interface
6 *
7 * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
8 */
9
10 #include "precomp.h"
11
12 #ifndef _MSC_VER
13 const GUID IID_IBDA_SignalStatistics = {0x1347d106, 0xcf3a, 0x428a, {0xa5, 0xcb, 0xac, 0x0d, 0x9a, 0x2a, 0x43, 0x38}};
14 const GUID KSPROPSETID_BdaSignalStats = {0x1347d106, 0xcf3a, 0x428a, {0xa5, 0xcb, 0xac, 0xd, 0x9a, 0x2a, 0x43, 0x38}};
15 #endif
16
17 class CBDASignalStatistics : public IBDA_SignalStatistics
18 {
19 public:
20 STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
21
22 STDMETHODIMP_(ULONG) AddRef()
23 {
24 InterlockedIncrement(&m_Ref);
25 return m_Ref;
26 }
27 STDMETHODIMP_(ULONG) Release()
28 {
29 InterlockedDecrement(&m_Ref);
30 if (!m_Ref)
31 {
32 delete this;
33 return 0;
34 }
35 return m_Ref;
36 }
37
38 // IBDA_SignalStatistics methods
39 HRESULT STDMETHODCALLTYPE put_SignalStrength(LONG lDbStrength);
40 HRESULT STDMETHODCALLTYPE get_SignalStrength(LONG *plDbStrength);
41 HRESULT STDMETHODCALLTYPE put_SignalQuality(LONG lPercentQuality);
42 HRESULT STDMETHODCALLTYPE get_SignalQuality(LONG *plPercentQuality);
43 HRESULT STDMETHODCALLTYPE put_SignalPresent(BOOLEAN fPresent);
44 HRESULT STDMETHODCALLTYPE get_SignalPresent(BOOLEAN *pfPresent);
45 HRESULT STDMETHODCALLTYPE put_SignalLocked(BOOLEAN fLocked);
46 HRESULT STDMETHODCALLTYPE get_SignalLocked(BOOLEAN *pfLocked);
47 HRESULT STDMETHODCALLTYPE put_SampleTime(LONG lmsSampleTime);
48 HRESULT STDMETHODCALLTYPE get_SampleTime(LONG *plmsSampleTime);
49
50 CBDASignalStatistics(IKsPropertySet * pProperty, ULONG NodeId) : m_Ref(0), m_pProperty(pProperty), m_NodeId(NodeId){};
51 ~CBDASignalStatistics(){};
52
53 protected:
54 LONG m_Ref;
55 IKsPropertySet * m_pProperty;
56 ULONG m_NodeId;
57 };
58
59 HRESULT
60 STDMETHODCALLTYPE
61 CBDASignalStatistics::QueryInterface(
62 IN REFIID refiid,
63 OUT PVOID* Output)
64 {
65 *Output = NULL;
66
67 if (IsEqualGUID(refiid, IID_IUnknown))
68 {
69 *Output = PVOID(this);
70 reinterpret_cast<IUnknown*>(*Output)->AddRef();
71 return NOERROR;
72 }
73
74 if (IsEqualGUID(refiid, IID_IBDA_SignalStatistics))
75 {
76 *Output = (IBDA_SignalStatistics*)(this);
77 reinterpret_cast<IBDA_SignalStatistics*>(*Output)->AddRef();
78 return NOERROR;
79 }
80 return E_NOINTERFACE;
81 }
82
83 HRESULT
84 STDMETHODCALLTYPE
85 CBDASignalStatistics::put_SignalStrength(LONG lDbStrength)
86 {
87 return E_NOINTERFACE;
88 }
89
90 HRESULT
91 STDMETHODCALLTYPE
92 CBDASignalStatistics::get_SignalStrength(LONG *plDbStrength)
93 {
94 KSP_NODE Node;
95 HRESULT hr;
96 ULONG BytesReturned;
97
98 // setup request
99 Node.NodeId = (ULONG)-1;
100 Node.Reserved = 0;
101
102 assert(m_pProperty);
103
104 hr = m_pProperty->Get(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SIGNAL_STRENGTH, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), plDbStrength, sizeof(LONG), &BytesReturned);
105
106
107 #ifdef BDAPLGIN_TRACE
108 WCHAR Buffer[100];
109 swprintf(Buffer, L"CBDASignalStatistics::get_SignalStrength: m_NodeId %lu hr %lx, BytesReturned %lu plDbStrength %ld\n", m_NodeId, hr, BytesReturned, *plDbStrength);
110 OutputDebugStringW(Buffer);
111 #endif
112
113 return hr;
114 }
115
116 HRESULT
117 STDMETHODCALLTYPE
118 CBDASignalStatistics::put_SignalQuality(LONG lPercentQuality)
119 {
120 return E_NOINTERFACE;
121 }
122
123 HRESULT
124 STDMETHODCALLTYPE
125 CBDASignalStatistics::get_SignalQuality(LONG *plPercentQuality)
126 {
127 KSP_NODE Node;
128 HRESULT hr;
129 ULONG BytesReturned;
130
131 // setup request
132 Node.NodeId = (ULONG)-1;
133 Node.Reserved = 0;
134
135 // perform request
136 hr = m_pProperty->Get(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SIGNAL_QUALITY, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), plPercentQuality, sizeof(LONG), &BytesReturned);
137
138 #ifdef BDAPLGIN_TRACE
139 WCHAR Buffer[100];
140 swprintf(Buffer, L"CBDASignalStatistics::get_SignalQuality: m_NodeId %lu hr %lx, BytesReturned %lu plPercentQuality %lu\n", m_NodeId, hr, BytesReturned, *plPercentQuality);
141 OutputDebugStringW(Buffer);
142 #endif
143
144 return hr;
145 }
146
147 HRESULT
148 STDMETHODCALLTYPE
149 CBDASignalStatistics::put_SignalPresent(BOOLEAN fPresent)
150 {
151 return E_NOINTERFACE;
152 }
153
154 HRESULT
155 STDMETHODCALLTYPE
156 CBDASignalStatistics::get_SignalPresent(BOOLEAN *pfPresent)
157 {
158 KSP_NODE Node;
159 HRESULT hr;
160 ULONG Present;
161 ULONG BytesReturned;
162
163 // setup request
164 Node.NodeId = (ULONG)-1;
165 Node.Reserved = 0;
166
167 // perform request
168 hr = m_pProperty->Get(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SIGNAL_PRESENT, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &Present, sizeof(ULONG), &BytesReturned);
169
170 // store result
171 *pfPresent = Present;
172
173 #ifdef BDAPLGIN_TRACE
174 WCHAR Buffer[100];
175 swprintf(Buffer, L"CBDASignalStatistics::get_SignalPresent: m_NodeId %lu hr %lx, BytesReturned %lu Present %lu\n", m_NodeId, hr, BytesReturned, Present);
176 OutputDebugStringW(Buffer);
177 #endif
178
179 return hr;
180 }
181
182 HRESULT
183 STDMETHODCALLTYPE
184 CBDASignalStatistics::put_SignalLocked(BOOLEAN fLocked)
185 {
186 return E_NOINTERFACE;
187 }
188
189 HRESULT
190 STDMETHODCALLTYPE
191 CBDASignalStatistics::get_SignalLocked(BOOLEAN *pfLocked)
192 {
193 KSP_NODE Node;
194 HRESULT hr;
195 ULONG Locked;
196 ULONG BytesReturned;
197
198 // setup request
199 Node.NodeId = (ULONG)-1;
200 Node.Reserved = 0;
201
202 // perform request
203 hr = m_pProperty->Get(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SIGNAL_LOCKED, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &Locked, sizeof(ULONG), &BytesReturned);
204
205 *pfLocked = Locked;
206
207 #ifdef BDAPLGIN_TRACE
208 WCHAR Buffer[100];
209 swprintf(Buffer, L"CBDASignalStatistics::get_SignalLocked: m_NodeId %lu hr %lx, BytesReturned %lu Locked %lu\n", m_NodeId, hr, BytesReturned, Locked);
210 OutputDebugStringW(Buffer);
211 #endif
212
213 return hr;
214 }
215
216 HRESULT
217 STDMETHODCALLTYPE
218 CBDASignalStatistics::put_SampleTime(LONG lmsSampleTime)
219 {
220 KSP_NODE Node;
221 HRESULT hr;
222
223 // setup request
224 Node.NodeId = (ULONG)-1;
225 Node.Reserved = 0;
226
227 // perform request
228 hr = m_pProperty->Set(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SAMPLE_TIME, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &lmsSampleTime, sizeof(LONG));
229
230 #ifdef BDAPLGIN_TRACE
231 WCHAR Buffer[100];
232 swprintf(Buffer, L"CBDASignalStatistics::put_SampleTime: m_NodeId %lu hr %lx\n", m_NodeId, hr);
233 OutputDebugStringW(Buffer);
234 #endif
235
236 return hr;
237 }
238
239 HRESULT
240 STDMETHODCALLTYPE
241 CBDASignalStatistics::get_SampleTime(LONG *plmsSampleTime)
242 {
243 KSP_NODE Node;
244 HRESULT hr;
245 ULONG BytesReturned;
246
247 // setup request
248 Node.NodeId = (ULONG)-1;
249 Node.Reserved = 0;
250
251 // perform request
252 hr = m_pProperty->Get(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SAMPLE_TIME, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), plmsSampleTime, sizeof(LONG), &BytesReturned);
253
254 #ifdef BDAPLGIN_TRACE
255 WCHAR Buffer[100];
256 swprintf(Buffer, L"CBDASignalStatistics::get_SampleTime: m_NodeId %lu hr %lx, BytesReturned %lu \n", m_NodeId, hr, BytesReturned);
257 OutputDebugStringW(Buffer);
258 #endif
259
260 return hr;
261 }
262
263 HRESULT
264 WINAPI
265 CBDASignalStatistics_fnConstructor(
266 IKsPropertySet * pProperty,
267 ULONG NodeId,
268 REFIID riid,
269 LPVOID * ppv)
270 {
271 // construct device control
272 CBDASignalStatistics * handler = new CBDASignalStatistics(pProperty, NodeId);
273
274 #ifdef BDAPLGIN_TRACE
275 OutputDebugStringW(L"CBDASignalStatistics_fnConstructor\n");
276 #endif
277
278 if (!handler)
279 return E_OUTOFMEMORY;
280
281 if (FAILED(handler->QueryInterface(riid, ppv)))
282 {
283 /* not supported */
284 delete handler;
285 return E_NOINTERFACE;
286 }
287
288 return NOERROR;
289 }