Commit 8bf00f1b authored by Antoine Cellerier's avatar Antoine Cellerier

Implement "@name var val" style commands in rc.lua (and other misc changes)

parent a804eaa4
...@@ -211,11 +211,12 @@ static int vlclua_command( lua_State *L ) ...@@ -211,11 +211,12 @@ static int vlclua_command( lua_State *L )
const char *psz_cmd; const char *psz_cmd;
const char *psz_arg; const char *psz_arg;
char *psz_msg; char *psz_msg;
int ret;
psz_name = luaL_checkstring( L, 1 ); psz_name = luaL_checkstring( L, 1 );
psz_cmd = luaL_checkstring( L, 2 ); psz_cmd = luaL_checkstring( L, 2 );
psz_arg = luaL_checkstring( L, 3 ); psz_arg = luaL_checkstring( L, 3 );
lua_pop( L, 3 ); lua_pop( L, 3 );
var_Command( p_this, psz_name, psz_cmd, psz_arg, &psz_msg ); ret = var_Command( p_this, psz_name, psz_cmd, psz_arg, &psz_msg );
if( psz_msg ) if( psz_msg )
{ {
lua_pushstring( L, psz_msg ); lua_pushstring( L, psz_msg );
...@@ -225,7 +226,7 @@ static int vlclua_command( lua_State *L ) ...@@ -225,7 +226,7 @@ static int vlclua_command( lua_State *L )
{ {
lua_pushstring( L, "" ); lua_pushstring( L, "" );
} }
return 1; return vlclua_push_ret( L, ret ) + 1;
} }
static int vlclua_libvlc_command( lua_State *L ) static int vlclua_libvlc_command( lua_State *L )
......
...@@ -95,7 +95,8 @@ misc.homedir(): Get the user's home directory. ...@@ -95,7 +95,8 @@ misc.homedir(): Get the user's home directory.
misc.configdir(): Get the user's VLC config directory. misc.configdir(): Get the user's VLC config directory.
misc.cachedir(): Get the user's VLC cache directory. misc.cachedir(): Get the user's VLC cache directory.
misc.datadir_list( name ): FIXME: write description ... or ditch function if it isn't usefull anymore, we have datadir and userdatadir :) misc.datadir_list( name ): FIXME: write description ... or ditch function
if it isn't usefull anymore, we have datadir and userdatadir :)
misc.mdate(): Get the current date (in milliseconds). misc.mdate(): Get the current date (in milliseconds).
misc.mwait(): Wait for the given date (in milliseconds). misc.mwait(): Wait for the given date (in milliseconds).
...@@ -124,7 +125,9 @@ end ...@@ -124,7 +125,9 @@ end
net.close( fd ): Close file descriptor. net.close( fd ): Close file descriptor.
net.send( fd, string, [length] ): Send data on fd. net.send( fd, string, [length] ): Send data on fd.
net.recv( fd, [max length] ): Receive data from fd. net.recv( fd, [max length] ): Receive data from fd.
net.select( nfds, fds_read, fds_write, timeout ): Monitor a bunch of file descriptors. Returns number of fds to handle and the amount of time not slept. See "man select". net.select( nfds, fds_read, fds_write, timeout ): Monitor a bunch of file
descriptors. Returns number of fds to handle and the amount of time not
slept. See "man select".
net.fd_set_new(): Create a new fd_set. net.fd_set_new(): Create a new fd_set.
local fds = vlc.net.fd_set_new() local fds = vlc.net.fd_set_new()
fds:clr( fd ) -- remove fd from set fds:clr( fd ) -- remove fd from set
...@@ -315,6 +318,7 @@ a reference to it, all VLM items will be deleted. ...@@ -315,6 +318,7 @@ a reference to it, all VLM items will be deleted.
Volume Volume
------ ------
volume.set( level ): Set volume to an absolute level between 0 and 1024. volume.set( level ): Set volume to an absolute level between 0 and 1024.
256 is 100%.
volume.get(): Get volume. volume.get(): Get volume.
volume.up( [n] ): Increment volume by n steps of 32. n defaults to 1. volume.up( [n] ): Increment volume by n steps of 32. n defaults to 1.
volume.down( [n] ): Decrement volume by n steps of 32. n defaults to 1. volume.down( [n] ): Decrement volume by n steps of 32. n defaults to 1.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
msg = [[ msg = [[
This is the `dummy' VLC Lua interface module. This is the `dummy' VLC Lua interface module.
Please specify a VLC Lua interface to load with the --lua-intf option. Please specify a VLC Lua interface to load with the --lua-intf option.
VLC Lua interface modules include: `rc', `telnet' and `hotkeys'. VLC Lua interface modules include: `rc', `telnet' and `http'.
For example: vlc -I lua --lua-intf rc]] For example: vlc -I lua --lua-intf rc]]
--You can also use the alternate syntax: vlc -I "lua{intf=rc}"]] --You can also use the alternate syntax: vlc -I "lua{intf=rc}"]]
......
--[==========================================================================[ --[==========================================================================[
rc.lua: remote control module for VLC rc.lua: remote control module for VLC
--[==========================================================================[ --[==========================================================================[
Copyright (C) 2007 the VideoLAN team Copyright (C) 2007-2009 the VideoLAN team
$Id$ $Id$
Authors: Antoine Cellerier <dionoea at videolan dot org> Authors: Antoine Cellerier <dionoea at videolan dot org>
...@@ -513,7 +513,7 @@ do ...@@ -513,7 +513,7 @@ do
end end
end end
list = list..")" list = list..")"
if count ~= 0 then if count ~= 0 and env.welcome then
env.welcome = env.welcome .. "\r\nWarning: "..count.." functions are still unimplemented "..list.."." env.welcome = env.welcome .. "\r\nWarning: "..count.." functions are still unimplemented "..list.."."
end end
end end
...@@ -556,6 +556,18 @@ function call_libvlc_command(cmd,client,arg) ...@@ -556,6 +556,18 @@ function call_libvlc_command(cmd,client,arg)
return vlcerr return vlcerr
end end
function call_object_command(cmd,client,arg)
local var, val = split_input(arg)
local ok, vlcmsg, vlcerr, vlcerrmsg = pcall( vlc.var.command, cmd, var, val )
if not ok then
client:append("Error in `"..cmd.." "..var.." "..val.."' ".. vlcmsg) -- when pcall fails the 2nd arg is the error message
end
if vlcmsg ~= "" then
client:append(vlcmsg)
end
return vlcerr
end
--[[ Setup host ]] --[[ Setup host ]]
require("host") require("host")
h = host.host() h = host.host()
...@@ -604,9 +616,12 @@ while not vlc.misc.should_die() do ...@@ -604,9 +616,12 @@ while not vlc.misc.should_die() do
client:switch_status(host.status.write) client:switch_status(host.status.write)
if commands[cmd] then if commands[cmd] then
call_command(cmd,client,arg) call_command(cmd,client,arg)
else elseif string.sub(cmd,0,1)=='@'
if client.type == host.client_type.stdio and call_object_command(string.sub(cmd,2,#cmd),client,arg) == 0 then
--
elseif client.type == host.client_type.stdio
and call_libvlc_command(cmd,client,arg) == 0 then and call_libvlc_command(cmd,client,arg) == 0 then
--
else else
local choices = {} local choices = {}
if client.env.autocompletion ~= 0 then if client.env.autocompletion ~= 0 then
...@@ -639,5 +654,4 @@ while not vlc.misc.should_die() do ...@@ -639,5 +654,4 @@ while not vlc.misc.should_die() do
end end
end end
end end
end
end end
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