- add log APIs to Activex
[vlc.git] / activex / vlccontrol2.h
1 /*****************************************************************************
2  * vlccontrol.h: ActiveX control for VLC
3  *****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  *
6  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 #ifndef _VLCCONTROL2_H_
24 #define _VLCCONTROL2_H_
25
26 #include "axvlc_idl.h"
27
28 #include <vlc/libvlc.h>
29
30 class VLCAudio : public IVLCAudio
31 {
32 public:
33     VLCAudio(VLCPlugin *p_instance) :
34         _p_instance(p_instance), _p_typeinfo(NULL) {};
35     virtual ~VLCAudio();
36
37     // IUnknown methods
38     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
39     {
40         if( NULL == ppv )
41           return E_POINTER;
42         if( (IID_IUnknown == riid)
43          || (IID_IDispatch == riid)
44          || (IID_IVLCAudio == riid) )
45         {
46             AddRef();
47             *ppv = reinterpret_cast<LPVOID>(this);
48             return NOERROR;
49         }
50         // behaves as a standalone object
51         return E_NOINTERFACE;
52     };
53
54     STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
55     STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
56
57     // IDispatch methods
58     STDMETHODIMP GetTypeInfoCount(UINT*);
59     STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
60     STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
61     STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
62
63     // IVLCAudio methods
64     STDMETHODIMP get_mute(VARIANT_BOOL*);
65     STDMETHODIMP put_mute(VARIANT_BOOL);
66     STDMETHODIMP get_volume(long*);
67     STDMETHODIMP put_volume(long);
68     STDMETHODIMP toggleMute();
69  
70 protected:
71     HRESULT loadTypeInfo();
72
73 private:
74     VLCPlugin*      _p_instance;
75     ITypeInfo*      _p_typeinfo;
76
77 };
78  
79 class VLCInput : public IVLCInput
80 {
81 public:
82
83     VLCInput(VLCPlugin *p_instance) :
84         _p_instance(p_instance), _p_typeinfo(NULL) {};
85     virtual ~VLCInput();
86
87     // IUnknown methods
88     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
89     {
90         if( NULL == ppv )
91           return E_POINTER;
92         if( (IID_IUnknown == riid)
93          || (IID_IDispatch == riid)
94          || (IID_IVLCInput == riid) )
95         {
96             AddRef();
97             *ppv = reinterpret_cast<LPVOID>(this);
98             return NOERROR;
99         }
100         // behaves as a standalone object
101         return E_NOINTERFACE;
102     };
103
104     STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
105     STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
106
107     // IDispatch methods
108     STDMETHODIMP GetTypeInfoCount(UINT*);
109     STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
110     STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
111     STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
112
113     // IVLCInput methods
114     STDMETHODIMP get_length(double*);
115     STDMETHODIMP get_position(double*);
116     STDMETHODIMP put_position(double);
117     STDMETHODIMP get_time(double*);
118     STDMETHODIMP put_time(double);
119     STDMETHODIMP get_state(long*);
120     STDMETHODIMP get_rate(double*);
121     STDMETHODIMP put_rate(double);
122     STDMETHODIMP get_fps(double*);
123     STDMETHODIMP get_hasVout(VARIANT_BOOL*);
124     
125 protected:
126     HRESULT loadTypeInfo();
127
128 private:
129     VLCPlugin*      _p_instance;
130     ITypeInfo*      _p_typeinfo;
131
132 };
133  
134 class VLCMessage: public IVLCMessage
135 {
136 public:
137
138     VLCMessage(VLCPlugin *p_instance, struct libvlc_log_message_t &msg) :
139         _p_instance(p_instance),
140         _p_typeinfo(NULL),
141         _refcount(1),
142         _msg(msg) {};
143     virtual ~VLCMessage();
144
145     // IUnknown methods
146     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
147     {
148         if( NULL == ppv )
149           return E_POINTER;
150         if( (IID_IUnknown == riid)
151          || (IID_IDispatch == riid)
152          || (IID_IVLCMessage == riid) )
153         {
154             AddRef();
155             *ppv = reinterpret_cast<LPVOID>(this);
156             return NOERROR;
157         }
158         // behaves as a standalone object
159         return E_NOINTERFACE;
160     };
161
162     STDMETHODIMP_(ULONG) AddRef(void) { return InterlockedIncrement(&_refcount); };
163     STDMETHODIMP_(ULONG) Release(void)
164     {
165         ULONG refcount = InterlockedDecrement(&_refcount);
166         if( 0 == refcount )
167         {
168             delete this;
169             return 0;
170         }
171         return refcount;
172     };
173
174     // IDispatch methods
175     STDMETHODIMP GetTypeInfoCount(UINT*);
176     STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
177     STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
178     STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
179
180     // IVLCMessage methods
181     STDMETHODIMP get__Value(VARIANT *);
182     STDMETHODIMP get_severity(long *);
183     STDMETHODIMP get_type(BSTR *);
184     STDMETHODIMP get_name(BSTR *);
185     STDMETHODIMP get_header(BSTR *);
186     STDMETHODIMP get_message(BSTR *);
187     
188 protected:
189     HRESULT loadTypeInfo();
190
191 private:
192     VLCPlugin*      _p_instance;
193     ITypeInfo*      _p_typeinfo;
194     LONG            _refcount;
195
196     struct libvlc_log_message_t _msg;
197 };
198  
199 class VLCLog;
200
201 class VLCMessageIterator : public IVLCMessageIterator
202 {
203 public:
204
205     VLCMessageIterator(VLCPlugin *p_instance, VLCLog* p_vlclog);
206     virtual ~VLCMessageIterator();
207
208     // IUnknown methods
209     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
210     {
211         if( NULL == ppv )
212           return E_POINTER;
213         if( (IID_IUnknown == riid)
214          || (IID_IDispatch == riid)
215          || (IID_IVLCMessageIterator == riid) )
216         {
217             AddRef();
218             *ppv = reinterpret_cast<LPVOID>(this);
219             return NOERROR;
220         }
221         // behaves as a standalone object
222         return E_NOINTERFACE;
223     };
224
225     STDMETHODIMP_(ULONG) AddRef(void) { return InterlockedIncrement(&_refcount); };
226     STDMETHODIMP_(ULONG) Release(void)
227     {
228         ULONG refcount = InterlockedDecrement(&_refcount);
229         if( 0 == refcount )
230         {
231             delete this;
232             return 0;
233         }
234         return refcount;
235     };
236
237     // IDispatch methods
238     STDMETHODIMP GetTypeInfoCount(UINT*);
239     STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
240     STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
241     STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
242
243     // IVLCMessageIterator methods
244     STDMETHODIMP get_hasNext(VARIANT_BOOL*);
245     STDMETHODIMP next(IVLCMessage**);
246     
247 protected:
248     HRESULT loadTypeInfo();
249
250 private:
251     VLCPlugin*      _p_instance;
252     ITypeInfo*      _p_typeinfo;
253     LONG            _refcount;
254
255     VLCLog*                 _p_vlclog;
256     libvlc_log_iterator_t*  _p_iter;
257 };
258  
259 class VLCMessages : public IVLCMessages
260 {
261 public:
262
263     VLCMessages(VLCPlugin *p_instance, VLCLog *p_vlclog) :
264         _p_instance(p_instance),
265         _p_typeinfo(NULL),
266         _p_vlclog(p_vlclog) {};
267     virtual ~VLCMessages();
268
269     // IUnknown methods
270     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
271     {
272         if( NULL == ppv )
273           return E_POINTER;
274         if( (IID_IUnknown == riid)
275          || (IID_IDispatch == riid)
276          || (IID_IVLCMessages == riid) )
277         {
278             AddRef();
279             *ppv = reinterpret_cast<LPVOID>(this);
280             return NOERROR;
281         }
282         // behaves as a standalone object
283         return E_NOINTERFACE;
284     };
285
286     STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
287     STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
288
289     // IDispatch methods
290     STDMETHODIMP GetTypeInfoCount(UINT*);
291     STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
292     STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
293     STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
294
295     // IVLCMessages methods
296     STDMETHODIMP get__NewEnum(LPUNKNOWN*);
297     STDMETHODIMP clear();
298     STDMETHODIMP get_count(long*);
299     STDMETHODIMP iterator(IVLCMessageIterator**);
300     
301 protected:
302     HRESULT loadTypeInfo();
303
304     VLCLog*     _p_vlclog;
305
306 private:
307     VLCPlugin*  _p_instance;
308     ITypeInfo*  _p_typeinfo;
309 };
310  
311 class VLCLog : public IVLCLog
312 {
313 public:
314
315     friend class VLCMessages;
316     friend class VLCMessageIterator;
317
318     VLCLog(VLCPlugin *p_instance) :
319         _p_instance(p_instance),
320         _p_typeinfo(NULL),
321         _p_log(NULL)
322     {
323         _p_vlcmessages = new VLCMessages(p_instance, this);
324     };
325     virtual ~VLCLog();
326
327     // IUnknown methods
328     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
329     {
330         if( NULL == ppv )
331           return E_POINTER;
332         if( (IID_IUnknown == riid)
333          || (IID_IDispatch == riid)
334          || (IID_IVLCLog == riid) )
335         {
336             AddRef();
337             *ppv = reinterpret_cast<LPVOID>(this);
338             return NOERROR;
339         }
340         // behaves as a standalone object
341         return E_NOINTERFACE;
342     };
343
344     STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
345     STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
346
347     // IDispatch methods
348     STDMETHODIMP GetTypeInfoCount(UINT*);
349     STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
350     STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
351     STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
352
353     // IVLCLog methods
354     STDMETHODIMP get_messages(IVLCMessages**);
355     STDMETHODIMP get_verbosity(long *);
356     STDMETHODIMP put_verbosity(long);
357     
358 protected:
359     HRESULT loadTypeInfo();
360
361     libvlc_log_t    *_p_log;
362
363 private:
364     VLCPlugin*      _p_instance;
365     ITypeInfo*      _p_typeinfo;
366
367     VLCMessages*    _p_vlcmessages;
368 };
369  
370 class VLCPlaylist : public IVLCPlaylist
371 {
372 public:
373     VLCPlaylist(VLCPlugin *p_instance) :
374         _p_instance(p_instance), _p_typeinfo(NULL) {};
375     virtual ~VLCPlaylist();
376
377     // IUnknown methods
378     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
379     {
380         if( NULL == ppv )
381           return E_POINTER;
382         if( (IID_IUnknown == riid)
383          || (IID_IDispatch == riid)
384          || (IID_IVLCPlaylist == riid) )
385         {
386             AddRef();
387             *ppv = reinterpret_cast<LPVOID>(this);
388             return NOERROR;
389         }
390         // behaves as a standalone object
391         return E_NOINTERFACE;
392     };
393
394     STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
395     STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
396
397     // IDispatch methods
398     STDMETHODIMP GetTypeInfoCount(UINT*);
399     STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
400     STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
401     STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
402
403     // IVLCPlaylist methods
404     STDMETHODIMP get_itemCount(long*);
405     STDMETHODIMP get_isPlaying(VARIANT_BOOL*);
406     STDMETHODIMP add(BSTR, VARIANT, VARIANT, long*);
407     STDMETHODIMP play();
408     STDMETHODIMP playItem(long);
409     STDMETHODIMP togglePause();
410     STDMETHODIMP stop();
411     STDMETHODIMP next();
412     STDMETHODIMP prev();
413     STDMETHODIMP clear();
414     STDMETHODIMP removeItem(long);
415  
416 protected:
417     HRESULT loadTypeInfo();
418
419 private:
420     VLCPlugin*  _p_instance;
421     ITypeInfo*  _p_typeinfo;
422
423 };
424  
425 class VLCVideo : public IVLCVideo
426 {
427 public:
428     VLCVideo(VLCPlugin *p_instance) :
429         _p_instance(p_instance), _p_typeinfo(NULL) {};
430     virtual ~VLCVideo();
431
432     // IUnknown methods
433     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
434     {
435         if( NULL == ppv )
436           return E_POINTER;
437         if( (IID_IUnknown == riid)
438          || (IID_IDispatch == riid)
439          || (IID_IVLCVideo == riid) )
440         {
441             AddRef();
442             *ppv = reinterpret_cast<LPVOID>(this);
443             return NOERROR;
444         }
445         // behaves as a standalone object
446         return E_NOINTERFACE;
447     };
448
449     STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
450     STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
451
452     // IDispatch methods
453     STDMETHODIMP GetTypeInfoCount(UINT*);
454     STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
455     STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
456     STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
457
458     // IVLCVideo methods
459     STDMETHODIMP get_fullscreen(VARIANT_BOOL*);
460     STDMETHODIMP put_fullscreen(VARIANT_BOOL);
461     STDMETHODIMP get_width(long*);
462     STDMETHODIMP get_height(long*);
463     STDMETHODIMP toggleFullscreen();
464  
465 protected:
466     HRESULT loadTypeInfo();
467
468 private:
469     VLCPlugin*      _p_instance;
470     ITypeInfo*      _p_typeinfo;
471
472 };
473  
474 class VLCControl2 : public IVLCControl2
475 {
476     
477 public:
478
479     VLCControl2(VLCPlugin *p_instance);
480     virtual ~VLCControl2();
481
482     // IUnknown methods
483     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
484     {
485         if( NULL == ppv )
486           return E_POINTER;
487         if( (IID_IUnknown == riid)
488          || (IID_IDispatch == riid)
489          || (IID_IVLCControl2 == riid) )
490         {
491             AddRef();
492             *ppv = reinterpret_cast<LPVOID>(this);
493             return NOERROR;
494         }
495         return _p_instance->pUnkOuter->QueryInterface(riid, ppv);
496     };
497
498     STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
499     STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
500
501     // IDispatch methods
502     STDMETHODIMP GetTypeInfoCount(UINT*);
503     STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
504     STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
505     STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
506
507     // IVLCControl2 methods
508     STDMETHODIMP get_AutoLoop(VARIANT_BOOL *autoloop);
509     STDMETHODIMP put_AutoLoop(VARIANT_BOOL autoloop);
510     STDMETHODIMP get_AutoPlay(VARIANT_BOOL *autoplay);
511     STDMETHODIMP put_AutoPlay(VARIANT_BOOL autoplay);
512     STDMETHODIMP get_BaseURL(BSTR *url);
513     STDMETHODIMP put_BaseURL(BSTR url);
514     STDMETHODIMP get_MRL(BSTR *mrl);
515     STDMETHODIMP put_MRL(BSTR mrl);
516     STDMETHODIMP get_StartTime(long *seconds);
517     STDMETHODIMP put_StartTime(long seconds);
518     STDMETHODIMP get_VersionInfo(BSTR *version);
519     STDMETHODIMP get_Visible(VARIANT_BOOL *visible);
520     STDMETHODIMP put_Visible(VARIANT_BOOL visible);
521     STDMETHODIMP get_Volume(long *volume);
522     STDMETHODIMP put_Volume(long volume);
523
524     STDMETHODIMP get_audio(IVLCAudio**);
525     STDMETHODIMP get_input(IVLCInput**);
526     STDMETHODIMP get_log(IVLCLog**);
527     STDMETHODIMP get_playlist(IVLCPlaylist**);
528     STDMETHODIMP get_video(IVLCVideo**);
529
530 protected:
531     HRESULT loadTypeInfo();
532
533 private:
534     VLCPlugin*      _p_instance;
535     ITypeInfo*      _p_typeinfo;
536
537     VLCAudio*       _p_vlcaudio;
538     VLCInput*       _p_vlcinput;
539     VLCLog  *       _p_vlclog;
540     VLCPlaylist*    _p_vlcplaylist;
541     VLCVideo*       _p_vlcvideo;
542 };
543  
544 #endif
545