Commit ffb98b35 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

activex: Remove unused wrappers & use libvlcpp

parent 61c98d59
...@@ -56,7 +56,7 @@ using namespace std; ...@@ -56,7 +56,7 @@ using namespace std;
#define THREADING_MODEL "Apartment" #define THREADING_MODEL "Apartment"
#define MISC_STATUS "131473" #define MISC_STATUS "131473"
#define PROGID_STR COMPANY_STR"."PROGRAM_STR #define PROGID_STR COMPANY_STR "." PROGRAM_STR
#define GUID_STRLEN 39 #define GUID_STRLEN 39
......
...@@ -43,17 +43,13 @@ VLCOleObject::~VLCOleObject() ...@@ -43,17 +43,13 @@ VLCOleObject::~VLCOleObject()
STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection) STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection)
{ {
return _p_advise_holder->Advise(pAdvSink, dwConnection); return _p_advise_holder->Advise(pAdvSink, dwConnection);
}; }
STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption) STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption)
{ {
if( _p_instance->isRunning() ) _p_advise_holder->SendOnClose();
{ return _p_instance->onClose(dwSaveOption);
_p_advise_holder->SendOnClose(); }
return _p_instance->onClose(dwSaveOption);
}
return S_OK;
};
STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite,
LONG, HWND hwndParent, LPCRECT lprcPosRect) LONG, HWND hwndParent, LPCRECT lprcPosRect)
......
This diff is collapsed.
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <olectl.h> #include <olectl.h>
#include "../common/win32_fullscreen.h" #include "../common/win32_fullscreen.h"
#include "../common/vlc_player.h"
extern "C" const GUID CLSID_VLCPlugin; extern "C" const GUID CLSID_VLCPlugin;
extern "C" const GUID CLSID_VLCPlugin2; extern "C" const GUID CLSID_VLCPlugin2;
...@@ -39,11 +40,6 @@ extern "C" const GUID DIID_DVLCEvents; ...@@ -39,11 +40,6 @@ extern "C" const GUID DIID_DVLCEvents;
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
typedef struct {
const libvlc_event_type_t libvlc_type; /* libvlc event type */
libvlc_callback_t libvlc_callback; /* libvlc callback function */
} vlcplugin_event_t;
class VLCPluginClass : public IClassFactory class VLCPluginClass : public IClassFactory
{ {
...@@ -82,7 +78,7 @@ private: ...@@ -82,7 +78,7 @@ private:
}; };
class VLCPlugin class VLCPlugin
: public IUnknown, private vlc_player_options, private vlc_player : public IUnknown, private vlc_player_options
{ {
public: public:
VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter); VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
...@@ -99,8 +95,7 @@ public: ...@@ -99,8 +95,7 @@ public:
vlc_player& get_player() vlc_player& get_player()
{ {
if( !vlc_player::is_open() ) initVLC(); return m_player;
return *static_cast<vlc_player*>(this);
} }
vlc_player_options& get_options() vlc_player_options& get_options()
...@@ -129,10 +124,8 @@ public: ...@@ -129,10 +124,8 @@ public:
inline void setAutoLoop(BOOL autoloop) inline void setAutoLoop(BOOL autoloop)
{ {
_b_autoloop = autoloop; _b_autoloop = autoloop;
if( vlc_player::is_open() ){ get_player().mlp().setPlaybackMode( autoloop ? libvlc_playback_mode_loop :
vlc_player::set_mode(autoloop ? libvlc_playback_mode_loop : libvlc_playback_mode_default );
libvlc_playback_mode_default);
}
setDirty(TRUE); setDirty(TRUE);
}; };
inline BOOL getAutoLoop(void) { return _b_autoloop;}; inline BOOL getAutoLoop(void) { return _b_autoloop;};
...@@ -218,20 +211,6 @@ public: ...@@ -218,20 +211,6 @@ public:
inline BOOL isDirty(void) { return _b_dirty; }; inline BOOL isDirty(void) { return _b_dirty; };
inline void setDirty(BOOL dirty) { _b_dirty = dirty; }; inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
inline BOOL isRunning(void) { return NULL != _p_libvlc; };
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 = get_player().get_mp();
return *pp_md ? 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
...@@ -288,58 +267,6 @@ public: ...@@ -288,58 +267,6 @@ public:
// controlling IUnknown interface // controlling IUnknown interface
LPUNKNOWN pUnkOuter; LPUNKNOWN pUnkOuter;
/*
** libvlc interface
*/
bool isPlaying()
{
return get_player().is_playing();
}
int playlist_get_current_index()
{
return get_player().current_item();
}
int playlist_add_extended_untrusted(const char *mrl, int optc, const char **optv)
{
return get_player().add_item(mrl, optc, optv);
}
void playlist_delete_item(int idx)
{
get_player().delete_item(idx);
}
void playlist_clear()
{
get_player().clear_items();
}
int playlist_count()
{
return get_player().items_count();
}
void playlist_pause()
{
get_player().pause();
}
void playlist_play()
{
get_player().play();
}
void playlist_play_item(int idx)
{
get_player().play(idx);
}
void playlist_stop()
{
get_player().stop();
}
void playlist_next()
{
get_player().next();
}
void playlist_prev()
{
get_player().prev();
}
protected: protected:
virtual ~VLCPlugin(); virtual ~VLCPlugin();
...@@ -347,7 +274,6 @@ private: ...@@ -347,7 +274,6 @@ private:
void initVLC(); void initVLC();
void set_player_window(); void set_player_window();
void player_register_events(); void player_register_events();
void player_unregister_events();
//implemented interfaces //implemented interfaces
class VLCOleObject *vlcOleObject; class VLCOleObject *vlcOleObject;
...@@ -374,7 +300,7 @@ private: ...@@ -374,7 +300,7 @@ private:
VLCPluginClass* _p_class; VLCPluginClass* _p_class;
ULONG _i_ref; ULONG _i_ref;
libvlc_instance_t *_p_libvlc; vlc_player m_player;
UINT _i_codepage; UINT _i_codepage;
BOOL _b_usermode; BOOL _b_usermode;
......
...@@ -131,17 +131,15 @@ STDMETHODIMP VLCControl::play(void) ...@@ -131,17 +131,15 @@ STDMETHODIMP VLCControl::play(void)
STDMETHODIMP VLCControl::pause(void) STDMETHODIMP VLCControl::pause(void)
{ {
_p_instance->get_player().pause(); _p_instance->get_player().mlp().pause();
return S_OK; return S_OK;
}; }
STDMETHODIMP VLCControl::stop(void) STDMETHODIMP VLCControl::stop(void)
{ {
_p_instance->get_player().stop(); _p_instance->get_player().mlp().stop();
return S_OK; return S_OK;
}; }
STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying) STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
{ {
...@@ -149,48 +147,48 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying) ...@@ -149,48 +147,48 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
return E_POINTER; return E_POINTER;
vlc_player& p = _p_instance->get_player(); vlc_player& p = _p_instance->get_player();
*isPlaying = p.is_playing() ? VARIANT_TRUE : VARIANT_FALSE; *isPlaying = p.mlp().isPlaying() ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK; return S_OK;
}; }
STDMETHODIMP VLCControl::get_Position(float *position) STDMETHODIMP VLCControl::get_Position(float *position)
{ {
if( NULL == position ) if( NULL == position )
return E_POINTER; return E_POINTER;
*position = _p_instance->get_player().get_position(); *position = _p_instance->get_player().get_mp().position();
return S_OK; return S_OK;
}; }
STDMETHODIMP VLCControl::put_Position(float position) STDMETHODIMP VLCControl::put_Position(float position)
{ {
_p_instance->get_player().set_position(position); _p_instance->get_player().get_mp().setPosition( position );
return S_OK; return S_OK;
}; }
STDMETHODIMP VLCControl::get_Time(int *seconds) STDMETHODIMP VLCControl::get_Time(int *seconds)
{ {
if( NULL == seconds ) if( NULL == seconds )
return E_POINTER; return E_POINTER;
*seconds = static_cast<int>(_p_instance->get_player().get_time()); //FIXME: time is in microseconds, this looks fishy
*seconds = static_cast<int>( _p_instance->get_player().get_mp().time() );
return S_OK; return S_OK;
}; }
STDMETHODIMP VLCControl::put_Time(int seconds) STDMETHODIMP VLCControl::put_Time(int seconds)
{ {
/* setTime function of the plugin sets the time. */ /* setTime function of the plugin sets the time. */
_p_instance->setTime(seconds); _p_instance->setTime(seconds);
return S_OK; return S_OK;
}; }
STDMETHODIMP VLCControl::shuttle(int seconds) STDMETHODIMP VLCControl::shuttle(int seconds)
{ {
_p_instance->get_player().set_time(seconds); _p_instance->setTime( seconds );
return S_OK; return S_OK;
}; };
...@@ -207,21 +205,21 @@ STDMETHODIMP VLCControl::get_Length(int *seconds) ...@@ -207,21 +205,21 @@ STDMETHODIMP VLCControl::get_Length(int *seconds)
if( NULL == seconds ) if( NULL == seconds )
return E_POINTER; return E_POINTER;
*seconds = static_cast<int>(_p_instance->get_player().get_length()); *seconds = _p_instance->get_player().get_mp().length();
return S_OK; return S_OK;
}; };
STDMETHODIMP VLCControl::playFaster(void) STDMETHODIMP VLCControl::playFaster(void)
{ {
_p_instance->get_player().set_rate(2.f); _p_instance->get_player().get_mp().setRate(2.f);
return S_OK; return S_OK;
}; };
STDMETHODIMP VLCControl::playSlower(void) STDMETHODIMP VLCControl::playSlower(void)
{ {
_p_instance->get_player().set_rate(0.5f); _p_instance->get_player().get_mp().setRate(.5f);
return S_OK; return S_OK;
}; };
...@@ -233,46 +231,36 @@ STDMETHODIMP VLCControl::get_Volume(int *volume) ...@@ -233,46 +231,36 @@ STDMETHODIMP VLCControl::get_Volume(int *volume)
*volume = _p_instance->getVolume(); *volume = _p_instance->getVolume();
return S_OK; return S_OK;
}; }
STDMETHODIMP VLCControl::put_Volume(int volume) STDMETHODIMP VLCControl::put_Volume(int volume)
{ {
_p_instance->setVolume(volume); _p_instance->setVolume(volume);
return S_OK; return S_OK;
}; }
STDMETHODIMP VLCControl::toggleMute(void) STDMETHODIMP VLCControl::toggleMute(void)
{ {
_p_instance->get_player().toggle_mute(); _p_instance->get_player().get_mp().toggleMute();
return S_OK; return S_OK;
}; }
STDMETHODIMP VLCControl::setVariable(BSTR, VARIANT) STDMETHODIMP VLCControl::setVariable(BSTR, VARIANT)
{ {
libvlc_instance_t* p_libvlc; _p_instance->setErrorInfo(IID_IVLCControl,
HRESULT result = _p_instance->getVLC(&p_libvlc); "setVariable() is an unsafe interface to use. "
if( SUCCEEDED(result) ) "It has been removed because of security implications." );
{
_p_instance->setErrorInfo(IID_IVLCControl,
"setVariable() is an unsafe interface to use. "
"It has been removed because of security implications." );
}
return E_FAIL; return E_FAIL;
}; }
STDMETHODIMP VLCControl::getVariable(BSTR, VARIANT *) STDMETHODIMP VLCControl::getVariable(BSTR, VARIANT *)
{ {
libvlc_instance_t* p_libvlc; _p_instance->setErrorInfo(IID_IVLCControl,
HRESULT result = _p_instance->getVLC(&p_libvlc); "getVariable() is an unsafe interface to use. "
if( SUCCEEDED(result) ) "It has been removed because of security implications." );
{
_p_instance->setErrorInfo(IID_IVLCControl,
"getVariable() is an unsafe interface to use. "
"It has been removed because of security implications." );
}
return E_FAIL; return E_FAIL;
}; }
void VLCControl::FreeTargetOptions(char **cOptions, int cOptionCount) void VLCControl::FreeTargetOptions(char **cOptions, int cOptionCount)
{ {
...@@ -598,39 +586,34 @@ STDMETHODIMP VLCControl::addTarget(BSTR uri, VARIANT options, enum VLCPlaylistMo ...@@ -598,39 +586,34 @@ STDMETHODIMP VLCControl::addTarget(BSTR uri, VARIANT options, enum VLCPlaylistMo
if( 0 == SysStringLen(uri) ) if( 0 == SysStringLen(uri) )
return E_INVALIDARG; return E_INVALIDARG;
libvlc_instance_t *p_libvlc; char *cUri = CStrFromBSTR(CP_UTF8, uri);
HRESULT hr = _p_instance->getVLC(&p_libvlc); if( NULL == cUri )
if( SUCCEEDED(hr) ) return E_OUTOFMEMORY;
{
char *cUri = CStrFromBSTR(CP_UTF8, uri);
if( NULL == cUri )
return E_OUTOFMEMORY;
int cOptionsCount; int cOptionsCount;
char **cOptions; char **cOptions;
if( FAILED(CreateTargetOptions(CP_UTF8, &options, &cOptions, &cOptionsCount)) ) if( FAILED(CreateTargetOptions(CP_UTF8, &options, &cOptions, &cOptionsCount)) )
return E_INVALIDARG; return E_INVALIDARG;
position = _p_instance->playlist_add_extended_untrusted(cUri, position = _p_instance->get_player().add_item( cUri, cOptionsCount,
cOptionsCount, const_cast<const char**>(cOptions)); const_cast<const char**>( cOptions ) );
FreeTargetOptions(cOptions, cOptionsCount); FreeTargetOptions(cOptions, cOptionsCount);
CoTaskMemFree(cUri); CoTaskMemFree(cUri);
if( position >= 0 ) if( position >= 0 )
{ {
if( mode & VLCPlayListAppendAndGo ) if( mode & VLCPlayListAppendAndGo )
_p_instance->fireOnPlayEvent(); _p_instance->fireOnPlayEvent();
}
else
{
if( mode & VLCPlayListAppendAndGo )
_p_instance->fireOnStopEvent();
}
} }
return hr; else
}; {
if( mode & VLCPlayListAppendAndGo )
_p_instance->fireOnStopEvent();
}
return S_OK;
}
STDMETHODIMP VLCControl::get_PlaylistIndex(int *index) STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
{ {
...@@ -650,18 +633,18 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count) ...@@ -650,18 +633,18 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
*count = _p_instance->get_player().items_count(); *count = _p_instance->get_player().items_count();
return S_OK; return S_OK;
}; }
STDMETHODIMP VLCControl::playlistNext(void) STDMETHODIMP VLCControl::playlistNext(void)
{ {
_p_instance->get_player().next(); _p_instance->get_player().mlp().next();
return S_OK; return S_OK;
}; };
STDMETHODIMP VLCControl::playlistPrev(void) STDMETHODIMP VLCControl::playlistPrev(void)
{ {
_p_instance->get_player().prev(); _p_instance->get_player().mlp().previous();
return S_OK; return S_OK;
}; };
......
This diff is collapsed.
...@@ -34,23 +34,20 @@ public: ...@@ -34,23 +34,20 @@ public:
VLCInterfaceBase(VLCPlugin *p): _plug(p), _ti(NULL) { } VLCInterfaceBase(VLCPlugin *p): _plug(p), _ti(NULL) { }
virtual ~VLCInterfaceBase() { if( _ti ) _ti->Release(); } virtual ~VLCInterfaceBase() { if( _ti ) _ti->Release(); }
VLCPlugin *Instance() const { return _plug; }
HRESULT getVLC(libvlc_instance_t **pp) const { return _plug->getVLC(pp); }
HRESULT getMD(libvlc_media_player_t **pp) const { return _plug->getMD(pp); }
protected: protected:
HRESULT loadTypeInfo(REFIID riid); HRESULT loadTypeInfo(REFIID riid);
ITypeInfo *TypeInfo() const { return _ti; } ITypeInfo *TypeInfo() const { return _ti; }
STDMETHODIMP_(ULONG) AddRef(void) { return _plug->pUnkOuter->AddRef(); }; STDMETHODIMP_(ULONG) AddRef(void) { return _plug->pUnkOuter->AddRef(); };
STDMETHODIMP_(ULONG) Release(void) { return _plug->pUnkOuter->Release(); }; STDMETHODIMP_(ULONG) Release(void) { return _plug->pUnkOuter->Release(); };
private:
VLCPlugin *_plug; VLCPlugin *_plug;
private:
ITypeInfo *_ti; ITypeInfo *_ti;
}; };
template<class T,class I> template<class T,class I>
class VLCInterface: public I, private VLCInterfaceBase class VLCInterface: public I, protected VLCInterfaceBase
{ {
private: private:
typedef VLCInterfaceBase Base; typedef VLCInterfaceBase Base;
...@@ -64,12 +61,6 @@ private: ...@@ -64,12 +61,6 @@ private:
public: public:
VLCInterface(VLCPlugin *p): Base(p) { } VLCInterface(VLCPlugin *p): Base(p) { }
VLCPlugin *Instance() const { return Base::Instance(); }
virtual ~VLCInterface() { }
HRESULT getVLC(libvlc_instance_t **pp) const { return Base::getVLC(pp); }
HRESULT getMD(libvlc_media_player_t **pp) const { return Base::getMD(pp); }
STDMETHODIMP QueryInterface(REFIID riid, void **ppv) STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{ {
...@@ -146,7 +137,7 @@ public: ...@@ -146,7 +137,7 @@ public:
STDMETHODIMP get_channel(long*); STDMETHODIMP get_channel(long*);
STDMETHODIMP put_channel(long); STDMETHODIMP put_channel(long);
STDMETHODIMP toggleMute(); STDMETHODIMP toggleMute();
STDMETHODIMP description(long, BSTR*); STDMETHODIMP description(long trackId, BSTR*);
}; };
class VLCInput: public VLCInterface<VLCInput,IVLCInput> class VLCInput: public VLCInterface<VLCInput,IVLCInput>
......
...@@ -101,3 +101,40 @@ void vlc_player::play() ...@@ -101,3 +101,40 @@ void vlc_player::play()
else else
_ml_p.play(); _ml_p.play();
} }
int vlc_player::currentAudioTrack()
{
auto current = _mp.spu();
if ( current < 0 )
return -1;
auto tracks = _mp.spuDescription();
return getTrack( current, tracks );
}
int vlc_player::currentSubtitleTrack()
{
auto current = _mp.spu();
if ( current < 0 )
return -1;
auto tracks = _mp.spuDescription();
return getTrack( current, tracks );
}
int vlc_player::getTrack( int currentId, const std::vector<VLC::TrackDescription>& tracks )
{
if ( currentId < 0 )
return -1;
if ( tracks.empty() )
return -1;
int trackId = 0;
for ( const auto& t : tracks )
{
if ( t.id() == currentId )
{
return trackId;
}
++trackId;
}
return -1;
}
...@@ -58,6 +58,14 @@ public: ...@@ -58,6 +58,14 @@ public:
return _ml_p; return _ml_p;
} }
int currentAudioTrack();
int currentSubtitleTrack();
private:
// Returns a 0-based track index, instead of the internal libvlc one
int getTrack( int currentId, const std::vector<VLC::TrackDescription>& tracks );
private: private:
VLC::Instance _libvlc_instance; VLC::Instance _libvlc_instance;
VLC::MediaPlayer _mp; VLC::MediaPlayer _mp;
......
...@@ -47,7 +47,7 @@ npapi-sdk: ...@@ -47,7 +47,7 @@ npapi-sdk:
svn export http://npapi-sdk.googlecode.com/svn/trunk/headers npapi-sdk-svn -r HEAD svn export http://npapi-sdk.googlecode.com/svn/trunk/headers npapi-sdk-svn -r HEAD
mv npapi-sdk-svn npapi-sdk mv npapi-sdk-svn npapi-sdk
if HAVE_XCB if HAVE_DARWIN
# Unix (x11) platforms # Unix (x11) platforms
# #
......
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