static int vlclua_var_create( lua_State *L ) { int i_type, i_ret; vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" ); const char *psz_var = luaL_checkstring( L, 2 ); switch( lua_type( L, 3 ) ) { case LUA_TNUMBER: i_type = VLC_VAR_FLOAT; break; case LUA_TBOOLEAN: i_type = VLC_VAR_BOOL; break; case LUA_TSTRING: i_type = VLC_VAR_STRING; break; case LUA_TNIL: i_type = VLC_VAR_VOID; break; default: return 0; } if( ( i_ret = var_Create( *pp_obj, psz_var, i_type ) ) != VLC_SUCCESS ) return vlclua_push_ret( L, i_ret ); // Special case for void variables if( i_type == VLC_VAR_VOID ) return 0; vlc_value_t val; vlclua_tovalue( L, i_type, &val ); return vlclua_push_ret( L, var_Set( *pp_obj, psz_var, val ) ); }
static int vlclua_playlist_delete( lua_State * L ) { int i_id = luaL_checkint( L, 1 ); playlist_t *p_playlist = vlclua_get_playlist_internal( L ); PL_LOCK; playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id ); if( !p_item ) { PL_UNLOCK; return vlclua_push_ret( L, -1 ); } int i_ret = playlist_DeleteFromInput( p_playlist, p_item -> p_input, true ); PL_UNLOCK; return vlclua_push_ret( L, i_ret ); }
static int vlclua_trigger_callback( lua_State *L ) { vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" ); const char *psz_var = luaL_checkstring( L, 2 ); return vlclua_push_ret( L, var_TriggerCallback( *pp_obj, psz_var ) ); }
/***************************************************************************** * Volume related *****************************************************************************/ static int vlclua_volume_set( lua_State *L ) { playlist_t *p_this = vlclua_get_playlist_internal( L ); int i_volume = VLC_CLIP( luaL_checkint( L, 1 ), 0, AOUT_VOLUME_MAX ); int i_ret = aout_VolumeSet( p_this, i_volume ); return vlclua_push_ret( L, i_ret ); }
static int vlclua_sd_remove( lua_State *L ) { const char *psz_sd = luaL_checkstring( L, 1 ); playlist_t *p_playlist = vlclua_get_playlist_internal( L ); int i_ret = playlist_ServicesDiscoveryRemove( p_playlist, psz_sd ); return vlclua_push_ret( L, i_ret ); }
static int vlclua_playlist_gotoitem( lua_State * L ) { int i_id = luaL_checkinteger( L, 1 ); playlist_t *p_playlist = vlclua_get_playlist_internal( L ); PL_LOCK; playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, true, NULL, playlist_ItemGetById( p_playlist, i_id ) ); PL_UNLOCK; return vlclua_push_ret( L, VLC_SUCCESS ); }
static int vlclua_vlm_execute_command( lua_State *L ) { vlm_t **pp_vlm = (vlm_t**)luaL_checkudata( L, 1, "vlm" ); const char *psz_command = luaL_checkstring( L, 2 ); vlm_message_t *message; int i_ret; i_ret = vlm_ExecuteCommand( *pp_vlm, psz_command, &message ); lua_settop( L, 0 ); push_message( L, message ); vlm_MessageDelete( message ); return 1 + vlclua_push_ret( L, i_ret ); }
static int vlclua_playlist_move( lua_State * L ) { int i_item = luaL_checkint( L, 1 ); int i_target = luaL_checkint( L, 2 ); playlist_t *p_playlist = vlclua_get_playlist_internal( L ); PL_LOCK; playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_item ); playlist_item_t *p_target = playlist_ItemGetById( p_playlist, i_target ); if( !p_item || !p_target ) { PL_UNLOCK; return vlclua_push_ret( L, -1 ); } int i_ret; if( p_target->i_children != -1 ) i_ret = playlist_TreeMove( p_playlist, p_item, p_target, 0 ); else i_ret = playlist_TreeMove( p_playlist, p_item, p_target->p_parent, p_target->i_id - p_target->p_parent->pp_children[0]->i_id + 1 ); PL_UNLOCK; return vlclua_push_ret( L, i_ret ); }
static int vlclua_var_get_list( lua_State *L ) { vlc_value_t val; vlc_value_t text; vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" ); const char *psz_var = luaL_checkstring( L, 2 ); int i_ret = var_Change( *pp_obj, psz_var, VLC_VAR_GETLIST, &val, &text ); if( i_ret < 0 ) return vlclua_push_ret( L, i_ret ); vlclua_pushvalue( L, VLC_VAR_LIST, val ); vlclua_pushvalue( L, VLC_VAR_LIST, text ); var_FreeList( &val, &text ); return 2; }
static int vlclua_var_set( lua_State *L ) { int i_type; vlc_value_t val; vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" ); const char *psz_var = luaL_checkstring( L, 2 ); int i_ret; i_type = var_Type( *pp_obj, psz_var ); vlclua_tovalue( L, i_type, &val ); i_ret = var_Set( *pp_obj, psz_var, val ); lua_pop( L, 3 ); return vlclua_push_ret( L, i_ret ); }
static int vlclua_playlist_sort( lua_State *L ) { /* allow setting the different sort keys */ int i_mode = vlc_sort_key_from_string( luaL_checkstring( L, 1 ) ); if( i_mode == -1 ) return luaL_error( L, "Invalid search key." ); int i_type = luaL_optboolean( L, 2, 0 ) ? ORDER_REVERSE : ORDER_NORMAL; playlist_t *p_playlist = vlclua_get_playlist_internal( L ); PL_LOCK; int i_ret = playlist_RecursiveNodeSort( p_playlist, p_playlist->p_playing, i_mode, i_type ); PL_UNLOCK; return vlclua_push_ret( L, i_ret ); }
static int vlclua_libvlc_command( lua_State *L ) { vlc_object_t * p_this = vlclua_get_this( L ); const char *psz_cmd; vlc_value_t val_arg; psz_cmd = luaL_checkstring( L, 1 ); val_arg.psz_string = strdup( luaL_optstring( L, 2, "" ) ); lua_pop( L, 2 ); int i_type = var_Type( p_this->p_libvlc, psz_cmd ); if( ! (i_type & VLC_VAR_ISCOMMAND) ) { free( val_arg.psz_string ); return luaL_error( L, "libvlc's \"%s\" is not a command", psz_cmd ); } return vlclua_push_ret( L, var_Set( p_this->p_libvlc, psz_cmd, val_arg ) ); }
static int vlclua_command( lua_State *L ) { vlc_object_t * p_this = vlclua_get_this( L ); char *psz_msg; const char *psz_name = luaL_checkstring( L, 1 ); const char *psz_cmd = luaL_checkstring( L, 2 ); const char *psz_arg = luaL_checkstring( L, 3 ); int ret = var_Command( p_this, psz_name, psz_cmd, psz_arg, &psz_msg ); lua_pop( L, 3 ); if( psz_msg ) { lua_pushstring( L, psz_msg ); free( psz_msg ); } else { lua_pushliteral( L, "" ); } return vlclua_push_ret( L, ret ) + 1; }