X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=projects%2Factivex%2Fvlccontrol2.cpp;h=4aeac925e9086b13d8cf9e89cea6ec253e197599;hb=4fd41d71393f627f94c48f8d867f0a8e2da34902;hp=169f2206f782490cf4db4750f2185f5948777c45;hpb=66bd92014e5d721d8fe74bfd69f601bfd228012a;p=vlc diff --git a/projects/activex/vlccontrol2.cpp b/projects/activex/vlccontrol2.cpp index 169f2206f7..4aeac925e9 100644 --- a/projects/activex/vlccontrol2.cpp +++ b/projects/activex/vlccontrol2.cpp @@ -38,7 +38,7 @@ HRESULT _exception_bridge(VLCPlugin *p,REFIID riid, libvlc_exception_t *ex) { if( libvlc_exception_raised(ex) ) { - p->setErrorInfo(riid,libvlc_exception_get_message(ex)); + p->setErrorInfo(riid,libvlc_errmsg()); libvlc_exception_clear(ex); return E_FAIL; } @@ -51,12 +51,14 @@ HRESULT _exception_bridge(VLCPlugin *p,REFIID riid, libvlc_exception_t *ex) EMIT_EXCEPTION_BRIDGE( VLCAudio ) EMIT_EXCEPTION_BRIDGE( VLCInput ) +EMIT_EXCEPTION_BRIDGE( VLCMarquee ) EMIT_EXCEPTION_BRIDGE( VLCMessageIterator ) EMIT_EXCEPTION_BRIDGE( VLCMessages ) EMIT_EXCEPTION_BRIDGE( VLCLog ) EMIT_EXCEPTION_BRIDGE( VLCPlaylistItems ) EMIT_EXCEPTION_BRIDGE( VLCPlaylist ) EMIT_EXCEPTION_BRIDGE( VLCVideo ) +EMIT_EXCEPTION_BRIDGE( VLCSubtitle ) #undef EMIT_EXCEPTION_BRIDGE @@ -238,6 +240,77 @@ STDMETHODIMP VLCAudio::put_track(long track) return hr; }; +STDMETHODIMP VLCAudio::get_count(long* trackNumber) +{ + if( NULL == trackNumber ) + return E_POINTER; + + libvlc_media_player_t* p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + // get the number of audio track available and return it + *trackNumber = libvlc_audio_get_track_count(p_md, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + + +STDMETHODIMP VLCAudio::description(long trackID, BSTR* name) +{ + if( NULL == name ) + return E_POINTER; + + libvlc_media_player_t* p_md; + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + int i, i_limit; + const char *psz_name; + libvlc_track_description_t *p_trackDesc; + + // get tracks description + p_trackDesc = libvlc_audio_get_track_description(p_md, &ex); + hr = exception_bridge(&ex); + if( FAILED(hr) ) + return hr; + + //get the number of available track + i_limit = libvlc_audio_get_track_count(p_md, &ex); + hr = exception_bridge(&ex); + if( FAILED(hr) ) + return hr; + + // check if the number given is a good one + if ( ( trackID > ( i_limit -1 ) ) || ( trackID < 0 ) ) + return E_FAIL; + + // get the good trackDesc + for( i = 0 ; i < trackID ; i++ ) + { + p_trackDesc = p_trackDesc->p_next; + } + // get the track name + psz_name = p_trackDesc->psz_name; + + // return it + if( psz_name != NULL ) + { + *name = BSTRFromCStr(CP_UTF8, psz_name); + return (NULL == *name) ? E_OUTOFMEMORY : NOERROR; + } + *name = NULL; + return E_FAIL; + } + return hr; +}; + STDMETHODIMP VLCAudio::get_channel(long *channel) { if( NULL == channel ) @@ -464,14 +537,12 @@ STDMETHODIMP VLCInput::get_state(long* state) libvlc_exception_init(&ex); *state = libvlc_media_player_get_state(p_md, &ex); - if( ! libvlc_exception_raised(&ex) ) + if( libvlc_exception_raised(&ex) ) { - return NOERROR; + // don't fail, just return the idle state + *state = 0; + libvlc_exception_clear(&ex); } - libvlc_exception_clear(&ex); - // don't fail, just return the idle state - *state = 0; - return NOERROR; } return hr; }; @@ -553,7 +624,7 @@ VLCLog::~VLCLog() { delete _p_vlcmessages; if( _p_log ) - libvlc_log_close(_p_log, NULL); + libvlc_log_close(_p_log); if( _p_typeinfo ) _p_typeinfo->Release(); @@ -654,13 +725,7 @@ STDMETHODIMP VLCLog::get_verbosity(long* level) libvlc_instance_t* p_libvlc; HRESULT hr = _p_instance->getVLC(&p_libvlc); if( SUCCEEDED(hr) ) - { - libvlc_exception_t ex; - libvlc_exception_init(&ex); - - *level = libvlc_get_log_verbosity(p_libvlc, &ex); - hr = exception_bridge(&ex); - } + *level = libvlc_get_log_verbosity(p_libvlc); return hr; } else @@ -688,12 +753,12 @@ STDMETHODIMP VLCLog::put_verbosity(long verbosity) hr = exception_bridge(&ex); } if( SUCCEEDED(hr) ) - libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex); + libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity); } else if( _p_log ) { /* close log when verbosity is set to -1 */ - libvlc_log_close(_p_log, &ex); + libvlc_log_close(_p_log); _p_log = NULL; } hr = exception_bridge(&ex); @@ -703,6 +768,252 @@ STDMETHODIMP VLCLog::put_verbosity(long verbosity) /*******************************************************************************/ +VLCMarquee::~VLCMarquee() +{ + if( _p_typeinfo ) + _p_typeinfo->Release(); +}; + +HRESULT VLCMarquee::loadTypeInfo(void) +{ + HRESULT hr = NOERROR; + if( NULL == _p_typeinfo ) + { + ITypeLib *p_typelib; + + hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib); + if( SUCCEEDED(hr) ) + { + hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMarquee, &_p_typeinfo); + if( FAILED(hr) ) + { + _p_typeinfo = NULL; + } + p_typelib->Release(); + } + } + return hr; +}; + +STDMETHODIMP VLCMarquee::GetTypeInfoCount(UINT* pctInfo) +{ + if( NULL == pctInfo ) + return E_INVALIDARG; + + if( SUCCEEDED(loadTypeInfo()) ) + *pctInfo = 1; + else + *pctInfo = 0; + + return NOERROR; +}; + +STDMETHODIMP VLCMarquee::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo) +{ + if( NULL == ppTInfo ) + return E_INVALIDARG; + + if( SUCCEEDED(loadTypeInfo()) ) + { + _p_typeinfo->AddRef(); + *ppTInfo = _p_typeinfo; + return NOERROR; + } + *ppTInfo = NULL; + return E_NOTIMPL; +}; + +STDMETHODIMP VLCMarquee::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, + UINT cNames, LCID lcid, DISPID* rgDispID) +{ + if( SUCCEEDED(loadTypeInfo()) ) + { + return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID); + } + return E_NOTIMPL; +}; + +STDMETHODIMP VLCMarquee::Invoke(DISPID dispIdMember, REFIID riid, + LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, + VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) +{ + if( SUCCEEDED(loadTypeInfo()) ) + { + return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams, + pVarResult, pExcepInfo, puArgErr); + } + return E_NOTIMPL; +}; + +STDMETHODIMP VLCMarquee::enable() +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, true, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCMarquee::disable() +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, false, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCMarquee::color(long val) +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Color, val, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCMarquee::opacity(long val) +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Opacity, val, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCMarquee::position(long val) +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Position, val, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCMarquee::refresh(long val) +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Refresh, val, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCMarquee::size(long val) +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Size, val, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCMarquee::text(BSTR text) +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + char *psz_text = CStrFromBSTR(CP_UTF8, text); + libvlc_video_set_marquee_option_as_string(p_md, libvlc_marquee_Text, psz_text, &ex); + hr = exception_bridge(&ex); + CoTaskMemFree(psz_text); + } + return hr; +}; + +STDMETHODIMP VLCMarquee::timeout(long val) +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Timeout, val, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCMarquee::x(long val) +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_X, val, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCMarquee::y(long val) +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Y, val, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +/*******************************************************************************/ + /* STL forward iterator used by VLCEnumIterator class to implement IEnumVARIANT */ class VLCMessageSTLIterator @@ -883,38 +1194,20 @@ STDMETHODIMP VLCMessages::get__NewEnum(LPUNKNOWN* _NewEnum) STDMETHODIMP VLCMessages::clear() { - HRESULT hr = NOERROR; libvlc_log_t *p_log = _p_vlclog->_p_log; if( p_log ) - { - libvlc_exception_t ex; - libvlc_exception_init(&ex); - - libvlc_log_clear(p_log, &ex); - hr = exception_bridge(&ex); - } - return hr; + libvlc_log_clear(p_log); + return NOERROR; }; STDMETHODIMP VLCMessages::get_count(long* count) { - HRESULT hr = S_OK; - if( NULL == count ) return E_POINTER; libvlc_log_t *p_log = _p_vlclog->_p_log; - if( p_log ) - { - libvlc_exception_t ex; - libvlc_exception_init(&ex); - - *count = libvlc_log_count(p_log, &ex); - hr = exception_bridge(&ex); - } - else - *count = 0; - return hr; + *count = libvlc_log_count(p_log); + return S_OK; }; STDMETHODIMP VLCMessages::iterator(IVLCMessageIterator** iter) @@ -946,7 +1239,7 @@ VLCMessageIterator::VLCMessageIterator(VLCPlugin *p_instance, VLCLog* p_vlclog ) VLCMessageIterator::~VLCMessageIterator() { if( _p_iter ) - libvlc_log_iterator_free(_p_iter, NULL); + libvlc_log_iterator_free(_p_iter); if( _p_typeinfo ) _p_typeinfo->Release(); @@ -1025,25 +1318,19 @@ STDMETHODIMP VLCMessageIterator::Invoke(DISPID dispIdMember, REFIID riid, STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext) { - HRESULT hr = S_OK; - if( NULL == hasNext ) return E_POINTER; if( _p_iter && _p_vlclog->_p_log ) { - libvlc_exception_t ex; - libvlc_exception_init(&ex); - - *hasNext = libvlc_log_iterator_has_next(_p_iter, &ex) ? + *hasNext = libvlc_log_iterator_has_next(_p_iter) ? VARIANT_TRUE : VARIANT_FALSE; - hr = exception_bridge(&ex); } else { *hasNext = VARIANT_FALSE; } - return hr; + return S_OK; }; STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message) @@ -1063,13 +1350,9 @@ STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message) libvlc_exception_init(&ex); libvlc_log_iterator_next(_p_iter, &buffer, &ex); - hr = exception_bridge(&ex); - if( SUCCEEDED(hr) ) - { - *message = new VLCMessage(_p_instance, buffer); - if( !message ) - hr = E_OUTOFMEMORY; - } + *message = new VLCMessage(_p_instance, buffer); + if( !message ) + hr = E_OUTOFMEMORY; } return hr; }; @@ -1645,8 +1928,192 @@ STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj) /*******************************************************************************/ +VLCSubtitle::~VLCSubtitle() +{ + if( _p_typeinfo ) + _p_typeinfo->Release(); +}; + +HRESULT VLCSubtitle::loadTypeInfo(void) +{ + HRESULT hr = NOERROR; + if( NULL == _p_typeinfo ) + { + ITypeLib *p_typelib; + + hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib); + if( SUCCEEDED(hr) ) + { + hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCSubtitle, &_p_typeinfo); + if( FAILED(hr) ) + { + _p_typeinfo = NULL; + } + p_typelib->Release(); + } + } + return hr; +}; + +STDMETHODIMP VLCSubtitle::GetTypeInfoCount(UINT* pctInfo) +{ + if( NULL == pctInfo ) + return E_INVALIDARG; + + if( SUCCEEDED(loadTypeInfo()) ) + *pctInfo = 1; + else + *pctInfo = 0; + + return NOERROR; +}; + +STDMETHODIMP VLCSubtitle::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo) +{ + if( NULL == ppTInfo ) + return E_INVALIDARG; + + if( SUCCEEDED(loadTypeInfo()) ) + { + _p_typeinfo->AddRef(); + *ppTInfo = _p_typeinfo; + return NOERROR; + } + *ppTInfo = NULL; + return E_NOTIMPL; +}; + +STDMETHODIMP VLCSubtitle::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, + UINT cNames, LCID lcid, DISPID* rgDispID) +{ + if( SUCCEEDED(loadTypeInfo()) ) + { + return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID); + } + return E_NOTIMPL; +}; + +STDMETHODIMP VLCSubtitle::Invoke(DISPID dispIdMember, REFIID riid, + LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, + VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) +{ + if( SUCCEEDED(loadTypeInfo()) ) + { + return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams, + pVarResult, pExcepInfo, puArgErr); + } + return E_NOTIMPL; +}; + +STDMETHODIMP VLCSubtitle::get_track(long* spu) +{ + if( NULL == spu ) + return E_POINTER; + + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + *spu = libvlc_video_get_spu(p_md, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCSubtitle::put_track(long spu) +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_spu(p_md, spu, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCSubtitle::get_count(long* spuNumber) +{ + if( NULL == spuNumber ) + return E_POINTER; + + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + // get the number of video subtitle available and return it + *spuNumber = libvlc_video_get_spu_count(p_md, &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + + +STDMETHODIMP VLCSubtitle::description(long nameID, BSTR* name) +{ + if( NULL == name ) + return E_POINTER; + + libvlc_media_player_t* p_md; + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + int i, i_limit; + const char *psz_name; + libvlc_track_description_t *p_spuDesc; + + // get subtitles description + p_spuDesc = libvlc_video_get_spu_description(p_md, &ex); + hr = exception_bridge(&ex); + if( FAILED(hr) ) + return hr; + + // get the number of available subtitle + i_limit = libvlc_video_get_spu_count(p_md, &ex); + hr = exception_bridge(&ex); + if( FAILED(hr) ) + return hr; + + // check if the number given is a good one + if ( ( nameID > ( i_limit -1 ) ) || ( nameID < 0 ) ) + return E_FAIL; + + // get the good spuDesc + for( i = 0 ; i < nameID ; i++ ) + { + p_spuDesc = p_spuDesc->p_next; + } + // get the subtitle name + psz_name = p_spuDesc->psz_name; + + // return it + if( psz_name != NULL ) + { + *name = BSTRFromCStr(CP_UTF8, psz_name); + return (NULL == *name) ? E_OUTOFMEMORY : NOERROR; + } + *name = NULL; + return E_FAIL; + } + return hr; +}; + +/*******************************************************************************/ + VLCVideo::~VLCVideo() { + delete _p_vlcmarquee; if( _p_typeinfo ) _p_typeinfo->Release(); }; @@ -1823,9 +2290,6 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect) if( NULL == aspect ) return E_POINTER; - if( 0 == SysStringLen(aspect) ) - return E_INVALIDARG; - libvlc_media_player_t *p_md; HRESULT hr = _p_instance->getMD(&p_md); if( SUCCEEDED(hr) ) @@ -1967,6 +2431,39 @@ STDMETHODIMP VLCVideo::put_teletext(long page) return hr; }; +STDMETHODIMP VLCVideo::deinterlaceDisable() +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + + libvlc_video_set_deinterlace(p_md, 0, "", &ex); + hr = exception_bridge(&ex); + } + return hr; +}; + +STDMETHODIMP VLCVideo::deinterlaceEnable(BSTR mode) +{ + libvlc_media_player_t *p_md; + HRESULT hr = _p_instance->getMD(&p_md); + if( SUCCEEDED(hr) ) + { + libvlc_exception_t ex; + libvlc_exception_init(&ex); + /* get deinterlace mode from the user */ + char *psz_mode = CStrFromBSTR(CP_UTF8, mode); + /* enable deinterlace filter if possible */ + libvlc_video_set_deinterlace(p_md, 1, psz_mode, &ex); + hr = exception_bridge(&ex); + CoTaskMemFree(psz_mode); + } + return hr; +}; + STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture) { if( NULL == picture ) @@ -2024,22 +2521,27 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture) char *psz_filepath = path; /* first convert to unicode using current code page */ WCHAR wpath[MAX_PATH+1]; - if( 0 == MultiByteToWideChar(CP_ACP, 0, filepath, -1, wpath, sizeof(wpath)/sizeof(WCHAR)) ) + if( 0 == MultiByteToWideChar(CP_ACP, 0, filepath, -1, + wpath, sizeof(wpath)/sizeof(WCHAR)) ) return E_FAIL; #endif /* convert to UTF8 */ - pathlen = WideCharToMultiByte(CP_UTF8, 0, wpath, -1, psz_filepath, sizeof(path), NULL, NULL); - // fail if path is 0 or too short (i.e pathlen is the same as storage size) + pathlen = WideCharToMultiByte(CP_UTF8, 0, wpath, -1, + psz_filepath, sizeof(path), NULL, NULL); + // fail if path is 0 or too short (i.e pathlen is the same as + // storage size) + if( (0 == pathlen) || (sizeof(path) == pathlen) ) return E_FAIL; /* take snapshot into file */ libvlc_video_take_snapshot(p_md, psz_filepath, 0, 0, &ex); - if( ! libvlc_exception_raised(&ex) ) + hr = exception_bridge(&ex); + if( SUCCEEDED(hr) ) { - hr = E_FAIL; /* open snapshot file */ - HANDLE snapPic = LoadImage(NULL, filepath, IMAGE_BITMAP,0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE); + HANDLE snapPic = LoadImage(NULL, filepath, IMAGE_BITMAP, 0, 0, + LR_CREATEDIBSECTION|LR_LOADFROMFILE); if( snapPic ) { PICTDESC snapDesc; @@ -2049,7 +2551,8 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture) snapDesc.bmp.hbitmap = (HBITMAP)snapPic; snapDesc.bmp.hpal = NULL; - hr = OleCreatePictureIndirect(&snapDesc, IID_IPictureDisp, TRUE, (LPVOID*)picture); + hr = OleCreatePictureIndirect(&snapDesc, IID_IPictureDisp, + TRUE, (LPVOID*)picture); if( FAILED(hr) ) { *picture = NULL; @@ -2057,11 +2560,7 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture) } } DeleteFile(filepath); - return hr; } - _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); - libvlc_exception_clear(&ex); - return E_FAIL; } return hr; }; @@ -2096,6 +2595,20 @@ STDMETHODIMP VLCVideo::toggleTeletext() return hr; }; +STDMETHODIMP VLCVideo::get_marquee(IVLCMarquee** obj) +{ + if( NULL == obj ) + return E_POINTER; + + *obj = _p_vlcmarquee; + if( NULL != _p_vlcmarquee ) + { + _p_vlcmarquee->AddRef(); + return NOERROR; + } + return E_OUTOFMEMORY; +}; + /*******************************************************************************/ VLCControl2::VLCControl2(VLCPlugin *p_instance) : @@ -2104,18 +2617,21 @@ VLCControl2::VLCControl2(VLCPlugin *p_instance) : _p_vlcaudio(NULL), _p_vlcinput(NULL), _p_vlcplaylist(NULL), + _p_vlcsubtitle(NULL), _p_vlcvideo(NULL) { _p_vlcaudio = new VLCAudio(p_instance); _p_vlcinput = new VLCInput(p_instance); _p_vlclog = new VLCLog(p_instance); _p_vlcplaylist = new VLCPlaylist(p_instance); + _p_vlcsubtitle = new VLCSubtitle(p_instance); _p_vlcvideo = new VLCVideo(p_instance); }; VLCControl2::~VLCControl2() { delete _p_vlcvideo; + delete _p_vlcsubtitle; delete _p_vlcplaylist; delete _p_vlclog; delete _p_vlcinput; @@ -2266,7 +2782,7 @@ STDMETHODIMP VLCControl2::get_Toolbar(VARIANT_BOOL *visible) return E_POINTER; /* - * Note to developpers + * Note to developers * * Returning the _b_toolbar is closer to the method specification. * But returning True when toolbar is not implemented so not displayed @@ -2427,6 +2943,20 @@ STDMETHODIMP VLCControl2::get_playlist(IVLCPlaylist** obj) return E_OUTOFMEMORY; }; +STDMETHODIMP VLCControl2::get_subtitle(IVLCSubtitle** obj) +{ + if( NULL == obj ) + return E_POINTER; + + *obj = _p_vlcsubtitle; + if( NULL != _p_vlcsubtitle ) + { + _p_vlcsubtitle->AddRef(); + return NOERROR; + } + return E_OUTOFMEMORY; +}; + STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj) { if( NULL == obj )