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;
#define THREADING_MODEL "Apartment"
#define MISC_STATUS "131473"
#define PROGID_STR COMPANY_STR"."PROGRAM_STR
#define PROGID_STR COMPANY_STR "." PROGRAM_STR
#define GUID_STRLEN 39
......
......@@ -43,17 +43,13 @@ VLCOleObject::~VLCOleObject()
STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection)
{
return _p_advise_holder->Advise(pAdvSink, dwConnection);
};
}
STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption)
{
if( _p_instance->isRunning() )
{
_p_advise_holder->SendOnClose();
return _p_instance->onClose(dwSaveOption);
}
return S_OK;
};
}
STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite,
LONG, HWND hwndParent, LPCRECT lprcPosRect)
......
This diff is collapsed.
......@@ -31,6 +31,7 @@
#include <olectl.h>
#include "../common/win32_fullscreen.h"
#include "../common/vlc_player.h"
extern "C" const GUID CLSID_VLCPlugin;
extern "C" const GUID CLSID_VLCPlugin2;
......@@ -39,11 +40,6 @@ extern "C" const GUID DIID_DVLCEvents;
#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
{
......@@ -82,7 +78,7 @@ private:
};
class VLCPlugin
: public IUnknown, private vlc_player_options, private vlc_player
: public IUnknown, private vlc_player_options
{
public:
VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
......@@ -99,8 +95,7 @@ public:
vlc_player& get_player()
{
if( !vlc_player::is_open() ) initVLC();
return *static_cast<vlc_player*>(this);
return m_player;
}
vlc_player_options& get_options()
......@@ -129,10 +124,8 @@ public:
inline void setAutoLoop(BOOL autoloop)
{
_b_autoloop = autoloop;
if( vlc_player::is_open() ){
vlc_player::set_mode(autoloop ? libvlc_playback_mode_loop :
libvlc_playback_mode_default);
}
get_player().mlp().setPlaybackMode( autoloop ? libvlc_playback_mode_loop :
libvlc_playback_mode_default );
setDirty(TRUE);
};
inline BOOL getAutoLoop(void) { return _b_autoloop;};
......@@ -218,20 +211,6 @@ public:
inline BOOL isDirty(void) { return _b_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);
// control geometry within container
......@@ -288,58 +267,6 @@ public:
// controlling IUnknown interface
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:
virtual ~VLCPlugin();
......@@ -347,7 +274,6 @@ private:
void initVLC();
void set_player_window();
void player_register_events();
void player_unregister_events();
//implemented interfaces
class VLCOleObject *vlcOleObject;
......@@ -374,7 +300,7 @@ private:
VLCPluginClass* _p_class;
ULONG _i_ref;
libvlc_instance_t *_p_libvlc;
vlc_player m_player;
UINT _i_codepage;
BOOL _b_usermode;
......
......@@ -131,17 +131,15 @@ STDMETHODIMP VLCControl::play(void)
STDMETHODIMP VLCControl::pause(void)
{
_p_instance->get_player().pause();
_p_instance->get_player().mlp().pause();
return S_OK;
};
}
STDMETHODIMP VLCControl::stop(void)
{
_p_instance->get_player().stop();
_p_instance->get_player().mlp().stop();
return S_OK;
};
}
STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
{
......@@ -149,48 +147,48 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
return E_POINTER;
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;
};
}
STDMETHODIMP VLCControl::get_Position(float *position)
{
if( NULL == position )
return E_POINTER;
*position = _p_instance->get_player().get_position();
*position = _p_instance->get_player().get_mp().position();
return S_OK;
};
}
STDMETHODIMP VLCControl::put_Position(float position)
{
_p_instance->get_player().set_position(position);
_p_instance->get_player().get_mp().setPosition( position );
return S_OK;
};
}
STDMETHODIMP VLCControl::get_Time(int *seconds)
{
if( NULL == seconds )
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;
};
}
STDMETHODIMP VLCControl::put_Time(int seconds)
{
/* setTime function of the plugin sets the time. */
_p_instance->setTime(seconds);
return S_OK;
};
}
STDMETHODIMP VLCControl::shuttle(int seconds)
{
_p_instance->get_player().set_time(seconds);
_p_instance->setTime( seconds );
return S_OK;
};
......@@ -207,21 +205,21 @@ STDMETHODIMP VLCControl::get_Length(int *seconds)
if( NULL == seconds )
return E_POINTER;
*seconds = static_cast<int>(_p_instance->get_player().get_length());
*seconds = _p_instance->get_player().get_mp().length();
return S_OK;
};
STDMETHODIMP VLCControl::playFaster(void)
{
_p_instance->get_player().set_rate(2.f);
_p_instance->get_player().get_mp().setRate(2.f);
return S_OK;
};
STDMETHODIMP VLCControl::playSlower(void)
{
_p_instance->get_player().set_rate(0.5f);
_p_instance->get_player().get_mp().setRate(.5f);
return S_OK;
};
......@@ -233,46 +231,36 @@ STDMETHODIMP VLCControl::get_Volume(int *volume)
*volume = _p_instance->getVolume();
return S_OK;
};
}
STDMETHODIMP VLCControl::put_Volume(int volume)
{
_p_instance->setVolume(volume);
return S_OK;
};
}
STDMETHODIMP VLCControl::toggleMute(void)
{
_p_instance->get_player().toggle_mute();
_p_instance->get_player().get_mp().toggleMute();
return S_OK;
};
}
STDMETHODIMP VLCControl::setVariable(BSTR, VARIANT)
{
libvlc_instance_t* p_libvlc;
HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{
_p_instance->setErrorInfo(IID_IVLCControl,
"setVariable() is an unsafe interface to use. "
"It has been removed because of security implications." );
}
return E_FAIL;
};
}
STDMETHODIMP VLCControl::getVariable(BSTR, VARIANT *)
{
libvlc_instance_t* p_libvlc;
HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{
_p_instance->setErrorInfo(IID_IVLCControl,
"getVariable() is an unsafe interface to use. "
"It has been removed because of security implications." );
}
return E_FAIL;
};
}
void VLCControl::FreeTargetOptions(char **cOptions, int cOptionCount)
{
......@@ -598,10 +586,6 @@ STDMETHODIMP VLCControl::addTarget(BSTR uri, VARIANT options, enum VLCPlaylistMo
if( 0 == SysStringLen(uri) )
return E_INVALIDARG;
libvlc_instance_t *p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
char *cUri = CStrFromBSTR(CP_UTF8, uri);
if( NULL == cUri )
return E_OUTOFMEMORY;
......@@ -612,8 +596,8 @@ STDMETHODIMP VLCControl::addTarget(BSTR uri, VARIANT options, enum VLCPlaylistMo
if( FAILED(CreateTargetOptions(CP_UTF8, &options, &cOptions, &cOptionsCount)) )
return E_INVALIDARG;
position = _p_instance->playlist_add_extended_untrusted(cUri,
cOptionsCount, const_cast<const char**>(cOptions));
position = _p_instance->get_player().add_item( cUri, cOptionsCount,
const_cast<const char**>( cOptions ) );
FreeTargetOptions(cOptions, cOptionsCount);
CoTaskMemFree(cUri);
......@@ -628,9 +612,8 @@ STDMETHODIMP VLCControl::addTarget(BSTR uri, VARIANT options, enum VLCPlaylistMo
if( mode & VLCPlayListAppendAndGo )
_p_instance->fireOnStopEvent();
}
}
return hr;
};
return S_OK;
}
STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
{
......@@ -650,18 +633,18 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
*count = _p_instance->get_player().items_count();
return S_OK;
};
}
STDMETHODIMP VLCControl::playlistNext(void)
{
_p_instance->get_player().next();
_p_instance->get_player().mlp().next();
return S_OK;
};
STDMETHODIMP VLCControl::playlistPrev(void)
{
_p_instance->get_player().prev();
_p_instance->get_player().mlp().previous();
return S_OK;
};
......
This diff is collapsed.
......@@ -34,23 +34,20 @@ public:
VLCInterfaceBase(VLCPlugin *p): _plug(p), _ti(NULL) { }
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:
HRESULT loadTypeInfo(REFIID riid);
ITypeInfo *TypeInfo() const { return _ti; }
STDMETHODIMP_(ULONG) AddRef(void) { return _plug->pUnkOuter->AddRef(); };
STDMETHODIMP_(ULONG) Release(void) { return _plug->pUnkOuter->Release(); };
private:
VLCPlugin *_plug;
private:
ITypeInfo *_ti;
};
template<class T,class I>
class VLCInterface: public I, private VLCInterfaceBase
class VLCInterface: public I, protected VLCInterfaceBase
{
private:
typedef VLCInterfaceBase Base;
......@@ -64,12 +61,6 @@ private:
public:
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)
{
......@@ -146,7 +137,7 @@ public:
STDMETHODIMP get_channel(long*);
STDMETHODIMP put_channel(long);
STDMETHODIMP toggleMute();
STDMETHODIMP description(long, BSTR*);
STDMETHODIMP description(long trackId, BSTR*);
};
class VLCInput: public VLCInterface<VLCInput,IVLCInput>
......
......@@ -101,3 +101,40 @@ void vlc_player::play()
else
_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:
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:
VLC::Instance _libvlc_instance;
VLC::MediaPlayer _mp;
......
......@@ -47,7 +47,7 @@ npapi-sdk:
svn export http://npapi-sdk.googlecode.com/svn/trunk/headers npapi-sdk-svn -r HEAD
mv npapi-sdk-svn npapi-sdk
if HAVE_XCB
if HAVE_DARWIN
# 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