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"
39 _p_typeinfo->Release();
42 HRESULT VLCAudio::loadTypeInfo(void)
45 if( NULL == _p_typeinfo )
49 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
52 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCAudio, &_p_typeinfo);
63 STDMETHODIMP VLCAudio::GetTypeInfoCount(UINT* pctInfo)
68 if( SUCCEEDED(loadTypeInfo()) )
76 STDMETHODIMP VLCAudio::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
81 if( SUCCEEDED(loadTypeInfo()) )
83 _p_typeinfo->AddRef();
84 *ppTInfo = _p_typeinfo;
91 STDMETHODIMP VLCAudio::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
92 UINT cNames, LCID lcid, DISPID* rgDispID)
94 if( SUCCEEDED(loadTypeInfo()) )
96 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
101 STDMETHODIMP VLCAudio::Invoke(DISPID dispIdMember, REFIID riid,
102 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
103 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
105 if( SUCCEEDED(loadTypeInfo()) )
107 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
108 pVarResult, pExcepInfo, puArgErr);
113 STDMETHODIMP VLCAudio::get_mute(VARIANT_BOOL* mute)
118 libvlc_instance_t* p_libvlc;
119 HRESULT hr = _p_instance->getVLC(&p_libvlc);
122 libvlc_exception_t ex;
123 libvlc_exception_init(&ex);
125 *mute = libvlc_audio_get_mute(p_libvlc, &ex) ?
126 VARIANT_TRUE : VARIANT_FALSE;
127 if( libvlc_exception_raised(&ex) )
129 _p_instance->setErrorInfo(IID_IVLCAudio,
130 libvlc_exception_get_message(&ex));
131 libvlc_exception_clear(&ex);
139 STDMETHODIMP VLCAudio::put_mute(VARIANT_BOOL mute)
141 libvlc_instance_t* p_libvlc;
142 HRESULT hr = _p_instance->getVLC(&p_libvlc);
145 libvlc_exception_t ex;
146 libvlc_exception_init(&ex);
148 libvlc_audio_set_mute(p_libvlc, VARIANT_FALSE != mute, &ex);
149 if( libvlc_exception_raised(&ex) )
151 _p_instance->setErrorInfo(IID_IVLCAudio,
152 libvlc_exception_get_message(&ex));
153 libvlc_exception_clear(&ex);
161 STDMETHODIMP VLCAudio::get_volume(long* volume)
166 libvlc_instance_t* p_libvlc;
167 HRESULT hr = _p_instance->getVLC(&p_libvlc);
170 libvlc_exception_t ex;
171 libvlc_exception_init(&ex);
173 *volume = libvlc_audio_get_volume(p_libvlc, &ex);
174 if( libvlc_exception_raised(&ex) )
176 _p_instance->setErrorInfo(IID_IVLCAudio,
177 libvlc_exception_get_message(&ex));
178 libvlc_exception_clear(&ex);
186 STDMETHODIMP VLCAudio::put_volume(long volume)
188 libvlc_instance_t* p_libvlc;
189 HRESULT hr = _p_instance->getVLC(&p_libvlc);
192 libvlc_exception_t ex;
193 libvlc_exception_init(&ex);
195 libvlc_audio_set_volume(p_libvlc, volume, &ex);
196 if( libvlc_exception_raised(&ex) )
198 _p_instance->setErrorInfo(IID_IVLCAudio,
199 libvlc_exception_get_message(&ex));
200 libvlc_exception_clear(&ex);
208 STDMETHODIMP VLCAudio::get_track(long* track)
213 libvlc_instance_t* p_libvlc;
214 HRESULT hr = _p_instance->getVLC(&p_libvlc);
217 libvlc_exception_t ex;
218 libvlc_exception_init(&ex);
220 libvlc_media_player_t *p_md;
221 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
222 *track = libvlc_audio_get_track(p_md, &ex);
223 libvlc_media_player_release(p_md);
224 if( libvlc_exception_raised(&ex) )
226 _p_instance->setErrorInfo(IID_IVLCAudio,
227 libvlc_exception_get_message(&ex));
228 libvlc_exception_clear(&ex);
236 STDMETHODIMP VLCAudio::put_track(long track)
238 libvlc_instance_t* p_libvlc;
239 HRESULT hr = _p_instance->getVLC(&p_libvlc);
242 libvlc_exception_t ex;
243 libvlc_exception_init(&ex);
245 libvlc_media_player_t *p_md;
246 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
247 libvlc_audio_set_track(p_md, track, &ex);
248 libvlc_media_player_release(p_md);
249 if( libvlc_exception_raised(&ex) )
251 _p_instance->setErrorInfo(IID_IVLCAudio,
252 libvlc_exception_get_message(&ex));
253 libvlc_exception_clear(&ex);
261 STDMETHODIMP VLCAudio::get_channel(long *channel)
263 if( NULL == channel )
266 libvlc_instance_t* p_libvlc;
267 HRESULT hr = _p_instance->getVLC(&p_libvlc);
270 libvlc_exception_t ex;
271 libvlc_exception_init(&ex);
273 *channel = libvlc_audio_get_channel(p_libvlc, &ex);
274 if( libvlc_exception_raised(&ex) )
276 _p_instance->setErrorInfo(IID_IVLCAudio,
277 libvlc_exception_get_message(&ex));
278 libvlc_exception_clear(&ex);
286 STDMETHODIMP VLCAudio::put_channel(long channel)
288 libvlc_instance_t* p_libvlc;
289 HRESULT hr = _p_instance->getVLC(&p_libvlc);
292 libvlc_exception_t ex;
293 libvlc_exception_init(&ex);
295 libvlc_audio_set_channel(p_libvlc, channel, &ex);
296 if( libvlc_exception_raised(&ex) )
298 _p_instance->setErrorInfo(IID_IVLCAudio,
299 libvlc_exception_get_message(&ex));
300 libvlc_exception_clear(&ex);
308 STDMETHODIMP VLCAudio::toggleMute()
310 libvlc_instance_t* p_libvlc;
311 HRESULT hr = _p_instance->getVLC(&p_libvlc);
314 libvlc_exception_t ex;
315 libvlc_exception_init(&ex);
317 libvlc_audio_toggle_mute(p_libvlc, &ex);
318 if( libvlc_exception_raised(&ex) )
320 _p_instance->setErrorInfo(IID_IVLCAudio,
321 libvlc_exception_get_message(&ex));
322 libvlc_exception_clear(&ex);
330 /*******************************************************************************/
332 VLCInput::~VLCInput()
335 _p_typeinfo->Release();
338 HRESULT VLCInput::loadTypeInfo(void)
340 HRESULT hr = NOERROR;
341 if( NULL == _p_typeinfo )
345 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
348 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCInput, &_p_typeinfo);
353 p_typelib->Release();
359 STDMETHODIMP VLCInput::GetTypeInfoCount(UINT* pctInfo)
361 if( NULL == pctInfo )
364 if( SUCCEEDED(loadTypeInfo()) )
372 STDMETHODIMP VLCInput::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
374 if( NULL == ppTInfo )
377 if( SUCCEEDED(loadTypeInfo()) )
379 _p_typeinfo->AddRef();
380 *ppTInfo = _p_typeinfo;
387 STDMETHODIMP VLCInput::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
388 UINT cNames, LCID lcid, DISPID* rgDispID)
390 if( SUCCEEDED(loadTypeInfo()) )
392 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
397 STDMETHODIMP VLCInput::Invoke(DISPID dispIdMember, REFIID riid,
398 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
399 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
401 if( SUCCEEDED(loadTypeInfo()) )
403 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
404 pVarResult, pExcepInfo, puArgErr);
409 STDMETHODIMP VLCInput::get_length(double* length)
415 libvlc_instance_t* p_libvlc;
416 HRESULT hr = _p_instance->getVLC(&p_libvlc);
419 libvlc_exception_t ex;
420 libvlc_exception_init(&ex);
422 libvlc_media_player_t *p_md;
423 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
424 if( ! libvlc_exception_raised(&ex) )
426 *length = (double)libvlc_media_player_get_length(p_md, &ex);
427 libvlc_media_player_release(p_md);
428 if( ! libvlc_exception_raised(&ex) )
433 _p_instance->setErrorInfo(IID_IVLCInput,
434 libvlc_exception_get_message(&ex));
435 libvlc_exception_clear(&ex);
441 STDMETHODIMP VLCInput::get_position(double* position)
443 if( NULL == position )
447 libvlc_instance_t* p_libvlc;
448 HRESULT hr = _p_instance->getVLC(&p_libvlc);
451 libvlc_exception_t ex;
452 libvlc_exception_init(&ex);
454 libvlc_media_player_t *p_md;
455 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
456 if( ! libvlc_exception_raised(&ex) )
458 *position = libvlc_media_player_get_position(p_md, &ex);
459 libvlc_media_player_release(p_md);
460 if( ! libvlc_exception_raised(&ex) )
465 _p_instance->setErrorInfo(IID_IVLCInput,
466 libvlc_exception_get_message(&ex));
467 libvlc_exception_clear(&ex);
473 STDMETHODIMP VLCInput::put_position(double position)
475 libvlc_instance_t* p_libvlc;
476 HRESULT hr = _p_instance->getVLC(&p_libvlc);
479 libvlc_exception_t ex;
480 libvlc_exception_init(&ex);
482 libvlc_media_player_t *p_md;
483 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
484 if( ! libvlc_exception_raised(&ex) )
486 libvlc_media_player_set_position(p_md, position, &ex);
487 libvlc_media_player_release(p_md);
488 if( ! libvlc_exception_raised(&ex) )
493 _p_instance->setErrorInfo(IID_IVLCInput,
494 libvlc_exception_get_message(&ex));
495 libvlc_exception_clear(&ex);
501 STDMETHODIMP VLCInput::get_time(double* time)
506 libvlc_instance_t* p_libvlc;
507 HRESULT hr = _p_instance->getVLC(&p_libvlc);
510 libvlc_exception_t ex;
511 libvlc_exception_init(&ex);
513 libvlc_media_player_t *p_md;
514 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
515 if( ! libvlc_exception_raised(&ex) )
517 *time = (double)libvlc_media_player_get_time(p_md, &ex);
518 libvlc_media_player_release(p_md);
519 if( ! libvlc_exception_raised(&ex) )
524 _p_instance->setErrorInfo(IID_IVLCInput,
525 libvlc_exception_get_message(&ex));
526 libvlc_exception_clear(&ex);
532 STDMETHODIMP VLCInput::put_time(double time)
534 libvlc_instance_t* p_libvlc;
535 HRESULT hr = _p_instance->getVLC(&p_libvlc);
538 libvlc_exception_t ex;
539 libvlc_exception_init(&ex);
541 libvlc_media_player_t *p_md;
542 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
543 if( ! libvlc_exception_raised(&ex) )
545 libvlc_media_player_set_time(p_md, (int64_t)time, &ex);
546 libvlc_media_player_release(p_md);
547 if( ! libvlc_exception_raised(&ex) )
552 _p_instance->setErrorInfo(IID_IVLCInput,
553 libvlc_exception_get_message(&ex));
554 libvlc_exception_clear(&ex);
560 STDMETHODIMP VLCInput::get_state(long* state)
565 libvlc_instance_t* p_libvlc;
566 HRESULT hr = _p_instance->getVLC(&p_libvlc);
569 libvlc_exception_t ex;
570 libvlc_exception_init(&ex);
572 libvlc_media_player_t *p_md;
573 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
574 if( ! libvlc_exception_raised(&ex) )
576 *state = libvlc_media_player_get_state(p_md, &ex);
577 libvlc_media_player_release(p_md);
578 if( ! libvlc_exception_raised(&ex) )
583 libvlc_exception_clear(&ex);
584 // don't fail, just return the idle state
591 STDMETHODIMP VLCInput::get_rate(double* rate)
596 libvlc_instance_t* p_libvlc;
597 HRESULT hr = _p_instance->getVLC(&p_libvlc);
600 libvlc_exception_t ex;
601 libvlc_exception_init(&ex);
603 libvlc_media_player_t *p_md;
604 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
605 if( ! libvlc_exception_raised(&ex) )
607 *rate = libvlc_media_player_get_rate(p_md, &ex);
608 libvlc_media_player_release(p_md);
609 if( ! libvlc_exception_raised(&ex) )
614 _p_instance->setErrorInfo(IID_IVLCInput,
615 libvlc_exception_get_message(&ex));
616 libvlc_exception_clear(&ex);
622 STDMETHODIMP VLCInput::put_rate(double rate)
624 libvlc_instance_t* p_libvlc;
625 HRESULT hr = _p_instance->getVLC(&p_libvlc);
628 libvlc_exception_t ex;
629 libvlc_exception_init(&ex);
631 libvlc_media_player_t *p_md;
632 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
633 if( ! libvlc_exception_raised(&ex) )
635 libvlc_media_player_set_rate(p_md, rate, &ex);
636 libvlc_media_player_release(p_md);
637 if( ! libvlc_exception_raised(&ex) )
642 _p_instance->setErrorInfo(IID_IVLCInput,
643 libvlc_exception_get_message(&ex));
644 libvlc_exception_clear(&ex);
650 STDMETHODIMP VLCInput::get_fps(double* fps)
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_media_player_t *p_md;
664 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
665 if( ! libvlc_exception_raised(&ex) )
667 *fps = libvlc_media_player_get_fps(p_md, &ex);
668 libvlc_media_player_release(p_md);
669 if( ! libvlc_exception_raised(&ex) )
674 _p_instance->setErrorInfo(IID_IVLCInput,
675 libvlc_exception_get_message(&ex));
676 libvlc_exception_clear(&ex);
682 STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
684 if( NULL == hasVout )
687 libvlc_instance_t* p_libvlc;
688 HRESULT hr = _p_instance->getVLC(&p_libvlc);
691 libvlc_exception_t ex;
692 libvlc_exception_init(&ex);
694 libvlc_media_player_t *p_md;
695 p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
696 if( ! libvlc_exception_raised(&ex) )
698 *hasVout = libvlc_media_player_has_vout(p_md, &ex) ?
699 VARIANT_TRUE : VARIANT_FALSE;
700 libvlc_media_player_release(p_md);
701 if( ! libvlc_exception_raised(&ex) )
706 _p_instance->setErrorInfo(IID_IVLCInput,
707 libvlc_exception_get_message(&ex));
708 libvlc_exception_clear(&ex);
714 /*******************************************************************************/
718 delete _p_vlcmessages;
720 libvlc_log_close(_p_log, NULL);
723 _p_typeinfo->Release();
726 HRESULT VLCLog::loadTypeInfo(void)
728 HRESULT hr = NOERROR;
729 if( NULL == _p_typeinfo )
733 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
736 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCLog, &_p_typeinfo);
741 p_typelib->Release();
747 STDMETHODIMP VLCLog::GetTypeInfoCount(UINT* pctInfo)
749 if( NULL == pctInfo )
752 if( SUCCEEDED(loadTypeInfo()) )
760 STDMETHODIMP VLCLog::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
762 if( NULL == ppTInfo )
765 if( SUCCEEDED(loadTypeInfo()) )
767 _p_typeinfo->AddRef();
768 *ppTInfo = _p_typeinfo;
775 STDMETHODIMP VLCLog::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
776 UINT cNames, LCID lcid, DISPID* rgDispID)
778 if( SUCCEEDED(loadTypeInfo()) )
780 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
785 STDMETHODIMP VLCLog::Invoke(DISPID dispIdMember, REFIID riid,
786 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
787 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
789 if( SUCCEEDED(loadTypeInfo()) )
791 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
792 pVarResult, pExcepInfo, puArgErr);
797 STDMETHODIMP VLCLog::get_messages(IVLCMessages** obj)
802 *obj = _p_vlcmessages;
803 if( NULL != _p_vlcmessages )
805 _p_vlcmessages->AddRef();
808 return E_OUTOFMEMORY;
811 STDMETHODIMP VLCLog::get_verbosity(long* level)
818 libvlc_instance_t* p_libvlc;
819 HRESULT hr = _p_instance->getVLC(&p_libvlc);
822 libvlc_exception_t ex;
823 libvlc_exception_init(&ex);
825 *level = libvlc_get_log_verbosity(p_libvlc, &ex);
826 if( libvlc_exception_raised(&ex) )
828 _p_instance->setErrorInfo(IID_IVLCLog,
829 libvlc_exception_get_message(&ex));
830 libvlc_exception_clear(&ex);
838 /* log is not enabled, return -1 */
844 STDMETHODIMP VLCLog::put_verbosity(long verbosity)
846 libvlc_exception_t ex;
847 libvlc_exception_init(&ex);
849 libvlc_instance_t* p_libvlc;
850 HRESULT hr = _p_instance->getVLC(&p_libvlc);
857 _p_log = libvlc_log_open(p_libvlc, &ex);
858 if( libvlc_exception_raised(&ex) )
860 _p_instance->setErrorInfo(IID_IVLCLog,
861 libvlc_exception_get_message(&ex));
862 libvlc_exception_clear(&ex);
866 libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
867 if( libvlc_exception_raised(&ex) )
869 _p_instance->setErrorInfo(IID_IVLCLog,
870 libvlc_exception_get_message(&ex));
871 libvlc_exception_clear(&ex);
877 /* close log when verbosity is set to -1 */
878 libvlc_log_close(_p_log, &ex);
880 if( libvlc_exception_raised(&ex) )
882 _p_instance->setErrorInfo(IID_IVLCLog,
883 libvlc_exception_get_message(&ex));
884 libvlc_exception_clear(&ex);
892 /*******************************************************************************/
894 /* STL forward iterator used by VLCEnumIterator class to implement IEnumVARIANT */
896 class VLCMessageSTLIterator
901 VLCMessageSTLIterator(IVLCMessageIterator* iter) : iter(iter), msg(NULL)
907 VLCMessageSTLIterator(const VLCMessageSTLIterator& other)
917 virtual ~VLCMessageSTLIterator()
926 // we only need prefix ++ operator
927 VLCMessageSTLIterator& operator++()
929 VARIANT_BOOL hasNext = VARIANT_FALSE;
932 iter->get_hasNext(&hasNext);
939 if( VARIANT_TRUE == hasNext ) {
946 VARIANT operator*() const
952 if( SUCCEEDED(msg->QueryInterface(IID_IDispatch,
953 (LPVOID*)&V_DISPATCH(&v))) )
955 V_VT(&v) = VT_DISPATCH;
961 bool operator==(const VLCMessageSTLIterator& other) const
963 return msg == other.msg;
966 bool operator!=(const VLCMessageSTLIterator& other) const
968 return msg != other.msg;
972 IVLCMessageIterator* iter;
976 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
978 VLCMessages::~VLCMessages()
981 _p_typeinfo->Release();
984 HRESULT VLCMessages::loadTypeInfo(void)
986 HRESULT hr = NOERROR;
987 if( NULL == _p_typeinfo )
991 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
994 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessages, &_p_typeinfo);
999 p_typelib->Release();
1005 STDMETHODIMP VLCMessages::GetTypeInfoCount(UINT* pctInfo)
1007 if( NULL == pctInfo )
1008 return E_INVALIDARG;
1010 if( SUCCEEDED(loadTypeInfo()) )
1018 STDMETHODIMP VLCMessages::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1020 if( NULL == ppTInfo )
1021 return E_INVALIDARG;
1023 if( SUCCEEDED(loadTypeInfo()) )
1025 _p_typeinfo->AddRef();
1026 *ppTInfo = _p_typeinfo;
1033 STDMETHODIMP VLCMessages::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1034 UINT cNames, LCID lcid, DISPID* rgDispID)
1036 if( SUCCEEDED(loadTypeInfo()) )
1038 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1043 STDMETHODIMP VLCMessages::Invoke(DISPID dispIdMember, REFIID riid,
1044 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1045 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1047 if( SUCCEEDED(loadTypeInfo()) )
1049 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1050 pVarResult, pExcepInfo, puArgErr);
1055 STDMETHODIMP VLCMessages::get__NewEnum(LPUNKNOWN* _NewEnum)
1057 if( NULL == _NewEnum )
1060 IVLCMessageIterator* iter = NULL;
1063 *_NewEnum= new VLCEnumIterator<IID_IEnumVARIANT,
1066 VLCMessageSTLIterator>
1067 (VLCMessageSTLIterator(iter), VLCMessageSTLIterator(NULL));
1069 return *_NewEnum ? S_OK : E_OUTOFMEMORY;
1072 STDMETHODIMP VLCMessages::clear()
1074 libvlc_log_t *p_log = _p_vlclog->_p_log;
1077 libvlc_exception_t ex;
1078 libvlc_exception_init(&ex);
1080 libvlc_log_clear(p_log, &ex);
1081 if( libvlc_exception_raised(&ex) )
1083 _p_instance->setErrorInfo(IID_IVLCMessages,
1084 libvlc_exception_get_message(&ex));
1085 libvlc_exception_clear(&ex);
1092 STDMETHODIMP VLCMessages::get_count(long* count)
1097 libvlc_log_t *p_log = _p_vlclog->_p_log;
1100 libvlc_exception_t ex;
1101 libvlc_exception_init(&ex);
1103 *count = libvlc_log_count(p_log, &ex);
1104 if( libvlc_exception_raised(&ex) )
1106 _p_instance->setErrorInfo(IID_IVLCMessages,
1107 libvlc_exception_get_message(&ex));
1108 libvlc_exception_clear(&ex);
1117 STDMETHODIMP VLCMessages::iterator(IVLCMessageIterator** iter)
1122 *iter = new VLCMessageIterator(_p_instance, _p_vlclog);
1124 return *iter ? S_OK : E_OUTOFMEMORY;
1127 /*******************************************************************************/
1129 VLCMessageIterator::VLCMessageIterator(VLCPlugin *p_instance, VLCLog* p_vlclog ) :
1130 _p_instance(p_instance),
1135 if( p_vlclog->_p_log )
1137 _p_iter = libvlc_log_get_iterator(p_vlclog->_p_log, NULL);
1143 VLCMessageIterator::~VLCMessageIterator()
1146 libvlc_log_iterator_free(_p_iter, NULL);
1149 _p_typeinfo->Release();
1152 HRESULT VLCMessageIterator::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_IVLCMessageIterator, &_p_typeinfo);
1167 p_typelib->Release();
1173 STDMETHODIMP VLCMessageIterator::GetTypeInfoCount(UINT* pctInfo)
1175 if( NULL == pctInfo )
1176 return E_INVALIDARG;
1178 if( SUCCEEDED(loadTypeInfo()) )
1186 STDMETHODIMP VLCMessageIterator::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 VLCMessageIterator::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 VLCMessageIterator::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 STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext)
1225 if( NULL == hasNext )
1228 if( _p_iter && _p_vlclog->_p_log )
1230 libvlc_exception_t ex;
1231 libvlc_exception_init(&ex);
1233 *hasNext = libvlc_log_iterator_has_next(_p_iter, &ex) ?
1234 VARIANT_TRUE : VARIANT_FALSE;
1235 if( libvlc_exception_raised(&ex) )
1237 _p_instance->setErrorInfo(IID_IVLCMessageIterator,
1238 libvlc_exception_get_message(&ex));
1239 libvlc_exception_clear(&ex);
1245 *hasNext = VARIANT_FALSE;
1250 STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
1252 if( NULL == message )
1255 if( _p_iter && _p_vlclog->_p_log )
1257 struct libvlc_log_message_t buffer;
1259 buffer.sizeof_msg = sizeof(buffer);
1261 libvlc_exception_t ex;
1262 libvlc_exception_init(&ex);
1264 libvlc_log_iterator_next(_p_iter, &buffer, &ex);
1265 if( libvlc_exception_raised(&ex) )
1267 _p_instance->setErrorInfo(IID_IVLCMessageIterator,
1268 libvlc_exception_get_message(&ex));
1269 libvlc_exception_clear(&ex);
1272 *message = new VLCMessage(_p_instance, buffer);
1273 return *message ? NOERROR : E_OUTOFMEMORY;
1278 /*******************************************************************************/
1280 VLCMessage::~VLCMessage()
1283 _p_typeinfo->Release();
1286 HRESULT VLCMessage::loadTypeInfo(void)
1288 HRESULT hr = NOERROR;
1289 if( NULL == _p_typeinfo )
1291 ITypeLib *p_typelib;
1293 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1296 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessage, &_p_typeinfo);
1301 p_typelib->Release();
1307 STDMETHODIMP VLCMessage::GetTypeInfoCount(UINT* pctInfo)
1309 if( NULL == pctInfo )
1310 return E_INVALIDARG;
1312 if( SUCCEEDED(loadTypeInfo()) )
1320 STDMETHODIMP VLCMessage::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1322 if( NULL == ppTInfo )
1323 return E_INVALIDARG;
1325 if( SUCCEEDED(loadTypeInfo()) )
1327 _p_typeinfo->AddRef();
1328 *ppTInfo = _p_typeinfo;
1335 STDMETHODIMP VLCMessage::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1336 UINT cNames, LCID lcid, DISPID* rgDispID)
1338 if( SUCCEEDED(loadTypeInfo()) )
1340 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1345 STDMETHODIMP VLCMessage::Invoke(DISPID dispIdMember, REFIID riid,
1346 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1347 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1349 if( SUCCEEDED(loadTypeInfo()) )
1351 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1352 pVarResult, pExcepInfo, puArgErr);
1357 inline const char *msgSeverity(int sev)
1372 STDMETHODIMP VLCMessage::get__Value(VARIANT* _Value)
1374 if( NULL == _Value )
1379 snprintf(buffer, sizeof(buffer), "%s %s %s: %s",
1380 _msg.psz_type, _msg.psz_name, msgSeverity(_msg.i_severity), _msg.psz_message);
1382 V_VT(_Value) = VT_BSTR;
1383 V_BSTR(_Value) = BSTRFromCStr(CP_UTF8, buffer);
1388 STDMETHODIMP VLCMessage::get_severity(long* level)
1393 *level = _msg.i_severity;
1398 STDMETHODIMP VLCMessage::get_type(BSTR* type)
1403 *type = BSTRFromCStr(CP_UTF8, _msg.psz_type);
1408 STDMETHODIMP VLCMessage::get_name(BSTR* name)
1413 *name = BSTRFromCStr(CP_UTF8, _msg.psz_name);
1418 STDMETHODIMP VLCMessage::get_header(BSTR* header)
1420 if( NULL == header )
1423 *header = BSTRFromCStr(CP_UTF8, _msg.psz_header);
1428 STDMETHODIMP VLCMessage::get_message(BSTR* message)
1430 if( NULL == message )
1433 *message = BSTRFromCStr(CP_UTF8, _msg.psz_message);
1438 /*******************************************************************************/
1440 VLCPlaylistItems::~VLCPlaylistItems()
1443 _p_typeinfo->Release();
1446 HRESULT VLCPlaylistItems::loadTypeInfo(void)
1448 HRESULT hr = NOERROR;
1449 if( NULL == _p_typeinfo )
1451 ITypeLib *p_typelib;
1453 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1456 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCPlaylistItems, &_p_typeinfo);
1461 p_typelib->Release();
1467 STDMETHODIMP VLCPlaylistItems::GetTypeInfoCount(UINT* pctInfo)
1469 if( NULL == pctInfo )
1470 return E_INVALIDARG;
1472 if( SUCCEEDED(loadTypeInfo()) )
1480 STDMETHODIMP VLCPlaylistItems::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1482 if( NULL == ppTInfo )
1483 return E_INVALIDARG;
1485 if( SUCCEEDED(loadTypeInfo()) )
1487 _p_typeinfo->AddRef();
1488 *ppTInfo = _p_typeinfo;
1495 STDMETHODIMP VLCPlaylistItems::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1496 UINT cNames, LCID lcid, DISPID* rgDispID)
1498 if( SUCCEEDED(loadTypeInfo()) )
1500 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1505 STDMETHODIMP VLCPlaylistItems::Invoke(DISPID dispIdMember, REFIID riid,
1506 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1507 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1509 if( SUCCEEDED(loadTypeInfo()) )
1511 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1512 pVarResult, pExcepInfo, puArgErr);
1517 STDMETHODIMP VLCPlaylistItems::get_count(long* count)
1522 libvlc_instance_t* p_libvlc;
1523 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1526 libvlc_exception_t ex;
1527 libvlc_exception_init(&ex);
1529 *count = libvlc_playlist_items_count(p_libvlc, &ex);
1530 if( libvlc_exception_raised(&ex) )
1532 _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
1533 libvlc_exception_get_message(&ex));
1534 libvlc_exception_clear(&ex);
1542 STDMETHODIMP VLCPlaylistItems::clear()
1544 libvlc_instance_t* p_libvlc;
1545 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1548 libvlc_exception_t ex;
1549 libvlc_exception_init(&ex);
1551 libvlc_playlist_clear(p_libvlc, &ex);
1552 if( libvlc_exception_raised(&ex) )
1554 _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
1555 libvlc_exception_get_message(&ex));
1556 libvlc_exception_clear(&ex);
1564 STDMETHODIMP VLCPlaylistItems::remove(long item)
1566 libvlc_instance_t* p_libvlc;
1567 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1570 libvlc_exception_t ex;
1571 libvlc_exception_init(&ex);
1573 libvlc_playlist_delete_item(p_libvlc, item, &ex);
1574 if( libvlc_exception_raised(&ex) )
1576 _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
1577 libvlc_exception_get_message(&ex));
1578 libvlc_exception_clear(&ex);
1586 /*******************************************************************************/
1588 VLCPlaylist::~VLCPlaylist()
1590 delete _p_vlcplaylistitems;
1592 _p_typeinfo->Release();
1595 HRESULT VLCPlaylist::loadTypeInfo(void)
1597 HRESULT hr = NOERROR;
1598 if( NULL == _p_typeinfo )
1600 ITypeLib *p_typelib;
1602 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
1605 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCPlaylist, &_p_typeinfo);
1610 p_typelib->Release();
1616 STDMETHODIMP VLCPlaylist::GetTypeInfoCount(UINT* pctInfo)
1618 if( NULL == pctInfo )
1619 return E_INVALIDARG;
1621 if( SUCCEEDED(loadTypeInfo()) )
1629 STDMETHODIMP VLCPlaylist::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
1631 if( NULL == ppTInfo )
1632 return E_INVALIDARG;
1634 if( SUCCEEDED(loadTypeInfo()) )
1636 _p_typeinfo->AddRef();
1637 *ppTInfo = _p_typeinfo;
1644 STDMETHODIMP VLCPlaylist::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
1645 UINT cNames, LCID lcid, DISPID* rgDispID)
1647 if( SUCCEEDED(loadTypeInfo()) )
1649 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
1654 STDMETHODIMP VLCPlaylist::Invoke(DISPID dispIdMember, REFIID riid,
1655 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
1656 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
1658 if( SUCCEEDED(loadTypeInfo()) )
1660 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
1661 pVarResult, pExcepInfo, puArgErr);
1666 STDMETHODIMP VLCPlaylist::get_itemCount(long* count)
1672 libvlc_instance_t* p_libvlc;
1673 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1676 libvlc_exception_t ex;
1677 libvlc_exception_init(&ex);
1679 *count = libvlc_playlist_items_count(p_libvlc, &ex);
1680 if( libvlc_exception_raised(&ex) )
1682 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1683 libvlc_exception_get_message(&ex));
1684 libvlc_exception_clear(&ex);
1692 STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
1694 if( NULL == isPlaying )
1697 libvlc_instance_t* p_libvlc;
1698 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1701 libvlc_exception_t ex;
1702 libvlc_exception_init(&ex);
1704 *isPlaying = libvlc_playlist_isplaying(p_libvlc, &ex) ?
1705 VARIANT_TRUE: VARIANT_FALSE;
1706 if( libvlc_exception_raised(&ex) )
1708 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1709 libvlc_exception_get_message(&ex));
1710 libvlc_exception_clear(&ex);
1718 STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* item)
1723 if( 0 == SysStringLen(uri) )
1724 return E_INVALIDARG;
1726 libvlc_instance_t* p_libvlc;
1727 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1730 libvlc_exception_t ex;
1731 libvlc_exception_init(&ex);
1733 char *psz_uri = NULL;
1734 if( SysStringLen(_p_instance->getBaseURL()) > 0 )
1737 ** if the MRL a relative URL, we should end up with an absolute URL
1739 LPWSTR abs_url = CombineURL(_p_instance->getBaseURL(), uri);
1740 if( NULL != abs_url )
1742 psz_uri = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url));
1743 CoTaskMemFree(abs_url);
1747 psz_uri = CStrFromBSTR(CP_UTF8, uri);
1753 ** baseURL is empty, assume MRL is absolute
1755 psz_uri = CStrFromBSTR(CP_UTF8, uri);
1758 if( NULL == psz_uri )
1760 return E_OUTOFMEMORY;
1764 char **ppsz_options;
1766 hr = VLCControl::CreateTargetOptions(CP_UTF8, &options, &ppsz_options, &i_options);
1769 CoTaskMemFree(psz_uri);
1773 char *psz_name = NULL;
1775 VariantInit(&v_name);
1776 if( SUCCEEDED(VariantChangeType(&v_name, &name, 0, VT_BSTR)) )
1778 if( SysStringLen(V_BSTR(&v_name)) > 0 )
1779 psz_name = CStrFromBSTR(CP_UTF8, V_BSTR(&v_name));
1781 VariantClear(&v_name);
1784 *item = libvlc_playlist_add_extended(p_libvlc,
1788 const_cast<const char **>(ppsz_options),
1791 VLCControl::FreeTargetOptions(ppsz_options, i_options);
1792 CoTaskMemFree(psz_uri);
1794 CoTaskMemFree(psz_name);
1795 if( libvlc_exception_raised(&ex) )
1797 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1798 libvlc_exception_get_message(&ex));
1799 libvlc_exception_clear(&ex);
1807 STDMETHODIMP VLCPlaylist::play()
1809 libvlc_instance_t* p_libvlc;
1810 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1813 libvlc_exception_t ex;
1814 libvlc_exception_init(&ex);
1816 libvlc_playlist_play(p_libvlc, -1, 0, NULL, &ex);
1817 if( libvlc_exception_raised(&ex) )
1819 libvlc_exception_clear(&ex);
1827 STDMETHODIMP VLCPlaylist::playItem(long item)
1829 libvlc_instance_t* p_libvlc;
1830 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1833 libvlc_exception_t ex;
1834 libvlc_exception_init(&ex);
1836 libvlc_playlist_play(p_libvlc, item, 0, NULL, &ex);
1837 if( libvlc_exception_raised(&ex) )
1839 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1840 libvlc_exception_get_message(&ex));
1841 libvlc_exception_clear(&ex);
1849 STDMETHODIMP VLCPlaylist::togglePause()
1851 libvlc_instance_t* p_libvlc;
1852 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1855 libvlc_exception_t ex;
1856 libvlc_exception_init(&ex);
1858 libvlc_playlist_pause(p_libvlc, &ex);
1859 if( libvlc_exception_raised(&ex) )
1861 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1862 libvlc_exception_get_message(&ex));
1863 libvlc_exception_clear(&ex);
1871 STDMETHODIMP VLCPlaylist::stop()
1873 libvlc_instance_t* p_libvlc;
1874 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1877 libvlc_exception_t ex;
1878 libvlc_exception_init(&ex);
1880 libvlc_playlist_stop(p_libvlc, &ex);
1881 if( libvlc_exception_raised(&ex) )
1883 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1884 libvlc_exception_get_message(&ex));
1885 libvlc_exception_clear(&ex);
1893 STDMETHODIMP VLCPlaylist::next()
1895 libvlc_instance_t* p_libvlc;
1896 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1899 libvlc_exception_t ex;
1900 libvlc_exception_init(&ex);
1902 libvlc_playlist_next(p_libvlc, &ex);
1903 if( libvlc_exception_raised(&ex) )
1905 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1906 libvlc_exception_get_message(&ex));
1907 libvlc_exception_clear(&ex);
1915 STDMETHODIMP VLCPlaylist::prev()
1917 libvlc_instance_t* p_libvlc;
1918 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1921 libvlc_exception_t ex;
1922 libvlc_exception_init(&ex);
1924 libvlc_playlist_prev(p_libvlc, &ex);
1925 if( libvlc_exception_raised(&ex) )
1927 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1928 libvlc_exception_get_message(&ex));
1929 libvlc_exception_clear(&ex);
1937 STDMETHODIMP VLCPlaylist::clear()
1939 libvlc_instance_t* p_libvlc;
1940 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1943 libvlc_exception_t ex;
1944 libvlc_exception_init(&ex);
1946 libvlc_playlist_clear(p_libvlc, &ex);
1947 if( libvlc_exception_raised(&ex) )
1949 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1950 libvlc_exception_get_message(&ex));
1951 libvlc_exception_clear(&ex);
1959 STDMETHODIMP VLCPlaylist::removeItem(long item)
1961 libvlc_instance_t* p_libvlc;
1962 HRESULT hr = _p_instance->getVLC(&p_libvlc);
1965 libvlc_exception_t ex;
1966 libvlc_exception_init(&ex);
1968 libvlc_playlist_delete_item(p_libvlc, item, &ex);
1969 if( libvlc_exception_raised(&ex) )
1971 _p_instance->setErrorInfo(IID_IVLCPlaylist,
1972 libvlc_exception_get_message(&ex));
1973 libvlc_exception_clear(&ex);
1981 STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj)
1986 *obj = _p_vlcplaylistitems;
1987 if( NULL != _p_vlcplaylistitems )
1989 _p_vlcplaylistitems->AddRef();
1992 return E_OUTOFMEMORY;
1995 /*******************************************************************************/
1997 VLCVideo::~VLCVideo()
2000 _p_typeinfo->Release();
2003 HRESULT VLCVideo::loadTypeInfo(void)
2005 HRESULT hr = NOERROR;
2006 if( NULL == _p_typeinfo )
2008 ITypeLib *p_typelib;
2010 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
2013 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCVideo, &_p_typeinfo);
2018 p_typelib->Release();
2024 STDMETHODIMP VLCVideo::GetTypeInfoCount(UINT* pctInfo)
2026 if( NULL == pctInfo )
2027 return E_INVALIDARG;
2029 if( SUCCEEDED(loadTypeInfo()) )
2037 STDMETHODIMP VLCVideo::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
2039 if( NULL == ppTInfo )
2040 return E_INVALIDARG;
2042 if( SUCCEEDED(loadTypeInfo()) )
2044 _p_typeinfo->AddRef();
2045 *ppTInfo = _p_typeinfo;
2052 STDMETHODIMP VLCVideo::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
2053 UINT cNames, LCID lcid, DISPID* rgDispID)
2055 if( SUCCEEDED(loadTypeInfo()) )
2057 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
2062 STDMETHODIMP VLCVideo::Invoke(DISPID dispIdMember, REFIID riid,
2063 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
2064 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
2066 if( SUCCEEDED(loadTypeInfo()) )
2068 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
2069 pVarResult, pExcepInfo, puArgErr);
2074 STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
2076 if( NULL == fullscreen )
2079 libvlc_instance_t* p_libvlc;
2080 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2083 libvlc_exception_t ex;
2084 libvlc_exception_init(&ex);
2086 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2087 if( ! libvlc_exception_raised(&ex) )
2089 *fullscreen = libvlc_get_fullscreen(p_md, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
2090 libvlc_media_player_release(p_md);
2091 if( ! libvlc_exception_raised(&ex) )
2096 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2097 libvlc_exception_clear(&ex);
2103 STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen)
2105 libvlc_instance_t* p_libvlc;
2106 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2109 libvlc_exception_t ex;
2110 libvlc_exception_init(&ex);
2112 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2113 if( ! libvlc_exception_raised(&ex) )
2115 libvlc_set_fullscreen(p_md, VARIANT_FALSE != fullscreen, &ex);
2116 libvlc_media_player_release(p_md);
2117 if( ! libvlc_exception_raised(&ex) )
2122 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2123 libvlc_exception_clear(&ex);
2129 STDMETHODIMP VLCVideo::get_width(long* width)
2134 libvlc_instance_t* p_libvlc;
2135 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2138 libvlc_exception_t ex;
2139 libvlc_exception_init(&ex);
2141 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2142 if( ! libvlc_exception_raised(&ex) )
2144 *width = libvlc_video_get_width(p_md, &ex);
2145 libvlc_media_player_release(p_md);
2146 if( ! libvlc_exception_raised(&ex) )
2151 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2152 libvlc_exception_clear(&ex);
2158 STDMETHODIMP VLCVideo::get_height(long* height)
2160 if( NULL == height )
2163 libvlc_instance_t* p_libvlc;
2164 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2167 libvlc_exception_t ex;
2168 libvlc_exception_init(&ex);
2170 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2171 if( ! libvlc_exception_raised(&ex) )
2173 *height = libvlc_video_get_height(p_md, &ex);
2174 libvlc_media_player_release(p_md);
2175 if( ! libvlc_exception_raised(&ex) )
2180 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2181 libvlc_exception_clear(&ex);
2187 STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect)
2189 if( NULL == aspect )
2192 libvlc_instance_t* p_libvlc;
2193 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2196 libvlc_exception_t ex;
2197 libvlc_exception_init(&ex);
2199 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2200 if( ! libvlc_exception_raised(&ex) )
2202 char *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
2204 libvlc_media_player_release(p_md);
2205 if( ! libvlc_exception_raised(&ex) )
2207 if( NULL == psz_aspect )
2208 return E_OUTOFMEMORY;
2210 *aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
2213 return (NULL == *aspect) ? E_OUTOFMEMORY : NOERROR;
2218 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2219 libvlc_exception_clear(&ex);
2225 STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
2227 if( NULL == aspect )
2230 if( 0 == SysStringLen(aspect) )
2231 return E_INVALIDARG;
2233 libvlc_instance_t* p_libvlc;
2234 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2237 libvlc_exception_t ex;
2238 libvlc_exception_init(&ex);
2240 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2241 if( ! libvlc_exception_raised(&ex) )
2243 char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
2244 if( NULL == psz_aspect )
2246 return E_OUTOFMEMORY;
2249 libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
2251 CoTaskMemFree(psz_aspect);
2252 libvlc_media_player_release(p_md);
2253 if( libvlc_exception_raised(&ex) )
2255 _p_instance->setErrorInfo(IID_IVLCVideo,
2256 libvlc_exception_get_message(&ex));
2257 libvlc_exception_clear(&ex);
2266 STDMETHODIMP VLCVideo::get_subtitle(long* spu)
2271 libvlc_instance_t* p_libvlc;
2272 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2275 libvlc_exception_t ex;
2276 libvlc_exception_init(&ex);
2278 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2279 if( ! libvlc_exception_raised(&ex) )
2281 *spu = libvlc_video_get_spu(p_md, &ex);
2282 libvlc_media_player_release(p_md);
2283 if( ! libvlc_exception_raised(&ex) )
2288 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2289 libvlc_exception_clear(&ex);
2295 STDMETHODIMP VLCVideo::put_subtitle(long spu)
2297 libvlc_instance_t* p_libvlc;
2298 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2301 libvlc_exception_t ex;
2302 libvlc_exception_init(&ex);
2304 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2305 libvlc_video_set_spu(p_md, spu, &ex);
2306 libvlc_media_player_release(p_md);
2307 if( libvlc_exception_raised(&ex) )
2309 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2310 libvlc_exception_clear(&ex);
2318 STDMETHODIMP VLCVideo::get_crop(BSTR* geometry)
2320 if( NULL == geometry )
2323 libvlc_instance_t* p_libvlc;
2324 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2327 libvlc_exception_t ex;
2328 libvlc_exception_init(&ex);
2330 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2331 if( ! libvlc_exception_raised(&ex) )
2333 char *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
2335 libvlc_media_player_release(p_md);
2336 if( ! libvlc_exception_raised(&ex) )
2338 if( NULL == psz_geometry )
2339 return E_OUTOFMEMORY;
2341 *geometry = BSTRFromCStr(CP_UTF8, psz_geometry);
2342 free( psz_geometry );
2343 psz_geometry = NULL;
2344 return (NULL == geometry) ? E_OUTOFMEMORY : NOERROR;
2346 free( psz_geometry );
2347 psz_geometry = NULL;
2349 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2350 libvlc_exception_clear(&ex);
2356 STDMETHODIMP VLCVideo::put_crop(BSTR geometry)
2358 if( NULL == geometry )
2361 if( 0 == SysStringLen(geometry) )
2362 return E_INVALIDARG;
2364 libvlc_instance_t* p_libvlc;
2365 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2368 libvlc_exception_t ex;
2369 libvlc_exception_init(&ex);
2371 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2372 if( ! libvlc_exception_raised(&ex) )
2374 char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry);
2375 if( NULL == psz_geometry )
2377 return E_OUTOFMEMORY;
2380 libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
2382 CoTaskMemFree(psz_geometry);
2383 libvlc_media_player_release(p_md);
2384 if( libvlc_exception_raised(&ex) )
2386 _p_instance->setErrorInfo(IID_IVLCVideo,
2387 libvlc_exception_get_message(&ex));
2388 libvlc_exception_clear(&ex);
2397 STDMETHODIMP VLCVideo::get_teletext(long* page)
2402 libvlc_instance_t* p_libvlc;
2403 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2406 libvlc_exception_t ex;
2407 libvlc_exception_init(&ex);
2409 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2410 if( ! libvlc_exception_raised(&ex) )
2412 *page = libvlc_video_get_teletext(p_md, &ex);
2413 libvlc_media_player_release(p_md);
2414 if( ! libvlc_exception_raised(&ex) )
2419 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2420 libvlc_exception_clear(&ex);
2426 STDMETHODIMP VLCVideo::put_teletext(long page)
2428 libvlc_instance_t* p_libvlc;
2429 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2432 libvlc_exception_t ex;
2433 libvlc_exception_init(&ex);
2435 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2436 libvlc_video_set_teletext(p_md, page, &ex);
2437 libvlc_media_player_release(p_md);
2438 if( libvlc_exception_raised(&ex) )
2440 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2441 libvlc_exception_clear(&ex);
2449 STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
2451 if( NULL == picture )
2454 libvlc_instance_t* p_libvlc;
2455 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2458 libvlc_exception_t ex;
2459 libvlc_exception_init(&ex);
2461 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2462 if( ! libvlc_exception_raised(&ex) )
2464 static int uniqueId = 0;
2465 TCHAR path[MAX_PATH+1];
2467 int pathlen = GetTempPath(MAX_PATH-24, path);
2468 if( (0 == pathlen) || (pathlen > (MAX_PATH-24)) )
2471 /* check temp directory path by openning it */
2473 HANDLE dirHandle = CreateFile(path,
2475 FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
2478 FILE_FLAG_BACKUP_SEMANTICS, NULL);
2479 if( INVALID_HANDLE_VALUE == dirHandle )
2481 _p_instance->setErrorInfo(IID_IVLCVideo,
2482 "Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
2487 BY_HANDLE_FILE_INFORMATION bhfi;
2488 BOOL res = GetFileInformationByHandle(dirHandle, &bhfi);
2489 CloseHandle(dirHandle);
2490 if( !res || !(bhfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
2492 _p_instance->setErrorInfo(IID_IVLCVideo,
2493 "Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
2499 TCHAR filepath[MAX_PATH+1];
2501 _stprintf(filepath, TEXT("%sAXVLC%lXS%lX.bmp"),
2502 path, GetCurrentProcessId(), ++uniqueId);
2505 /* reuse path storage for UTF8 string */
2506 char *psz_filepath = (char *)path;
2507 WCHAR* wpath = filepath;
2509 char *psz_filepath = path;
2510 /* first convert to unicode using current code page */
2511 WCHAR wpath[MAX_PATH+1];
2512 if( 0 == MultiByteToWideChar(CP_ACP, 0, filepath, -1, wpath, sizeof(wpath)/sizeof(WCHAR)) )
2515 /* convert to UTF8 */
2516 pathlen = WideCharToMultiByte(CP_UTF8, 0, wpath, -1, psz_filepath, sizeof(path), NULL, NULL);
2517 // fail if path is 0 or too short (i.e pathlen is the same as storage size)
2518 if( (0 == pathlen) || (sizeof(path) == pathlen) )
2521 /* take snapshot into file */
2522 libvlc_video_take_snapshot(p_md, psz_filepath, 0, 0, &ex);
2523 libvlc_media_player_release(p_md);
2524 if( ! libvlc_exception_raised(&ex) )
2527 /* open snapshot file */
2528 HANDLE snapPic = LoadImage(NULL, filepath, IMAGE_BITMAP,0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE);
2533 snapDesc.cbSizeofstruct = sizeof(PICTDESC);
2534 snapDesc.picType = PICTYPE_BITMAP;
2535 snapDesc.bmp.hbitmap = (HBITMAP)snapPic;
2536 snapDesc.bmp.hpal = NULL;
2538 hr = OleCreatePictureIndirect(&snapDesc, IID_IPictureDisp, TRUE, (LPVOID*)picture);
2542 DeleteObject(snapPic);
2545 DeleteFile(filepath);
2549 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2550 libvlc_exception_clear(&ex);
2556 STDMETHODIMP VLCVideo::toggleFullscreen()
2558 libvlc_instance_t* p_libvlc;
2559 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2562 libvlc_exception_t ex;
2563 libvlc_exception_init(&ex);
2565 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2566 if( ! libvlc_exception_raised(&ex) )
2568 libvlc_toggle_fullscreen(p_md, &ex);
2569 libvlc_media_player_release(p_md);
2570 if( ! libvlc_exception_raised(&ex) )
2575 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2576 libvlc_exception_clear(&ex);
2582 STDMETHODIMP VLCVideo::toggleTeletext()
2584 libvlc_instance_t* p_libvlc;
2585 HRESULT hr = _p_instance->getVLC(&p_libvlc);
2588 libvlc_exception_t ex;
2589 libvlc_exception_init(&ex);
2591 libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
2592 if( ! libvlc_exception_raised(&ex) )
2594 libvlc_toggle_teletext(p_md, &ex);
2595 libvlc_media_player_release(p_md);
2596 if( ! libvlc_exception_raised(&ex) )
2601 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
2602 libvlc_exception_clear(&ex);
2608 /*******************************************************************************/
2610 VLCControl2::VLCControl2(VLCPlugin *p_instance) :
2611 _p_instance(p_instance),
2615 _p_vlcplaylist(NULL),
2618 _p_vlcaudio = new VLCAudio(p_instance);
2619 _p_vlcinput = new VLCInput(p_instance);
2620 _p_vlclog = new VLCLog(p_instance);
2621 _p_vlcplaylist = new VLCPlaylist(p_instance);
2622 _p_vlcvideo = new VLCVideo(p_instance);
2625 VLCControl2::~VLCControl2()
2628 delete _p_vlcplaylist;
2633 _p_typeinfo->Release();
2636 HRESULT VLCControl2::loadTypeInfo(void)
2638 HRESULT hr = NOERROR;
2639 if( NULL == _p_typeinfo )
2641 ITypeLib *p_typelib;
2643 hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
2646 hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCControl2, &_p_typeinfo);
2651 p_typelib->Release();
2657 STDMETHODIMP VLCControl2::GetTypeInfoCount(UINT* pctInfo)
2659 if( NULL == pctInfo )
2660 return E_INVALIDARG;
2662 if( SUCCEEDED(loadTypeInfo()) )
2670 STDMETHODIMP VLCControl2::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
2672 if( NULL == ppTInfo )
2673 return E_INVALIDARG;
2675 if( SUCCEEDED(loadTypeInfo()) )
2677 _p_typeinfo->AddRef();
2678 *ppTInfo = _p_typeinfo;
2685 STDMETHODIMP VLCControl2::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
2686 UINT cNames, LCID lcid, DISPID* rgDispID)
2688 if( SUCCEEDED(loadTypeInfo()) )
2690 return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
2695 STDMETHODIMP VLCControl2::Invoke(DISPID dispIdMember, REFIID riid,
2696 LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
2697 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
2699 if( SUCCEEDED(loadTypeInfo()) )
2701 return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
2702 pVarResult, pExcepInfo, puArgErr);
2707 STDMETHODIMP VLCControl2::get_AutoLoop(VARIANT_BOOL *autoloop)
2709 if( NULL == autoloop )
2712 *autoloop = _p_instance->getAutoLoop() ? VARIANT_TRUE: VARIANT_FALSE;
2716 STDMETHODIMP VLCControl2::put_AutoLoop(VARIANT_BOOL autoloop)
2718 _p_instance->setAutoLoop((VARIANT_FALSE != autoloop) ? TRUE: FALSE);
2722 STDMETHODIMP VLCControl2::get_AutoPlay(VARIANT_BOOL *autoplay)
2724 if( NULL == autoplay )
2727 *autoplay = _p_instance->getAutoPlay() ? VARIANT_TRUE: VARIANT_FALSE;
2731 STDMETHODIMP VLCControl2::put_AutoPlay(VARIANT_BOOL autoplay)
2733 _p_instance->setAutoPlay((VARIANT_FALSE != autoplay) ? TRUE: FALSE);
2737 STDMETHODIMP VLCControl2::get_BaseURL(BSTR *url)
2742 *url = SysAllocStringLen(_p_instance->getBaseURL(),
2743 SysStringLen(_p_instance->getBaseURL()));
2747 STDMETHODIMP VLCControl2::put_BaseURL(BSTR mrl)
2749 _p_instance->setBaseURL(mrl);
2754 STDMETHODIMP VLCControl2::get_MRL(BSTR *mrl)
2759 *mrl = SysAllocStringLen(_p_instance->getMRL(),
2760 SysStringLen(_p_instance->getMRL()));
2764 STDMETHODIMP VLCControl2::put_MRL(BSTR mrl)
2766 _p_instance->setMRL(mrl);
2772 STDMETHODIMP VLCControl2::get_Toolbar(VARIANT_BOOL *visible)
2774 if( NULL == visible )
2778 * Note to developpers
2780 * Returning the _b_toolbar is closer to the method specification.
2781 * But returning True when toolbar is not implemented so not displayed
2782 * could be bad for ActiveX users which rely on this value to show their
2783 * own toolbar if not provided by the ActiveX.
2785 * This is the reason why FALSE is returned, until toolbar get implemented.
2788 /* DISABLED for now */
2789 // *visible = _p_instance->getShowToolbar() ? VARIANT_TRUE: VARIANT_FALSE;
2791 *visible = VARIANT_FALSE;
2796 STDMETHODIMP VLCControl2::put_Toolbar(VARIANT_BOOL visible)
2798 _p_instance->setShowToolbar((VARIANT_FALSE != visible) ? TRUE: FALSE);
2803 STDMETHODIMP VLCControl2::get_StartTime(long *seconds)
2805 if( NULL == seconds )
2808 *seconds = _p_instance->getStartTime();
2813 STDMETHODIMP VLCControl2::put_StartTime(long seconds)
2815 _p_instance->setStartTime(seconds);
2820 STDMETHODIMP VLCControl2::get_VersionInfo(BSTR *version)
2822 if( NULL == version )
2825 const char *versionStr = libvlc_get_version();
2826 if( NULL != versionStr )
2828 *version = BSTRFromCStr(CP_UTF8, versionStr);
2830 return (NULL == *version) ? E_OUTOFMEMORY : NOERROR;
2836 STDMETHODIMP VLCControl2::get_Visible(VARIANT_BOOL *isVisible)
2838 if( NULL == isVisible )
2841 *isVisible = _p_instance->getVisible() ? VARIANT_TRUE : VARIANT_FALSE;
2846 STDMETHODIMP VLCControl2::put_Visible(VARIANT_BOOL isVisible)
2848 _p_instance->setVisible(isVisible != VARIANT_FALSE);
2853 STDMETHODIMP VLCControl2::get_Volume(long *volume)
2855 if( NULL == volume )
2858 *volume = _p_instance->getVolume();
2862 STDMETHODIMP VLCControl2::put_Volume(long volume)
2864 _p_instance->setVolume(volume);
2868 STDMETHODIMP VLCControl2::get_BackColor(OLE_COLOR *backcolor)
2870 if( NULL == backcolor )
2873 *backcolor = _p_instance->getBackColor();
2877 STDMETHODIMP VLCControl2::put_BackColor(OLE_COLOR backcolor)
2879 _p_instance->setBackColor(backcolor);
2883 STDMETHODIMP VLCControl2::get_audio(IVLCAudio** obj)
2889 if( NULL != _p_vlcaudio )
2891 _p_vlcaudio->AddRef();
2894 return E_OUTOFMEMORY;
2897 STDMETHODIMP VLCControl2::get_input(IVLCInput** obj)
2903 if( NULL != _p_vlcinput )
2905 _p_vlcinput->AddRef();
2908 return E_OUTOFMEMORY;
2911 STDMETHODIMP VLCControl2::get_log(IVLCLog** obj)
2917 if( NULL != _p_vlclog )
2919 _p_vlclog->AddRef();
2922 return E_OUTOFMEMORY;
2925 STDMETHODIMP VLCControl2::get_playlist(IVLCPlaylist** obj)
2930 *obj = _p_vlcplaylist;
2931 if( NULL != _p_vlcplaylist )
2933 _p_vlcplaylist->AddRef();
2936 return E_OUTOFMEMORY;
2939 STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj)
2945 if( NULL != _p_vlcvideo )
2947 _p_vlcvideo->AddRef();
2950 return E_OUTOFMEMORY;