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