ad15ed0d94d6d287e06ac90b7755e1217a56f3f2
[reactos.git] / reactos / dll / directx / msvidctl / tunerequest.cpp
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS BDA Proxy
4 * FILE: dll/directx/msvidctl/tuningspace.cpp
5 * PURPOSE: ITuningRequest interface
6 *
7 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8 */
9 #include "precomp.h"
10
11 class CTuneRequest : public IDVBTuneRequest
12 {
13 public:
14 STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
15
16 STDMETHODIMP_(ULONG) AddRef()
17 {
18 InterlockedIncrement(&m_Ref);
19 return m_Ref;
20 }
21 STDMETHODIMP_(ULONG) Release()
22 {
23 InterlockedDecrement(&m_Ref);
24 if (!m_Ref)
25 {
26 OutputDebugStringW(L"CTuneRequest::Release : delete\n");
27
28 WCHAR Buffer[100];
29 swprintf(Buffer, L"CTuneRequest::Release : m_TuningSpace %p delete\n", m_TuningSpace);
30 OutputDebugStringW(Buffer);
31
32
33 m_TuningSpace->Release();
34 //delete this;
35 return 0;
36 }
37 return m_Ref;
38 }
39
40 //IDispatch methods
41 HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo);
42 HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo);
43 HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId);
44 HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
45
46 //ITuneRequest methods
47 HRESULT STDMETHODCALLTYPE get_TuningSpace(ITuningSpace **TuningSpace);
48 HRESULT STDMETHODCALLTYPE get_Components(IComponents **Components);
49 HRESULT STDMETHODCALLTYPE Clone(ITuneRequest **NewTuneRequest);
50 HRESULT STDMETHODCALLTYPE get_Locator(ILocator **Locator);
51 HRESULT STDMETHODCALLTYPE put_Locator(ILocator *Locator);
52
53 //IDVBTuneRequest methods
54 HRESULT STDMETHODCALLTYPE get_ONID(long *ONID);
55 HRESULT STDMETHODCALLTYPE put_ONID(long ONID);
56 HRESULT STDMETHODCALLTYPE get_TSID(long *TSID);
57 HRESULT STDMETHODCALLTYPE put_TSID(long TSID);
58 HRESULT STDMETHODCALLTYPE get_SID(long *SID);
59 HRESULT STDMETHODCALLTYPE put_SID(long SID);
60
61 CTuneRequest(ITuningSpace * TuningSpace) : m_Ref(0), m_ONID(-1), m_TSID(-1), m_SID(-1), m_Locator(0), m_TuningSpace(TuningSpace)
62 {
63 m_TuningSpace->AddRef();
64 };
65
66 CTuneRequest(ITuningSpace * TuningSpace, LONG ONID, LONG TSID, LONG SID, ILocator * Locator) : m_Ref(1), m_ONID(ONID), m_TSID(TSID), m_SID(SID), m_Locator(Locator), m_TuningSpace(TuningSpace)
67 {
68 if (m_Locator)
69 m_Locator->AddRef();
70
71 m_TuningSpace->AddRef();
72 };
73
74 virtual ~CTuneRequest(){};
75
76 protected:
77 LONG m_Ref;
78 LONG m_ONID;
79 LONG m_TSID;
80 LONG m_SID;
81 ILocator * m_Locator;
82 ITuningSpace * m_TuningSpace;
83 };
84
85
86 HRESULT
87 STDMETHODCALLTYPE
88 CTuneRequest::QueryInterface(
89 IN REFIID refiid,
90 OUT PVOID* Output)
91 {
92 if (IsEqualGUID(refiid, IID_IUnknown))
93 {
94 *Output = PVOID(this);
95 reinterpret_cast<IUnknown*>(*Output)->AddRef();
96 return NOERROR;
97 }
98
99 if (IsEqualGUID(refiid, IID_ITuneRequest))
100 {
101 *Output = (ITuneRequest*)this;
102 reinterpret_cast<ITuneRequest*>(*Output)->AddRef();
103 return NOERROR;
104 }
105
106 if (IsEqualGUID(refiid, IID_IDVBTuneRequest))
107 {
108 *Output = (IDVBTuneRequest*)this;
109 reinterpret_cast<IDVBTuneRequest*>(*Output)->AddRef();
110 return NOERROR;
111 }
112
113 WCHAR Buffer[MAX_PATH];
114 LPOLESTR lpstr;
115 StringFromCLSID(refiid, &lpstr);
116 swprintf(Buffer, L"CTuneRequest::QueryInterface: NoInterface for %s", lpstr);
117 OutputDebugStringW(Buffer);
118 CoTaskMemFree(lpstr);
119
120
121 return E_NOINTERFACE;
122 }
123
124 //-------------------------------------------------------------------
125 // IDispatch methods
126 //
127 HRESULT
128 STDMETHODCALLTYPE
129 CTuneRequest::GetTypeInfoCount(UINT *pctinfo)
130 {
131 OutputDebugStringW(L"CTuneRequest::GetTypeInfoCount : NotImplemented\n");
132 return E_NOTIMPL;
133 }
134
135 HRESULT
136 STDMETHODCALLTYPE
137 CTuneRequest::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
138 {
139 OutputDebugStringW(L"CTuneRequest::GetTypeInfo : NotImplemented\n");
140 return E_NOTIMPL;
141 }
142 HRESULT
143 STDMETHODCALLTYPE
144 CTuneRequest::GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
145 {
146 OutputDebugStringW(L"CTuneRequest::GetIDsOfNames : NotImplemented\n");
147 return E_NOTIMPL;
148 }
149 HRESULT
150 STDMETHODCALLTYPE
151 CTuneRequest::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
152 {
153 OutputDebugStringW(L"CTuneRequest::Invoke : NotImplemented\n");
154 return E_NOTIMPL;
155 }
156
157 //-------------------------------------------------------------------
158 // ITuneRequest interface
159 //
160
161 HRESULT
162 STDMETHODCALLTYPE
163 CTuneRequest::get_TuningSpace(ITuningSpace **TuningSpace)
164 {
165 #ifdef MSVIDCTL_TRACE
166 OutputDebugStringW(L"CTuneRequest::get_TuningSpace\n");
167 #endif
168
169 *TuningSpace = m_TuningSpace;
170 m_TuningSpace->AddRef();
171
172 return S_OK;
173 }
174
175 HRESULT
176 STDMETHODCALLTYPE
177 CTuneRequest::get_Components(IComponents **Components)
178 {
179 OutputDebugStringW(L"CTuneRequest::get_Components : NotImplemented\n");
180 return E_NOTIMPL;
181 }
182
183 HRESULT
184 STDMETHODCALLTYPE
185 CTuneRequest::Clone(ITuneRequest **NewTuneRequest)
186 {
187 #ifdef MSVIDCTL_TRACE
188 WCHAR Buffer[100];
189 swprintf(Buffer, L"CTuneRequest::Clone %p\n", NewTuneRequest);
190 OutputDebugStringW(Buffer);
191 #endif
192
193 *NewTuneRequest = new CTuneRequest(m_TuningSpace, m_ONID, m_TSID, m_SID, m_Locator);
194
195 if (!*NewTuneRequest)
196 return E_OUTOFMEMORY;
197
198 return S_OK;
199 }
200
201 HRESULT
202 STDMETHODCALLTYPE
203 CTuneRequest::get_Locator(ILocator **Locator)
204 {
205 OutputDebugStringW(L"CTuneRequest::get_Locator : NotImplemented\n");
206 return E_NOTIMPL;
207 }
208
209 HRESULT
210 STDMETHODCALLTYPE
211 CTuneRequest::put_Locator(ILocator *Locator)
212 {
213 OutputDebugStringW(L"CTuneRequest::put_Locator : stub\n");
214 m_Locator = Locator;
215
216 return S_OK;
217 }
218
219 //-------------------------------------------------------------------
220 // IDVBTuneRequest interface
221 //
222
223 HRESULT
224 STDMETHODCALLTYPE
225 CTuneRequest::get_ONID(long *ONID)
226 {
227 #ifdef MSVIDCTL_TRACE
228 OutputDebugStringW(L"CTuneRequest::get_ONID\n");
229 #endif
230
231 *ONID = m_ONID;
232 return S_OK;
233 }
234
235 HRESULT
236 STDMETHODCALLTYPE
237 CTuneRequest::put_ONID(long ONID)
238 {
239 #ifdef MSVIDCTL_TRACE
240 WCHAR Buffer[100];
241 swprintf(Buffer, L"CTuneRequest::put_ONID : %lu\n", ONID);
242 OutputDebugStringW(Buffer);
243 #endif
244
245 m_ONID = ONID;
246 return S_OK;
247 }
248
249 HRESULT
250 STDMETHODCALLTYPE
251 CTuneRequest::get_TSID(long *TSID)
252 {
253 #ifdef MSVIDCTL_TRACE
254 OutputDebugStringW(L"CTuneRequest::get_TSID\n");
255 #endif
256
257 *TSID = m_TSID;
258 return S_OK;
259 }
260
261 HRESULT
262 STDMETHODCALLTYPE
263 CTuneRequest::put_TSID(long TSID)
264 {
265 #ifdef MSVIDCTL_TRACE
266 WCHAR Buffer[100];
267 swprintf(Buffer, L"CTuneRequest::put_TSID : %lu\n", TSID);
268 OutputDebugStringW(Buffer);
269 #endif
270
271 m_TSID = TSID;
272 return S_OK;
273 }
274
275 HRESULT
276 STDMETHODCALLTYPE
277 CTuneRequest::get_SID(long *SID)
278 {
279 #ifdef MSVIDCTL_TRACE
280 OutputDebugStringW(L"CTuneRequest::get_SID\n");
281 #endif
282
283 *SID = m_SID;
284 return S_OK;
285 }
286
287 HRESULT
288 STDMETHODCALLTYPE
289 CTuneRequest::put_SID(long SID)
290 {
291 #ifdef MSVIDCTL_TRACE
292 WCHAR Buffer[100];
293 swprintf(Buffer, L"CTuneRequest::put_SID : %lu\n", SID);
294 OutputDebugStringW(Buffer);
295 #endif
296
297 m_SID = SID;
298 return S_OK;
299 }
300
301 HRESULT
302 WINAPI
303 CTuneRequest_fnConstructor(
304 IUnknown *pUnknown,
305 ITuningSpace * TuningSpace,
306 REFIID riid,
307 LPVOID * ppv)
308 {
309 // construct device control
310 CTuneRequest * request = new CTuneRequest(TuningSpace);
311
312 #ifdef MSVIDCTL_TRACE
313 WCHAR Buffer[MAX_PATH];
314 LPOLESTR lpstr;
315 StringFromCLSID(riid, &lpstr);
316 swprintf(Buffer, L"CTuneRequest_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown);
317 OutputDebugStringW(Buffer);
318 #endif
319
320 if (!request)
321 return E_OUTOFMEMORY;
322
323 if (FAILED(request->QueryInterface(riid, ppv)))
324 {
325 /* not supported */
326 delete request;
327 return E_NOINTERFACE;
328 }
329
330 return NOERROR;
331 }