- added support for returning custom error messages from libvlc exception messages
[vlc.git] / activex / vlccontrol2.cpp
1 /*****************************************************************************
2  * vlccontrol2.cpp: 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 #include "plugin.h"
24 #include "vlccontrol2.h"
25 #include "vlccontrol.h"
26
27 #include "utils.h"
28
29 using namespace std;
30
31 VLCAudio::~VLCAudio()
32 {
33     if( _p_typeinfo )
34         _p_typeinfo->Release();
35 };
36
37 HRESULT VLCAudio::loadTypeInfo(void)
38 {
39     HRESULT hr = NOERROR;
40     if( NULL == _p_typeinfo )
41     {
42         ITypeLib *p_typelib;
43
44         hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
45         if( SUCCEEDED(hr) )
46         {
47             hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCAudio, &_p_typeinfo);
48             if( FAILED(hr) )
49             {
50                 _p_typeinfo = NULL;
51             }
52             p_typelib->Release();
53         }
54     }
55     return hr;
56 };
57
58 STDMETHODIMP VLCAudio::GetTypeInfoCount(UINT* pctInfo)
59 {
60     if( NULL == pctInfo )
61         return E_INVALIDARG;
62
63     if( SUCCEEDED(loadTypeInfo()) )
64         *pctInfo = 1;
65     else
66         *pctInfo = 0;
67
68     return NOERROR;
69 };
70
71 STDMETHODIMP VLCAudio::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
72 {
73     if( NULL == ppTInfo )
74         return E_INVALIDARG;
75
76     if( SUCCEEDED(loadTypeInfo()) )
77     {
78         _p_typeinfo->AddRef();
79         *ppTInfo = _p_typeinfo;
80         return NOERROR;
81     }
82     *ppTInfo = NULL;
83     return E_NOTIMPL;
84 };
85
86 STDMETHODIMP VLCAudio::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, 
87         UINT cNames, LCID lcid, DISPID* rgDispID)
88 {
89     if( SUCCEEDED(loadTypeInfo()) )
90     {
91         return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
92     }
93     return E_NOTIMPL;
94 };
95
96 STDMETHODIMP VLCAudio::Invoke(DISPID dispIdMember, REFIID riid,
97         LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
98         VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
99 {
100     if( SUCCEEDED(loadTypeInfo()) )
101     {
102         return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
103                 pVarResult, pExcepInfo, puArgErr);
104     }
105     return E_NOTIMPL;
106 };
107
108 STDMETHODIMP VLCAudio::get_mute(VARIANT_BOOL* mute)
109 {
110     if( NULL == mute )
111         return E_POINTER;
112
113     libvlc_instance_t* p_libvlc;
114     HRESULT hr = _p_instance->getVLC(&p_libvlc);
115     if( SUCCEEDED(hr) )
116     {
117         libvlc_exception_t ex;
118         libvlc_exception_init(&ex);
119
120         *mute = libvlc_audio_get_mute(p_libvlc, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
121         if( libvlc_exception_raised(&ex) )
122         {
123             _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
124             libvlc_exception_clear(&ex);
125             return E_FAIL;
126         }
127         return NOERROR;
128     }
129     return hr;
130 };
131
132 STDMETHODIMP VLCAudio::put_mute(VARIANT_BOOL mute)
133 {
134     libvlc_instance_t* p_libvlc;
135     HRESULT hr = _p_instance->getVLC(&p_libvlc);
136     if( SUCCEEDED(hr) )
137     {
138         libvlc_exception_t ex;
139         libvlc_exception_init(&ex);
140
141         libvlc_audio_set_mute(p_libvlc, VARIANT_FALSE != mute, &ex);
142         if( libvlc_exception_raised(&ex) )
143         {
144             _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
145             libvlc_exception_clear(&ex);
146             return E_FAIL;
147         }
148         return NOERROR;
149     }
150     return hr;
151 };
152
153 STDMETHODIMP VLCAudio::get_volume(int* volume)
154 {
155     if( NULL == volume )
156         return E_POINTER;
157
158     libvlc_instance_t* p_libvlc;
159     HRESULT hr = _p_instance->getVLC(&p_libvlc);
160     if( SUCCEEDED(hr) )
161     {
162         libvlc_exception_t ex;
163         libvlc_exception_init(&ex);
164
165         *volume = libvlc_audio_get_volume(p_libvlc, &ex);
166         if( libvlc_exception_raised(&ex) )
167         {
168             _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
169             libvlc_exception_clear(&ex);
170             return E_FAIL;
171         }
172         return NOERROR;
173     }
174     return hr;
175 };
176
177 STDMETHODIMP VLCAudio::put_volume(int volume)
178 {
179     libvlc_instance_t* p_libvlc;
180     HRESULT hr = _p_instance->getVLC(&p_libvlc);
181     if( SUCCEEDED(hr) )
182     {
183         libvlc_exception_t ex;
184         libvlc_exception_init(&ex);
185
186         libvlc_audio_set_volume(p_libvlc, volume, &ex);
187         if( libvlc_exception_raised(&ex) )
188         {
189             _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
190             libvlc_exception_clear(&ex);
191             return E_FAIL;
192         }
193         return NOERROR;
194     }
195     return hr;
196 };
197
198 STDMETHODIMP VLCAudio::toggleMute()
199 {
200     libvlc_instance_t* p_libvlc;
201     HRESULT hr = _p_instance->getVLC(&p_libvlc);
202     if( SUCCEEDED(hr) )
203     {
204         libvlc_exception_t ex;
205         libvlc_exception_init(&ex);
206
207         libvlc_audio_toggle_mute(p_libvlc, &ex);
208         if( libvlc_exception_raised(&ex) )
209         {
210             _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
211             libvlc_exception_clear(&ex);
212             return E_FAIL;
213         }
214         return NOERROR;
215     }
216     return hr;
217 };
218
219 /*******************************************************************************/
220
221 VLCInput::~VLCInput()
222 {
223     if( _p_typeinfo )
224         _p_typeinfo->Release();
225 };
226
227 HRESULT VLCInput::loadTypeInfo(void)
228 {
229     HRESULT hr = NOERROR;
230     if( NULL == _p_typeinfo )
231     {
232         ITypeLib *p_typelib;
233
234         hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
235         if( SUCCEEDED(hr) )
236         {
237             hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCInput, &_p_typeinfo);
238             if( FAILED(hr) )
239             {
240                 _p_typeinfo = NULL;
241             }
242             p_typelib->Release();
243         }
244     }
245     return hr;
246 };
247
248 STDMETHODIMP VLCInput::GetTypeInfoCount(UINT* pctInfo)
249 {
250     if( NULL == pctInfo )
251         return E_INVALIDARG;
252
253     if( SUCCEEDED(loadTypeInfo()) )
254         *pctInfo = 1;
255     else
256         *pctInfo = 0;
257
258     return NOERROR;
259 };
260
261 STDMETHODIMP VLCInput::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
262 {
263     if( NULL == ppTInfo )
264         return E_INVALIDARG;
265
266     if( SUCCEEDED(loadTypeInfo()) )
267     {
268         _p_typeinfo->AddRef();
269         *ppTInfo = _p_typeinfo;
270         return NOERROR;
271     }
272     *ppTInfo = NULL;
273     return E_NOTIMPL;
274 };
275
276 STDMETHODIMP VLCInput::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, 
277         UINT cNames, LCID lcid, DISPID* rgDispID)
278 {
279     if( SUCCEEDED(loadTypeInfo()) )
280     {
281         return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
282     }
283     return E_NOTIMPL;
284 };
285
286 STDMETHODIMP VLCInput::Invoke(DISPID dispIdMember, REFIID riid,
287         LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
288         VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
289 {
290     if( SUCCEEDED(loadTypeInfo()) )
291     {
292         return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
293                 pVarResult, pExcepInfo, puArgErr);
294     }
295     return E_NOTIMPL;
296 };
297
298 STDMETHODIMP VLCInput::get_length(double* length)
299 {
300     if( NULL == length )
301         return E_POINTER;
302
303     libvlc_instance_t* p_libvlc;
304     HRESULT hr = _p_instance->getVLC(&p_libvlc);
305     if( SUCCEEDED(hr) )
306     {
307         libvlc_exception_t ex;
308         libvlc_exception_init(&ex);
309
310         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
311         if( ! libvlc_exception_raised(&ex) )
312         {
313             *length = (double)libvlc_input_get_length(p_input, &ex);
314             libvlc_input_free(p_input);
315             if( ! libvlc_exception_raised(&ex) )
316             {
317                 return NOERROR;
318             }
319         }
320         _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
321         libvlc_exception_clear(&ex);
322         return E_FAIL;
323     }
324     return hr;
325 };
326
327 STDMETHODIMP VLCInput::get_position(float* position)
328 {
329     if( NULL == position )
330         return E_POINTER;
331
332     libvlc_instance_t* p_libvlc;
333     HRESULT hr = _p_instance->getVLC(&p_libvlc);
334     if( SUCCEEDED(hr) )
335     {
336         libvlc_exception_t ex;
337         libvlc_exception_init(&ex);
338
339         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
340         if( ! libvlc_exception_raised(&ex) )
341         {
342             *position = libvlc_input_get_position(p_input, &ex);
343             libvlc_input_free(p_input);
344             if( ! libvlc_exception_raised(&ex) )
345             {
346                 return NOERROR;
347             }
348         }
349         _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
350         libvlc_exception_clear(&ex);
351         return E_FAIL;
352     }
353     return hr;
354 };
355
356 STDMETHODIMP VLCInput::put_position(float position)
357 {
358     libvlc_instance_t* p_libvlc;
359     HRESULT hr = _p_instance->getVLC(&p_libvlc);
360     if( SUCCEEDED(hr) )
361     {
362         libvlc_exception_t ex;
363         libvlc_exception_init(&ex);
364
365         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
366         if( ! libvlc_exception_raised(&ex) )
367         {
368             libvlc_input_set_position(p_input, position, &ex);
369             libvlc_input_free(p_input);
370             if( ! libvlc_exception_raised(&ex) )
371             {
372                 return NOERROR;
373             }
374         }
375         _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
376         libvlc_exception_clear(&ex);
377         return E_FAIL;
378     }
379     return hr;
380 };
381
382 STDMETHODIMP VLCInput::get_time(double* time)
383 {
384     if( NULL == time )
385         return E_POINTER;
386
387     libvlc_instance_t* p_libvlc;
388     HRESULT hr = _p_instance->getVLC(&p_libvlc);
389     if( SUCCEEDED(hr) )
390     {
391         libvlc_exception_t ex;
392         libvlc_exception_init(&ex);
393
394         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
395         if( ! libvlc_exception_raised(&ex) )
396         {
397             *time = (double)libvlc_input_get_time(p_input, &ex);
398             libvlc_input_free(p_input);
399             if( ! libvlc_exception_raised(&ex) )
400             {
401                 return NOERROR;
402             }
403         }
404         _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
405         libvlc_exception_clear(&ex);
406         return E_FAIL;
407     }
408     return hr;
409 };
410
411 STDMETHODIMP VLCInput::put_time(double time)
412 {
413     libvlc_instance_t* p_libvlc;
414     HRESULT hr = _p_instance->getVLC(&p_libvlc);
415     if( SUCCEEDED(hr) )
416     {
417         libvlc_exception_t ex;
418         libvlc_exception_init(&ex);
419
420         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
421         if( ! libvlc_exception_raised(&ex) )
422         {
423             libvlc_input_set_time(p_input, (vlc_int64_t)time, &ex);
424             libvlc_input_free(p_input);
425             if( ! libvlc_exception_raised(&ex) )
426             {
427                 return NOERROR;
428             }
429         }
430         _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
431         libvlc_exception_clear(&ex);
432         return E_FAIL;
433     }
434     return hr;
435 };
436
437 STDMETHODIMP VLCInput::get_state(int* state)
438 {
439     if( NULL == state )
440         return E_POINTER;
441
442     libvlc_instance_t* p_libvlc;
443     HRESULT hr = _p_instance->getVLC(&p_libvlc);
444     if( SUCCEEDED(hr) )
445     {
446         libvlc_exception_t ex;
447         libvlc_exception_init(&ex);
448
449         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
450         if( ! libvlc_exception_raised(&ex) )
451         {
452             *state = libvlc_input_get_state(p_input, &ex);
453             libvlc_input_free(p_input);
454             if( ! libvlc_exception_raised(&ex) )
455             {
456                 return NOERROR;
457             }
458         }
459         libvlc_exception_clear(&ex);
460         // don't fail, just return the idle state
461         *state = 0;
462         return NOERROR;
463     }
464     return hr;
465 };
466
467 STDMETHODIMP VLCInput::get_rate(float* rate)
468 {
469     if( NULL == rate )
470         return E_POINTER;
471
472     libvlc_instance_t* p_libvlc;
473     HRESULT hr = _p_instance->getVLC(&p_libvlc);
474     if( SUCCEEDED(hr) )
475     {
476         libvlc_exception_t ex;
477         libvlc_exception_init(&ex);
478
479         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
480         if( ! libvlc_exception_raised(&ex) )
481         {
482             *rate = libvlc_input_get_rate(p_input, &ex);
483             libvlc_input_free(p_input);
484             if( ! libvlc_exception_raised(&ex) )
485             {
486                 return NOERROR;
487             }
488         }
489         _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
490         libvlc_exception_clear(&ex);
491         return E_FAIL;
492     }
493     return hr;
494 };
495
496 STDMETHODIMP VLCInput::put_rate(float rate)
497 {
498     libvlc_instance_t* p_libvlc;
499     HRESULT hr = _p_instance->getVLC(&p_libvlc);
500     if( SUCCEEDED(hr) )
501     {
502         libvlc_exception_t ex;
503         libvlc_exception_init(&ex);
504
505         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
506         if( ! libvlc_exception_raised(&ex) )
507         {
508             libvlc_input_set_rate(p_input, rate, &ex);
509             libvlc_input_free(p_input);
510             if( ! libvlc_exception_raised(&ex) )
511             {
512                 return NOERROR;
513             }
514         }
515         _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
516         libvlc_exception_clear(&ex);
517         return E_FAIL;
518     }
519     return hr;
520 };
521
522 STDMETHODIMP VLCInput::get_fps(float* fps)
523 {
524     if( NULL == fps )
525         return E_POINTER;
526
527     libvlc_instance_t* p_libvlc;
528     HRESULT hr = _p_instance->getVLC(&p_libvlc);
529     if( SUCCEEDED(hr) )
530     {
531         libvlc_exception_t ex;
532         libvlc_exception_init(&ex);
533
534         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
535         if( ! libvlc_exception_raised(&ex) )
536         {
537             *fps = libvlc_input_get_fps(p_input, &ex);
538             libvlc_input_free(p_input);
539             if( ! libvlc_exception_raised(&ex) )
540             {
541                 return NOERROR;
542             }
543         }
544         _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
545         libvlc_exception_clear(&ex);
546         return E_FAIL;
547     }
548     return hr;
549 };
550
551 STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
552 {
553     if( NULL == hasVout )
554         return E_POINTER;
555
556     libvlc_instance_t* p_libvlc;
557     HRESULT hr = _p_instance->getVLC(&p_libvlc);
558     if( SUCCEEDED(hr) )
559     {
560         libvlc_exception_t ex;
561         libvlc_exception_init(&ex);
562
563         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
564         if( ! libvlc_exception_raised(&ex) )
565         {
566             *hasVout = libvlc_input_has_vout(p_input, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
567             libvlc_input_free(p_input);
568             if( ! libvlc_exception_raised(&ex) )
569             {
570                 return NOERROR;
571             }
572         }
573         _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
574         libvlc_exception_clear(&ex);
575         return E_FAIL;
576     }
577     return hr;
578 };
579
580 /*******************************************************************************/
581
582 VLCPlaylist::~VLCPlaylist()
583 {
584     if( _p_typeinfo )
585         _p_typeinfo->Release();
586 };
587
588 HRESULT VLCPlaylist::loadTypeInfo(void)
589 {
590     HRESULT hr = NOERROR;
591     if( NULL == _p_typeinfo )
592     {
593         ITypeLib *p_typelib;
594
595         hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
596         if( SUCCEEDED(hr) )
597         {
598             hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCPlaylist, &_p_typeinfo);
599             if( FAILED(hr) )
600             {
601                 _p_typeinfo = NULL;
602             }
603             p_typelib->Release();
604         }
605     }
606     return hr;
607 };
608
609 STDMETHODIMP VLCPlaylist::GetTypeInfoCount(UINT* pctInfo)
610 {
611     if( NULL == pctInfo )
612         return E_INVALIDARG;
613
614     if( SUCCEEDED(loadTypeInfo()) )
615         *pctInfo = 1;
616     else
617         *pctInfo = 0;
618
619     return NOERROR;
620 };
621
622 STDMETHODIMP VLCPlaylist::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
623 {
624     if( NULL == ppTInfo )
625         return E_INVALIDARG;
626
627     if( SUCCEEDED(loadTypeInfo()) )
628     {
629         _p_typeinfo->AddRef();
630         *ppTInfo = _p_typeinfo;
631         return NOERROR;
632     }
633     *ppTInfo = NULL;
634     return E_NOTIMPL;
635 };
636
637 STDMETHODIMP VLCPlaylist::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, 
638         UINT cNames, LCID lcid, DISPID* rgDispID)
639 {
640     if( SUCCEEDED(loadTypeInfo()) )
641     {
642         return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
643     }
644     return E_NOTIMPL;
645 };
646
647 STDMETHODIMP VLCPlaylist::Invoke(DISPID dispIdMember, REFIID riid,
648         LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
649         VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
650 {
651     if( SUCCEEDED(loadTypeInfo()) )
652     {
653         return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
654                 pVarResult, pExcepInfo, puArgErr);
655     }
656     return E_NOTIMPL;
657 };
658
659 STDMETHODIMP VLCPlaylist::get_itemCount(int* count)
660 {
661     if( NULL == count )
662         return E_POINTER;
663
664     libvlc_instance_t* p_libvlc;
665     HRESULT hr = _p_instance->getVLC(&p_libvlc);
666     if( SUCCEEDED(hr) )
667     {
668         libvlc_exception_t ex;
669         libvlc_exception_init(&ex);
670
671         *count = libvlc_playlist_items_count(p_libvlc, &ex);
672         if( libvlc_exception_raised(&ex) )
673         {
674             _p_instance->setErrorInfo(IID_IVLCPlaylist,
675                 libvlc_exception_get_message(&ex));
676             libvlc_exception_clear(&ex);
677             return E_FAIL;
678         }
679         return NOERROR;
680     }
681     return hr;
682 };
683
684 STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
685 {
686     if( NULL == isPlaying )
687         return E_POINTER;
688
689     libvlc_instance_t* p_libvlc;
690     HRESULT hr = _p_instance->getVLC(&p_libvlc);
691     if( SUCCEEDED(hr) )
692     {
693         libvlc_exception_t ex;
694         libvlc_exception_init(&ex);
695
696         *isPlaying = libvlc_playlist_isplaying(p_libvlc, &ex) ? VARIANT_TRUE: VARIANT_FALSE;
697         if( libvlc_exception_raised(&ex) )
698         {
699             _p_instance->setErrorInfo(IID_IVLCPlaylist,
700                 libvlc_exception_get_message(&ex));
701             libvlc_exception_clear(&ex);
702             return E_FAIL;
703         }
704         return NOERROR;
705     }
706     return hr;
707 };
708
709 STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, int* item)
710 {
711     if( NULL == item )
712         return E_POINTER;
713
714     if( 0 == SysStringLen(uri) )
715         return E_INVALIDARG;
716
717     libvlc_instance_t* p_libvlc;
718     HRESULT hr = _p_instance->getVLC(&p_libvlc);
719     if( SUCCEEDED(hr) )
720     {
721         libvlc_exception_t ex;
722         libvlc_exception_init(&ex);
723
724         int i_options;
725         char **ppsz_options;
726
727         hr = VLCControl::CreateTargetOptions(CP_UTF8, &options, &ppsz_options, &i_options);
728         if( FAILED(hr) )
729             return hr;
730
731         char *psz_uri = CStrFromBSTR(CP_UTF8, uri);
732         if( NULL == psz_uri )
733         {
734             VLCControl::FreeTargetOptions(ppsz_options, i_options);
735             return E_OUTOFMEMORY;
736         }
737
738         char *psz_name = NULL;
739         VARIANT v_name;
740         VariantInit(&v_name);
741         if( SUCCEEDED(VariantChangeType(&v_name, &name, 0, VT_BSTR)) )
742         {
743             if( SysStringLen(V_BSTR(&v_name)) > 0 )
744                 psz_name = CStrFromBSTR(CP_UTF8, V_BSTR(&v_name));
745
746             VariantClear(&v_name);
747         }
748
749         *item = libvlc_playlist_add_extended(p_libvlc,
750             psz_uri,
751             psz_name,
752             i_options,
753             const_cast<const char **>(ppsz_options),
754             &ex);
755
756         VLCControl::FreeTargetOptions(ppsz_options, i_options);
757         CoTaskMemFree(psz_uri);
758         if( psz_name )
759             CoTaskMemFree(psz_name);
760         if( libvlc_exception_raised(&ex) )
761         {
762             _p_instance->setErrorInfo(IID_IVLCPlaylist,
763                 libvlc_exception_get_message(&ex));
764             libvlc_exception_clear(&ex);
765             return E_FAIL;
766         }
767         return NOERROR;
768     }
769     return hr;
770 };
771
772 STDMETHODIMP VLCPlaylist::play()
773 {
774     libvlc_instance_t* p_libvlc;
775     HRESULT hr = _p_instance->getVLC(&p_libvlc);
776     if( SUCCEEDED(hr) )
777     {
778         libvlc_exception_t ex;
779         libvlc_exception_init(&ex);
780
781         libvlc_playlist_play(p_libvlc, -1, 0, NULL, &ex);
782         if( libvlc_exception_raised(&ex) )
783         {
784             libvlc_exception_clear(&ex);
785             return E_FAIL;
786         }
787         return NOERROR;
788     }
789     return hr;
790 };
791
792 STDMETHODIMP VLCPlaylist::playItem(int item)
793 {
794     libvlc_instance_t* p_libvlc;
795     HRESULT hr = _p_instance->getVLC(&p_libvlc);
796     if( SUCCEEDED(hr) )
797     {
798         libvlc_exception_t ex;
799         libvlc_exception_init(&ex);
800
801         libvlc_playlist_play(p_libvlc, item, 0, NULL, &ex);
802         if( libvlc_exception_raised(&ex) )
803         {
804             _p_instance->setErrorInfo(IID_IVLCPlaylist,
805                 libvlc_exception_get_message(&ex));
806             libvlc_exception_clear(&ex);
807             return E_FAIL;
808         }
809         return NOERROR;
810     }
811     return hr;
812 };
813
814 STDMETHODIMP VLCPlaylist::togglePause()
815 {
816     libvlc_instance_t* p_libvlc;
817     HRESULT hr = _p_instance->getVLC(&p_libvlc);
818     if( SUCCEEDED(hr) )
819     {
820         libvlc_exception_t ex;
821         libvlc_exception_init(&ex);
822
823         libvlc_playlist_pause(p_libvlc, &ex);
824         if( libvlc_exception_raised(&ex) )
825         {
826             _p_instance->setErrorInfo(IID_IVLCPlaylist,
827                 libvlc_exception_get_message(&ex));
828             libvlc_exception_clear(&ex);
829             return E_FAIL;
830         }
831         return NOERROR;
832     }
833     return hr;
834 };
835
836 STDMETHODIMP VLCPlaylist::stop()
837 {
838     libvlc_instance_t* p_libvlc;
839     HRESULT hr = _p_instance->getVLC(&p_libvlc);
840     if( SUCCEEDED(hr) )
841     {
842         libvlc_exception_t ex;
843         libvlc_exception_init(&ex);
844
845         libvlc_playlist_stop(p_libvlc, &ex);
846         if( libvlc_exception_raised(&ex) )
847         {
848             _p_instance->setErrorInfo(IID_IVLCPlaylist,
849                 libvlc_exception_get_message(&ex));
850             libvlc_exception_clear(&ex);
851             return E_FAIL;
852         }
853         return NOERROR;
854     }
855     return hr;
856 };
857
858 STDMETHODIMP VLCPlaylist::next()
859 {
860     libvlc_instance_t* p_libvlc;
861     HRESULT hr = _p_instance->getVLC(&p_libvlc);
862     if( SUCCEEDED(hr) )
863     {
864         libvlc_exception_t ex;
865         libvlc_exception_init(&ex);
866
867         libvlc_playlist_next(p_libvlc, &ex);
868         if( libvlc_exception_raised(&ex) )
869         {
870             _p_instance->setErrorInfo(IID_IVLCPlaylist,
871                 libvlc_exception_get_message(&ex));
872             libvlc_exception_clear(&ex);
873             return E_FAIL;
874         }
875         return NOERROR;
876     }
877     return hr;
878 };
879
880 STDMETHODIMP VLCPlaylist::prev()
881 {
882     libvlc_instance_t* p_libvlc;
883     HRESULT hr = _p_instance->getVLC(&p_libvlc);
884     if( SUCCEEDED(hr) )
885     {
886         libvlc_exception_t ex;
887         libvlc_exception_init(&ex);
888
889         libvlc_playlist_prev(p_libvlc, &ex);
890         if( libvlc_exception_raised(&ex) )
891         {
892             _p_instance->setErrorInfo(IID_IVLCPlaylist,
893                 libvlc_exception_get_message(&ex));
894             libvlc_exception_clear(&ex);
895             return E_FAIL;
896         }
897         return NOERROR;
898     }
899     return hr;
900 };
901
902 STDMETHODIMP VLCPlaylist::clear()
903 {
904     libvlc_instance_t* p_libvlc;
905     HRESULT hr = _p_instance->getVLC(&p_libvlc);
906     if( SUCCEEDED(hr) )
907     {
908         libvlc_exception_t ex;
909         libvlc_exception_init(&ex);
910
911         libvlc_playlist_clear(p_libvlc, &ex);
912         if( libvlc_exception_raised(&ex) )
913         {
914             _p_instance->setErrorInfo(IID_IVLCPlaylist,
915                 libvlc_exception_get_message(&ex));
916             libvlc_exception_clear(&ex);
917             return E_FAIL;
918         }
919         return NOERROR;
920     }
921     return hr;
922 };
923
924 STDMETHODIMP VLCPlaylist::removeItem(int item)
925 {
926     libvlc_instance_t* p_libvlc;
927     HRESULT hr = _p_instance->getVLC(&p_libvlc);
928     if( SUCCEEDED(hr) )
929     {
930         libvlc_exception_t ex;
931         libvlc_exception_init(&ex);
932
933         libvlc_playlist_delete_item(p_libvlc, item, &ex);
934         if( libvlc_exception_raised(&ex) )
935         {
936             _p_instance->setErrorInfo(IID_IVLCPlaylist,
937                 libvlc_exception_get_message(&ex));
938             libvlc_exception_clear(&ex);
939             return E_FAIL;
940         }
941         return NOERROR;
942     }
943     return hr;
944 };
945
946 /*******************************************************************************/
947
948 VLCVideo::~VLCVideo()
949 {
950     if( _p_typeinfo )
951         _p_typeinfo->Release();
952 };
953
954 HRESULT VLCVideo::loadTypeInfo(void)
955 {
956     HRESULT hr = NOERROR;
957     if( NULL == _p_typeinfo )
958     {
959         ITypeLib *p_typelib;
960
961         hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
962         if( SUCCEEDED(hr) )
963         {
964             hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCVideo, &_p_typeinfo);
965             if( FAILED(hr) )
966             {
967                 _p_typeinfo = NULL;
968             }
969             p_typelib->Release();
970         }
971     }
972     return hr;
973 };
974
975 STDMETHODIMP VLCVideo::GetTypeInfoCount(UINT* pctInfo)
976 {
977     if( NULL == pctInfo )
978         return E_INVALIDARG;
979
980     if( SUCCEEDED(loadTypeInfo()) )
981         *pctInfo = 1;
982     else
983         *pctInfo = 0;
984
985     return NOERROR;
986 };
987
988 STDMETHODIMP VLCVideo::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
989 {
990     if( NULL == ppTInfo )
991         return E_INVALIDARG;
992
993     if( SUCCEEDED(loadTypeInfo()) )
994     {
995         _p_typeinfo->AddRef();
996         *ppTInfo = _p_typeinfo;
997         return NOERROR;
998     }
999     *ppTInfo = NULL;
1000     return E_NOTIMPL;
1001 };
1002
1003 STDMETHODIMP VLCVideo::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, 
1004         UINT cNames, LCID lcid, DISPID* rgDispID)
1005 {
1006     if( SUCCEEDED(loadTypeInfo()) )
1007     {
1008         return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1009     }
1010     return E_NOTIMPL;
1011 };
1012
1013 STDMETHODIMP VLCVideo::Invoke(DISPID dispIdMember, REFIID riid,
1014         LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1015         VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1016 {
1017     if( SUCCEEDED(loadTypeInfo()) )
1018     {
1019         return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1020                 pVarResult, pExcepInfo, puArgErr);
1021     }
1022     return E_NOTIMPL;
1023 };
1024
1025 STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
1026 {
1027     if( NULL == fullscreen )
1028         return E_POINTER;
1029
1030     libvlc_instance_t* p_libvlc;
1031     HRESULT hr = _p_instance->getVLC(&p_libvlc);
1032     if( SUCCEEDED(hr) )
1033     {
1034         libvlc_exception_t ex;
1035         libvlc_exception_init(&ex);
1036
1037         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
1038         if( ! libvlc_exception_raised(&ex) )
1039         {
1040             *fullscreen = libvlc_get_fullscreen(p_input, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
1041             libvlc_input_free(p_input);
1042             if( ! libvlc_exception_raised(&ex) )
1043             {
1044                 return NOERROR;
1045             }
1046         }
1047         _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
1048         libvlc_exception_clear(&ex);
1049         return E_FAIL;
1050     }
1051     return hr;
1052 };
1053
1054 STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen)
1055 {
1056     libvlc_instance_t* p_libvlc;
1057     HRESULT hr = _p_instance->getVLC(&p_libvlc);
1058     if( SUCCEEDED(hr) )
1059     {
1060         libvlc_exception_t ex;
1061         libvlc_exception_init(&ex);
1062
1063         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
1064         if( ! libvlc_exception_raised(&ex) )
1065         {
1066             libvlc_set_fullscreen(p_input, VARIANT_FALSE != fullscreen, &ex);
1067             libvlc_input_free(p_input);
1068             if( ! libvlc_exception_raised(&ex) )
1069             {
1070                 return NOERROR;
1071             }
1072         }
1073         _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
1074         libvlc_exception_clear(&ex);
1075         return E_FAIL;
1076     }
1077     return hr;
1078 };
1079
1080 STDMETHODIMP VLCVideo::get_width(int* width)
1081 {
1082     if( NULL == width )
1083         return E_POINTER;
1084
1085     libvlc_instance_t* p_libvlc;
1086     HRESULT hr = _p_instance->getVLC(&p_libvlc);
1087     if( SUCCEEDED(hr) )
1088     {
1089         libvlc_exception_t ex;
1090         libvlc_exception_init(&ex);
1091
1092         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
1093         if( ! libvlc_exception_raised(&ex) )
1094         {
1095             *width = libvlc_video_get_width(p_input, &ex);
1096             libvlc_input_free(p_input);
1097             if( ! libvlc_exception_raised(&ex) )
1098             {
1099                 return NOERROR;
1100             }
1101         }
1102         _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
1103         libvlc_exception_clear(&ex);
1104         return E_FAIL;
1105     }
1106     return hr;
1107 };
1108
1109 STDMETHODIMP VLCVideo::get_height(int* height)
1110 {
1111     if( NULL == height )
1112         return E_POINTER;
1113
1114     libvlc_instance_t* p_libvlc;
1115     HRESULT hr = _p_instance->getVLC(&p_libvlc);
1116     if( SUCCEEDED(hr) )
1117     {
1118         libvlc_exception_t ex;
1119         libvlc_exception_init(&ex);
1120
1121         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
1122         if( ! libvlc_exception_raised(&ex) )
1123         {
1124             *height = libvlc_video_get_height(p_input, &ex);
1125             libvlc_input_free(p_input);
1126             if( ! libvlc_exception_raised(&ex) )
1127             {
1128                 return NOERROR;
1129             }
1130         }
1131         _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
1132         libvlc_exception_clear(&ex);
1133         return E_FAIL;
1134     }
1135     return hr;
1136 };
1137
1138 STDMETHODIMP VLCVideo::toggleFullscreen()
1139 {
1140     libvlc_instance_t* p_libvlc;
1141     HRESULT hr = _p_instance->getVLC(&p_libvlc);
1142     if( SUCCEEDED(hr) )
1143     {
1144         libvlc_exception_t ex;
1145         libvlc_exception_init(&ex);
1146
1147         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
1148         if( ! libvlc_exception_raised(&ex) )
1149         {
1150             libvlc_toggle_fullscreen(p_input, &ex);
1151             libvlc_input_free(p_input);
1152             if( ! libvlc_exception_raised(&ex) )
1153             {
1154                 return NOERROR;
1155             }
1156         }
1157         _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
1158         libvlc_exception_clear(&ex);
1159         return E_FAIL;
1160     }
1161     return hr;
1162 };
1163
1164 /*******************************************************************************/
1165
1166 VLCControl2::VLCControl2(VLCPlugin *p_instance) :
1167     _p_instance(p_instance),
1168     _p_typeinfo(NULL),
1169     _p_vlcaudio(NULL),
1170     _p_vlcinput(NULL),
1171     _p_vlcplaylist(NULL),
1172     _p_vlcvideo(NULL)
1173 {
1174     _p_vlcaudio     = new VLCAudio(p_instance);
1175     _p_vlcinput     = new VLCInput(p_instance);
1176     _p_vlcplaylist  = new VLCPlaylist(p_instance);
1177     _p_vlcvideo     = new VLCVideo(p_instance);
1178 };
1179
1180 VLCControl2::~VLCControl2()
1181 {
1182     delete _p_vlcvideo;
1183     delete _p_vlcplaylist;
1184     delete _p_vlcinput;
1185     delete _p_vlcaudio;
1186     if( _p_typeinfo )
1187         _p_typeinfo->Release();
1188 };
1189
1190 HRESULT VLCControl2::loadTypeInfo(void)
1191 {
1192     HRESULT hr = NOERROR;
1193     if( NULL == _p_typeinfo )
1194     {
1195         ITypeLib *p_typelib;
1196
1197         hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1198         if( SUCCEEDED(hr) )
1199         {
1200             hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCControl2, &_p_typeinfo);
1201             if( FAILED(hr) )
1202             {
1203                 _p_typeinfo = NULL;
1204             }
1205             p_typelib->Release();
1206         }
1207     }
1208     return hr;
1209 };
1210
1211 STDMETHODIMP VLCControl2::GetTypeInfoCount(UINT* pctInfo)
1212 {
1213     if( NULL == pctInfo )
1214         return E_INVALIDARG;
1215
1216     if( SUCCEEDED(loadTypeInfo()) )
1217         *pctInfo = 1;
1218     else
1219         *pctInfo = 0;
1220
1221     return NOERROR;
1222 };
1223
1224 STDMETHODIMP VLCControl2::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1225 {
1226     if( NULL == ppTInfo )
1227         return E_INVALIDARG;
1228
1229     if( SUCCEEDED(loadTypeInfo()) )
1230     {
1231         _p_typeinfo->AddRef();
1232         *ppTInfo = _p_typeinfo;
1233         return NOERROR;
1234     }
1235     *ppTInfo = NULL;
1236     return E_NOTIMPL;
1237 };
1238
1239 STDMETHODIMP VLCControl2::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, 
1240         UINT cNames, LCID lcid, DISPID* rgDispID)
1241 {
1242     if( SUCCEEDED(loadTypeInfo()) )
1243     {
1244         return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1245     }
1246     return E_NOTIMPL;
1247 };
1248
1249 STDMETHODIMP VLCControl2::Invoke(DISPID dispIdMember, REFIID riid,
1250         LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1251         VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1252 {
1253     if( SUCCEEDED(loadTypeInfo()) )
1254     {
1255         return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1256                 pVarResult, pExcepInfo, puArgErr);
1257     }
1258     return E_NOTIMPL;
1259 };
1260
1261 STDMETHODIMP VLCControl2::get_AutoLoop(VARIANT_BOOL *autoloop)
1262 {
1263     if( NULL == autoloop )
1264         return E_POINTER;
1265
1266     *autoloop = _p_instance->getAutoLoop() ? VARIANT_TRUE: VARIANT_FALSE;
1267     return S_OK;
1268 };
1269
1270 STDMETHODIMP VLCControl2::put_AutoLoop(VARIANT_BOOL autoloop)
1271 {
1272     _p_instance->setAutoLoop((VARIANT_FALSE != autoloop) ? TRUE: FALSE);
1273     return S_OK;
1274 };
1275
1276 STDMETHODIMP VLCControl2::get_AutoPlay(VARIANT_BOOL *autoplay)
1277 {
1278     if( NULL == autoplay )
1279         return E_POINTER;
1280
1281     *autoplay = _p_instance->getAutoPlay() ? VARIANT_TRUE: VARIANT_FALSE;
1282     return S_OK;
1283 };
1284
1285 STDMETHODIMP VLCControl2::put_AutoPlay(VARIANT_BOOL autoplay)
1286 {
1287     _p_instance->setAutoPlay((VARIANT_FALSE != autoplay) ? TRUE: FALSE);
1288     return S_OK;
1289 };
1290
1291 STDMETHODIMP VLCControl2::get_BaseURL(BSTR *url)
1292 {
1293     if( NULL == url )
1294         return E_POINTER;
1295
1296     *url = SysAllocStringLen(_p_instance->getBaseURL(),
1297                 SysStringLen(_p_instance->getBaseURL()));
1298     return NOERROR;
1299 };
1300
1301 STDMETHODIMP VLCControl2::put_BaseURL(BSTR mrl)
1302 {
1303     _p_instance->setBaseURL(mrl);
1304
1305     return S_OK;
1306 };
1307
1308 STDMETHODIMP VLCControl2::get_MRL(BSTR *mrl)
1309 {
1310     if( NULL == mrl )
1311         return E_POINTER;
1312
1313     *mrl = SysAllocStringLen(_p_instance->getMRL(),
1314                 SysStringLen(_p_instance->getMRL()));
1315     return NOERROR;
1316 };
1317
1318 STDMETHODIMP VLCControl2::put_MRL(BSTR mrl)
1319 {
1320     _p_instance->setMRL(mrl);
1321
1322     return S_OK;
1323 };
1324
1325 STDMETHODIMP VLCControl2::get_StartTime(int *seconds)
1326 {
1327     if( NULL == seconds )
1328         return E_POINTER;
1329
1330     *seconds = _p_instance->getStartTime();
1331
1332     return S_OK;
1333 };
1334      
1335 STDMETHODIMP VLCControl2::put_StartTime(int seconds)
1336 {
1337     _p_instance->setStartTime(seconds);
1338
1339     return NOERROR;
1340 };
1341         
1342 STDMETHODIMP VLCControl2::get_VersionInfo(BSTR *version)
1343 {
1344     if( NULL == version )
1345         return E_POINTER;
1346
1347     const char *versionStr = VLC_Version();
1348     if( NULL != versionStr )
1349     {
1350         *version = BSTRFromCStr(_p_instance->getCodePage(), versionStr);
1351         
1352         return NULL == *version ? E_OUTOFMEMORY : NOERROR;
1353     }
1354     *version = NULL;
1355     return E_FAIL;
1356 };
1357  
1358 STDMETHODIMP VLCControl2::get_Visible(VARIANT_BOOL *isVisible)
1359 {
1360     if( NULL == isVisible )
1361         return E_POINTER;
1362
1363     *isVisible = _p_instance->getVisible() ? VARIANT_TRUE : VARIANT_FALSE;
1364
1365     return NOERROR;
1366 };
1367         
1368 STDMETHODIMP VLCControl2::put_Visible(VARIANT_BOOL isVisible)
1369 {
1370     _p_instance->setVisible(isVisible != VARIANT_FALSE);
1371
1372     return NOERROR;
1373 };
1374
1375 STDMETHODIMP VLCControl2::get_Volume(int *volume)
1376 {
1377     if( NULL == volume )
1378         return E_POINTER;
1379
1380     *volume  = _p_instance->getVolume();
1381     return NOERROR;
1382 };
1383         
1384 STDMETHODIMP VLCControl2::put_Volume(int volume)
1385 {
1386     _p_instance->setVolume(volume);
1387     return NOERROR;
1388 };
1389
1390 STDMETHODIMP VLCControl2::get_audio(IVLCAudio** obj)
1391 {
1392     if( NULL == obj )
1393         return E_POINTER;
1394
1395     *obj = _p_vlcaudio;
1396     if( NULL != _p_vlcaudio )
1397     {
1398         _p_vlcaudio->AddRef();
1399         return NOERROR;
1400     }
1401     return E_OUTOFMEMORY;
1402 };
1403
1404 STDMETHODIMP VLCControl2::get_input(IVLCInput** obj)
1405 {
1406     if( NULL == obj )
1407         return E_POINTER;
1408
1409     *obj = _p_vlcinput;
1410     if( NULL != _p_vlcinput )
1411     {
1412         _p_vlcinput->AddRef();
1413         return NOERROR;
1414     }
1415     return E_OUTOFMEMORY;
1416 };
1417
1418 STDMETHODIMP VLCControl2::get_playlist(IVLCPlaylist** obj)
1419 {
1420     if( NULL == obj )
1421         return E_POINTER;
1422
1423     *obj = _p_vlcplaylist;
1424     if( NULL != _p_vlcplaylist )
1425     {
1426         _p_vlcplaylist->AddRef();
1427         return NOERROR;
1428     }
1429     return E_OUTOFMEMORY;
1430 };
1431
1432 STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj)
1433 {
1434     if( NULL == obj )
1435         return E_POINTER;
1436
1437     *obj = _p_vlcvideo;
1438     if( NULL != _p_vlcvideo )
1439     {
1440         _p_vlcvideo->AddRef();
1441         return NOERROR;
1442     }
1443     return E_OUTOFMEMORY;
1444 };
1445