Commit 4d89b290 authored by Jean-Paul Saman's avatar Jean-Paul Saman

activex: remove libvlc_exceptions and adapt to recent libvlc changes

The libvlc_exceptions have been removed from libvlc.
The libvlc audio functions prototypes have changed.
parent 2f58aad4
/*****************************************************************************
* plugin.cpp: ActiveX control for VLC
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* Copyright (C) 2006-2010 the VideoLAN team
*
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -47,6 +48,7 @@
#include <servprov.h>
#include <shlwapi.h>
#include <wininet.h>
#include <assert.h>
using namespace std;
......@@ -418,7 +420,6 @@ HRESULT VLCPlugin::onLoad(void)
return S_OK;
};
void VLCPlugin::initVLC()
{
extern HMODULE DllGetModule();
......@@ -486,22 +487,12 @@ void VLCPlugin::initVLC()
if( _b_autoloop )
ppsz_argv[ppsz_argc++] = "--loop";
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, &ex);
if( libvlc_exception_raised(&ex) )
_p_libvlc = libvlc_new(ppsz_argc, ppsz_argv);
if( !_p_libvlc )
return;
_p_mlist = libvlc_media_list_new(_p_libvlc);
// initial volume setting
libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL);
if( _b_mute )
{
libvlc_audio_set_mute(_p_libvlc, TRUE);
}
// initial playlist item
if( SysStringLen(_bstr_mrl) > 0 )
{
......@@ -542,7 +533,7 @@ void VLCPlugin::initVLC()
options[i_options++] = timeBuffer;
}
// add default target to playlist
playlist_add_extended_untrusted(psz_mrl, i_options, options, NULL);
playlist_add_extended_untrusted(psz_mrl, i_options, options);
CoTaskMemFree(psz_mrl);
}
}
......@@ -668,8 +659,6 @@ BOOL VLCPlugin::isInPlaceActive(void)
HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{
RECT clipRect = *lprcClipRect;
libvlc_exception_t ex;
libvlc_exception_init(&ex);
/*
** record keeping of control geometry within container
......@@ -714,9 +703,9 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
if( FAILED(result) )
return result;
if( _b_autoplay && playlist_select(0,NULL) )
if( _b_autoplay && playlist_select(0) )
{
libvlc_media_player_play(_p_mplayer,NULL);
libvlc_media_player_play(_p_mplayer);
fireOnPlayEvent();
}
}
......@@ -729,9 +718,9 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
HRESULT VLCPlugin::onInPlaceDeactivate(void)
{
if( isPlaying(NULL) )
if( isPlaying() )
{
playlist_stop(NULL);
playlist_stop();
fireOnStopEvent();
}
......@@ -769,7 +758,10 @@ void VLCPlugin::setVolume(int volume)
_i_volume = volume;
if( isRunning() )
{
libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL);
libvlc_media_player_t *p_md;
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
libvlc_audio_set_volume(p_md, _i_volume);
}
setDirty(TRUE);
}
......@@ -798,7 +790,7 @@ void VLCPlugin::setTime(int seconds)
setStartTime(_i_time);
if( NULL != _p_mplayer )
{
libvlc_media_player_set_time(_p_mplayer, _i_time, NULL);
libvlc_media_player_set_time(_p_mplayer, _i_time);
}
}
};
......@@ -1004,25 +996,24 @@ void VLCPlugin::fireOnStopEvent(void)
vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs);
};
bool VLCPlugin::playlist_select( int idx, libvlc_exception_t *ex )
bool VLCPlugin::playlist_select( int idx )
{
libvlc_media_t *p_m = NULL;
assert(_p_mlist);
libvlc_media_list_lock(_p_mlist);
int count = libvlc_media_list_count(_p_mlist);
if( libvlc_exception_raised(ex) )
goto bad_unlock;
if( idx<0||idx>=count )
if( (idx < 0) || (idx >= count) )
goto bad_unlock;
_i_midx = idx;
p_m = libvlc_media_list_item_at_index(_p_mlist,_i_midx,ex);
p_m = libvlc_media_list_item_at_index(_p_mlist,_i_midx);
libvlc_media_list_unlock(_p_mlist);
if( libvlc_exception_raised(ex) )
if( !p_m )
return false;
if( _p_mplayer )
......@@ -1031,37 +1022,42 @@ bool VLCPlugin::playlist_select( int idx, libvlc_exception_t *ex )
_p_mplayer = NULL;
}
_p_mplayer = libvlc_media_player_new_from_media(p_m,ex);
_p_mplayer = libvlc_media_player_new_from_media(p_m);
if( _p_mplayer )
set_player_window(ex);
{
// initial volume setting
libvlc_audio_set_volume(_p_mplayer, _i_volume);
if( _b_mute )
libvlc_audio_set_mute(_p_mplayer, TRUE);
set_player_window();
}
libvlc_media_release( p_m );
return !libvlc_exception_raised(ex);
libvlc_media_release(p_m);
return _p_mplayer ? true : false;
bad_unlock:
libvlc_media_list_unlock(_p_mlist);
return false;
}
void VLCPlugin::set_player_window(libvlc_exception_t *ex)
void VLCPlugin::set_player_window()
{
// XXX FIXME no idea if this is correct or not
libvlc_media_player_set_hwnd(_p_mplayer,getInPlaceWindow());
}
int VLCPlugin::playlist_add_extended_untrusted(const char *mrl, int optc, const char **optv, libvlc_exception_t *ex)
int VLCPlugin::playlist_add_extended_untrusted(const char *mrl, int optc, const char **optv)
{
int item = -1;
libvlc_media_t *p_m = libvlc_media_new(_p_libvlc,mrl,ex);
if( libvlc_exception_raised(ex) )
libvlc_media_t *p_m = libvlc_media_new(_p_libvlc,mrl);
if( !p_m )
return -1;
for( int i = 0; i < optc; ++i )
libvlc_media_add_option_flag(p_m, optv[i], libvlc_media_option_unique);
libvlc_media_list_lock(_p_mlist);
libvlc_media_list_add_media(_p_mlist,p_m,ex);
if( !libvlc_exception_raised(ex) )
if( libvlc_media_list_add_media(_p_mlist,p_m) == 0 )
item = libvlc_media_list_count(_p_mlist)-1;
libvlc_media_list_unlock(_p_mlist);
libvlc_media_release(p_m);
......
/*****************************************************************************
* plugin.h: ActiveX control for VLC
*****************************************************************************
* Copyright (C) 2005 the VideoLAN team
* Copyright (C) 2005-2010 the VideoLAN team
*
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -199,12 +200,12 @@ public:
if( !isRunning() )
initVLC();
*pp_libvlc = _p_libvlc;
return _p_libvlc?S_OK:E_FAIL;
return _p_libvlc ? S_OK : E_FAIL;
}
HRESULT getMD(libvlc_media_player_t **pp_md)
{
*pp_md = _p_mplayer;
return _p_mplayer?S_OK:E_FAIL;
return _p_mplayer ? S_OK : E_FAIL;
}
void setErrorInfo(REFIID riid, const char *description);
......@@ -243,18 +244,18 @@ public:
/*
** libvlc interface
*/
bool isPlaying(libvlc_exception_t *ex)
bool isPlaying()
{
return _p_mplayer && libvlc_media_player_is_playing(_p_mplayer);
}
int playlist_get_current_index(libvlc_exception_t *) { return _i_midx; }
int playlist_add_extended_untrusted(const char *, int, const char **, libvlc_exception_t *);
void playlist_delete_item(int idx, libvlc_exception_t *ex)
int playlist_get_current_index() { return _i_midx; }
int playlist_add_extended_untrusted(const char *, int, const char **);
void playlist_delete_item(int idx)
{
if( _p_mlist )
libvlc_media_list_remove_index(_p_mlist,idx,ex);
libvlc_media_list_remove_index(_p_mlist,idx);
}
void playlist_clear(libvlc_exception_t *ex)
void playlist_clear()
{
if( !_p_libvlc )
return;
......@@ -262,7 +263,7 @@ public:
libvlc_media_list_release(_p_mlist);
_p_mlist = libvlc_media_list_new(_p_libvlc);
}
int playlist_count(libvlc_exception_t *ex)
int playlist_count()
{
int r = 0;
if( !_p_mlist )
......@@ -272,39 +273,39 @@ public:
libvlc_media_list_unlock(_p_mlist);
return r;
}
void playlist_pause(libvlc_exception_t *ex)
void playlist_pause()
{
if( isPlaying(ex) )
libvlc_media_player_pause(_p_mplayer,ex);
if( isPlaying() )
libvlc_media_player_pause(_p_mplayer);
}
void playlist_play(libvlc_exception_t *ex)
void playlist_play()
{
if( !_p_libvlc )
initVLC();
if( _p_mplayer||playlist_select(0,ex) )
libvlc_media_player_play(_p_mplayer,ex);
if( _p_mplayer || playlist_select(0) )
libvlc_media_player_play(_p_mplayer);
}
void playlist_play_item(int idx,libvlc_exception_t *ex)
void playlist_play_item(int idx)
{
if( !_p_libvlc )
initVLC();
if( playlist_select(idx,ex) )
libvlc_media_player_play(_p_mplayer,ex);
if( playlist_select(idx) )
libvlc_media_player_play(_p_mplayer);
}
void playlist_stop(libvlc_exception_t *ex)
void playlist_stop()
{
if( _p_mplayer )
libvlc_media_player_stop(_p_mplayer);
}
void playlist_next(libvlc_exception_t *ex)
void playlist_next()
{
if( playlist_select( _i_midx+1, ex) )
libvlc_media_player_play(_p_mplayer,ex);
if( playlist_select( _i_midx+1 ) )
libvlc_media_player_play(_p_mplayer);
}
void playlist_prev(libvlc_exception_t *ex)
void playlist_prev()
{
if( playlist_select( _i_midx-1, ex) )
libvlc_media_player_play(_p_mplayer,ex);
if( playlist_select( _i_midx-1 ) )
libvlc_media_player_play(_p_mplayer);
}
protected:
......@@ -313,8 +314,8 @@ protected:
private:
void initVLC();
bool playlist_select(int i,libvlc_exception_t *);
void set_player_window(libvlc_exception_t *);
bool playlist_select(int i);
void set_player_window();
//implemented interfaces
class VLCOleObject *vlcOleObject;
......
/*****************************************************************************
* vlccontrol.cpp: ActiveX control for VLC
*****************************************************************************
* Copyright (C) 2005 the VideoLAN team
* Copyright (C) 2005-2010 the VideoLAN team
*
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
* Jean-Paul Saman <jpsaman@videolan.org>
......@@ -112,26 +112,21 @@ STDMETHODIMP VLCControl::get_Visible(VARIANT_BOOL *isVisible)
*isVisible = _p_instance->getVisible() ? VARIANT_TRUE : VARIANT_FALSE;
return NOERROR;
return S_OK;
};
STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible)
{
_p_instance->setVisible(isVisible != VARIANT_FALSE);
return NOERROR;
return S_OK;
};
STDMETHODIMP VLCControl::play(void)
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_play(&ex);
HRESULT result = exception_bridge(&ex);
if( SUCCEEDED(result) )
_p_instance->fireOnPlayEvent();
return result;
_p_instance->playlist_play();
_p_instance->fireOnPlayEvent();
return S_OK;
};
STDMETHODIMP VLCControl::pause(void)
......@@ -140,13 +135,8 @@ STDMETHODIMP VLCControl::pause(void)
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_pause(p_md, &ex);
result = exception_bridge(&ex);
if( SUCCEEDED(result) )
_p_instance->fireOnPauseEvent();
libvlc_media_player_pause(p_md);
_p_instance->fireOnPauseEvent();
}
return result;
};
......@@ -157,13 +147,8 @@ STDMETHODIMP VLCControl::stop(void)
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_stop(p_md);
result = exception_bridge(&ex);
if( SUCCEEDED(result) )
_p_instance->fireOnStopEvent();
_p_instance->fireOnStopEvent();
}
return result;
};
......@@ -193,11 +178,7 @@ STDMETHODIMP VLCControl::get_Position(float *position)
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*position = libvlc_media_player_get_position(p_md, &ex);
result = exception_bridge(&ex);
*position = libvlc_media_player_get_position(p_md);
}
return result;
};
......@@ -208,11 +189,7 @@ STDMETHODIMP VLCControl::put_Position(float position)
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_set_position(p_md, position, &ex);
result = exception_bridge(&ex);
libvlc_media_player_set_position(p_md, position);
}
return result;
};
......@@ -227,11 +204,7 @@ STDMETHODIMP VLCControl::get_Time(int *seconds)
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*seconds = libvlc_media_player_get_time(p_md, &ex);
result = exception_bridge(&ex);
*seconds = libvlc_media_player_get_time(p_md);
}
return result;
};
......@@ -240,7 +213,7 @@ STDMETHODIMP VLCControl::put_Time(int seconds)
{
/* setTime function of the plugin sets the time. */
_p_instance->setTime(seconds);
return NOERROR;
return S_OK;
};
STDMETHODIMP VLCControl::shuttle(int seconds)
......@@ -249,12 +222,8 @@ STDMETHODIMP VLCControl::shuttle(int seconds)
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
if( seconds < 0 ) seconds = 0;
libvlc_media_player_set_time(p_md, (int64_t)seconds, &ex);
result = exception_bridge(&ex);
libvlc_media_player_set_time(p_md, (int64_t)seconds);
}
return result;
......@@ -268,7 +237,7 @@ STDMETHODIMP VLCControl::fullscreen(void)
{
if( libvlc_media_player_is_playing(p_md) )
{
libvlc_toggle_fullscreen(p_md, NULL);
libvlc_toggle_fullscreen(p_md);
}
}
return result;
......@@ -284,11 +253,7 @@ STDMETHODIMP VLCControl::get_Length(int *seconds)
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*seconds = (double)libvlc_media_player_get_length(p_md, &ex);
result = exception_bridge(&ex);
*seconds = (double)libvlc_media_player_get_length(p_md);
}
return result;
......@@ -303,11 +268,7 @@ STDMETHODIMP VLCControl::playFaster(void)
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_set_rate(p_md, rate, &ex);
result = exception_bridge(&ex);
libvlc_media_player_set_rate(p_md, rate);
}
return result;
};
......@@ -320,11 +281,7 @@ STDMETHODIMP VLCControl::playSlower(void)
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_set_rate(p_md, rate, &ex);
result = exception_bridge(&ex);
libvlc_media_player_set_rate(p_md, rate);
}
return result;
};
......@@ -335,21 +292,21 @@ STDMETHODIMP VLCControl::get_Volume(int *volume)
return E_POINTER;
*volume = _p_instance->getVolume();
return NOERROR;
return S_OK;
};
STDMETHODIMP VLCControl::put_Volume(int volume)
{
_p_instance->setVolume(volume);
return NOERROR;
return S_OK;
};
STDMETHODIMP VLCControl::toggleMute(void)
{
libvlc_instance_t* p_libvlc;
HRESULT result = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
libvlc_audio_toggle_mute(p_libvlc);
libvlc_audio_toggle_mute(p_md);
return result;
};
......@@ -717,17 +674,13 @@ STDMETHODIMP VLCControl::addTarget(BSTR uri, VARIANT options, enum VLCPlaylistMo
if( FAILED(CreateTargetOptions(CP_UTF8, &options, &cOptions, &cOptionsCount)) )
return E_INVALIDARG;
libvlc_exception_t ex;
libvlc_exception_init(&ex);
position = _p_instance->playlist_add_extended_untrusted(cUri,
cOptionsCount, const_cast<const char**>(cOptions), &ex);
cOptionsCount, const_cast<const char**>(cOptions));
FreeTargetOptions(cOptions, cOptionsCount);
CoTaskMemFree(cUri);
hr = exception_bridge(&ex);
if( SUCCEEDED(hr) )
if( position >= 0 )
{
if( mode & VLCPlayListAppendAndGo )
_p_instance->fireOnPlayEvent();
......@@ -751,11 +704,7 @@ STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*index = _p_instance->playlist_get_current_index(&ex);
result = exception_bridge(&ex);
*index = _p_instance->playlist_get_current_index();
}
return result;
};
......@@ -765,11 +714,8 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
if( NULL == count )
return E_POINTER;
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*count = _p_instance->playlist_count(&ex);
return exception_bridge(&ex);
*count = _p_instance->playlist_count();
return S_OK;
};
STDMETHODIMP VLCControl::playlistNext(void)
......@@ -778,11 +724,7 @@ STDMETHODIMP VLCControl::playlistNext(void)
HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_next(&ex);
result = exception_bridge(&ex);
_p_instance->playlist_next();
}
return result;
};
......@@ -793,11 +735,7 @@ STDMETHODIMP VLCControl::playlistPrev(void)
HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_prev(&ex);
result = exception_bridge(&ex);
_p_instance->playlist_prev();
}
return result;
};
......@@ -808,11 +746,7 @@ STDMETHODIMP VLCControl::playlistClear(void)
HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_clear(&ex);
result = exception_bridge(&ex);
_p_instance->playlist_clear();
}
return result;
};
......@@ -839,7 +773,7 @@ STDMETHODIMP VLCControl::get_MRL(BSTR *mrl)
*mrl = SysAllocStringLen(_p_instance->getMRL(),
SysStringLen(_p_instance->getMRL()));
return NOERROR;
return S_OK;
};
STDMETHODIMP VLCControl::put_MRL(BSTR mrl)
......
/*****************************************************************************
* vlccontrol.h: ActiveX control for VLC
*****************************************************************************
* Copyright (C) 2005 the VideoLAN team
* Copyright (C) 2005-2010 the VideoLAN team
*
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
*
......@@ -101,14 +101,6 @@ public:
private:
HRESULT getTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex)
{
if( ! libvlc_exception_raised(ex) )
return NOERROR;
_p_instance->setErrorInfo(IID_IVLCControl, libvlc_errmsg());
libvlc_exception_clear(ex);
return E_FAIL;
}
VLCPlugin *_p_instance;
ITypeInfo *_p_typeinfo;
......
This diff is collapsed.
......@@ -40,7 +40,6 @@ public:
HRESULT getMD(libvlc_media_player_t **pp) const { return _plug->getMD(pp); }
protected:
HRESULT report_exception(REFIID riid, libvlc_exception_t *ex);
HRESULT loadTypeInfo(REFIID riid);
ITypeInfo *TypeInfo() const { return _ti; }
......@@ -71,12 +70,6 @@ public:
HRESULT getVLC(libvlc_instance_t **pp) const { return Base::getVLC(pp); }
HRESULT getMD(libvlc_media_player_t **pp) const { return Base::getMD(pp); }
HRESULT exception_bridge(libvlc_exception_t *ex)
{
return libvlc_exception_raised(ex) ?
Base::report_exception(_riid,ex) : NOERROR;
}
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv ) return E_POINTER;
......@@ -206,7 +199,6 @@ private:
HRESULT do_get_int(unsigned idx, LONG *val);
};
class VLCLogo: public VLCInterface<VLCLogo,IVLCLogo>
{
public:
......@@ -239,7 +231,6 @@ private:
HRESULT do_get_int(unsigned idx, LONG *val);
};
class VLCDeinterlace: public VLCInterface<VLCDeinterlace,IVLCDeinterlace>
{
public:
......@@ -250,7 +241,6 @@ public:
STDMETHODIMP disable();
};
class VLCPlaylistItems: public VLCInterface<VLCPlaylistItems,IVLCPlaylistItems>
{
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment