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

Remove useless wrapper methods

parent 08e1f2d5
......@@ -43,16 +43,6 @@ bool vlc_player::open(VLC::Instance& inst)
return true;
}
bool vlc_player::is_playing()
{
return _ml_p && _ml_p.isPlaying() != 0;
}
libvlc_state_t vlc_player::get_state()
{
return _ml_p.state();
}
int vlc_player::add_item(const char * mrl, unsigned int optc, const char **optv)
{
VLC::Media media;
......@@ -106,150 +96,8 @@ void vlc_player::play()
if( 0 == items_count() )
return;
else if( -1 == current_item() ) {
play(0);
_ml_p.playItemAtIndex( 0 );
}
else
_ml_p.play();
}
bool vlc_player::play(unsigned int idx)
{
return _ml_p.playItemAtIndex( idx );
}
void vlc_player::pause()
{
_mp.setPause( true );
}
void vlc_player::togglePause()
{
_ml_p.pause();
}
void vlc_player::stop()
{
libvlc_media_list_player_stop(_ml_p);
}
bool vlc_player::next()
{
if( _ml_p.next() ) {
return true;
}
return false;
}
bool vlc_player::prev()
{
return _ml_p.previous();
}
float vlc_player::get_rate()
{
return _mp.rate();
}
void vlc_player::set_rate(float rate)
{
_mp.setRate( rate );
}
float vlc_player::get_fps()
{
return _mp.fps();
}
bool vlc_player::has_vout()
{
return _mp.hasVout() > 0;
}
float vlc_player::get_position()
{
float p = _mp.position();
return p < 0 ? 0.f : p;
}
void vlc_player::set_position(float p)
{
_mp.setPosition( p );
}
libvlc_time_t vlc_player::get_time()
{
auto t = _mp.time();
return t < 0 ? 0 : t;
}
void vlc_player::set_time(libvlc_time_t t)
{
_mp.setTime( t );
}
libvlc_time_t vlc_player::get_length()
{
auto t = _mp.length();
return t < 0 ? 0 : t;
}
void vlc_player::set_mode(libvlc_playback_mode_t mode)
{
_ml_p.setPlaybackMode( mode );
}
bool vlc_player::is_muted()
{
return _mp.mute();
}
void vlc_player::toggle_mute()
{
_mp.toggleMute();
}
void vlc_player::set_mute(bool mute)
{
_mp.setMute( mute );
}
unsigned int vlc_player::get_volume()
{
int v = _mp.volume();
return v < 0 ? 0 : v;
}
void vlc_player::set_volume(unsigned int volume)
{
_mp.setVolume( volume );
}
unsigned int vlc_player::track_count()
{
int tc = _mp.audioTrackCount();
return tc<0 ? 0 : tc ;
}
unsigned int vlc_player::get_track()
{
int t = libvlc_audio_get_track(_mp);
return t < 0 ? 0 : t;
}
void vlc_player::set_track(unsigned int track)
{
_mp.setAudioTrack( track );
}
unsigned int vlc_player::get_channel()
{
return _mp.channel();
}
void vlc_player::set_channel(unsigned int channel)
{
_mp.setChannel( channel );
}
......@@ -37,13 +37,9 @@ class vlc_player
public:
bool open(VLC::Instance& inst);
bool is_playing();
libvlc_state_t get_state();
bool is_stopped() { return libvlc_Stopped == get_state(); }
int add_item(const char * mrl, unsigned int optc, const char **optv);
int add_item(const char * mrl)
{ return add_item(mrl, 0, 0); }
{ return add_item( mrl, 0, nullptr ); }
int current_item();
int items_count();
......@@ -51,47 +47,16 @@ public:
void clear_items();
void play();
bool play(unsigned int idx);
void pause();
void togglePause();
void stop();
bool next();
bool prev();
float get_rate();
void set_rate(float);
float get_fps();
bool has_vout();
float get_position();
void set_position(float);
libvlc_time_t get_time();
void set_time(libvlc_time_t);
libvlc_time_t get_length();
void set_mode(libvlc_playback_mode_t);
bool is_muted();
void toggle_mute();
void set_mute(bool);
unsigned int get_volume();
void set_volume(unsigned int);
unsigned int track_count();
unsigned int get_track();
void set_track(unsigned int);
unsigned int get_channel();
void set_channel(unsigned int);
VLC::MediaPlayer& get_mp()
{ return _mp; }
{
return _mp;
}
VLC::MediaListPlayer& mlp()
{
return _ml_p;
}
private:
VLC::Instance _libvlc_instance;
......
......@@ -492,7 +492,7 @@ LibvlcInputNPObject::getProperty(int index, NPVariant &result)
}
case ID_input_hasvout:
{
bool val = p_plugin->player_has_vout();
bool val = p_plugin->player().get_mp().hasVout() != 0;
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
......@@ -713,7 +713,7 @@ LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
{
case ID_playlistitems_count:
{
int val = p_plugin->playlist_count();
int val = p_plugin->player().items_count();
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
......@@ -751,7 +751,7 @@ LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
case ID_playlistitems_clear:
if( argCount == 0 )
{
p_plugin->playlist_clear();
p_plugin->player().clear_items();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
......@@ -763,7 +763,7 @@ LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
auto v = npapi::Variant( args[0] );
if( v.is<int>() )
{
if( !p_plugin->playlist_delete_item(v) )
if( !p_plugin->player().delete_item( v ) )
return INVOKERESULT_GENERIC_ERROR;
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
......@@ -817,19 +817,19 @@ LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
{
case ID_playlist_itemcount: /* deprecated */
{
int val = p_plugin->playlist_count();
int val = p_plugin->player().items_count();
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_playlist_isplaying:
{
int val = p_plugin->playlist_isplaying();
int val = p_plugin->player().mlp().isPlaying();
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_playlist_currentitem:
{
int val = p_plugin->playlist_currentitem();
int val = p_plugin->player().current_item();
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
......@@ -903,6 +903,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
auto s = npapi::to_string( args[0] );
auto url = CStr( p_plugin->getAbsoluteURL( s.get() ), free );
//FIXME: This is never used
auto name = npapi::NPStringPtr( nullptr, NPN_MemFree );
// grab name if available
if( argCount > 1 )
......@@ -947,9 +948,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
}
}
int item = p_plugin->playlist_add_extended_untrusted(
url ? url.get() : s.get(),
name.get(), i_options, const_cast<const char **>(ppsz_options));
int item = p_plugin->player().add_item( url ? url.get() : s.get(), i_options, const_cast<const char **>(ppsz_options));
if( item == -1 )
RETURN_ON_ERROR;
......@@ -977,7 +976,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
npapi::Variant v = args[0];
if ( v.is<int>() )
{
p_plugin->playlist_play_item( v );
p_plugin->player().mlp().playItemAtIndex( v );
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
......@@ -986,7 +985,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_pause:
if( argCount == 0 )
{
p_plugin->playlist_pause();
p_plugin->player().get_mp().setPause( true );
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
......@@ -994,7 +993,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_togglepause:
if( argCount == 0 )
{
p_plugin->playlist_togglePause();
p_plugin->player().mlp().pause();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
......@@ -1002,7 +1001,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_stop:
if( argCount == 0 )
{
p_plugin->playlist_stop();
p_plugin->player().mlp().stop();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
......@@ -1010,7 +1009,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_next:
if( argCount == 0 )
{
p_plugin->playlist_next();
p_plugin->player().mlp().next();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
......@@ -1018,7 +1017,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_prev:
if( argCount == 0 )
{
p_plugin->playlist_prev();
p_plugin->player().mlp().previous();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
......@@ -1026,7 +1025,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_clear: /* deprecated */
if( argCount == 0 )
{
p_plugin->playlist_clear();
p_plugin->player().clear_items();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
......@@ -1038,7 +1037,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
npapi::Variant v = args[0];
if ( v.is<int>() )
{
if( !p_plugin->playlist_delete_item( v ) )
if( !p_plugin->player().delete_item( v ) )
return INVOKERESULT_GENERIC_ERROR;
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
......
......@@ -185,7 +185,7 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[])
return NPERR_GENERIC_ERROR;
}
m_player.set_mode(b_autoloop ? libvlc_playback_mode_loop :
m_player.mlp().setPlaybackMode( b_autoloop ? libvlc_playback_mode_loop :
libvlc_playback_mode_default);
/*
......@@ -244,9 +244,6 @@ VlcPluginBase::~VlcPluginBase()
free(psz_baseURL);
free(psz_target);
if( playlist_isplaying() )
playlist_stop();
_instances.erase(this);
}
......@@ -435,16 +432,6 @@ void VlcPluginBase::unsubscribe(const char* eventName, npapi::Variant listener)
m_events.erase( event );
}
/*****************************************************************************
* VlcPluginBase playlist replacement methods
*****************************************************************************/
bool VlcPluginBase::player_has_vout()
{
if( playlist_isplaying() )
return player().get_mp().hasVout() != 0;
return false;
}
/*****************************************************************************
* VlcPluginBase methods
*****************************************************************************/
......@@ -615,13 +602,13 @@ void VlcPluginBase::control_handler(vlc_toolbar_clicked_t clicked)
case clicked_Pause:
{
playlist_pause();
player().get_mp().pause();
}
break;
case clicked_Stop:
{
playlist_stop();
player().get_mp().stop();
}
break;
......
......@@ -90,65 +90,8 @@ public:
int b_stream;
char * psz_target;
void playlist_play_item(int idx)
{
m_player.play(idx);
}
void playlist_stop()
{
m_player.stop();
}
void playlist_next()
{
m_player.next();
}
void playlist_prev()
{
m_player.prev();
}
void playlist_pause()
{
m_player.pause();
}
void playlist_togglePause()
{
m_player.togglePause();
}
int playlist_isplaying()
{
return m_player.is_playing();
}
int playlist_currentitem()
{
return m_player.current_item();
}
int playlist_add( const char * mrl)
{
return m_player.add_item(mrl);
}
int playlist_add_extended_untrusted( const char *mrl, const char *,
int optc, const char **optv )
{
return m_player.add_item(mrl, optc, optv);
}
int playlist_delete_item( int idx)
{
return m_player.delete_item(idx);
}
void playlist_clear()
{
m_player.clear_items() ;
}
int playlist_count()
{
return m_player.items_count();
}
bool playlist_select(int);
void control_handler(vlc_toolbar_clicked_t);
bool player_has_vout();
vlc_player& player()
{
return m_player;
......
......@@ -206,7 +206,7 @@ void VlcPluginGtk::popup_menu()
/* play/pause */
menuitem = gtk_image_menu_item_new_from_stock(
playlist_isplaying() ?
player().mlp().isPlaying() ?
GTK_STOCK_MEDIA_PAUSE :
GTK_STOCK_MEDIA_PLAY, NULL);
g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menu_handler), this);
......@@ -364,7 +364,7 @@ static gboolean fullscreen_win_keypress_handler(GtkWidget *widget, GdkEventKey *
switch (event->keyval)
{
case GDK_KEY_space:
plugin->playlist_togglePause();
plugin->player().mlp().pause();
return True;
case GDK_KEY_Escape:
plugin->set_fullscreen(false);
......@@ -387,7 +387,7 @@ void VlcPluginGtk::update_controls()
GtkToolItem *toolbutton;
/* play/pause button */
const gchar *stock_id = playlist_isplaying() ? GTK_STOCK_MEDIA_PAUSE : GTK_STOCK_MEDIA_PLAY;
const gchar *stock_id = player().mlp().isPlaying() ? GTK_STOCK_MEDIA_PAUSE : GTK_STOCK_MEDIA_PLAY;
toolbutton = gtk_toolbar_get_nth_item(GTK_TOOLBAR(toolbar), 0);
if (strcmp(gtk_tool_button_get_stock_id(GTK_TOOL_BUTTON(toolbutton)), stock_id)) {
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(toolbutton), stock_id);
......
......@@ -312,9 +312,6 @@ NPError NPP_Destroy( NPP instance, NPSavedData** )
instance->pdata = NULL;
if( p_plugin->playlist_isplaying() )
p_plugin->playlist_stop();
p_plugin->destroy_windows();
delete p_plugin;
......@@ -365,7 +362,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{
if( p_plugin->psz_target )
{
if( p_plugin->playlist_add( p_plugin->psz_target ) != -1 )
if( p_plugin->player().add_item( p_plugin->psz_target ) != -1 )
{
if( p_plugin->get_options().get_autoplay() )
{
......@@ -466,7 +463,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* )
return;
}
if( p_plugin->playlist_add( stream->url ) != -1 )
if( p_plugin->player().add_item( stream->url ) != -1 )
{
if( p_plugin->get_options().get_autoplay() )
{
......
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