Commit 47808d9b authored by JP Dinger's avatar JP Dinger Committed by Rémi Denis-Courmont

De-deprecate activex plugin.

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 6395b3e5
...@@ -206,6 +206,9 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) : ...@@ -206,6 +206,9 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
_p_class(p_class), _p_class(p_class),
_i_ref(1UL), _i_ref(1UL),
_p_libvlc(NULL), _p_libvlc(NULL),
_p_mlist(NULL),
_p_mplayer(NULL),
_i_midx(-1),
_i_codepage(CP_ACP), _i_codepage(CP_ACP),
_b_usermode(TRUE) _b_usermode(TRUE)
{ {
...@@ -267,6 +270,10 @@ VLCPlugin::~VLCPlugin() ...@@ -267,6 +270,10 @@ VLCPlugin::~VLCPlugin()
SysFreeString(_bstr_mrl); SysFreeString(_bstr_mrl);
SysFreeString(_bstr_baseurl); SysFreeString(_bstr_baseurl);
if( _p_mplayer ) { libvlc_media_player_release(_p_mplayer); _p_mplayer=NULL; }
if( _p_mlist ) { libvlc_media_list_release(_p_mlist); _p_mlist=NULL; }
if( _p_libvlc ) { libvlc_release(_p_libvlc); _p_libvlc=NULL; }
_p_class->Release(); _p_class->Release();
}; };
...@@ -411,12 +418,11 @@ HRESULT VLCPlugin::onLoad(void) ...@@ -411,12 +418,11 @@ HRESULT VLCPlugin::onLoad(void)
return S_OK; return S_OK;
}; };
HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
void VLCPlugin::initVLC()
{ {
extern HMODULE DllGetModule(); extern HMODULE DllGetModule();
if( ! isRunning() )
{
/* /*
** default initialization options ** default initialization options
*/ */
...@@ -482,11 +488,14 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc) ...@@ -482,11 +488,14 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
_p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, &ex); _p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, &ex);
if( libvlc_exception_raised(&ex) )
return;
_p_mlist = libvlc_media_list_new(_p_libvlc, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
*pp_libvlc = NULL; libvlc_release(_p_libvlc);
libvlc_exception_clear(&ex); return;
return E_FAIL;
} }
// initial volume setting // initial volume setting
...@@ -536,13 +545,10 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc) ...@@ -536,13 +545,10 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
options[i_options++] = timeBuffer; options[i_options++] = timeBuffer;
} }
// add default target to playlist // add default target to playlist
libvlc_playlist_add_extended_untrusted(_p_libvlc, psz_mrl, NULL, i_options, options, NULL); playlist_add_extended_untrusted(psz_mrl, i_options, options, NULL);
CoTaskMemFree(psz_mrl); CoTaskMemFree(psz_mrl);
} }
} }
}
*pp_libvlc = _p_libvlc;
return S_OK;
}; };
void VLCPlugin::setErrorInfo(REFIID riid, const char *description) void VLCPlugin::setErrorInfo(REFIID riid, const char *description)
...@@ -729,17 +735,11 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc ...@@ -729,17 +735,11 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
libvlc_video_set_parent(p_libvlc, libvlc_video_set_parent(p_libvlc,
reinterpret_cast<libvlc_drawable_t>(_inplacewnd), NULL); reinterpret_cast<libvlc_drawable_t>(_inplacewnd), NULL);
if( _b_autoplay ) if( _b_autoplay && playlist_select(0,NULL) )
{
libvlc_playlist_lock(p_libvlc);
unsigned count = libvlc_playlist_items_count(p_libvlc, &ex);
if( count > 0 )
{ {
libvlc_playlist_play(p_libvlc, 0, 0, NULL, NULL); libvlc_media_player_play(_p_mplayer,NULL);
fireOnPlayEvent(); fireOnPlayEvent();
} }
libvlc_playlist_unlock(p_libvlc);
}
} }
if( isVisible() ) if( isVisible() )
...@@ -750,9 +750,9 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc ...@@ -750,9 +750,9 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
HRESULT VLCPlugin::onInPlaceDeactivate(void) HRESULT VLCPlugin::onInPlaceDeactivate(void)
{ {
if( isRunning() ) if( isPlaying(NULL) )
{ {
libvlc_playlist_stop(_p_libvlc, NULL); playlist_stop(NULL);
fireOnStopEvent(); fireOnStopEvent();
} }
...@@ -817,14 +817,9 @@ void VLCPlugin::setTime(int seconds) ...@@ -817,14 +817,9 @@ void VLCPlugin::setTime(int seconds)
if( seconds != _i_time ) if( seconds != _i_time )
{ {
setStartTime(_i_time); setStartTime(_i_time);
if( isRunning() ) if( NULL != _p_mplayer )
{
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(_p_libvlc, NULL);
if( NULL != p_md )
{ {
libvlc_media_player_set_time(p_md, _i_time, NULL); libvlc_media_player_set_time(_p_mplayer, _i_time, NULL);
libvlc_media_player_release(p_md);
}
} }
} }
}; };
...@@ -1036,3 +1031,77 @@ void VLCPlugin::fireOnStopEvent(void) ...@@ -1036,3 +1031,77 @@ void VLCPlugin::fireOnStopEvent(void)
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs); vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs);
}; };
bool VLCPlugin::playlist_select( int idx, libvlc_exception_t *ex )
{
libvlc_media_t *p_m = NULL;
libvlc_media_list_lock(_p_mlist);
int count = libvlc_media_list_count(_p_mlist,ex);
if( libvlc_exception_raised(ex) )
goto bad_unlock;
if( idx<0||idx>=count )
goto bad_unlock;
_i_midx = idx;
p_m = libvlc_media_list_item_at_index(_p_mlist,_i_midx,ex);
libvlc_media_list_unlock(_p_mlist);
if( libvlc_exception_raised(ex) )
return false;
if( _p_mplayer )
{
libvlc_media_player_release( _p_mplayer );
_p_mplayer = NULL;
}
_p_mplayer = libvlc_media_player_new_from_media(p_m,ex);
if( _p_mplayer )
set_player_window(ex);
libvlc_media_release( p_m );
return !libvlc_exception_raised(ex);
bad_unlock:
libvlc_media_list_unlock(_p_mlist);
return false;
}
void VLCPlugin::set_player_window(libvlc_exception_t *ex)
{
// XXX FIXME no idea if this is correct or not
libvlc_media_player_set_hwnd(_p_mplayer,getInPlaceWindow(),ex);
}
int VLCPlugin::playlist_add_extended_untrusted(const char *mrl, int optc, const char **optv, libvlc_exception_t *ex)
{
int item = -1;
libvlc_media_t *p_m = libvlc_media_new(_p_libvlc,mrl,ex);
if( libvlc_exception_raised(ex) )
return -1;
for( int i = 0; i < optc; ++i )
{
libvlc_media_add_option_untrusted(p_m, optv[i],ex);
if( libvlc_exception_raised(ex) )
{
libvlc_media_release(p_m);
return -1;
}
}
libvlc_media_list_lock(_p_mlist);
libvlc_media_list_add_media(_p_mlist,p_m,ex);
if( !libvlc_exception_raised(ex) )
item = libvlc_media_list_count(_p_mlist,ex)-1;
libvlc_media_list_unlock(_p_mlist);
libvlc_media_release(p_m);
return item;
}
...@@ -193,7 +193,20 @@ public: ...@@ -193,7 +193,20 @@ public:
inline void setDirty(BOOL dirty) { _b_dirty = dirty; }; inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
inline BOOL isRunning(void) { return NULL != _p_libvlc; }; inline BOOL isRunning(void) { return NULL != _p_libvlc; };
HRESULT getVLC(libvlc_instance_t** p_vlc);
HRESULT getVLC(libvlc_instance_t** pp_libvlc)
{
if( !isRunning() )
initVLC();
*pp_libvlc = _p_libvlc;
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;
}
void setErrorInfo(REFIID riid, const char *description); void setErrorInfo(REFIID riid, const char *description);
// control geometry within container // control geometry within container
...@@ -227,11 +240,81 @@ public: ...@@ -227,11 +240,81 @@ public:
// controlling IUnknown interface // controlling IUnknown interface
LPUNKNOWN pUnkOuter; LPUNKNOWN pUnkOuter;
/*
** libvlc interface
*/
bool isPlaying(libvlc_exception_t *ex)
{
return _p_mplayer && libvlc_media_player_is_playing(_p_mplayer,ex);
}
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)
{
if( _p_mlist )
libvlc_media_list_remove_index(_p_mlist,idx,ex);
}
void playlist_clear(libvlc_exception_t *ex)
{
if( !_p_libvlc )
return;
if( _p_mlist )
libvlc_media_list_release(_p_mlist);
_p_mlist = libvlc_media_list_new(_p_libvlc,ex);
}
int playlist_count(libvlc_exception_t *ex)
{
int r = 0;
if( !_p_mlist )
return 0;
libvlc_media_list_lock(_p_mlist);
r = libvlc_media_list_count(_p_mlist,ex);
libvlc_media_list_unlock(_p_mlist);
return r;
}
void playlist_pause(libvlc_exception_t *ex)
{
if( isPlaying(ex) )
libvlc_media_player_pause(_p_mplayer,ex);
}
void playlist_play(libvlc_exception_t *ex)
{
if( !_p_libvlc )
initVLC();
if( _p_mplayer||playlist_select(0,ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
void playlist_play_item(int idx,libvlc_exception_t *ex)
{
if( !_p_libvlc )
initVLC();
if( playlist_select(idx,ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
void playlist_stop(libvlc_exception_t *ex)
{
if( _p_mplayer )
libvlc_media_player_stop(_p_mplayer,ex);
}
void playlist_next(libvlc_exception_t *ex)
{
if( playlist_select( _i_midx+1, ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
void playlist_prev(libvlc_exception_t *ex)
{
if( playlist_select( _i_midx-1, ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
protected: protected:
virtual ~VLCPlugin(); virtual ~VLCPlugin();
private: private:
void initVLC();
bool playlist_select(int i,libvlc_exception_t *);
void set_player_window(libvlc_exception_t *);
//implemented interfaces //implemented interfaces
class VLCOleObject *vlcOleObject; class VLCOleObject *vlcOleObject;
...@@ -256,7 +339,11 @@ private: ...@@ -256,7 +339,11 @@ private:
VLCPluginClass* _p_class; VLCPluginClass* _p_class;
ULONG _i_ref; ULONG _i_ref;
libvlc_instance_t* _p_libvlc; libvlc_instance_t *_p_libvlc;
libvlc_media_list_t *_p_mlist;
libvlc_media_player_t *_p_mplayer;
int _i_midx;
UINT _i_codepage; UINT _i_codepage;
BOOL _b_usermode; BOOL _b_usermode;
RECT _posRect; RECT _posRect;
......
This diff is collapsed.
This diff is collapsed.
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