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