1 /*****************************************************************************
2 * vlccontrol2.cpp: ActiveX control for VLC
3 *****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
5 * Copyright (C) 2010 M2X BV
7 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8 * Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
32 #include "vlccontrol2.h"
33 #include "vlccontrol.h"
37 HRESULT _exception_bridge(VLCPlugin *p,REFIID riid, libvlc_exception_t *ex)
39 if( libvlc_exception_raised(ex) )
41 p->setErrorInfo(riid,libvlc_errmsg());
42 libvlc_exception_clear(ex);
48 #define EMIT_EXCEPTION_BRIDGE( classname ) \
49 HRESULT classname::exception_bridge( libvlc_exception_t *ex ) \
50 { return _exception_bridge( _p_instance, IID_I##classname, ex ); }
52 EMIT_EXCEPTION_BRIDGE( VLCAudio )
53 EMIT_EXCEPTION_BRIDGE( VLCInput )
54 EMIT_EXCEPTION_BRIDGE( VLCMarquee )
55 EMIT_EXCEPTION_BRIDGE( VLCMessageIterator )
56 EMIT_EXCEPTION_BRIDGE( VLCMessages )
57 EMIT_EXCEPTION_BRIDGE( VLCLog )
58 EMIT_EXCEPTION_BRIDGE( VLCLogo )
59 EMIT_EXCEPTION_BRIDGE( VLCPlaylistItems )
60 EMIT_EXCEPTION_BRIDGE( VLCPlaylist )
61 EMIT_EXCEPTION_BRIDGE( VLCVideo )
62 EMIT_EXCEPTION_BRIDGE( VLCSubtitle )
64 #undef EMIT_EXCEPTION_BRIDGE
70 _p_typeinfo->Release();
73 HRESULT VLCAudio::loadTypeInfo(void)
76 if( NULL == _p_typeinfo )
80 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
83 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCAudio, &_p_typeinfo);
94 STDMETHODIMP VLCAudio::GetTypeInfoCount(UINT* pctInfo)
99 if( SUCCEEDED(loadTypeInfo()) )
107 STDMETHODIMP VLCAudio::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
109 if( NULL == ppTInfo )
112 if( SUCCEEDED(loadTypeInfo()) )
114 _p_typeinfo->AddRef();
115 *ppTInfo = _p_typeinfo;
122 STDMETHODIMP VLCAudio::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
123 UINT cNames, LCID lcid, DISPID* rgDispID)
125 if( SUCCEEDED(loadTypeInfo()) )
127 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
132 STDMETHODIMP VLCAudio::Invoke(DISPID dispIdMember, REFIID riid,
133 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
134 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
136 if( SUCCEEDED(loadTypeInfo()) )
138 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
139 pVarResult, pExcepInfo, puArgErr);
144 STDMETHODIMP VLCAudio::get_mute(VARIANT_BOOL* mute)
149 libvlc_instance_t* p_libvlc;
150 HRESULT hr = _p_instance->getVLC(&p_libvlc);
152 *mute = libvlc_audio_get_mute(p_libvlc) ?
153 VARIANT_TRUE : VARIANT_FALSE;
157 STDMETHODIMP VLCAudio::put_mute(VARIANT_BOOL mute)
159 libvlc_instance_t* p_libvlc;
160 HRESULT hr = _p_instance->getVLC(&p_libvlc);
162 libvlc_audio_set_mute(p_libvlc, VARIANT_FALSE != mute);
166 STDMETHODIMP VLCAudio::get_volume(long* volume)
171 libvlc_instance_t* p_libvlc;
172 HRESULT hr = _p_instance->getVLC(&p_libvlc);
174 *volume = libvlc_audio_get_volume(p_libvlc);
178 STDMETHODIMP VLCAudio::put_volume(long volume)
180 libvlc_instance_t* p_libvlc;
181 HRESULT hr = _p_instance->getVLC(&p_libvlc);
184 libvlc_exception_t ex;
185 libvlc_exception_init(&ex);
187 libvlc_audio_set_volume(p_libvlc, volume, &ex);
188 hr = exception_bridge(&ex);
193 STDMETHODIMP VLCAudio::get_track(long* track)
198 libvlc_media_player_t* p_md;
199 HRESULT hr = _p_instance->getMD(&p_md);
202 libvlc_exception_t ex;
203 libvlc_exception_init(&ex);
205 *track = libvlc_audio_get_track(p_md, &ex);
206 hr = exception_bridge(&ex);
211 STDMETHODIMP VLCAudio::put_track(long track)
213 libvlc_media_player_t *p_md;
214 HRESULT hr = _p_instance->getMD(&p_md);
217 libvlc_exception_t ex;
218 libvlc_exception_init(&ex);
220 libvlc_audio_set_track(p_md, track, &ex);
221 hr = exception_bridge(&ex);
226 STDMETHODIMP VLCAudio::get_count(long* trackNumber)
228 if( NULL == trackNumber )
231 libvlc_media_player_t* p_md;
232 HRESULT hr = _p_instance->getMD(&p_md);
235 libvlc_exception_t ex;
236 libvlc_exception_init(&ex);
237 // get the number of audio track available and return it
238 *trackNumber = libvlc_audio_get_track_count(p_md, &ex);
239 hr = exception_bridge(&ex);
245 STDMETHODIMP VLCAudio::description(long trackID, BSTR* name)
250 libvlc_media_player_t* p_md;
251 libvlc_exception_t ex;
252 libvlc_exception_init(&ex);
254 HRESULT hr = _p_instance->getMD(&p_md);
258 const char *psz_name;
259 libvlc_track_description_t *p_trackDesc;
261 // get tracks description
262 p_trackDesc = libvlc_audio_get_track_description(p_md, &ex);
263 hr = exception_bridge(&ex);
267 //get the number of available track
268 i_limit = libvlc_audio_get_track_count(p_md, &ex);
269 hr = exception_bridge(&ex);
273 // check if the number given is a good one
274 if ( ( trackID > ( i_limit -1 ) ) || ( trackID < 0 ) )
277 // get the good trackDesc
278 for( i = 0 ; i < trackID ; i++ )
280 p_trackDesc = p_trackDesc->p_next;
282 // get the track name
283 psz_name = p_trackDesc->psz_name;
286 if( psz_name != NULL )
288 *name = BSTRFromCStr(CP_UTF8, psz_name);
289 return (NULL == *name) ? E_OUTOFMEMORY : NOERROR;
297 STDMETHODIMP VLCAudio::get_channel(long *channel)
299 if( NULL == channel )
302 libvlc_instance_t* p_libvlc;
303 HRESULT hr = _p_instance->getVLC(&p_libvlc);
306 libvlc_exception_t ex;
307 libvlc_exception_init(&ex);
309 *channel = libvlc_audio_get_channel(p_libvlc, &ex);
310 hr = exception_bridge(&ex);
315 STDMETHODIMP VLCAudio::put_channel(long channel)
317 libvlc_instance_t* p_libvlc;
318 HRESULT hr = _p_instance->getVLC(&p_libvlc);
321 libvlc_exception_t ex;
322 libvlc_exception_init(&ex);
324 libvlc_audio_set_channel(p_libvlc, channel, &ex);
325 hr = exception_bridge(&ex);
330 STDMETHODIMP VLCAudio::toggleMute()
332 libvlc_instance_t* p_libvlc;
333 HRESULT hr = _p_instance->getVLC(&p_libvlc);
335 libvlc_audio_toggle_mute(p_libvlc);
339 /****************************************************************************/
341 VLCInput::~VLCInput()
344 _p_typeinfo->Release();
347 HRESULT VLCInput::loadTypeInfo(void)
349 HRESULT hr = NOERROR;
350 if( NULL == _p_typeinfo )
354 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
357 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCInput, &_p_typeinfo);
362 p_typelib->Release();
368 STDMETHODIMP VLCInput::GetTypeInfoCount(UINT* pctInfo)
370 if( NULL == pctInfo )
373 if( SUCCEEDED(loadTypeInfo()) )
381 STDMETHODIMP VLCInput::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
383 if( NULL == ppTInfo )
386 if( SUCCEEDED(loadTypeInfo()) )
388 _p_typeinfo->AddRef();
389 *ppTInfo = _p_typeinfo;
396 STDMETHODIMP VLCInput::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
397 UINT cNames, LCID lcid, DISPID* rgDispID)
399 if( SUCCEEDED(loadTypeInfo()) )
401 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
406 STDMETHODIMP VLCInput::Invoke(DISPID dispIdMember, REFIID riid,
407 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
408 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
410 if( SUCCEEDED(loadTypeInfo()) )
412 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
413 pVarResult, pExcepInfo, puArgErr);
418 STDMETHODIMP VLCInput::get_length(double* length)
424 libvlc_media_player_t *p_md;
425 HRESULT hr = _p_instance->getMD(&p_md);
428 libvlc_exception_t ex;
429 libvlc_exception_init(&ex);
431 *length = (double)libvlc_media_player_get_length(p_md, &ex);
432 hr = exception_bridge(&ex);
437 STDMETHODIMP VLCInput::get_position(double* position)
439 if( NULL == position )
443 libvlc_media_player_t *p_md;
444 HRESULT hr = _p_instance->getMD(&p_md);
447 libvlc_exception_t ex;
448 libvlc_exception_init(&ex);
450 *position = libvlc_media_player_get_position(p_md, &ex);
451 hr = exception_bridge(&ex);
456 STDMETHODIMP VLCInput::put_position(double position)
458 libvlc_media_player_t *p_md;
459 HRESULT hr = _p_instance->getMD(&p_md);
462 libvlc_exception_t ex;
463 libvlc_exception_init(&ex);
465 libvlc_media_player_set_position(p_md, position, &ex);
466 hr = exception_bridge(&ex);
471 STDMETHODIMP VLCInput::get_time(double* time)
476 libvlc_media_player_t *p_md;
477 HRESULT hr = _p_instance->getMD(&p_md);
480 libvlc_exception_t ex;
481 libvlc_exception_init(&ex);
483 *time = (double)libvlc_media_player_get_time(p_md, &ex);
484 hr = exception_bridge(&ex);
489 STDMETHODIMP VLCInput::put_time(double time)
491 libvlc_media_player_t *p_md;
492 HRESULT hr = _p_instance->getMD(&p_md);
495 libvlc_exception_t ex;
496 libvlc_exception_init(&ex);
498 libvlc_media_player_set_time(p_md, (int64_t)time, &ex);
499 hr = exception_bridge(&ex);
504 STDMETHODIMP VLCInput::get_state(long* state)
509 libvlc_media_player_t *p_md;
510 HRESULT hr = _p_instance->getMD(&p_md);
513 libvlc_exception_t ex;
514 libvlc_exception_init(&ex);
516 *state = libvlc_media_player_get_state(p_md, &ex);
517 if( libvlc_exception_raised(&ex) )
519 // don't fail, just return the idle state
521 libvlc_exception_clear(&ex);
527 STDMETHODIMP VLCInput::get_rate(double* rate)
532 libvlc_media_player_t *p_md;
533 HRESULT hr = _p_instance->getMD(&p_md);
536 libvlc_exception_t ex;
537 libvlc_exception_init(&ex);
539 *rate = libvlc_media_player_get_rate(p_md, &ex);
540 hr = exception_bridge(&ex);
545 STDMETHODIMP VLCInput::put_rate(double rate)
547 libvlc_media_player_t *p_md;
548 HRESULT hr = _p_instance->getMD(&p_md);
551 libvlc_exception_t ex;
552 libvlc_exception_init(&ex);
554 libvlc_media_player_set_rate(p_md, rate, &ex);
555 hr = exception_bridge(&ex);
560 STDMETHODIMP VLCInput::get_fps(double* fps)
566 libvlc_media_player_t *p_md;
567 HRESULT hr = _p_instance->getMD(&p_md);
570 libvlc_exception_t ex;
571 libvlc_exception_init(&ex);
573 *fps = libvlc_media_player_get_fps(p_md, &ex);
574 hr = exception_bridge(&ex);
579 STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
581 if( NULL == hasVout )
584 libvlc_media_player_t *p_md;
585 HRESULT hr = _p_instance->getMD(&p_md);
588 libvlc_exception_t ex;
589 libvlc_exception_init(&ex);
591 *hasVout = libvlc_media_player_has_vout(p_md, &ex) ?
592 VARIANT_TRUE : VARIANT_FALSE;
593 hr = exception_bridge(&ex);
598 /****************************************************************************/
602 delete _p_vlcmessages;
604 libvlc_log_close(_p_log);
607 _p_typeinfo->Release();
610 HRESULT VLCLog::loadTypeInfo(void)
612 HRESULT hr = NOERROR;
613 if( NULL == _p_typeinfo )
617 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
620 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCLog, &_p_typeinfo);
625 p_typelib->Release();
631 STDMETHODIMP VLCLog::GetTypeInfoCount(UINT* pctInfo)
633 if( NULL == pctInfo )
636 if( SUCCEEDED(loadTypeInfo()) )
644 STDMETHODIMP VLCLog::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
646 if( NULL == ppTInfo )
649 if( SUCCEEDED(loadTypeInfo()) )
651 _p_typeinfo->AddRef();
652 *ppTInfo = _p_typeinfo;
659 STDMETHODIMP VLCLog::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
660 UINT cNames, LCID lcid, DISPID* rgDispID)
662 if( SUCCEEDED(loadTypeInfo()) )
664 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
669 STDMETHODIMP VLCLog::Invoke(DISPID dispIdMember, REFIID riid,
670 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
671 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
673 if( SUCCEEDED(loadTypeInfo()) )
675 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
676 pVarResult, pExcepInfo, puArgErr);
681 STDMETHODIMP VLCLog::get_messages(IVLCMessages** obj)
686 *obj = _p_vlcmessages;
687 if( NULL != _p_vlcmessages )
689 _p_vlcmessages->AddRef();
692 return E_OUTOFMEMORY;
695 STDMETHODIMP VLCLog::get_verbosity(long* level)
702 libvlc_instance_t* p_libvlc;
703 HRESULT hr = _p_instance->getVLC(&p_libvlc);
705 *level = libvlc_get_log_verbosity(p_libvlc);
710 /* log is not enabled, return -1 */
716 STDMETHODIMP VLCLog::put_verbosity(long verbosity)
718 libvlc_instance_t* p_libvlc;
719 HRESULT hr = _p_instance->getVLC(&p_libvlc);
722 libvlc_exception_t ex;
723 libvlc_exception_init(&ex);
729 _p_log = libvlc_log_open(p_libvlc, &ex);
730 hr = exception_bridge(&ex);
733 libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity);
737 /* close log when verbosity is set to -1 */
738 libvlc_log_close(_p_log);
741 hr = exception_bridge(&ex);
746 /****************************************************************************/
748 VLCMarquee::~VLCMarquee()
751 _p_typeinfo->Release();
754 HRESULT VLCMarquee::loadTypeInfo(void)
756 HRESULT hr = NOERROR;
757 if( NULL == _p_typeinfo )
761 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
764 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMarquee, &_p_typeinfo);
769 p_typelib->Release();
775 STDMETHODIMP VLCMarquee::GetTypeInfoCount(UINT* pctInfo)
777 if( NULL == pctInfo )
780 if( SUCCEEDED(loadTypeInfo()) )
788 STDMETHODIMP VLCMarquee::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
790 if( NULL == ppTInfo )
793 if( SUCCEEDED(loadTypeInfo()) )
795 _p_typeinfo->AddRef();
796 *ppTInfo = _p_typeinfo;
803 STDMETHODIMP VLCMarquee::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
804 UINT cNames, LCID lcid, DISPID* rgDispID)
806 if( SUCCEEDED(loadTypeInfo()) )
808 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
813 STDMETHODIMP VLCMarquee::Invoke(DISPID dispIdMember, REFIID riid,
814 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
815 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
817 if( SUCCEEDED(loadTypeInfo()) )
819 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
820 pVarResult, pExcepInfo, puArgErr);
825 STDMETHODIMP VLCMarquee::enable()
827 libvlc_media_player_t *p_md;
828 HRESULT hr = _p_instance->getMD(&p_md);
831 libvlc_exception_t ex;
832 libvlc_exception_init(&ex);
834 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, true, &ex);
835 hr = exception_bridge(&ex);
840 STDMETHODIMP VLCMarquee::disable()
842 libvlc_media_player_t *p_md;
843 HRESULT hr = _p_instance->getMD(&p_md);
846 libvlc_exception_t ex;
847 libvlc_exception_init(&ex);
849 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, false, &ex);
850 hr = exception_bridge(&ex);
855 STDMETHODIMP VLCMarquee::color(long val)
857 libvlc_media_player_t *p_md;
858 HRESULT hr = _p_instance->getMD(&p_md);
861 libvlc_exception_t ex;
862 libvlc_exception_init(&ex);
864 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Color, val, &ex);
865 hr = exception_bridge(&ex);
870 STDMETHODIMP VLCMarquee::opacity(long val)
872 libvlc_media_player_t *p_md;
873 HRESULT hr = _p_instance->getMD(&p_md);
876 libvlc_exception_t ex;
877 libvlc_exception_init(&ex);
879 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Opacity, val, &ex);
880 hr = exception_bridge(&ex);
885 STDMETHODIMP VLCMarquee::position(long val)
887 libvlc_media_player_t *p_md;
888 HRESULT hr = _p_instance->getMD(&p_md);
891 libvlc_exception_t ex;
892 libvlc_exception_init(&ex);
894 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Position, val, &ex);
895 hr = exception_bridge(&ex);
900 STDMETHODIMP VLCMarquee::refresh(long val)
902 libvlc_media_player_t *p_md;
903 HRESULT hr = _p_instance->getMD(&p_md);
906 libvlc_exception_t ex;
907 libvlc_exception_init(&ex);
909 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Refresh, val, &ex);
910 hr = exception_bridge(&ex);
915 STDMETHODIMP VLCMarquee::size(long val)
917 libvlc_media_player_t *p_md;
918 HRESULT hr = _p_instance->getMD(&p_md);
921 libvlc_exception_t ex;
922 libvlc_exception_init(&ex);
924 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Size, val, &ex);
925 hr = exception_bridge(&ex);
930 STDMETHODIMP VLCMarquee::text(BSTR text)
932 libvlc_media_player_t *p_md;
933 HRESULT hr = _p_instance->getMD(&p_md);
936 libvlc_exception_t ex;
937 libvlc_exception_init(&ex);
939 char *psz_text = CStrFromBSTR(CP_UTF8, text);
940 libvlc_video_set_marquee_option_as_string(p_md, libvlc_marquee_Text, psz_text, &ex);
941 hr = exception_bridge(&ex);
942 CoTaskMemFree(psz_text);
947 STDMETHODIMP VLCMarquee::timeout(long val)
949 libvlc_media_player_t *p_md;
950 HRESULT hr = _p_instance->getMD(&p_md);
953 libvlc_exception_t ex;
954 libvlc_exception_init(&ex);
956 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Timeout, val, &ex);
957 hr = exception_bridge(&ex);
962 STDMETHODIMP VLCMarquee::x(long val)
964 libvlc_media_player_t *p_md;
965 HRESULT hr = _p_instance->getMD(&p_md);
968 libvlc_exception_t ex;
969 libvlc_exception_init(&ex);
971 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_X, val, &ex);
972 hr = exception_bridge(&ex);
977 STDMETHODIMP VLCMarquee::y(long val)
979 libvlc_media_player_t *p_md;
980 HRESULT hr = _p_instance->getMD(&p_md);
983 libvlc_exception_t ex;
984 libvlc_exception_init(&ex);
986 libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Y, val, &ex);
987 hr = exception_bridge(&ex);
992 /****************************************************************************/
994 /* STL forward iterator used by VLCEnumIterator class to implement IEnumVARIANT */
996 class VLCMessageSTLIterator
1001 VLCMessageSTLIterator(IVLCMessageIterator* iter) : iter(iter), msg(NULL)
1003 // get first message
1007 VLCMessageSTLIterator(const VLCMessageSTLIterator& other)
1017 virtual ~VLCMessageSTLIterator()
1026 // we only need prefix ++ operator
1027 VLCMessageSTLIterator& operator++()
1029 VARIANT_BOOL hasNext = VARIANT_FALSE;
1032 iter->get_hasNext(&hasNext);
1039 if( VARIANT_TRUE == hasNext ) {
1046 VARIANT operator*() const
1052 if( SUCCEEDED(msg->QueryInterface(IID_IDispatch,
1053 (LPVOID*)&V_DISPATCH(&v))) )
1055 V_VT(&v) = VT_DISPATCH;
1061 bool operator==(const VLCMessageSTLIterator& other) const
1063 return msg == other.msg;
1066 bool operator!=(const VLCMessageSTLIterator& other) const
1068 return msg != other.msg;
1072 IVLCMessageIterator* iter;
1076 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
1078 VLCMessages::~VLCMessages()
1081 _p_typeinfo->Release();
1084 HRESULT VLCMessages::loadTypeInfo(void)
1086 HRESULT hr = NOERROR;
1087 if( NULL == _p_typeinfo )
1089 ITypeLib *p_typelib;
1091 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1094 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessages, &_p_typeinfo);
1099 p_typelib->Release();
1105 STDMETHODIMP VLCMessages::GetTypeInfoCount(UINT* pctInfo)
1107 if( NULL == pctInfo )
1108 return E_INVALIDARG;
1110 if( SUCCEEDED(loadTypeInfo()) )
1118 STDMETHODIMP VLCMessages::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1120 if( NULL == ppTInfo )
1121 return E_INVALIDARG;
1123 if( SUCCEEDED(loadTypeInfo()) )
1125 _p_typeinfo->AddRef();
1126 *ppTInfo = _p_typeinfo;
1133 STDMETHODIMP VLCMessages::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1134 UINT cNames, LCID lcid, DISPID* rgDispID)
1136 if( SUCCEEDED(loadTypeInfo()) )
1138 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1143 STDMETHODIMP VLCMessages::Invoke(DISPID dispIdMember, REFIID riid,
1144 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1145 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1147 if( SUCCEEDED(loadTypeInfo()) )
1149 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1150 pVarResult, pExcepInfo, puArgErr);
1155 STDMETHODIMP VLCMessages::get__NewEnum(LPUNKNOWN* _NewEnum)
1157 if( NULL == _NewEnum )
1160 IVLCMessageIterator* iter = NULL;
1163 *_NewEnum= new VLCEnumIterator<IID_IEnumVARIANT,
1166 VLCMessageSTLIterator>
1167 (VLCMessageSTLIterator(iter), VLCMessageSTLIterator(NULL));
1169 return *_NewEnum ? S_OK : E_OUTOFMEMORY;
1172 STDMETHODIMP VLCMessages::clear()
1174 libvlc_log_t *p_log = _p_vlclog->_p_log;
1176 libvlc_log_clear(p_log);
1180 STDMETHODIMP VLCMessages::get_count(long* count)
1185 libvlc_log_t *p_log = _p_vlclog->_p_log;
1186 *count = libvlc_log_count(p_log);
1190 STDMETHODIMP VLCMessages::iterator(IVLCMessageIterator** iter)
1195 *iter = new VLCMessageIterator(_p_instance, _p_vlclog);
1197 return *iter ? S_OK : E_OUTOFMEMORY;
1200 /****************************************************************************/
1202 VLCMessageIterator::VLCMessageIterator(VLCPlugin *p_instance, VLCLog* p_vlclog ) :
1203 _p_instance(p_instance),
1208 if( p_vlclog->_p_log )
1210 _p_iter = libvlc_log_get_iterator(p_vlclog->_p_log, NULL);
1216 VLCMessageIterator::~VLCMessageIterator()
1219 libvlc_log_iterator_free(_p_iter);
1222 _p_typeinfo->Release();
1225 HRESULT VLCMessageIterator::loadTypeInfo(void)
1227 HRESULT hr = NOERROR;
1228 if( NULL == _p_typeinfo )
1230 ITypeLib *p_typelib;
1232 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1235 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessageIterator, &_p_typeinfo);
1240 p_typelib->Release();
1246 STDMETHODIMP VLCMessageIterator::GetTypeInfoCount(UINT* pctInfo)
1248 if( NULL == pctInfo )
1249 return E_INVALIDARG;
1251 if( SUCCEEDED(loadTypeInfo()) )
1259 STDMETHODIMP VLCMessageIterator::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1261 if( NULL == ppTInfo )
1262 return E_INVALIDARG;
1264 if( SUCCEEDED(loadTypeInfo()) )
1266 _p_typeinfo->AddRef();
1267 *ppTInfo = _p_typeinfo;
1274 STDMETHODIMP VLCMessageIterator::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1275 UINT cNames, LCID lcid, DISPID* rgDispID)
1277 if( SUCCEEDED(loadTypeInfo()) )
1279 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1284 STDMETHODIMP VLCMessageIterator::Invoke(DISPID dispIdMember, REFIID riid,
1285 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1286 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1288 if( SUCCEEDED(loadTypeInfo()) )
1290 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1291 pVarResult, pExcepInfo, puArgErr);
1296 STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext)
1298 if( NULL == hasNext )
1301 if( _p_iter && _p_vlclog->_p_log )
1303 *hasNext = libvlc_log_iterator_has_next(_p_iter) ?
1304 VARIANT_TRUE : VARIANT_FALSE;
1308 *hasNext = VARIANT_FALSE;
1313 STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
1317 if( NULL == message )
1320 if( _p_iter && _p_vlclog->_p_log )
1322 struct libvlc_log_message_t buffer;
1324 buffer.sizeof_msg = sizeof(buffer);
1326 libvlc_exception_t ex;
1327 libvlc_exception_init(&ex);
1329 libvlc_log_iterator_next(_p_iter, &buffer, &ex);
1330 *message = new VLCMessage(_p_instance, buffer);
1337 /****************************************************************************/
1339 VLCMessage::~VLCMessage()
1342 _p_typeinfo->Release();
1345 HRESULT VLCMessage::loadTypeInfo(void)
1347 HRESULT hr = NOERROR;
1348 if( NULL == _p_typeinfo )
1350 ITypeLib *p_typelib;
1352 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1355 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessage, &_p_typeinfo);
1360 p_typelib->Release();
1366 STDMETHODIMP VLCMessage::GetTypeInfoCount(UINT* pctInfo)
1368 if( NULL == pctInfo )
1369 return E_INVALIDARG;
1371 if( SUCCEEDED(loadTypeInfo()) )
1379 STDMETHODIMP VLCMessage::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1381 if( NULL == ppTInfo )
1382 return E_INVALIDARG;
1384 if( SUCCEEDED(loadTypeInfo()) )
1386 _p_typeinfo->AddRef();
1387 *ppTInfo = _p_typeinfo;
1394 STDMETHODIMP VLCMessage::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1395 UINT cNames, LCID lcid, DISPID* rgDispID)
1397 if( SUCCEEDED(loadTypeInfo()) )
1399 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1404 STDMETHODIMP VLCMessage::Invoke(DISPID dispIdMember, REFIID riid,
1405 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1406 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1408 if( SUCCEEDED(loadTypeInfo()) )
1410 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1411 pVarResult, pExcepInfo, puArgErr);
1416 inline const char *msgSeverity(int sev)
1431 STDMETHODIMP VLCMessage::get__Value(VARIANT* _Value)
1433 if( NULL == _Value )
1438 snprintf(buffer, sizeof(buffer), "%s %s %s: %s",
1439 _msg.psz_type, _msg.psz_name, msgSeverity(_msg.i_severity), _msg.psz_message);
1441 V_VT(_Value) = VT_BSTR;
1442 V_BSTR(_Value) = BSTRFromCStr(CP_UTF8, buffer);
1447 STDMETHODIMP VLCMessage::get_severity(long* level)
1452 *level = _msg.i_severity;
1457 STDMETHODIMP VLCMessage::get_type(BSTR* type)
1462 *type = BSTRFromCStr(CP_UTF8, _msg.psz_type);
1467 STDMETHODIMP VLCMessage::get_name(BSTR* name)
1472 *name = BSTRFromCStr(CP_UTF8, _msg.psz_name);
1477 STDMETHODIMP VLCMessage::get_header(BSTR* header)
1479 if( NULL == header )
1482 *header = BSTRFromCStr(CP_UTF8, _msg.psz_header);
1487 STDMETHODIMP VLCMessage::get_message(BSTR* message)
1489 if( NULL == message )
1492 *message = BSTRFromCStr(CP_UTF8, _msg.psz_message);
1497 /****************************************************************************/
1499 VLCPlaylistItems::~VLCPlaylistItems()
1502 _p_typeinfo->Release();
1505 HRESULT VLCPlaylistItems::loadTypeInfo(void)
1507 HRESULT hr = NOERROR;
1508 if( NULL == _p_typeinfo )
1510 ITypeLib *p_typelib;
1512 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1515 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCPlaylistItems, &_p_typeinfo);
1520 p_typelib->Release();
1526 STDMETHODIMP VLCPlaylistItems::GetTypeInfoCount(UINT* pctInfo)
1528 if( NULL == pctInfo )
1529 return E_INVALIDARG;
1531 if( SUCCEEDED(loadTypeInfo()) )
1539 STDMETHODIMP VLCPlaylistItems::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1541 if( NULL == ppTInfo )
1542 return E_INVALIDARG;
1544 if( SUCCEEDED(loadTypeInfo()) )
1546 _p_typeinfo->AddRef();
1547 *ppTInfo = _p_typeinfo;
1554 STDMETHODIMP VLCPlaylistItems::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1555 UINT cNames, LCID lcid, DISPID* rgDispID)
1557 if( SUCCEEDED(loadTypeInfo()) )
1559 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1564 STDMETHODIMP VLCPlaylistItems::Invoke(DISPID dispIdMember, REFIID riid,
1565 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1566 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1568 if( SUCCEEDED(loadTypeInfo()) )
1570 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1571 pVarResult, pExcepInfo, puArgErr);
1576 STDMETHODIMP VLCPlaylistItems::get_count(long* count)
1581 libvlc_exception_t ex;
1582 libvlc_exception_init(&ex);
1584 *count = _p_instance->playlist_count(&ex);
1585 return exception_bridge(&ex);
1588 STDMETHODIMP VLCPlaylistItems::clear()
1590 libvlc_exception_t ex;
1591 libvlc_exception_init(&ex);
1593 _p_instance->playlist_clear(&ex);
1594 return exception_bridge(&ex);
1597 STDMETHODIMP VLCPlaylistItems::remove(long item)
1599 libvlc_instance_t* p_libvlc;
1600 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1603 libvlc_exception_t ex;
1604 libvlc_exception_init(&ex);
1606 _p_instance->playlist_delete_item(item, &ex);
1607 hr = exception_bridge(&ex);
1612 /****************************************************************************/
1614 VLCPlaylist::~VLCPlaylist()
1616 delete _p_vlcplaylistitems;
1618 _p_typeinfo->Release();
1621 HRESULT VLCPlaylist::loadTypeInfo(void)
1623 HRESULT hr = NOERROR;
1624 if( NULL == _p_typeinfo )
1626 ITypeLib *p_typelib;
1628 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1631 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCPlaylist, &_p_typeinfo);
1636 p_typelib->Release();
1642 STDMETHODIMP VLCPlaylist::GetTypeInfoCount(UINT* pctInfo)
1644 if( NULL == pctInfo )
1645 return E_INVALIDARG;
1647 if( SUCCEEDED(loadTypeInfo()) )
1655 STDMETHODIMP VLCPlaylist::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1657 if( NULL == ppTInfo )
1658 return E_INVALIDARG;
1660 if( SUCCEEDED(loadTypeInfo()) )
1662 _p_typeinfo->AddRef();
1663 *ppTInfo = _p_typeinfo;
1670 STDMETHODIMP VLCPlaylist::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1671 UINT cNames, LCID lcid, DISPID* rgDispID)
1673 if( SUCCEEDED(loadTypeInfo()) )
1675 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1680 STDMETHODIMP VLCPlaylist::Invoke(DISPID dispIdMember, REFIID riid,
1681 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1682 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1684 if( SUCCEEDED(loadTypeInfo()) )
1686 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1687 pVarResult, pExcepInfo, puArgErr);
1692 STDMETHODIMP VLCPlaylist::get_itemCount(long* count)
1698 libvlc_exception_t ex;
1699 libvlc_exception_init(&ex);
1701 *count = _p_instance->playlist_count(&ex);
1702 return exception_bridge(&ex);
1705 STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
1707 if( NULL == isPlaying )
1710 libvlc_media_player_t *p_md;
1711 HRESULT hr = _p_instance->getMD(&p_md);
1714 libvlc_exception_t ex;
1715 libvlc_exception_init(&ex);
1717 *isPlaying = libvlc_media_player_is_playing(p_md, &ex) ?
1718 VARIANT_TRUE: VARIANT_FALSE;
1719 libvlc_exception_clear(&ex);
1724 STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* item)
1729 if( 0 == SysStringLen(uri) )
1730 return E_INVALIDARG;
1732 libvlc_instance_t* p_libvlc;
1733 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1736 libvlc_exception_t ex;
1737 libvlc_exception_init(&ex);
1739 char *psz_uri = NULL;
1740 if( SysStringLen(_p_instance->getBaseURL()) > 0 )
1743 ** if the MRL a relative URL, we should end up with an absolute URL
1745 LPWSTR abs_url = CombineURL(_p_instance->getBaseURL(), uri);
1746 if( NULL != abs_url )
1748 psz_uri = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url));
1749 CoTaskMemFree(abs_url);
1753 psz_uri = CStrFromBSTR(CP_UTF8, uri);
1759 ** baseURL is empty, assume MRL is absolute
1761 psz_uri = CStrFromBSTR(CP_UTF8, uri);
1764 if( NULL == psz_uri )
1766 return E_OUTOFMEMORY;
1770 char **ppsz_options;
1772 hr = VLCControl::CreateTargetOptions(CP_UTF8, &options, &ppsz_options, &i_options);
1775 CoTaskMemFree(psz_uri);
1779 char *psz_name = NULL;
1781 VariantInit(&v_name);
1782 if( SUCCEEDED(VariantChangeType(&v_name, &name, 0, VT_BSTR)) )
1784 if( SysStringLen(V_BSTR(&v_name)) > 0 )
1785 psz_name = CStrFromBSTR(CP_UTF8, V_BSTR(&v_name));
1787 VariantClear(&v_name);
1790 *item = _p_instance->playlist_add_extended_untrusted(psz_uri,
1791 i_options, const_cast<const char **>(ppsz_options), &ex);
1793 VLCControl::FreeTargetOptions(ppsz_options, i_options);
1794 CoTaskMemFree(psz_uri);
1795 if( psz_name ) /* XXX Do we even need to check? */
1796 CoTaskMemFree(psz_name);
1797 hr = exception_bridge(&ex);
1802 STDMETHODIMP VLCPlaylist::play()
1804 libvlc_exception_t ex;
1805 libvlc_exception_init(&ex);
1807 _p_instance->playlist_play(&ex);
1808 return exception_bridge(&ex);
1811 STDMETHODIMP VLCPlaylist::playItem(long item)
1813 libvlc_exception_t ex;
1814 libvlc_exception_init(&ex);
1816 _p_instance->playlist_play_item(item,&ex);
1817 return exception_bridge(&ex);;
1820 STDMETHODIMP VLCPlaylist::togglePause()
1822 libvlc_media_player_t* p_md;
1823 HRESULT hr = _p_instance->getMD(&p_md);
1826 libvlc_exception_t ex;
1827 libvlc_exception_init(&ex);
1829 libvlc_media_player_pause(p_md, &ex);
1830 hr = exception_bridge(&ex);;
1835 STDMETHODIMP VLCPlaylist::stop()
1837 libvlc_media_player_t *p_md;
1838 HRESULT hr = _p_instance->getMD(&p_md);
1841 libvlc_exception_t ex;
1842 libvlc_exception_init(&ex);
1844 libvlc_media_player_stop(p_md, &ex);
1845 hr = exception_bridge(&ex);;
1850 STDMETHODIMP VLCPlaylist::next()
1852 libvlc_exception_t ex;
1853 libvlc_exception_init(&ex);
1855 _p_instance->playlist_next(&ex);
1856 return exception_bridge(&ex);;
1859 STDMETHODIMP VLCPlaylist::prev()
1861 libvlc_exception_t ex;
1862 libvlc_exception_init(&ex);
1864 _p_instance->playlist_prev(&ex);
1865 return exception_bridge(&ex);;
1868 STDMETHODIMP VLCPlaylist::clear()
1870 libvlc_exception_t ex;
1871 libvlc_exception_init(&ex);
1873 _p_instance->playlist_clear(&ex);
1874 return exception_bridge(&ex);;
1877 STDMETHODIMP VLCPlaylist::removeItem(long item)
1879 libvlc_instance_t* p_libvlc;
1880 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1883 libvlc_exception_t ex;
1884 libvlc_exception_init(&ex);
1886 _p_instance->playlist_delete_item(item, &ex);
1887 hr = exception_bridge(&ex);;
1892 STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj)
1897 *obj = _p_vlcplaylistitems;
1898 if( NULL != _p_vlcplaylistitems )
1900 _p_vlcplaylistitems->AddRef();
1903 return E_OUTOFMEMORY;
1906 /****************************************************************************/
1908 VLCSubtitle::~VLCSubtitle()
1911 _p_typeinfo->Release();
1914 HRESULT VLCSubtitle::loadTypeInfo(void)
1916 HRESULT hr = NOERROR;
1917 if( NULL == _p_typeinfo )
1919 ITypeLib *p_typelib;
1921 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1924 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCSubtitle, &_p_typeinfo);
1929 p_typelib->Release();
1935 STDMETHODIMP VLCSubtitle::GetTypeInfoCount(UINT* pctInfo)
1937 if( NULL == pctInfo )
1938 return E_INVALIDARG;
1940 if( SUCCEEDED(loadTypeInfo()) )
1948 STDMETHODIMP VLCSubtitle::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1950 if( NULL == ppTInfo )
1951 return E_INVALIDARG;
1953 if( SUCCEEDED(loadTypeInfo()) )
1955 _p_typeinfo->AddRef();
1956 *ppTInfo = _p_typeinfo;
1963 STDMETHODIMP VLCSubtitle::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1964 UINT cNames, LCID lcid, DISPID* rgDispID)
1966 if( SUCCEEDED(loadTypeInfo()) )
1968 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1973 STDMETHODIMP VLCSubtitle::Invoke(DISPID dispIdMember, REFIID riid,
1974 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1975 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1977 if( SUCCEEDED(loadTypeInfo()) )
1979 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1980 pVarResult, pExcepInfo, puArgErr);
1985 STDMETHODIMP VLCSubtitle::get_track(long* spu)
1990 libvlc_media_player_t *p_md;
1991 HRESULT hr = _p_instance->getMD(&p_md);
1994 libvlc_exception_t ex;
1995 libvlc_exception_init(&ex);
1997 *spu = libvlc_video_get_spu(p_md, &ex);
1998 hr = exception_bridge(&ex);
2003 STDMETHODIMP VLCSubtitle::put_track(long spu)
2005 libvlc_media_player_t *p_md;
2006 HRESULT hr = _p_instance->getMD(&p_md);
2009 libvlc_exception_t ex;
2010 libvlc_exception_init(&ex);
2012 libvlc_video_set_spu(p_md, spu, &ex);
2013 hr = exception_bridge(&ex);
2018 STDMETHODIMP VLCSubtitle::get_count(long* spuNumber)
2020 if( NULL == spuNumber )
2023 libvlc_media_player_t *p_md;
2024 HRESULT hr = _p_instance->getMD(&p_md);
2027 libvlc_exception_t ex;
2028 libvlc_exception_init(&ex);
2029 // get the number of video subtitle available and return it
2030 *spuNumber = libvlc_video_get_spu_count(p_md, &ex);
2031 hr = exception_bridge(&ex);
2037 STDMETHODIMP VLCSubtitle::description(long nameID, BSTR* name)
2042 libvlc_media_player_t* p_md;
2043 libvlc_exception_t ex;
2044 libvlc_exception_init(&ex);
2046 HRESULT hr = _p_instance->getMD(&p_md);
2050 const char *psz_name;
2051 libvlc_track_description_t *p_spuDesc;
2053 // get subtitles description
2054 p_spuDesc = libvlc_video_get_spu_description(p_md, &ex);
2055 hr = exception_bridge(&ex);
2059 // get the number of available subtitle
2060 i_limit = libvlc_video_get_spu_count(p_md, &ex);
2061 hr = exception_bridge(&ex);
2065 // check if the number given is a good one
2066 if ( ( nameID > ( i_limit -1 ) ) || ( nameID < 0 ) )
2069 // get the good spuDesc
2070 for( i = 0 ; i < nameID ; i++ )
2072 p_spuDesc = p_spuDesc->p_next;
2074 // get the subtitle name
2075 psz_name = p_spuDesc->psz_name;
2078 if( psz_name != NULL )
2080 *name = BSTRFromCStr(CP_UTF8, psz_name);
2081 return (NULL == *name) ? E_OUTOFMEMORY : NOERROR;
2089 /****************************************************************************/
2091 VLCVideo::~VLCVideo()
2093 delete _p_vlcmarquee;
2096 _p_typeinfo->Release();
2099 HRESULT VLCVideo::loadTypeInfo(void)
2101 HRESULT hr = NOERROR;
2102 if( NULL == _p_typeinfo )
2104 ITypeLib *p_typelib;
2106 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
2109 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCVideo, &_p_typeinfo);
2114 p_typelib->Release();
2120 STDMETHODIMP VLCVideo::GetTypeInfoCount(UINT* pctInfo)
2122 if( NULL == pctInfo )
2123 return E_INVALIDARG;
2125 if( SUCCEEDED(loadTypeInfo()) )
2133 STDMETHODIMP VLCVideo::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
2135 if( NULL == ppTInfo )
2136 return E_INVALIDARG;
2138 if( SUCCEEDED(loadTypeInfo()) )
2140 _p_typeinfo->AddRef();
2141 *ppTInfo = _p_typeinfo;
2148 STDMETHODIMP VLCVideo::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
2149 UINT cNames, LCID lcid, DISPID* rgDispID)
2151 if( SUCCEEDED(loadTypeInfo()) )
2153 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
2158 STDMETHODIMP VLCVideo::Invoke(DISPID dispIdMember, REFIID riid,
2159 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
2160 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
2162 if( SUCCEEDED(loadTypeInfo()) )
2164 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
2165 pVarResult, pExcepInfo, puArgErr);
2170 STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
2172 if( NULL == fullscreen )
2175 libvlc_media_player_t *p_md;
2176 HRESULT hr = _p_instance->getMD(&p_md);
2179 libvlc_exception_t ex;
2180 libvlc_exception_init(&ex);
2182 *fullscreen = libvlc_get_fullscreen(p_md, &ex) ?
2183 VARIANT_TRUE : VARIANT_FALSE;
2184 hr = exception_bridge(&ex);
2189 STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen)
2191 libvlc_media_player_t *p_md;
2192 HRESULT hr = _p_instance->getMD(&p_md);
2195 libvlc_exception_t ex;
2196 libvlc_exception_init(&ex);
2198 libvlc_set_fullscreen(p_md, VARIANT_FALSE != fullscreen, &ex);
2199 hr = exception_bridge(&ex);
2204 STDMETHODIMP VLCVideo::get_width(long* width)
2209 libvlc_media_player_t *p_md;
2210 HRESULT hr = _p_instance->getMD(&p_md);
2213 libvlc_exception_t ex;
2214 libvlc_exception_init(&ex);
2216 *width = libvlc_video_get_width(p_md, &ex);
2217 hr = exception_bridge(&ex);
2222 STDMETHODIMP VLCVideo::get_height(long* height)
2224 if( NULL == height )
2227 libvlc_media_player_t *p_md;
2228 HRESULT hr = _p_instance->getMD(&p_md);
2231 libvlc_exception_t ex;
2232 libvlc_exception_init(&ex);
2234 *height = libvlc_video_get_height(p_md, &ex);
2235 hr = exception_bridge(&ex);
2240 STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect)
2242 if( NULL == aspect )
2245 libvlc_media_player_t *p_md;
2246 HRESULT hr = _p_instance->getMD(&p_md);
2249 libvlc_exception_t ex;
2250 libvlc_exception_init(&ex);
2252 char *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
2254 hr = exception_bridge(&ex);
2255 if( SUCCEEDED(hr) && NULL != psz_aspect )
2257 *aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
2258 if( NULL == *aspect )
2260 } else if( NULL == psz_aspect) hr = E_OUTOFMEMORY; // strdup("") failed
2266 STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
2268 if( NULL == aspect )
2271 libvlc_media_player_t *p_md;
2272 HRESULT hr = _p_instance->getMD(&p_md);
2275 libvlc_exception_t ex;
2276 libvlc_exception_init(&ex);
2278 char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
2279 if( NULL == psz_aspect )
2281 return E_OUTOFMEMORY;
2284 libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
2286 CoTaskMemFree(psz_aspect);
2287 hr = exception_bridge(&ex);
2292 STDMETHODIMP VLCVideo::get_subtitle(long* spu)
2297 libvlc_media_player_t *p_md;
2298 HRESULT hr = _p_instance->getMD(&p_md);
2301 libvlc_exception_t ex;
2302 libvlc_exception_init(&ex);
2304 *spu = libvlc_video_get_spu(p_md, &ex);
2305 hr = exception_bridge(&ex);
2310 STDMETHODIMP VLCVideo::put_subtitle(long spu)
2312 libvlc_media_player_t *p_md;
2313 HRESULT hr = _p_instance->getMD(&p_md);
2316 libvlc_exception_t ex;
2317 libvlc_exception_init(&ex);
2319 libvlc_video_set_spu(p_md, spu, &ex);
2320 hr = exception_bridge(&ex);
2325 STDMETHODIMP VLCVideo::get_crop(BSTR* geometry)
2327 if( NULL == geometry )
2330 libvlc_media_player_t *p_md;
2331 HRESULT hr = _p_instance->getMD(&p_md);
2334 libvlc_exception_t ex;
2335 libvlc_exception_init(&ex);
2337 char *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
2339 hr = exception_bridge(&ex);
2340 if( SUCCEEDED(&ex) && NULL != psz_geometry )
2342 *geometry = BSTRFromCStr(CP_UTF8, psz_geometry);
2343 if( NULL == geometry ) hr = E_OUTOFMEMORY;
2344 } else if( NULL == psz_geometry ) hr = E_OUTOFMEMORY;
2345 free( psz_geometry );
2350 STDMETHODIMP VLCVideo::put_crop(BSTR geometry)
2352 if( NULL == geometry )
2355 if( 0 == SysStringLen(geometry) )
2356 return E_INVALIDARG;
2358 libvlc_media_player_t *p_md;
2359 HRESULT hr = _p_instance->getMD(&p_md);
2362 libvlc_exception_t ex;
2363 libvlc_exception_init(&ex);
2365 char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry);
2366 if( NULL == psz_geometry )
2368 return E_OUTOFMEMORY;
2371 libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
2373 CoTaskMemFree(psz_geometry);
2374 hr = exception_bridge(&ex);
2379 STDMETHODIMP VLCVideo::get_teletext(long* page)
2384 libvlc_media_player_t *p_md;
2385 HRESULT hr = _p_instance->getMD(&p_md);
2388 libvlc_exception_t ex;
2389 libvlc_exception_init(&ex);
2391 *page = libvlc_video_get_teletext(p_md, &ex);
2392 hr = exception_bridge(&ex);
2397 STDMETHODIMP VLCVideo::put_teletext(long page)
2399 libvlc_media_player_t *p_md;
2400 HRESULT hr = _p_instance->getMD(&p_md);
2403 libvlc_exception_t ex;
2404 libvlc_exception_init(&ex);
2406 libvlc_video_set_teletext(p_md, page, &ex);
2407 hr = exception_bridge(&ex);
2412 STDMETHODIMP VLCVideo::deinterlaceDisable()
2414 libvlc_media_player_t *p_md;
2415 HRESULT hr = _p_instance->getMD(&p_md);
2418 libvlc_exception_t ex;
2419 libvlc_exception_init(&ex);
2421 libvlc_video_set_deinterlace(p_md, 0, "", &ex);
2422 hr = exception_bridge(&ex);
2427 STDMETHODIMP VLCVideo::deinterlaceEnable(BSTR mode)
2429 libvlc_media_player_t *p_md;
2430 HRESULT hr = _p_instance->getMD(&p_md);
2433 libvlc_exception_t ex;
2434 libvlc_exception_init(&ex);
2435 /* get deinterlace mode from the user */
2436 char *psz_mode = CStrFromBSTR(CP_UTF8, mode);
2437 /* enable deinterlace filter if possible */
2438 libvlc_video_set_deinterlace(p_md, 1, psz_mode, &ex);
2439 hr = exception_bridge(&ex);
2440 CoTaskMemFree(psz_mode);
2445 STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
2447 if( NULL == picture )
2450 libvlc_media_player_t *p_md;
2451 HRESULT hr = _p_instance->getMD(&p_md);
2454 libvlc_exception_t ex;
2455 libvlc_exception_init(&ex);
2457 static int uniqueId = 0;
2458 TCHAR path[MAX_PATH+1];
2460 int pathlen = GetTempPath(MAX_PATH-24, path);
2461 if( (0 == pathlen) || (pathlen > (MAX_PATH-24)) )
2464 /* check temp directory path by openning it */
2466 HANDLE dirHandle = CreateFile(path, GENERIC_READ,
2467 FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
2468 NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
2469 if( INVALID_HANDLE_VALUE == dirHandle )
2471 _p_instance->setErrorInfo(IID_IVLCVideo,
2472 "Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
2477 BY_HANDLE_FILE_INFORMATION bhfi;
2478 BOOL res = GetFileInformationByHandle(dirHandle, &bhfi);
2479 CloseHandle(dirHandle);
2480 if( !res || !(bhfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
2482 _p_instance->setErrorInfo(IID_IVLCVideo,
2483 "Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
2489 TCHAR filepath[MAX_PATH+1];
2491 _stprintf(filepath, TEXT("%sAXVLC%lXS%lX.bmp"),
2492 path, GetCurrentProcessId(), ++uniqueId);
2495 /* reuse path storage for UTF8 string */
2496 char *psz_filepath = (char *)path;
2497 WCHAR* wpath = filepath;
2499 char *psz_filepath = path;
2500 /* first convert to unicode using current code page */
2501 WCHAR wpath[MAX_PATH+1];
2502 if( 0 == MultiByteToWideChar(CP_ACP, 0, filepath, -1,
2503 wpath, sizeof(wpath)/sizeof(WCHAR)) )
2506 /* convert to UTF8 */
2507 pathlen = WideCharToMultiByte(CP_UTF8, 0, wpath, -1,
2508 psz_filepath, sizeof(path), NULL, NULL);
2509 // fail if path is 0 or too short (i.e pathlen is the same as
2512 if( (0 == pathlen) || (sizeof(path) == pathlen) )
2515 /* take snapshot into file */
2516 libvlc_video_take_snapshot(p_md, psz_filepath, 0, 0, &ex);
2517 hr = exception_bridge(&ex);
2520 /* open snapshot file */
2521 HANDLE snapPic = LoadImage(NULL, filepath, IMAGE_BITMAP, 0, 0,
2522 LR_CREATEDIBSECTION|LR_LOADFROMFILE);
2527 snapDesc.cbSizeofstruct = sizeof(PICTDESC);
2528 snapDesc.picType = PICTYPE_BITMAP;
2529 snapDesc.bmp.hbitmap = (HBITMAP)snapPic;
2530 snapDesc.bmp.hpal = NULL;
2532 hr = OleCreatePictureIndirect(&snapDesc, IID_IPictureDisp,
2533 TRUE, (LPVOID*)picture);
2537 DeleteObject(snapPic);
2540 DeleteFile(filepath);
2546 STDMETHODIMP VLCVideo::toggleFullscreen()
2548 libvlc_media_player_t *p_md;
2549 HRESULT hr = _p_instance->getMD(&p_md);
2552 libvlc_exception_t ex;
2553 libvlc_exception_init(&ex);
2555 libvlc_toggle_fullscreen(p_md, &ex);
2556 hr = exception_bridge(&ex);
2561 STDMETHODIMP VLCVideo::toggleTeletext()
2563 libvlc_media_player_t *p_md;
2564 HRESULT hr = _p_instance->getMD(&p_md);
2567 libvlc_exception_t ex;
2568 libvlc_exception_init(&ex);
2570 libvlc_toggle_teletext(p_md, &ex);
2571 hr = exception_bridge(&ex);
2576 STDMETHODIMP VLCVideo::get_marquee(IVLCMarquee** obj)
2581 *obj = _p_vlcmarquee;
2582 if( NULL != _p_vlcmarquee )
2584 _p_vlcmarquee->AddRef();
2587 return E_OUTOFMEMORY;
2590 STDMETHODIMP VLCVideo::get_logo(IVLCLogo** obj)
2596 if( NULL != _p_vlclogo )
2598 _p_vlclogo->AddRef();
2601 return E_OUTOFMEMORY;
2605 /****************************************************************************/
2607 HRESULT VLCLogo::loadTypeInfo(void)
2609 HRESULT hr = NOERROR;
2610 if( NULL == _p_typeinfo )
2612 ITypeLib *p_typelib;
2614 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
2617 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCLogo, &_p_typeinfo);
2622 p_typelib->Release();
2628 STDMETHODIMP VLCLogo::GetTypeInfoCount(UINT* pctInfo)
2630 if( NULL == pctInfo )
2631 return E_INVALIDARG;
2633 if( SUCCEEDED(loadTypeInfo()) )
2641 STDMETHODIMP VLCLogo::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
2643 if( NULL == ppTInfo )
2644 return E_INVALIDARG;
2646 if( SUCCEEDED(loadTypeInfo()) )
2648 _p_typeinfo->AddRef();
2649 *ppTInfo = _p_typeinfo;
2656 STDMETHODIMP VLCLogo::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
2657 UINT cNames, LCID lcid, DISPID* rgDispID)
2659 if( SUCCEEDED(loadTypeInfo()) )
2660 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
2664 STDMETHODIMP VLCLogo::Invoke(DISPID dispIdMember, REFIID riid,
2665 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
2666 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
2668 if( SUCCEEDED(loadTypeInfo()) )
2670 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags,
2671 pDispParams, pVarResult, pExcepInfo, puArgErr);
2677 HRESULT VLCLogo::do_put_int(unsigned idx, LONG val)
2679 libvlc_media_player_t *p_md;
2680 HRESULT hr = _p_instance->getMD(&p_md);
2683 libvlc_exception_t ex;
2684 libvlc_exception_init(&ex);
2685 libvlc_video_set_logo_int(p_md, idx, val, &ex);
2686 hr = exception_bridge(&ex);
2691 HRESULT VLCLogo::do_get_int(unsigned idx, LONG *val)
2696 libvlc_media_player_t *p_md;
2697 HRESULT hr = _p_instance->getMD(&p_md);
2700 libvlc_exception_t ex;
2701 libvlc_exception_init(&ex);
2702 *val = libvlc_video_get_logo_int(p_md, idx, &ex);
2703 hr = exception_bridge(&ex);
2707 STDMETHODIMP VLCLogo::file(BSTR fname)
2709 libvlc_media_player_t *p_md;
2710 HRESULT hr = _p_instance->getMD(&p_md);
2712 char *n = CStrFromBSTR(CP_UTF8, fname);
2713 if( !n ) hr = E_OUTOFMEMORY;
2717 libvlc_exception_t ex;
2718 libvlc_exception_init(&ex);
2719 libvlc_video_set_logo_string(p_md, libvlc_logo_file, n, &ex);
2720 hr = exception_bridge(&ex);
2727 struct posidx_s { const char *n; size_t i; };
2728 static const posidx_s posidx[] = {
2736 { "bottom-left", 9 },
2737 { "bottom-right", 10 },
2739 enum { num_posidx = sizeof(posidx)/sizeof(*posidx) };
2740 STDMETHODIMP VLCLogo::get_position(BSTR* val)
2746 HRESULT hr = do_get_int(libvlc_logo_position, &i);
2750 const char *n="undefined";
2752 for( const posidx_s *h=posidx; h<posidx+num_posidx; ++h )
2758 *val = BSTRFromCStr(CP_UTF8, n);
2762 STDMETHODIMP VLCLogo::put_position(BSTR val)
2764 char *n = CStrFromBSTR(CP_UTF8, val);
2765 if( !n ) return E_OUTOFMEMORY;
2767 HRESULT hr = E_NOTIMPL;
2770 for( h=posidx; h<posidx+num_posidx; ++h )
2771 if( !strcasecmp( n, h->n ) )
2773 hr = do_put_int(libvlc_logo_position,h->i);
2777 if( h == posidx+num_posidx )
2784 /****************************************************************************/
2786 VLCControl2::VLCControl2(VLCPlugin *p_instance) :
2787 _p_instance(p_instance),
2789 _p_vlcaudio(new VLCAudio(p_instance)),
2790 _p_vlcinput(new VLCInput(p_instance)),
2791 _p_vlclog(new VLCLog(p_instance)),
2792 _p_vlcplaylist(new VLCPlaylist(p_instance)),
2793 _p_vlcsubtitle(new VLCSubtitle(p_instance)),
2794 _p_vlcvideo(new VLCVideo(p_instance))
2798 VLCControl2::~VLCControl2()
2801 delete _p_vlcsubtitle;
2802 delete _p_vlcplaylist;
2807 _p_typeinfo->Release();
2810 HRESULT VLCControl2::loadTypeInfo(void)
2812 HRESULT hr = NOERROR;
2813 if( NULL == _p_typeinfo )
2815 ITypeLib *p_typelib;
2817 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
2820 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCControl2, &_p_typeinfo);
2825 p_typelib->Release();
2831 STDMETHODIMP VLCControl2::GetTypeInfoCount(UINT* pctInfo)
2833 if( NULL == pctInfo )
2834 return E_INVALIDARG;
2836 if( SUCCEEDED(loadTypeInfo()) )
2844 STDMETHODIMP VLCControl2::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
2846 if( NULL == ppTInfo )
2847 return E_INVALIDARG;
2849 if( SUCCEEDED(loadTypeInfo()) )
2851 _p_typeinfo->AddRef();
2852 *ppTInfo = _p_typeinfo;
2859 STDMETHODIMP VLCControl2::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
2860 UINT cNames, LCID lcid, DISPID* rgDispID)
2862 if( SUCCEEDED(loadTypeInfo()) )
2864 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
2869 STDMETHODIMP VLCControl2::Invoke(DISPID dispIdMember, REFIID riid,
2870 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
2871 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
2873 if( SUCCEEDED(loadTypeInfo()) )
2875 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
2876 pVarResult, pExcepInfo, puArgErr);
2881 STDMETHODIMP VLCControl2::get_AutoLoop(VARIANT_BOOL *autoloop)
2883 if( NULL == autoloop )
2886 *autoloop = _p_instance->getAutoLoop() ? VARIANT_TRUE: VARIANT_FALSE;
2890 STDMETHODIMP VLCControl2::put_AutoLoop(VARIANT_BOOL autoloop)
2892 _p_instance->setAutoLoop((VARIANT_FALSE != autoloop) ? TRUE: FALSE);
2896 STDMETHODIMP VLCControl2::get_AutoPlay(VARIANT_BOOL *autoplay)
2898 if( NULL == autoplay )
2901 *autoplay = _p_instance->getAutoPlay() ? VARIANT_TRUE: VARIANT_FALSE;
2905 STDMETHODIMP VLCControl2::put_AutoPlay(VARIANT_BOOL autoplay)
2907 _p_instance->setAutoPlay((VARIANT_FALSE != autoplay) ? TRUE: FALSE);
2911 STDMETHODIMP VLCControl2::get_BaseURL(BSTR *url)
2916 *url = SysAllocStringLen(_p_instance->getBaseURL(),
2917 SysStringLen(_p_instance->getBaseURL()));
2921 STDMETHODIMP VLCControl2::put_BaseURL(BSTR mrl)
2923 _p_instance->setBaseURL(mrl);
2928 STDMETHODIMP VLCControl2::get_MRL(BSTR *mrl)
2933 *mrl = SysAllocStringLen(_p_instance->getMRL(),
2934 SysStringLen(_p_instance->getMRL()));
2938 STDMETHODIMP VLCControl2::put_MRL(BSTR mrl)
2940 _p_instance->setMRL(mrl);
2946 STDMETHODIMP VLCControl2::get_Toolbar(VARIANT_BOOL *visible)
2948 if( NULL == visible )
2952 * Note to developers
2954 * Returning the _b_toolbar is closer to the method specification.
2955 * But returning True when toolbar is not implemented so not displayed
2956 * could be bad for ActiveX users which rely on this value to show their
2957 * own toolbar if not provided by the ActiveX.
2959 * This is the reason why FALSE is returned, until toolbar get implemented.
2962 /* DISABLED for now */
2963 // *visible = _p_instance->getShowToolbar() ? VARIANT_TRUE: VARIANT_FALSE;
2965 *visible = VARIANT_FALSE;
2970 STDMETHODIMP VLCControl2::put_Toolbar(VARIANT_BOOL visible)
2972 _p_instance->setShowToolbar((VARIANT_FALSE != visible) ? TRUE: FALSE);
2977 STDMETHODIMP VLCControl2::get_StartTime(long *seconds)
2979 if( NULL == seconds )
2982 *seconds = _p_instance->getStartTime();
2987 STDMETHODIMP VLCControl2::put_StartTime(long seconds)
2989 _p_instance->setStartTime(seconds);
2994 STDMETHODIMP VLCControl2::get_VersionInfo(BSTR *version)
2996 if( NULL == version )
2999 const char *versionStr = libvlc_get_version();
3000 if( NULL != versionStr )
3002 *version = BSTRFromCStr(CP_UTF8, versionStr);
3004 return (NULL == *version) ? E_OUTOFMEMORY : NOERROR;
3010 STDMETHODIMP VLCControl2::get_Visible(VARIANT_BOOL *isVisible)
3012 if( NULL == isVisible )
3015 *isVisible = _p_instance->getVisible() ? VARIANT_TRUE : VARIANT_FALSE;
3020 STDMETHODIMP VLCControl2::put_Visible(VARIANT_BOOL isVisible)
3022 _p_instance->setVisible(isVisible != VARIANT_FALSE);
3027 STDMETHODIMP VLCControl2::get_Volume(long *volume)
3029 if( NULL == volume )
3032 *volume = _p_instance->getVolume();
3036 STDMETHODIMP VLCControl2::put_Volume(long volume)
3038 _p_instance->setVolume(volume);
3042 STDMETHODIMP VLCControl2::get_BackColor(OLE_COLOR *backcolor)
3044 if( NULL == backcolor )
3047 *backcolor = _p_instance->getBackColor();
3051 STDMETHODIMP VLCControl2::put_BackColor(OLE_COLOR backcolor)
3053 _p_instance->setBackColor(backcolor);
3057 STDMETHODIMP VLCControl2::get_audio(IVLCAudio** obj)
3063 if( NULL != _p_vlcaudio )
3065 _p_vlcaudio->AddRef();
3068 return E_OUTOFMEMORY;
3071 STDMETHODIMP VLCControl2::get_input(IVLCInput** obj)
3077 if( NULL != _p_vlcinput )
3079 _p_vlcinput->AddRef();
3082 return E_OUTOFMEMORY;
3085 STDMETHODIMP VLCControl2::get_log(IVLCLog** obj)
3091 if( NULL != _p_vlclog )
3093 _p_vlclog->AddRef();
3096 return E_OUTOFMEMORY;
3099 STDMETHODIMP VLCControl2::get_playlist(IVLCPlaylist** obj)
3104 *obj = _p_vlcplaylist;
3105 if( NULL != _p_vlcplaylist )
3107 _p_vlcplaylist->AddRef();
3110 return E_OUTOFMEMORY;
3113 STDMETHODIMP VLCControl2::get_subtitle(IVLCSubtitle** obj)
3118 *obj = _p_vlcsubtitle;
3119 if( NULL != _p_vlcsubtitle )
3121 _p_vlcsubtitle->AddRef();
3124 return E_OUTOFMEMORY;
3127 STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj)
3133 if( NULL != _p_vlcvideo )
3135 _p_vlcvideo->AddRef();
3138 return E_OUTOFMEMORY;