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

npapi: Start replacing libvlc by libvlcpp

parent 7cf66b81
AM_CPPFLAGS = $(LIBVLC_CFLAGS)
AM_CPPFLAGS = $(LIBVLC_CFLAGS) -I$(top_srcdir)/vlcpp
libvlcplugin_common_la_SOURCES = \
position.h \
......
This diff is collapsed.
......@@ -21,7 +21,8 @@
#pragma once
#include <vlc/vlc.h>
#include <vlcpp/vlc.hpp>
#include <memory>
enum vlc_player_action_e
{
......@@ -36,12 +37,10 @@ class vlc_player
{
public:
vlc_player();
~vlc_player(void);
bool open(libvlc_instance_t* inst);
void close();
bool open(VLC::Instance& inst);
bool is_open() const { return _ml_p != 0; }
bool is_open() const { return _ml_p.isValid(); }
bool is_playing();
libvlc_state_t get_state();
bool is_stopped() { return libvlc_Stopped == get_state(); }
......@@ -95,15 +94,15 @@ public:
unsigned int get_channel();
void set_channel(unsigned int);
libvlc_media_player_t* get_mp() const
VLC::MediaPlayer& get_mp()
{ return _mp; }
protected:
virtual void on_player_action( vlc_player_action_e ){};
virtual void on_player_action( vlc_player_action_e ){}
private:
libvlc_instance_t * _libvlc_instance;
libvlc_media_player_t* _mp;
libvlc_media_list_t* _ml;
libvlc_media_list_player_t* _ml_p;
VLC::Instance _libvlc_instance;
VLC::MediaPlayer _mp;
VLC::MediaList _ml;
VLC::MediaListPlayer _ml_p;
};
......@@ -13,7 +13,7 @@ CLEANFILES = $(BUILT_SOURCES) \
npvlcdir = $(libdir)/mozilla/plugins
AM_CPPFLAGS = $(LIBVLC_CFLAGS) -Inpapi-sdk $(MOZILLA_CFLAGS)
AM_CPPFLAGS = $(LIBVLC_CFLAGS) -Inpapi-sdk $(MOZILLA_CFLAGS) -I$(top_srcdir)/vlcpp
libvlcplugin_la_SOURCES = \
common.h \
......
This diff is collapsed.
......@@ -52,7 +52,6 @@ VlcPluginBase::VlcPluginBase( NPP instance, NPuint16_t mode ) :
i_npmode(mode),
b_stream(0),
psz_target(NULL),
libvlc_instance(NULL),
p_scriptClass(NULL),
p_browser(instance),
psz_baseURL(NULL)
......@@ -199,11 +198,13 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[])
}
}
libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv);
if( !libvlc_instance )
try {
VLC::Instance instance( ppsz_argc, ppsz_argv );
vlc_player::open(instance);
}
catch (std::runtime_error&) {
return NPERR_GENERIC_ERROR;
vlc_player::open(libvlc_instance);
}
vlc_player::set_mode(b_autoloop ? libvlc_playback_mode_loop :
libvlc_playback_mode_default);
......@@ -273,14 +274,10 @@ VlcPluginBase::~VlcPluginBase()
if( vlc_player::is_open() )
{
if( playlist_isplaying() )
playlist_stop();
events.unhook_manager( this );
vlc_player::close();
}
if( libvlc_instance )
libvlc_release( libvlc_instance );
_instances.erase(this);
}
......
......@@ -74,7 +74,7 @@ public:
NPError init(int argc, char* const argn[], char* const argv[]);
libvlc_media_player_t* getMD()
VLC::MediaPlayer& getMD()
{
if( !is_open() )
{
......@@ -189,12 +189,10 @@ public:
protected:
// called after libvlc_media_player_new_from_media
virtual void on_media_player_new() {};
virtual void on_media_player_new() {}
// called before libvlc_media_player_release
virtual void on_media_player_release() {};
virtual void on_media_player_release() {}
/* VLC reference */
libvlc_instance_t *libvlc_instance;
NPClass *p_scriptClass;
/* browser reference */
......
......@@ -61,9 +61,8 @@ VlcPluginGtk::~VlcPluginGtk()
void VlcPluginGtk::set_player_window()
{
libvlc_media_player_set_xwindow(get_player().get_mp(),
video_xwindow);
libvlc_video_set_mouse_input(get_player().get_mp(), 0);
get_player().get_mp().setXwindow( video_xwindow);
get_player().get_mp().setMouseInput( false );
}
void VlcPluginGtk::toggle_fullscreen()
......@@ -378,11 +377,8 @@ static gboolean fullscreen_win_keypress_handler(GtkWidget *widget, GdkEventKey *
void VlcPluginGtk::update_controls()
{
if (get_player().is_open()) {
libvlc_state_t state = libvlc_media_player_get_state(get_player().get_mp());
bool is_stopped = (state == libvlc_Stopped) ||
(state == libvlc_Ended) ||
(state == libvlc_Error);
if (is_stopped) {
libvlc_state_t state = get_player().get_mp().state();
if ( state == libvlc_Stopped || state == libvlc_Ended || state == libvlc_Error ) {
XUnmapWindow(display, video_xwindow);
} else {
XMapWindow(display, video_xwindow);
......@@ -409,12 +405,12 @@ void VlcPluginGtk::update_controls()
/* time slider */
if (!get_player().is_open() ||
!libvlc_media_player_is_seekable(get_player().get_mp())) {
!get_player().get_mp().isSeekable()) {
gtk_widget_set_sensitive(time_slider, false);
gtk_range_set_value(GTK_RANGE(time_slider), 0);
} else {
gtk_widget_set_sensitive(time_slider, true);
gdouble timepos = 100*libvlc_media_player_get_position(get_player().get_mp());
gdouble timepos = 100.0 * get_player().get_mp().position();
if (time_slider_timeout_id == 0) {
/* only set the time if the user is not dragging the slider */
gtk_range_set_value(GTK_RANGE(time_slider), timepos);
......
......@@ -41,14 +41,9 @@ VlcPluginXcb::VlcPluginXcb(NPP instance, NPuint16_t mode) :
memset(&video, 0, sizeof(Window));
}
VlcPluginXcb::~VlcPluginXcb()
{
}
void VlcPluginXcb::set_player_window()
{
libvlc_media_player_set_xwindow(get_player().get_mp(),
(uint32_t) video);
get_player().get_mp().setXwindow( (uint32_t) video );
}
void VlcPluginXcb::toggle_fullscreen()
......@@ -62,15 +57,14 @@ void VlcPluginXcb::set_fullscreen(int yes)
{
if (!get_options().get_enable_fs()) return;
if (playlist_isplaying())
libvlc_set_fullscreen(get_player().get_mp(),yes);
get_player().get_mp().setFullscreen( yes );
}
int VlcPluginXcb::get_fullscreen()
int VlcPluginXcb::get_fullscreen()
{
int r = 0;
if (playlist_isplaying())
r = libvlc_get_fullscreen(get_player().get_mp());
return r;
return get_player().get_mp().fullscreen();
return 0;
}
bool VlcPluginXcb::create_windows()
......
......@@ -31,7 +31,6 @@ class VlcPluginXcb : public VlcPluginBase
{
public:
VlcPluginXcb(NPP, NPuint16_t);
virtual ~VlcPluginXcb();
int setSize(unsigned width, unsigned height);
......
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