1 /*****************************************************************************
2 * vlccontrol2.cpp: ActiveX control for VLC
3 *****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
7 * Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
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.
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.
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 *****************************************************************************/
25 #include "vlccontrol2.h"
26 #include "vlccontrol.h"
38 _p_typeinfo->Release();
41 HRESULT VLCAudio::loadTypeInfo(void)
44 if( NULL == _p_typeinfo )
48 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
51 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCAudio, &_p_typeinfo);
62 STDMETHODIMP VLCAudio::GetTypeInfoCount(UINT* pctInfo)
67 if( SUCCEEDED(loadTypeInfo()) )
75 STDMETHODIMP VLCAudio::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
80 if( SUCCEEDED(loadTypeInfo()) )
82 _p_typeinfo->AddRef();
83 *ppTInfo = _p_typeinfo;
90 STDMETHODIMP VLCAudio::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
91 UINT cNames, LCID lcid, DISPID* rgDispID)
93 if( SUCCEEDED(loadTypeInfo()) )
95 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
100 STDMETHODIMP VLCAudio::Invoke(DISPID dispIdMember, REFIID riid,
101 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
102 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
104 if( SUCCEEDED(loadTypeInfo()) )
106 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
107 pVarResult, pExcepInfo, puArgErr);
112 STDMETHODIMP VLCAudio::get_mute(VARIANT_BOOL* mute)
117 libvlc_instance_t* p_libvlc;
118 HRESULT hr = _p_instance->getVLC(&p_libvlc);
121 libvlc_exception_t ex;
122 libvlc_exception_init(&ex);
124 *mute = libvlc_audio_get_mute(p_libvlc, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
125 if( libvlc_exception_raised(&ex) )
127 _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
128 libvlc_exception_clear(&ex);
136 STDMETHODIMP VLCAudio::put_mute(VARIANT_BOOL mute)
138 libvlc_instance_t* p_libvlc;
139 HRESULT hr = _p_instance->getVLC(&p_libvlc);
142 libvlc_exception_t ex;
143 libvlc_exception_init(&ex);
145 libvlc_audio_set_mute(p_libvlc, VARIANT_FALSE != mute, &ex);
146 if( libvlc_exception_raised(&ex) )
148 _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
149 libvlc_exception_clear(&ex);
157 STDMETHODIMP VLCAudio::get_volume(long* volume)
162 libvlc_instance_t* p_libvlc;
163 HRESULT hr = _p_instance->getVLC(&p_libvlc);
166 libvlc_exception_t ex;
167 libvlc_exception_init(&ex);
169 *volume = libvlc_audio_get_volume(p_libvlc, &ex);
170 if( libvlc_exception_raised(&ex) )
172 _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
173 libvlc_exception_clear(&ex);
181 STDMETHODIMP VLCAudio::put_volume(long volume)
183 libvlc_instance_t* p_libvlc;
184 HRESULT hr = _p_instance->getVLC(&p_libvlc);
187 libvlc_exception_t ex;
188 libvlc_exception_init(&ex);
190 libvlc_audio_set_volume(p_libvlc, volume, &ex);
191 if( libvlc_exception_raised(&ex) )
193 _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
194 libvlc_exception_clear(&ex);
202 STDMETHODIMP VLCAudio::get_track(long* track)
207 libvlc_instance_t* p_libvlc;
208 HRESULT hr = _p_instance->getVLC(&p_libvlc);
211 libvlc_exception_t ex;
212 libvlc_exception_init(&ex);
214 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
215 *track = libvlc_audio_get_track(p_input, &ex);
216 libvlc_input_free(p_input);
217 if( libvlc_exception_raised(&ex) )
219 _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
220 libvlc_exception_clear(&ex);
228 STDMETHODIMP VLCAudio::put_track(long track)
230 libvlc_instance_t* p_libvlc;
231 HRESULT hr = _p_instance->getVLC(&p_libvlc);
234 libvlc_exception_t ex;
235 libvlc_exception_init(&ex);
237 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
238 libvlc_audio_set_track(p_input, track, &ex);
239 libvlc_input_free(p_input);
240 if( libvlc_exception_raised(&ex) )
242 _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
243 libvlc_exception_clear(&ex);
251 STDMETHODIMP VLCAudio::get_channel(long *channel)
253 if( NULL == channel )
256 libvlc_instance_t* p_libvlc;
257 HRESULT hr = _p_instance->getVLC(&p_libvlc);
260 libvlc_exception_t ex;
261 libvlc_exception_init(&ex);
263 *channel = libvlc_audio_get_channel(p_libvlc, &ex);
264 if( libvlc_exception_raised(&ex) )
266 _p_instance->setErrorInfo(IID_IVLCAudio,
267 libvlc_exception_get_message(&ex));
268 libvlc_exception_clear(&ex);
276 STDMETHODIMP VLCAudio::put_channel(long channel)
278 libvlc_instance_t* p_libvlc;
279 HRESULT hr = _p_instance->getVLC(&p_libvlc);
282 libvlc_exception_t ex;
283 libvlc_exception_init(&ex);
285 libvlc_audio_set_channel(p_libvlc, channel, &ex);
286 if( libvlc_exception_raised(&ex) )
288 _p_instance->setErrorInfo(IID_IVLCAudio,
289 libvlc_exception_get_message(&ex));
290 libvlc_exception_clear(&ex);
298 STDMETHODIMP VLCAudio::toggleMute()
300 libvlc_instance_t* p_libvlc;
301 HRESULT hr = _p_instance->getVLC(&p_libvlc);
304 libvlc_exception_t ex;
305 libvlc_exception_init(&ex);
307 libvlc_audio_toggle_mute(p_libvlc, &ex);
308 if( libvlc_exception_raised(&ex) )
310 _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
311 libvlc_exception_clear(&ex);
319 /*******************************************************************************/
321 VLCInput::~VLCInput()
324 _p_typeinfo->Release();
327 HRESULT VLCInput::loadTypeInfo(void)
329 HRESULT hr = NOERROR;
330 if( NULL == _p_typeinfo )
334 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
337 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCInput, &_p_typeinfo);
342 p_typelib->Release();
348 STDMETHODIMP VLCInput::GetTypeInfoCount(UINT* pctInfo)
350 if( NULL == pctInfo )
353 if( SUCCEEDED(loadTypeInfo()) )
361 STDMETHODIMP VLCInput::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
363 if( NULL == ppTInfo )
366 if( SUCCEEDED(loadTypeInfo()) )
368 _p_typeinfo->AddRef();
369 *ppTInfo = _p_typeinfo;
376 STDMETHODIMP VLCInput::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
377 UINT cNames, LCID lcid, DISPID* rgDispID)
379 if( SUCCEEDED(loadTypeInfo()) )
381 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
386 STDMETHODIMP VLCInput::Invoke(DISPID dispIdMember, REFIID riid,
387 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
388 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
390 if( SUCCEEDED(loadTypeInfo()) )
392 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
393 pVarResult, pExcepInfo, puArgErr);
398 STDMETHODIMP VLCInput::get_length(double* length)
403 libvlc_instance_t* p_libvlc;
404 HRESULT hr = _p_instance->getVLC(&p_libvlc);
407 libvlc_exception_t ex;
408 libvlc_exception_init(&ex);
410 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
411 if( ! libvlc_exception_raised(&ex) )
413 *length = (double)libvlc_input_get_length(p_input, &ex);
414 libvlc_input_free(p_input);
415 if( ! libvlc_exception_raised(&ex) )
420 _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
421 libvlc_exception_clear(&ex);
427 STDMETHODIMP VLCInput::get_position(double* position)
429 if( NULL == position )
432 libvlc_instance_t* p_libvlc;
433 HRESULT hr = _p_instance->getVLC(&p_libvlc);
436 libvlc_exception_t ex;
437 libvlc_exception_init(&ex);
439 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
440 if( ! libvlc_exception_raised(&ex) )
442 *position = libvlc_input_get_position(p_input, &ex);
443 libvlc_input_free(p_input);
444 if( ! libvlc_exception_raised(&ex) )
449 _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
450 libvlc_exception_clear(&ex);
456 STDMETHODIMP VLCInput::put_position(double position)
458 libvlc_instance_t* p_libvlc;
459 HRESULT hr = _p_instance->getVLC(&p_libvlc);
462 libvlc_exception_t ex;
463 libvlc_exception_init(&ex);
465 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
466 if( ! libvlc_exception_raised(&ex) )
468 libvlc_input_set_position(p_input, position, &ex);
469 libvlc_input_free(p_input);
470 if( ! libvlc_exception_raised(&ex) )
475 _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
476 libvlc_exception_clear(&ex);
482 STDMETHODIMP VLCInput::get_time(double* time)
487 libvlc_instance_t* p_libvlc;
488 HRESULT hr = _p_instance->getVLC(&p_libvlc);
491 libvlc_exception_t ex;
492 libvlc_exception_init(&ex);
494 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
495 if( ! libvlc_exception_raised(&ex) )
497 *time = (double)libvlc_input_get_time(p_input, &ex);
498 libvlc_input_free(p_input);
499 if( ! libvlc_exception_raised(&ex) )
504 _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
505 libvlc_exception_clear(&ex);
511 STDMETHODIMP VLCInput::put_time(double time)
513 libvlc_instance_t* p_libvlc;
514 HRESULT hr = _p_instance->getVLC(&p_libvlc);
517 libvlc_exception_t ex;
518 libvlc_exception_init(&ex);
520 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
521 if( ! libvlc_exception_raised(&ex) )
523 libvlc_input_set_time(p_input, (vlc_int64_t)time, &ex);
524 libvlc_input_free(p_input);
525 if( ! libvlc_exception_raised(&ex) )
530 _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
531 libvlc_exception_clear(&ex);
537 STDMETHODIMP VLCInput::get_state(long* state)
542 libvlc_instance_t* p_libvlc;
543 HRESULT hr = _p_instance->getVLC(&p_libvlc);
546 libvlc_exception_t ex;
547 libvlc_exception_init(&ex);
549 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
550 if( ! libvlc_exception_raised(&ex) )
552 *state = libvlc_input_get_state(p_input, &ex);
553 libvlc_input_free(p_input);
554 if( ! libvlc_exception_raised(&ex) )
559 libvlc_exception_clear(&ex);
560 // don't fail, just return the idle state
567 STDMETHODIMP VLCInput::get_rate(double* rate)
572 libvlc_instance_t* p_libvlc;
573 HRESULT hr = _p_instance->getVLC(&p_libvlc);
576 libvlc_exception_t ex;
577 libvlc_exception_init(&ex);
579 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
580 if( ! libvlc_exception_raised(&ex) )
582 *rate = libvlc_input_get_rate(p_input, &ex);
583 libvlc_input_free(p_input);
584 if( ! libvlc_exception_raised(&ex) )
589 _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
590 libvlc_exception_clear(&ex);
596 STDMETHODIMP VLCInput::put_rate(double rate)
598 libvlc_instance_t* p_libvlc;
599 HRESULT hr = _p_instance->getVLC(&p_libvlc);
602 libvlc_exception_t ex;
603 libvlc_exception_init(&ex);
605 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
606 if( ! libvlc_exception_raised(&ex) )
608 libvlc_input_set_rate(p_input, rate, &ex);
609 libvlc_input_free(p_input);
610 if( ! libvlc_exception_raised(&ex) )
615 _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
616 libvlc_exception_clear(&ex);
622 STDMETHODIMP VLCInput::get_fps(double* fps)
627 libvlc_instance_t* p_libvlc;
628 HRESULT hr = _p_instance->getVLC(&p_libvlc);
631 libvlc_exception_t ex;
632 libvlc_exception_init(&ex);
634 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
635 if( ! libvlc_exception_raised(&ex) )
637 *fps = libvlc_input_get_fps(p_input, &ex);
638 libvlc_input_free(p_input);
639 if( ! libvlc_exception_raised(&ex) )
644 _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
645 libvlc_exception_clear(&ex);
651 STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
653 if( NULL == hasVout )
656 libvlc_instance_t* p_libvlc;
657 HRESULT hr = _p_instance->getVLC(&p_libvlc);
660 libvlc_exception_t ex;
661 libvlc_exception_init(&ex);
663 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
664 if( ! libvlc_exception_raised(&ex) )
666 *hasVout = libvlc_input_has_vout(p_input, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
667 libvlc_input_free(p_input);
668 if( ! libvlc_exception_raised(&ex) )
673 _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
674 libvlc_exception_clear(&ex);
680 /*******************************************************************************/
684 delete _p_vlcmessages;
686 libvlc_log_close(_p_log, NULL);
689 _p_typeinfo->Release();
692 HRESULT VLCLog::loadTypeInfo(void)
694 HRESULT hr = NOERROR;
695 if( NULL == _p_typeinfo )
699 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
702 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCLog, &_p_typeinfo);
707 p_typelib->Release();
713 STDMETHODIMP VLCLog::GetTypeInfoCount(UINT* pctInfo)
715 if( NULL == pctInfo )
718 if( SUCCEEDED(loadTypeInfo()) )
726 STDMETHODIMP VLCLog::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
728 if( NULL == ppTInfo )
731 if( SUCCEEDED(loadTypeInfo()) )
733 _p_typeinfo->AddRef();
734 *ppTInfo = _p_typeinfo;
741 STDMETHODIMP VLCLog::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
742 UINT cNames, LCID lcid, DISPID* rgDispID)
744 if( SUCCEEDED(loadTypeInfo()) )
746 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
751 STDMETHODIMP VLCLog::Invoke(DISPID dispIdMember, REFIID riid,
752 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
753 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
755 if( SUCCEEDED(loadTypeInfo()) )
757 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
758 pVarResult, pExcepInfo, puArgErr);
763 STDMETHODIMP VLCLog::get_messages(IVLCMessages** obj)
768 *obj = _p_vlcmessages;
769 if( NULL != _p_vlcmessages )
771 _p_vlcmessages->AddRef();
774 return E_OUTOFMEMORY;
777 STDMETHODIMP VLCLog::get_verbosity(long* level)
784 libvlc_instance_t* p_libvlc;
785 HRESULT hr = _p_instance->getVLC(&p_libvlc);
788 libvlc_exception_t ex;
789 libvlc_exception_init(&ex);
791 *level = libvlc_get_log_verbosity(p_libvlc, &ex);
792 if( libvlc_exception_raised(&ex) )
794 _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
795 libvlc_exception_clear(&ex);
803 /* log is not enabled, return -1 */
809 STDMETHODIMP VLCLog::put_verbosity(long verbosity)
811 libvlc_exception_t ex;
812 libvlc_exception_init(&ex);
814 libvlc_instance_t* p_libvlc;
815 HRESULT hr = _p_instance->getVLC(&p_libvlc);
822 _p_log = libvlc_log_open(p_libvlc, &ex);
823 if( libvlc_exception_raised(&ex) )
825 _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
826 libvlc_exception_clear(&ex);
830 libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
831 if( libvlc_exception_raised(&ex) )
833 _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
834 libvlc_exception_clear(&ex);
840 /* close log when verbosity is set to -1 */
841 libvlc_log_close(_p_log, &ex);
843 if( libvlc_exception_raised(&ex) )
845 _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
846 libvlc_exception_clear(&ex);
854 /*******************************************************************************/
856 VLCMessages::~VLCMessages()
859 _p_typeinfo->Release();
862 HRESULT VLCMessages::loadTypeInfo(void)
864 HRESULT hr = NOERROR;
865 if( NULL == _p_typeinfo )
869 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
872 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessages, &_p_typeinfo);
877 p_typelib->Release();
883 STDMETHODIMP VLCMessages::GetTypeInfoCount(UINT* pctInfo)
885 if( NULL == pctInfo )
888 if( SUCCEEDED(loadTypeInfo()) )
896 STDMETHODIMP VLCMessages::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
898 if( NULL == ppTInfo )
901 if( SUCCEEDED(loadTypeInfo()) )
903 _p_typeinfo->AddRef();
904 *ppTInfo = _p_typeinfo;
911 STDMETHODIMP VLCMessages::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
912 UINT cNames, LCID lcid, DISPID* rgDispID)
914 if( SUCCEEDED(loadTypeInfo()) )
916 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
921 STDMETHODIMP VLCMessages::Invoke(DISPID dispIdMember, REFIID riid,
922 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
923 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
925 if( SUCCEEDED(loadTypeInfo()) )
927 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
928 pVarResult, pExcepInfo, puArgErr);
933 STDMETHODIMP VLCMessages::get__NewEnum(LPUNKNOWN* _NewEnum)
935 if( NULL == _NewEnum )
943 STDMETHODIMP VLCMessages::clear()
945 libvlc_log_t *p_log = _p_vlclog->_p_log;
948 libvlc_exception_t ex;
949 libvlc_exception_init(&ex);
951 libvlc_log_clear(p_log, &ex);
952 if( libvlc_exception_raised(&ex) )
954 _p_instance->setErrorInfo(IID_IVLCMessages, libvlc_exception_get_message(&ex));
955 libvlc_exception_clear(&ex);
962 STDMETHODIMP VLCMessages::get_count(long* count)
967 libvlc_log_t *p_log = _p_vlclog->_p_log;
970 libvlc_exception_t ex;
971 libvlc_exception_init(&ex);
973 *count = libvlc_log_count(p_log, &ex);
974 if( libvlc_exception_raised(&ex) )
976 _p_instance->setErrorInfo(IID_IVLCMessages, libvlc_exception_get_message(&ex));
977 libvlc_exception_clear(&ex);
986 STDMETHODIMP VLCMessages::iterator(IVLCMessageIterator** iter)
991 *iter = new VLCMessageIterator(_p_instance, _p_vlclog);
993 return *iter ? S_OK : E_OUTOFMEMORY;
996 /*******************************************************************************/
998 VLCMessageIterator::VLCMessageIterator(VLCPlugin *p_instance, VLCLog* p_vlclog ) :
999 _p_instance(p_instance),
1004 if( p_vlclog->_p_log )
1006 _p_iter = libvlc_log_get_iterator(p_vlclog->_p_log, NULL);
1012 VLCMessageIterator::~VLCMessageIterator()
1015 libvlc_log_iterator_free(_p_iter, NULL);
1018 _p_typeinfo->Release();
1021 HRESULT VLCMessageIterator::loadTypeInfo(void)
1023 HRESULT hr = NOERROR;
1024 if( NULL == _p_typeinfo )
1026 ITypeLib *p_typelib;
1028 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1031 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessageIterator, &_p_typeinfo);
1036 p_typelib->Release();
1042 STDMETHODIMP VLCMessageIterator::GetTypeInfoCount(UINT* pctInfo)
1044 if( NULL == pctInfo )
1045 return E_INVALIDARG;
1047 if( SUCCEEDED(loadTypeInfo()) )
1055 STDMETHODIMP VLCMessageIterator::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1057 if( NULL == ppTInfo )
1058 return E_INVALIDARG;
1060 if( SUCCEEDED(loadTypeInfo()) )
1062 _p_typeinfo->AddRef();
1063 *ppTInfo = _p_typeinfo;
1070 STDMETHODIMP VLCMessageIterator::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1071 UINT cNames, LCID lcid, DISPID* rgDispID)
1073 if( SUCCEEDED(loadTypeInfo()) )
1075 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1080 STDMETHODIMP VLCMessageIterator::Invoke(DISPID dispIdMember, REFIID riid,
1081 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1082 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1084 if( SUCCEEDED(loadTypeInfo()) )
1086 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1087 pVarResult, pExcepInfo, puArgErr);
1092 STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext)
1094 if( NULL == hasNext )
1097 if( _p_iter && _p_vlclog->_p_log )
1099 libvlc_exception_t ex;
1100 libvlc_exception_init(&ex);
1102 *hasNext = libvlc_log_iterator_has_next(_p_iter, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
1103 if( libvlc_exception_raised(&ex) )
1105 _p_instance->setErrorInfo(IID_IVLCMessageIterator, libvlc_exception_get_message(&ex));
1106 libvlc_exception_clear(&ex);
1112 *hasNext = VARIANT_FALSE;
1117 STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
1119 if( NULL == message )
1122 if( _p_iter && _p_vlclog->_p_log )
1124 struct libvlc_log_message_t buffer;
1126 buffer.sizeof_msg = sizeof(buffer);
1128 libvlc_exception_t ex;
1129 libvlc_exception_init(&ex);
1131 libvlc_log_iterator_next(_p_iter, &buffer, &ex);
1132 if( libvlc_exception_raised(&ex) )
1134 _p_instance->setErrorInfo(IID_IVLCMessageIterator, libvlc_exception_get_message(&ex));
1135 libvlc_exception_clear(&ex);
1138 *message = new VLCMessage(_p_instance, buffer);
1139 return *message ? NOERROR : E_OUTOFMEMORY;
1144 /*******************************************************************************/
1146 VLCMessage::~VLCMessage()
1149 _p_typeinfo->Release();
1152 HRESULT VLCMessage::loadTypeInfo(void)
1154 HRESULT hr = NOERROR;
1155 if( NULL == _p_typeinfo )
1157 ITypeLib *p_typelib;
1159 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1162 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessage, &_p_typeinfo);
1167 p_typelib->Release();
1173 STDMETHODIMP VLCMessage::GetTypeInfoCount(UINT* pctInfo)
1175 if( NULL == pctInfo )
1176 return E_INVALIDARG;
1178 if( SUCCEEDED(loadTypeInfo()) )
1186 STDMETHODIMP VLCMessage::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1188 if( NULL == ppTInfo )
1189 return E_INVALIDARG;
1191 if( SUCCEEDED(loadTypeInfo()) )
1193 _p_typeinfo->AddRef();
1194 *ppTInfo = _p_typeinfo;
1201 STDMETHODIMP VLCMessage::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1202 UINT cNames, LCID lcid, DISPID* rgDispID)
1204 if( SUCCEEDED(loadTypeInfo()) )
1206 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1211 STDMETHODIMP VLCMessage::Invoke(DISPID dispIdMember, REFIID riid,
1212 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1213 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1215 if( SUCCEEDED(loadTypeInfo()) )
1217 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1218 pVarResult, pExcepInfo, puArgErr);
1223 inline const char *msgSeverity(int sev)
1238 STDMETHODIMP VLCMessage::get__Value(VARIANT* _Value)
1240 if( NULL == _Value )
1245 snprintf(buffer, sizeof(buffer), "%s %s %s: %s",
1246 _msg.psz_type, _msg.psz_name, msgSeverity(_msg.i_severity), _msg.psz_message);
1248 V_VT(_Value) = VT_BSTR;
1249 V_BSTR(_Value) = BSTRFromCStr(CP_UTF8, buffer);
1254 STDMETHODIMP VLCMessage::get_severity(long* level)
1259 *level = _msg.i_severity;
1264 STDMETHODIMP VLCMessage::get_type(BSTR* type)
1269 *type = BSTRFromCStr(CP_UTF8, _msg.psz_type);
1274 STDMETHODIMP VLCMessage::get_name(BSTR* name)
1279 *name = BSTRFromCStr(CP_UTF8, _msg.psz_name);
1284 STDMETHODIMP VLCMessage::get_header(BSTR* header)
1286 if( NULL == header )
1289 *header = BSTRFromCStr(CP_UTF8, _msg.psz_header);
1294 STDMETHODIMP VLCMessage::get_message(BSTR* message)
1296 if( NULL == message )
1299 *message = BSTRFromCStr(CP_UTF8, _msg.psz_message);
1304 /*******************************************************************************/
1306 VLCPlaylistItems::~VLCPlaylistItems()
1309 _p_typeinfo->Release();
1312 HRESULT VLCPlaylistItems::loadTypeInfo(void)
1314 HRESULT hr = NOERROR;
1315 if( NULL == _p_typeinfo )
1317 ITypeLib *p_typelib;
1319 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1322 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCPlaylistItems, &_p_typeinfo);
1327 p_typelib->Release();
1333 STDMETHODIMP VLCPlaylistItems::GetTypeInfoCount(UINT* pctInfo)
1335 if( NULL == pctInfo )
1336 return E_INVALIDARG;
1338 if( SUCCEEDED(loadTypeInfo()) )
1346 STDMETHODIMP VLCPlaylistItems::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1348 if( NULL == ppTInfo )
1349 return E_INVALIDARG;
1351 if( SUCCEEDED(loadTypeInfo()) )
1353 _p_typeinfo->AddRef();
1354 *ppTInfo = _p_typeinfo;
1361 STDMETHODIMP VLCPlaylistItems::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1362 UINT cNames, LCID lcid, DISPID* rgDispID)
1364 if( SUCCEEDED(loadTypeInfo()) )
1366 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1371 STDMETHODIMP VLCPlaylistItems::Invoke(DISPID dispIdMember, REFIID riid,
1372 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1373 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1375 if( SUCCEEDED(loadTypeInfo()) )
1377 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1378 pVarResult, pExcepInfo, puArgErr);
1383 STDMETHODIMP VLCPlaylistItems::get_count(long* count)
1388 libvlc_instance_t* p_libvlc;
1389 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1392 libvlc_exception_t ex;
1393 libvlc_exception_init(&ex);
1395 *count = libvlc_playlist_items_count(p_libvlc, &ex);
1396 if( libvlc_exception_raised(&ex) )
1398 _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
1399 libvlc_exception_get_message(&ex));
1400 libvlc_exception_clear(&ex);
1408 STDMETHODIMP VLCPlaylistItems::clear()
1410 libvlc_instance_t* p_libvlc;
1411 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1414 libvlc_exception_t ex;
1415 libvlc_exception_init(&ex);
1417 libvlc_playlist_clear(p_libvlc, &ex);
1418 if( libvlc_exception_raised(&ex) )
1420 _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
1421 libvlc_exception_get_message(&ex));
1422 libvlc_exception_clear(&ex);
1430 STDMETHODIMP VLCPlaylistItems::remove(long item)
1432 libvlc_instance_t* p_libvlc;
1433 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1436 libvlc_exception_t ex;
1437 libvlc_exception_init(&ex);
1439 libvlc_playlist_delete_item(p_libvlc, item, &ex);
1440 if( libvlc_exception_raised(&ex) )
1442 _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
1443 libvlc_exception_get_message(&ex));
1444 libvlc_exception_clear(&ex);
1452 /*******************************************************************************/
1454 VLCPlaylist::~VLCPlaylist()
1456 delete _p_vlcplaylistitems;
1458 _p_typeinfo->Release();
1461 HRESULT VLCPlaylist::loadTypeInfo(void)
1463 HRESULT hr = NOERROR;
1464 if( NULL == _p_typeinfo )
1466 ITypeLib *p_typelib;
1468 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1471 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCPlaylist, &_p_typeinfo);
1476 p_typelib->Release();
1482 STDMETHODIMP VLCPlaylist::GetTypeInfoCount(UINT* pctInfo)
1484 if( NULL == pctInfo )
1485 return E_INVALIDARG;
1487 if( SUCCEEDED(loadTypeInfo()) )
1495 STDMETHODIMP VLCPlaylist::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1497 if( NULL == ppTInfo )
1498 return E_INVALIDARG;
1500 if( SUCCEEDED(loadTypeInfo()) )
1502 _p_typeinfo->AddRef();
1503 *ppTInfo = _p_typeinfo;
1510 STDMETHODIMP VLCPlaylist::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1511 UINT cNames, LCID lcid, DISPID* rgDispID)
1513 if( SUCCEEDED(loadTypeInfo()) )
1515 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1520 STDMETHODIMP VLCPlaylist::Invoke(DISPID dispIdMember, REFIID riid,
1521 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1522 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1524 if( SUCCEEDED(loadTypeInfo()) )
1526 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1527 pVarResult, pExcepInfo, puArgErr);
1532 STDMETHODIMP VLCPlaylist::get_itemCount(long* count)
1537 libvlc_instance_t* p_libvlc;
1538 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1541 libvlc_exception_t ex;
1542 libvlc_exception_init(&ex);
1544 *count = libvlc_playlist_items_count(p_libvlc, &ex);
1545 if( libvlc_exception_raised(&ex) )
1547 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1548 libvlc_exception_get_message(&ex));
1549 libvlc_exception_clear(&ex);
1557 STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
1559 if( NULL == isPlaying )
1562 libvlc_instance_t* p_libvlc;
1563 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1566 libvlc_exception_t ex;
1567 libvlc_exception_init(&ex);
1569 *isPlaying = libvlc_playlist_isplaying(p_libvlc, &ex) ? VARIANT_TRUE: VARIANT_FALSE;
1570 if( libvlc_exception_raised(&ex) )
1572 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1573 libvlc_exception_get_message(&ex));
1574 libvlc_exception_clear(&ex);
1582 STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* item)
1587 if( 0 == SysStringLen(uri) )
1588 return E_INVALIDARG;
1590 libvlc_instance_t* p_libvlc;
1591 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1594 libvlc_exception_t ex;
1595 libvlc_exception_init(&ex);
1597 char *psz_uri = NULL;
1598 if( SysStringLen(_p_instance->getBaseURL()) > 0 )
1601 ** if the MRL a relative URL, we should end up with an absolute URL
1603 LPWSTR abs_url = CombineURL(_p_instance->getBaseURL(), uri);
1604 if( NULL != abs_url )
1606 psz_uri = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url));
1607 CoTaskMemFree(abs_url);
1611 psz_uri = CStrFromBSTR(CP_UTF8, uri);
1617 ** baseURL is empty, assume MRL is absolute
1619 psz_uri = CStrFromBSTR(CP_UTF8, uri);
1622 if( NULL == psz_uri )
1624 return E_OUTOFMEMORY;
1628 char **ppsz_options;
1630 hr = VLCControl::CreateTargetOptions(CP_UTF8, &options, &ppsz_options, &i_options);
1633 CoTaskMemFree(psz_uri);
1637 char *psz_name = NULL;
1639 VariantInit(&v_name);
1640 if( SUCCEEDED(VariantChangeType(&v_name, &name, 0, VT_BSTR)) )
1642 if( SysStringLen(V_BSTR(&v_name)) > 0 )
1643 psz_name = CStrFromBSTR(CP_UTF8, V_BSTR(&v_name));
1645 VariantClear(&v_name);
1648 *item = libvlc_playlist_add_extended(p_libvlc,
1652 const_cast<const char **>(ppsz_options),
1655 VLCControl::FreeTargetOptions(ppsz_options, i_options);
1656 CoTaskMemFree(psz_uri);
1658 CoTaskMemFree(psz_name);
1659 if( libvlc_exception_raised(&ex) )
1661 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1662 libvlc_exception_get_message(&ex));
1663 libvlc_exception_clear(&ex);
1671 STDMETHODIMP VLCPlaylist::play()
1673 libvlc_instance_t* p_libvlc;
1674 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1677 libvlc_exception_t ex;
1678 libvlc_exception_init(&ex);
1680 libvlc_playlist_play(p_libvlc, -1, 0, NULL, &ex);
1681 if( libvlc_exception_raised(&ex) )
1683 libvlc_exception_clear(&ex);
1691 STDMETHODIMP VLCPlaylist::playItem(long item)
1693 libvlc_instance_t* p_libvlc;
1694 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1697 libvlc_exception_t ex;
1698 libvlc_exception_init(&ex);
1700 libvlc_playlist_play(p_libvlc, item, 0, NULL, &ex);
1701 if( libvlc_exception_raised(&ex) )
1703 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1704 libvlc_exception_get_message(&ex));
1705 libvlc_exception_clear(&ex);
1713 STDMETHODIMP VLCPlaylist::togglePause()
1715 libvlc_instance_t* p_libvlc;
1716 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1719 libvlc_exception_t ex;
1720 libvlc_exception_init(&ex);
1722 libvlc_playlist_pause(p_libvlc, &ex);
1723 if( libvlc_exception_raised(&ex) )
1725 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1726 libvlc_exception_get_message(&ex));
1727 libvlc_exception_clear(&ex);
1735 STDMETHODIMP VLCPlaylist::stop()
1737 libvlc_instance_t* p_libvlc;
1738 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1741 libvlc_exception_t ex;
1742 libvlc_exception_init(&ex);
1744 libvlc_playlist_stop(p_libvlc, &ex);
1745 if( libvlc_exception_raised(&ex) )
1747 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1748 libvlc_exception_get_message(&ex));
1749 libvlc_exception_clear(&ex);
1757 STDMETHODIMP VLCPlaylist::next()
1759 libvlc_instance_t* p_libvlc;
1760 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1763 libvlc_exception_t ex;
1764 libvlc_exception_init(&ex);
1766 libvlc_playlist_next(p_libvlc, &ex);
1767 if( libvlc_exception_raised(&ex) )
1769 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1770 libvlc_exception_get_message(&ex));
1771 libvlc_exception_clear(&ex);
1779 STDMETHODIMP VLCPlaylist::prev()
1781 libvlc_instance_t* p_libvlc;
1782 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1785 libvlc_exception_t ex;
1786 libvlc_exception_init(&ex);
1788 libvlc_playlist_prev(p_libvlc, &ex);
1789 if( libvlc_exception_raised(&ex) )
1791 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1792 libvlc_exception_get_message(&ex));
1793 libvlc_exception_clear(&ex);
1801 STDMETHODIMP VLCPlaylist::clear()
1803 libvlc_instance_t* p_libvlc;
1804 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1807 libvlc_exception_t ex;
1808 libvlc_exception_init(&ex);
1810 libvlc_playlist_clear(p_libvlc, &ex);
1811 if( libvlc_exception_raised(&ex) )
1813 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1814 libvlc_exception_get_message(&ex));
1815 libvlc_exception_clear(&ex);
1823 STDMETHODIMP VLCPlaylist::removeItem(long item)
1825 libvlc_instance_t* p_libvlc;
1826 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1829 libvlc_exception_t ex;
1830 libvlc_exception_init(&ex);
1832 libvlc_playlist_delete_item(p_libvlc, item, &ex);
1833 if( libvlc_exception_raised(&ex) )
1835 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1836 libvlc_exception_get_message(&ex));
1837 libvlc_exception_clear(&ex);
1845 STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj)
1850 *obj = _p_vlcplaylistitems;
1851 if( NULL != _p_vlcplaylistitems )
1853 _p_vlcplaylistitems->AddRef();
1856 return E_OUTOFMEMORY;
1859 /*******************************************************************************/
1861 VLCVideo::~VLCVideo()
1864 _p_typeinfo->Release();
1867 HRESULT VLCVideo::loadTypeInfo(void)
1869 HRESULT hr = NOERROR;
1870 if( NULL == _p_typeinfo )
1872 ITypeLib *p_typelib;
1874 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1877 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCVideo, &_p_typeinfo);
1882 p_typelib->Release();
1888 STDMETHODIMP VLCVideo::GetTypeInfoCount(UINT* pctInfo)
1890 if( NULL == pctInfo )
1891 return E_INVALIDARG;
1893 if( SUCCEEDED(loadTypeInfo()) )
1901 STDMETHODIMP VLCVideo::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1903 if( NULL == ppTInfo )
1904 return E_INVALIDARG;
1906 if( SUCCEEDED(loadTypeInfo()) )
1908 _p_typeinfo->AddRef();
1909 *ppTInfo = _p_typeinfo;
1916 STDMETHODIMP VLCVideo::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1917 UINT cNames, LCID lcid, DISPID* rgDispID)
1919 if( SUCCEEDED(loadTypeInfo()) )
1921 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1926 STDMETHODIMP VLCVideo::Invoke(DISPID dispIdMember, REFIID riid,
1927 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1928 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1930 if( SUCCEEDED(loadTypeInfo()) )
1932 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1933 pVarResult, pExcepInfo, puArgErr);
1938 STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
1940 if( NULL == fullscreen )
1943 libvlc_instance_t* p_libvlc;
1944 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1947 libvlc_exception_t ex;
1948 libvlc_exception_init(&ex);
1950 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
1951 if( ! libvlc_exception_raised(&ex) )
1953 *fullscreen = libvlc_get_fullscreen(p_input, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
1954 libvlc_input_free(p_input);
1955 if( ! libvlc_exception_raised(&ex) )
1960 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
1961 libvlc_exception_clear(&ex);
1967 STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen)
1969 libvlc_instance_t* p_libvlc;
1970 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1973 libvlc_exception_t ex;
1974 libvlc_exception_init(&ex);
1976 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
1977 if( ! libvlc_exception_raised(&ex) )
1979 libvlc_set_fullscreen(p_input, VARIANT_FALSE != fullscreen, &ex);
1980 libvlc_input_free(p_input);
1981 if( ! libvlc_exception_raised(&ex) )
1986 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
1987 libvlc_exception_clear(&ex);
1993 STDMETHODIMP VLCVideo::get_width(long* width)
1998 libvlc_instance_t* p_libvlc;
1999 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2002 libvlc_exception_t ex;
2003 libvlc_exception_init(&ex);
2005 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
2006 if( ! libvlc_exception_raised(&ex) )
2008 *width = libvlc_video_get_width(p_input, &ex);
2009 libvlc_input_free(p_input);
2010 if( ! libvlc_exception_raised(&ex) )
2015 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2016 libvlc_exception_clear(&ex);
2022 STDMETHODIMP VLCVideo::get_height(long* height)
2024 if( NULL == height )
2027 libvlc_instance_t* p_libvlc;
2028 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2031 libvlc_exception_t ex;
2032 libvlc_exception_init(&ex);
2034 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
2035 if( ! libvlc_exception_raised(&ex) )
2037 *height = libvlc_video_get_height(p_input, &ex);
2038 libvlc_input_free(p_input);
2039 if( ! libvlc_exception_raised(&ex) )
2044 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2045 libvlc_exception_clear(&ex);
2051 STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect)
2053 if( NULL == aspect )
2056 libvlc_instance_t* p_libvlc;
2057 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2060 libvlc_exception_t ex;
2061 libvlc_exception_init(&ex);
2063 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
2064 if( ! libvlc_exception_raised(&ex) )
2066 char *psz_aspect = libvlc_video_get_aspect_ratio(p_input, &ex);
2068 libvlc_input_free(p_input);
2069 if( ! libvlc_exception_raised(&ex) )
2071 if( NULL == psz_aspect )
2072 return E_OUTOFMEMORY;
2074 *aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
2077 return (NULL == aspect) ? E_OUTOFMEMORY : NOERROR;
2079 if( psz_aspect ) free( psz_aspect );
2082 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2083 libvlc_exception_clear(&ex);
2089 STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
2091 if( NULL == aspect )
2094 if( 0 == SysStringLen(aspect) )
2095 return E_INVALIDARG;
2097 libvlc_instance_t* p_libvlc;
2098 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2101 libvlc_exception_t ex;
2102 libvlc_exception_init(&ex);
2104 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
2105 if( ! libvlc_exception_raised(&ex) )
2107 char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
2108 if( NULL == psz_aspect )
2110 return E_OUTOFMEMORY;
2113 libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex);
2115 CoTaskMemFree(psz_aspect);
2116 libvlc_input_free(p_input);
2117 if( libvlc_exception_raised(&ex) )
2119 _p_instance->setErrorInfo(IID_IVLCVideo,
2120 libvlc_exception_get_message(&ex));
2121 libvlc_exception_clear(&ex);
2130 STDMETHODIMP VLCVideo::get_crop(BSTR* geometry)
2132 if( NULL == geometry )
2135 libvlc_instance_t* p_libvlc;
2136 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2139 libvlc_exception_t ex;
2140 libvlc_exception_init(&ex);
2142 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
2143 if( ! libvlc_exception_raised(&ex) )
2145 char *psz_geometry = libvlc_video_get_crop_geometry(p_input, &ex);
2147 libvlc_input_free(p_input);
2148 if( ! libvlc_exception_raised(&ex) )
2150 if( NULL == psz_geometry )
2151 return E_OUTOFMEMORY;
2153 *geometry = BSTRFromCStr(CP_UTF8, psz_geometry);
2154 free( psz_geometry );
2155 psz_geometry = NULL;
2156 return (NULL == geometry) ? E_OUTOFMEMORY : NOERROR;
2158 if( psz_geometry ) free( psz_geometry );
2159 psz_geometry = NULL;
2161 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2162 libvlc_exception_clear(&ex);
2168 STDMETHODIMP VLCVideo::put_crop(BSTR geometry)
2170 if( NULL == geometry )
2173 if( 0 == SysStringLen(geometry) )
2174 return E_INVALIDARG;
2176 libvlc_instance_t* p_libvlc;
2177 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2180 libvlc_exception_t ex;
2181 libvlc_exception_init(&ex);
2183 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
2184 if( ! libvlc_exception_raised(&ex) )
2186 char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry);
2187 if( NULL == psz_geometry )
2189 return E_OUTOFMEMORY;
2192 libvlc_video_set_crop_geometry(p_input, psz_geometry, &ex);
2194 CoTaskMemFree(psz_geometry);
2195 libvlc_input_free(p_input);
2196 if( libvlc_exception_raised(&ex) )
2198 _p_instance->setErrorInfo(IID_IVLCVideo,
2199 libvlc_exception_get_message(&ex));
2200 libvlc_exception_clear(&ex);
2209 STDMETHODIMP VLCVideo::takeSnapshot(BSTR filePath)
2211 if( NULL == filePath )
2214 if( 0 == SysStringLen(filePath) )
2215 return E_INVALIDARG;
2217 libvlc_instance_t* p_libvlc;
2218 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2221 libvlc_exception_t ex;
2222 libvlc_exception_init(&ex);
2224 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
2225 if( ! libvlc_exception_raised(&ex) )
2227 char *psz_filepath = CStrFromBSTR(CP_UTF8, filePath);
2228 if( NULL == psz_filepath )
2230 return E_OUTOFMEMORY;
2232 /* TODO: check file security */
2234 libvlc_video_take_snapshot(p_input, psz_filepath, &ex);
2235 libvlc_input_free(p_input);
2236 if( ! libvlc_exception_raised(&ex) )
2241 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2242 libvlc_exception_clear(&ex);
2248 STDMETHODIMP VLCVideo::toggleFullscreen()
2250 libvlc_instance_t* p_libvlc;
2251 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2254 libvlc_exception_t ex;
2255 libvlc_exception_init(&ex);
2257 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
2258 if( ! libvlc_exception_raised(&ex) )
2260 libvlc_toggle_fullscreen(p_input, &ex);
2261 libvlc_input_free(p_input);
2262 if( ! libvlc_exception_raised(&ex) )
2267 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2268 libvlc_exception_clear(&ex);
2274 /*******************************************************************************/
2276 VLCControl2::VLCControl2(VLCPlugin *p_instance) :
2277 _p_instance(p_instance),
2281 _p_vlcplaylist(NULL),
2284 _p_vlcaudio = new VLCAudio(p_instance);
2285 _p_vlcinput = new VLCInput(p_instance);
2286 _p_vlclog = new VLCLog(p_instance);
2287 _p_vlcplaylist = new VLCPlaylist(p_instance);
2288 _p_vlcvideo = new VLCVideo(p_instance);
2291 VLCControl2::~VLCControl2()
2294 delete _p_vlcplaylist;
2299 _p_typeinfo->Release();
2302 HRESULT VLCControl2::loadTypeInfo(void)
2304 HRESULT hr = NOERROR;
2305 if( NULL == _p_typeinfo )
2307 ITypeLib *p_typelib;
2309 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
2312 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCControl2, &_p_typeinfo);
2317 p_typelib->Release();
2323 STDMETHODIMP VLCControl2::GetTypeInfoCount(UINT* pctInfo)
2325 if( NULL == pctInfo )
2326 return E_INVALIDARG;
2328 if( SUCCEEDED(loadTypeInfo()) )
2336 STDMETHODIMP VLCControl2::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
2338 if( NULL == ppTInfo )
2339 return E_INVALIDARG;
2341 if( SUCCEEDED(loadTypeInfo()) )
2343 _p_typeinfo->AddRef();
2344 *ppTInfo = _p_typeinfo;
2351 STDMETHODIMP VLCControl2::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
2352 UINT cNames, LCID lcid, DISPID* rgDispID)
2354 if( SUCCEEDED(loadTypeInfo()) )
2356 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
2361 STDMETHODIMP VLCControl2::Invoke(DISPID dispIdMember, REFIID riid,
2362 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
2363 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
2365 if( SUCCEEDED(loadTypeInfo()) )
2367 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
2368 pVarResult, pExcepInfo, puArgErr);
2373 STDMETHODIMP VLCControl2::get_AutoLoop(VARIANT_BOOL *autoloop)
2375 if( NULL == autoloop )
2378 *autoloop = _p_instance->getAutoLoop() ? VARIANT_TRUE: VARIANT_FALSE;
2382 STDMETHODIMP VLCControl2::put_AutoLoop(VARIANT_BOOL autoloop)
2384 _p_instance->setAutoLoop((VARIANT_FALSE != autoloop) ? TRUE: FALSE);
2388 STDMETHODIMP VLCControl2::get_AutoPlay(VARIANT_BOOL *autoplay)
2390 if( NULL == autoplay )
2393 *autoplay = _p_instance->getAutoPlay() ? VARIANT_TRUE: VARIANT_FALSE;
2397 STDMETHODIMP VLCControl2::put_AutoPlay(VARIANT_BOOL autoplay)
2399 _p_instance->setAutoPlay((VARIANT_FALSE != autoplay) ? TRUE: FALSE);
2403 STDMETHODIMP VLCControl2::get_BaseURL(BSTR *url)
2408 *url = SysAllocStringLen(_p_instance->getBaseURL(),
2409 SysStringLen(_p_instance->getBaseURL()));
2413 STDMETHODIMP VLCControl2::put_BaseURL(BSTR mrl)
2415 _p_instance->setBaseURL(mrl);
2420 STDMETHODIMP VLCControl2::get_MRL(BSTR *mrl)
2425 *mrl = SysAllocStringLen(_p_instance->getMRL(),
2426 SysStringLen(_p_instance->getMRL()));
2430 STDMETHODIMP VLCControl2::put_MRL(BSTR mrl)
2432 _p_instance->setMRL(mrl);
2437 STDMETHODIMP VLCControl2::get_StartTime(long *seconds)
2439 if( NULL == seconds )
2442 *seconds = _p_instance->getStartTime();
2447 STDMETHODIMP VLCControl2::put_StartTime(long seconds)
2449 _p_instance->setStartTime(seconds);
2454 STDMETHODIMP VLCControl2::get_VersionInfo(BSTR *version)
2456 if( NULL == version )
2459 const char *versionStr = VLC_Version();
2460 if( NULL != versionStr )
2462 *version = BSTRFromCStr(CP_UTF8, versionStr);
2463 return NULL == *version ? E_OUTOFMEMORY : NOERROR;
2469 STDMETHODIMP VLCControl2::get_Visible(VARIANT_BOOL *isVisible)
2471 if( NULL == isVisible )
2474 *isVisible = _p_instance->getVisible() ? VARIANT_TRUE : VARIANT_FALSE;
2479 STDMETHODIMP VLCControl2::put_Visible(VARIANT_BOOL isVisible)
2481 _p_instance->setVisible(isVisible != VARIANT_FALSE);
2486 STDMETHODIMP VLCControl2::get_Volume(long *volume)
2488 if( NULL == volume )
2491 *volume = _p_instance->getVolume();
2495 STDMETHODIMP VLCControl2::put_Volume(long volume)
2497 _p_instance->setVolume(volume);
2501 STDMETHODIMP VLCControl2::get_audio(IVLCAudio** obj)
2507 if( NULL != _p_vlcaudio )
2509 _p_vlcaudio->AddRef();
2512 return E_OUTOFMEMORY;
2515 STDMETHODIMP VLCControl2::get_input(IVLCInput** obj)
2521 if( NULL != _p_vlcinput )
2523 _p_vlcinput->AddRef();
2526 return E_OUTOFMEMORY;
2529 STDMETHODIMP VLCControl2::get_log(IVLCLog** obj)
2535 if( NULL != _p_vlclog )
2537 _p_vlclog->AddRef();
2540 return E_OUTOFMEMORY;
2543 STDMETHODIMP VLCControl2::get_playlist(IVLCPlaylist** obj)
2548 *obj = _p_vlcplaylist;
2549 if( NULL != _p_vlcplaylist )
2551 _p_vlcplaylist->AddRef();
2554 return E_OUTOFMEMORY;
2557 STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj)
2563 if( NULL != _p_vlcvideo )
2565 _p_vlcvideo->AddRef();
2568 return E_OUTOFMEMORY;