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

Plugin classes do not inherit from vlc_player anymore

parent abd4e591
...@@ -965,7 +965,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -965,7 +965,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_play: case ID_playlist_play:
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->playlist_play(); p_plugin->player().play();
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
......
...@@ -179,13 +179,13 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[]) ...@@ -179,13 +179,13 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[])
try { try {
VLC::Instance instance( ppsz_argc, ppsz_argv ); VLC::Instance instance( ppsz_argc, ppsz_argv );
vlc_player::open(instance); m_player.open(instance);
} }
catch (std::runtime_error&) { catch (std::runtime_error&) {
return NPERR_GENERIC_ERROR; return NPERR_GENERIC_ERROR;
} }
vlc_player::set_mode(b_autoloop ? libvlc_playback_mode_loop : m_player.set_mode(b_autoloop ? libvlc_playback_mode_loop :
libvlc_playback_mode_default); libvlc_playback_mode_default);
/* /*
...@@ -365,55 +365,55 @@ void VlcPluginBase::subscribe(const char* eventName, npapi::Variant listener) ...@@ -365,55 +365,55 @@ void VlcPluginBase::subscribe(const char* eventName, npapi::Variant listener)
switch ( event->type ) switch ( event->type )
{ {
case libvlc_MediaPlayerNothingSpecial: case libvlc_MediaPlayerNothingSpecial:
e = get_mp().eventManager().onNothingSpecial( std::move( closure ) ); e = player().get_mp().eventManager().onNothingSpecial( std::move( closure ) );
break; break;
case libvlc_MediaPlayerOpening: case libvlc_MediaPlayerOpening:
e = get_mp().eventManager().onOpening( std::move( closure ) ); e = player().get_mp().eventManager().onOpening( std::move( closure ) );
break; break;
case libvlc_MediaPlayerPlaying: case libvlc_MediaPlayerPlaying:
e = get_mp().eventManager().onPlaying( std::move( closure ) ); e = player().get_mp().eventManager().onPlaying( std::move( closure ) );
break; break;
case libvlc_MediaPlayerPaused: case libvlc_MediaPlayerPaused:
e = get_mp().eventManager().onPaused( std::move( closure ) ); e = player().get_mp().eventManager().onPaused( std::move( closure ) );
break; break;
case libvlc_MediaPlayerStopped: case libvlc_MediaPlayerStopped:
e = get_mp().eventManager().onStopped( std::move( closure ) ); e = player().get_mp().eventManager().onStopped( std::move( closure ) );
break; break;
case libvlc_MediaPlayerForward: case libvlc_MediaPlayerForward:
e = get_mp().eventManager().onForward( std::move( closure ) ); e = player().get_mp().eventManager().onForward( std::move( closure ) );
break; break;
case libvlc_MediaPlayerBackward: case libvlc_MediaPlayerBackward:
e = get_mp().eventManager().onBackward( std::move( closure ) ); e = player().get_mp().eventManager().onBackward( std::move( closure ) );
break; break;
case libvlc_MediaPlayerEndReached: case libvlc_MediaPlayerEndReached:
e = get_mp().eventManager().onEndReached( std::move( closure ) ); e = player().get_mp().eventManager().onEndReached( std::move( closure ) );
break; break;
case libvlc_MediaPlayerEncounteredError: case libvlc_MediaPlayerEncounteredError:
e = get_mp().eventManager().onEncounteredError( std::move( closure ) ); e = player().get_mp().eventManager().onEncounteredError( std::move( closure ) );
break; break;
case libvlc_MediaPlayerBuffering: case libvlc_MediaPlayerBuffering:
e = get_mp().eventManager().onBuffering( std::move( closure ) ); e = player().get_mp().eventManager().onBuffering( std::move( closure ) );
break; break;
case libvlc_MediaPlayerTimeChanged: case libvlc_MediaPlayerTimeChanged:
e = get_mp().eventManager().onTimeChanged( std::move( closure ) ); e = player().get_mp().eventManager().onTimeChanged( std::move( closure ) );
break; break;
case libvlc_MediaPlayerMediaChanged: case libvlc_MediaPlayerMediaChanged:
e = get_mp().eventManager().onMediaChanged( std::move( closure ) ); e = player().get_mp().eventManager().onMediaChanged( std::move( closure ) );
break; break;
case libvlc_MediaPlayerPositionChanged: case libvlc_MediaPlayerPositionChanged:
e = get_mp().eventManager().onPositionChanged( std::move( closure ) ); e = player().get_mp().eventManager().onPositionChanged( std::move( closure ) );
break; break;
case libvlc_MediaPlayerSeekableChanged: case libvlc_MediaPlayerSeekableChanged:
e = get_mp().eventManager().onSeekableChanged( std::move( closure ) ); e = player().get_mp().eventManager().onSeekableChanged( std::move( closure ) );
break; break;
case libvlc_MediaPlayerPausableChanged: case libvlc_MediaPlayerPausableChanged:
e = get_mp().eventManager().onPausableChanged( std::move( closure ) ); e = player().get_mp().eventManager().onPausableChanged( std::move( closure ) );
break; break;
case libvlc_MediaPlayerTitleChanged: case libvlc_MediaPlayerTitleChanged:
e = get_mp().eventManager().onTitleChanged( std::move( closure ) ); e = player().get_mp().eventManager().onTitleChanged( std::move( closure ) );
break; break;
case libvlc_MediaPlayerLengthChanged: case libvlc_MediaPlayerLengthChanged:
e = get_mp().eventManager().onLengthChanged( std::move( closure ) ); e = player().get_mp().eventManager().onLengthChanged( std::move( closure ) );
break; break;
default: default:
break; break;
...@@ -440,10 +440,9 @@ void VlcPluginBase::unsubscribe(const char* eventName, npapi::Variant listener) ...@@ -440,10 +440,9 @@ void VlcPluginBase::unsubscribe(const char* eventName, npapi::Variant listener)
*****************************************************************************/ *****************************************************************************/
bool VlcPluginBase::player_has_vout() bool VlcPluginBase::player_has_vout()
{ {
bool r = false;
if( playlist_isplaying() ) if( playlist_isplaying() )
r = libvlc_media_player_has_vout(get_mp())!=0; return player().get_mp().hasVout() != 0;
return r; return false;
} }
/***************************************************************************** /*****************************************************************************
...@@ -610,7 +609,7 @@ void VlcPluginBase::control_handler(vlc_toolbar_clicked_t clicked) ...@@ -610,7 +609,7 @@ void VlcPluginBase::control_handler(vlc_toolbar_clicked_t clicked)
{ {
case clicked_Play: case clicked_Play:
{ {
playlist_play(); player().play();
} }
break; break;
......
...@@ -56,7 +56,7 @@ typedef enum vlc_toolbar_clicked_e { ...@@ -56,7 +56,7 @@ typedef enum vlc_toolbar_clicked_e {
clicked_Unmute clicked_Unmute
} vlc_toolbar_clicked_t; } vlc_toolbar_clicked_t;
class VlcPluginBase: private vlc_player_options, private vlc_player class VlcPluginBase: private vlc_player_options
{ {
protected: protected:
...@@ -64,11 +64,6 @@ public: ...@@ -64,11 +64,6 @@ public:
VlcPluginBase( NPP, NPuint16_t ); VlcPluginBase( NPP, NPuint16_t );
virtual ~VlcPluginBase(); virtual ~VlcPluginBase();
vlc_player& get_player()
{
return *static_cast<vlc_player*>(this);
}
vlc_player_options& get_options() vlc_player_options& get_options()
{ return *static_cast<vlc_player_options*>(this); } { return *static_cast<vlc_player_options*>(this); }
const vlc_player_options& get_options() const const vlc_player_options& get_options() const
...@@ -78,7 +73,7 @@ public: ...@@ -78,7 +73,7 @@ public:
VLC::MediaPlayer& getMD() VLC::MediaPlayer& getMD()
{ {
return get_mp(); return m_player.get_mp();
} }
NPP getBrowser() { return p_browser; }; NPP getBrowser() { return p_browser; };
...@@ -95,62 +90,58 @@ public: ...@@ -95,62 +90,58 @@ public:
int b_stream; int b_stream;
char * psz_target; char * psz_target;
void playlist_play()
{
play();
}
void playlist_play_item(int idx) void playlist_play_item(int idx)
{ {
play(idx); m_player.play(idx);
} }
void playlist_stop() void playlist_stop()
{ {
stop(); m_player.stop();
} }
void playlist_next() void playlist_next()
{ {
next(); m_player.next();
} }
void playlist_prev() void playlist_prev()
{ {
prev(); m_player.prev();
} }
void playlist_pause() void playlist_pause()
{ {
pause(); m_player.pause();
} }
void playlist_togglePause() void playlist_togglePause()
{ {
togglePause(); m_player.togglePause();
} }
int playlist_isplaying() int playlist_isplaying()
{ {
return is_playing(); return m_player.is_playing();
} }
int playlist_currentitem() int playlist_currentitem()
{ {
return current_item(); return m_player.current_item();
} }
int playlist_add( const char * mrl) int playlist_add( const char * mrl)
{ {
return add_item(mrl); return m_player.add_item(mrl);
} }
int playlist_add_extended_untrusted( const char *mrl, const char *, int playlist_add_extended_untrusted( const char *mrl, const char *,
int optc, const char **optv ) int optc, const char **optv )
{ {
return add_item(mrl, optc, optv); return m_player.add_item(mrl, optc, optv);
} }
int playlist_delete_item( int idx) int playlist_delete_item( int idx)
{ {
return delete_item(idx); return m_player.delete_item(idx);
} }
void playlist_clear() void playlist_clear()
{ {
clear_items() ; m_player.clear_items() ;
} }
int playlist_count() int playlist_count()
{ {
return items_count(); return m_player.items_count();
} }
bool playlist_select(int); bool playlist_select(int);
...@@ -158,6 +149,11 @@ public: ...@@ -158,6 +149,11 @@ public:
bool player_has_vout(); bool player_has_vout();
vlc_player& player()
{
return m_player;
}
virtual bool create_windows() = 0; virtual bool create_windows() = 0;
virtual bool resize_windows() = 0; virtual bool resize_windows() = 0;
virtual bool destroy_windows() = 0; virtual bool destroy_windows() = 0;
...@@ -199,6 +195,8 @@ protected: ...@@ -199,6 +195,8 @@ protected:
/* display settings */ /* display settings */
NPWindow npwindow; NPWindow npwindow;
vlc_player m_player;
private: private:
static std::set<VlcPluginBase*> _instances; static std::set<VlcPluginBase*> _instances;
......
...@@ -61,8 +61,8 @@ VlcPluginGtk::~VlcPluginGtk() ...@@ -61,8 +61,8 @@ VlcPluginGtk::~VlcPluginGtk()
void VlcPluginGtk::set_player_window() void VlcPluginGtk::set_player_window()
{ {
get_player().get_mp().setXwindow( video_xwindow); player().get_mp().setXwindow( video_xwindow);
get_player().get_mp().setMouseInput( false ); player().get_mp().setMouseInput( false );
} }
void VlcPluginGtk::toggle_fullscreen() void VlcPluginGtk::toggle_fullscreen()
...@@ -376,7 +376,7 @@ static gboolean fullscreen_win_keypress_handler(GtkWidget *widget, GdkEventKey * ...@@ -376,7 +376,7 @@ static gboolean fullscreen_win_keypress_handler(GtkWidget *widget, GdkEventKey *
void VlcPluginGtk::update_controls() void VlcPluginGtk::update_controls()
{ {
libvlc_state_t state = get_player().get_mp().state(); auto state = player().get_mp().state();
if ( state == libvlc_Stopped || state == libvlc_Ended || state == libvlc_Error ) { if ( state == libvlc_Stopped || state == libvlc_Ended || state == libvlc_Error ) {
XUnmapWindow(display, video_xwindow); XUnmapWindow(display, video_xwindow);
} else { } else {
...@@ -402,12 +402,12 @@ void VlcPluginGtk::update_controls() ...@@ -402,12 +402,12 @@ void VlcPluginGtk::update_controls()
gtk_widget_set_sensitive( toolbar, true ); gtk_widget_set_sensitive( toolbar, true );
/* time slider */ /* time slider */
if (!get_player().get_mp().isSeekable()) { if (!player().get_mp().isSeekable()) {
gtk_widget_set_sensitive(time_slider, false); gtk_widget_set_sensitive(time_slider, false);
gtk_range_set_value(GTK_RANGE(time_slider), 0); gtk_range_set_value(GTK_RANGE(time_slider), 0);
} else { } else {
gtk_widget_set_sensitive(time_slider, true); gtk_widget_set_sensitive(time_slider, true);
gdouble timepos = 100.0 * get_player().get_mp().position(); gdouble timepos = 100.0 * player().get_mp().position();
if (time_slider_timeout_id == 0) { if (time_slider_timeout_id == 0) {
/* only set the time if the user is not dragging the slider */ /* only set the time if the user is not dragging the slider */
gtk_range_set_value(GTK_RANGE(time_slider), timepos); gtk_range_set_value(GTK_RANGE(time_slider), timepos);
......
...@@ -369,7 +369,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -369,7 +369,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{ {
if( p_plugin->get_options().get_autoplay() ) if( p_plugin->get_options().get_autoplay() )
{ {
p_plugin->playlist_play(); p_plugin->player().play();
} }
} }
p_plugin->b_stream = true; p_plugin->b_stream = true;
...@@ -470,7 +470,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* ) ...@@ -470,7 +470,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* )
{ {
if( p_plugin->get_options().get_autoplay() ) if( p_plugin->get_options().get_autoplay() )
{ {
p_plugin->playlist_play(); p_plugin->player().play();
} }
} }
} }
......
vlcpp @ 7602f030
Subproject commit 6297c12addf623e85f471748088d079603e33afc Subproject commit 7602f030e07209a135310652fd00413a082f86ef
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