Commit 66bffcc5 authored by Antoine Cellerier's avatar Antoine Cellerier

Update lua intf scripts to new API (untested).

parent 009f2b02
......@@ -376,8 +376,8 @@ static const luaL_Reg vlclua_net_reg[] = {
{ "recv", vlclua_net_recv },
{ "select", vlclua_net_select },
{ "fd_set_new", vlclua_fd_set_new },
{ "fd_read", vlclua_fd_read },
{ "fd_write", vlclua_fd_write },
{ "read", vlclua_fd_read },
{ "write", vlclua_fd_write },
{ "stat", vlclua_stat }, /* Not really "net" */
{ "opendir", vlclua_opendir }, /* Not really "net" */
{ NULL, NULL }
......
......@@ -22,4 +22,4 @@ function dialogs(...)
end
_G.dialogs = dialogs
_G.vlm = vlc.vlm.new()
_G.vlm = vlc.vlm()
......@@ -33,5 +33,5 @@ This dialog needs the following dialogs to be fully functional: <none>
<a href="/flash.html">Flash based remote playback</a> -
<a href="http://www.videolan.org">VideoLAN website</a>
<br />
<?vlc print(vlc.copyright()) ?>
<?vlc print(vlc.misc.copyright()) ?>
</div>
......@@ -29,15 +29,15 @@ vim:syntax=lua
<?vlc
local dir = _GET["dir"]
if dir then
if dir == "~" then dir = vlc.homedir() end
if dir == "~" then dir = vlc.misc.homedir() end
dir = common.realpath(dir.."/")
local d = vlc.fd.opendir(dir)
local d = vlc.net.opendir(dir)
table.sort(d)
for _,f in pairs(d) do
if f == ".." or not string.match(f,"^%.") then
local df = common.realpath(dir..f)
local s = vlc.fd.stat(df)
local path, name = vlc.convert_xml_special_chars( df, f )
local s = vlc.net.stat(df)
local path, name = vlc.strings.convert_xml_special_chars( df, f )
print("<element type='"..s.type.."' size='"..s.size.."' path='"..path.."' name='"..name.."'/>\n")
end
end
......
......@@ -30,14 +30,14 @@ vim:syntax=lua
function print_playlist(item)
if item.flags.disabled then return end
if item.children then
local name = vlc.convert_xml_special_chars(item.name)
local name = vlc.strings.convert_xml_special_chars(item.name)
print("<node id=\""..tostring(item.id).."\" name=\""..name.."\" ro=\""..(item.flags.ro and "ro" or "rw").."\">")
for _, c in ipairs(item.children) do
print_playlist(c)
end
print("</node>")
else
local name, path = vlc.convert_xml_special_chars(item.name,item.path or "")
local name, path = vlc.strings.convert_xml_special_chars(item.name,item.path or "")
print("<leaf id='"..tostring(item.id).."' uri='"..path.."' name='"..name.."' ro='"..(item.flags.ro and "ro" or "rw").."' duration='"..tostring(item.duration).."'/>")
end
end
......@@ -64,7 +64,7 @@ if _GET["search"] then
else
_G.search_key = nil
end
local key = vlc.decode_uri(_GET["search"])
local key = vlc.strings.decode_uri(_GET["search"])
p = vlc.playlist.search(key)
else
p = vlc.playlist.get()
......
......@@ -132,7 +132,7 @@ local vout = input and vlc.object.find(input,'vout','child')
<stats>
<?vlc
if input then
local stats = vlc.playlist.stats()
local stats = vlc.input.stats()
for k,v in pairs(stats) do
local tag = string.gsub(k,"_","")
print("<"..tag..">"..tostring(v).."</"..tag..">\n")
......
......@@ -149,7 +149,7 @@ local function print_msg(m)
print("</"..m.name..">\n")
end
local msg = vlc.vlm.execute_command(vlm,"show")
local msg = vlm:execute_command("show")
print_xml(msg)
--print_msg(msg)
......
......@@ -25,7 +25,7 @@
]]?>
<vlm><error><?vlc
if _GET["command"] then
local msg = vlc.vlm.execute_command(vlm,_GET["command"])
local msg = vlm:execute_command(_GET["command"])
if msg.value then
print(msg.name,":",msg.value)
end
......
......@@ -74,7 +74,7 @@ function action_trigger( action )
print("action_trigger:",tostring(action))
local a = actions[action]
if a then
local date = vlc.mdate()
local date = vlc.misc.mdate()
if a.delta and date > a.last + a.delta then
a.times = 0
else
......@@ -82,9 +82,9 @@ function action_trigger( action )
end
a.last = date
table.insert(queue,action)
vlc.signal()
vlc.misc.signal()
else
vlc.msg_err("Key `"..key.."' points to unknown action `"..bindings[key].."'.")
vlc.msg.err("Key `"..key.."' points to unknown action `"..bindings[key].."'.")
end
end
......@@ -94,7 +94,7 @@ function key_press( var, old, new, data )
if bindings[key] then
action_trigger(bindings[key])
else
vlc.msg_err("Key `"..key.."' isn't bound to any action.")
vlc.msg.err("Key `"..key.."' isn't bound to any action.")
end
end
......@@ -110,7 +110,7 @@ while not die do
end
table.remove(queue,1)
else
die = vlc.lock_and_wait()
die = vlc.misc.lock_and_wait()
end
end
......
......@@ -31,8 +31,6 @@ Configuration options:
--]==========================================================================]
require "httpd"
require "acl"
require "common"
vlc.msg.info("Lua HTTP interface")
......@@ -69,10 +67,10 @@ function process_raw(filename)
return assert(loadstring(code,filename))
end
function process(filename)
local mtime = 0 -- vlc.fd.stat(filename).modification_time
local mtime = 0 -- vlc.net.stat(filename).modification_time
local func = false -- process_raw(filename)
return function(...)
local new_mtime = vlc.fd.stat(filename).modification_time
local new_mtime = vlc.net.stat(filename).modification_time
if new_mtime ~= mtime then
-- Re-read the file if it changed
if mtime == 0 then
......@@ -122,7 +120,7 @@ function dirlisting(url,listing,acl_)
</body>
</html>]]
end
return h:file_new(url,"text/html",nil,nil,acl_,callback,nil)
return h:file(url,"text/html",nil,nil,acl_,callback,nil)
end
function file(h,path,url,acl_,mime)
......@@ -151,15 +149,15 @@ function file(h,path,url,acl_,mime)
end
return table.concat(page)
end
return h:file_new(url or path,mime,nil,nil,acl_,callback,nil)
return h:file(url or path,mime,nil,nil,acl_,callback,nil)
end
function rawfile(h,path,url,acl_)
local filename = path
local mtime = 0 -- vlc.fd.stat(filename).modification_time
local mtime = 0 -- vlc.net.stat(filename).modification_time
local page = false -- io.open(filename):read("*a")
local callback = function(data,request)
local new_mtime = vlc.fd.stat(filename).modification_time
local new_mtime = vlc.net.stat(filename).modification_time
if mtime ~= new_mtime then
-- Re-read the file if it changed
if mtime == 0 then
......@@ -172,15 +170,15 @@ function rawfile(h,path,url,acl_)
end
return page
end
return h:file_new(url or path,nil,nil,nil,acl_,callback,nil)
return h:file(url or path,nil,nil,nil,acl_,callback,nil)
end
function parse_url_request(request)
if not request then return {} end
t = {}
for k,v in string.gmatch(request,"([^=&]+)=?([^=&]*)") do
local k_ = vlc.decode_uri(k)
local v_ = vlc.decode_uri(v)
local k_ = vlc.strings.decode_uri(k)
local v_ = vlc.strings.decode_uri(v)
if t[k_] ~= nil then
local t2
if type(t[k_]) ~= "table" then
......@@ -199,9 +197,9 @@ function parse_url_request(request)
end
local function find_datadir(name)
local list = vlc.datadir_list(name)
local list = vlc.misc.datadir_list(name)
for _, l in ipairs(list) do
local s = vlc.fd.stat(l)
local s = vlc.net.stat(l)
if s then
return l
end
......@@ -237,17 +235,17 @@ local function load_dir(dir,root,parent_acl)
local my_acl = parent_acl
do
local af = dir.."/.hosts"
local s = vlc.fd.stat(af)
local s = vlc.net.stat(af)
if s and s.type == "file" then
-- We found an acl
my_acl = acl.new(false)
my_acl = vlc.acl(false)
my_acl:load_file(af)
end
end
local d = vlc.fd.opendir(dir)
local d = vlc.net.opendir(dir)
for _,f in ipairs(d) do
if not string.match(f,"^%.") then
local s = vlc.fd.stat(dir.."/"..f)
local s = vlc.net.stat(dir.."/"..f)
if s.type == "file" then
local url
if f == "index.html" then
......@@ -276,10 +274,10 @@ local function load_dir(dir,root,parent_acl)
end
local u = vlc.net.url_parse( config.host or "localhost:8080" )
h = httpd.new(u.host,u.port)
h = vlc.httpd(u.host,u.port)
load_dir( http_dir )
while not die do die = vlc.lock_and_wait() end -- everything happens in callbacks
while not die do die = vlc.misc.lock_and_wait() end -- everything happens in callbacks
-- FIXME: We shouldn't need to do this ourselves.
for i=1,#files do
......
......@@ -38,7 +38,7 @@ Example use:
--or h:listen( { "localhost:4212", "*console" } )
-- The main loop
while not vlc.should_die() do
while not vlc.misc.should_die() do
-- accept new connections
h:accept()
......@@ -75,24 +75,9 @@ function host()
local listeners = {}
local status_callbacks = {}
-- private methods
local function new_fd_set()
function foo_fds(foo)
return function(fd,...) return foo(fd.fds,...) end
end
return { -- data
fds = vlc.fd.new_fd_set(),
-- methods
zero = foo_fds( vlc.fd.fd_zero ),
set = foo_fds( vlc.fd.fd_set ),
isset = foo_fds( vlc.fd.fd_isset ),
clr = foo_fds( vlc.fd.fd_clr ),
}
end
-- private data
local fds_read = new_fd_set()
local fds_write = new_fd_set()
local fds_read = vlc.net.fd_set_new()
local fds_write = vlc.net.fd_set_new()
-- private methods
local function client_accept( clients, listen )
......@@ -102,7 +87,7 @@ function host()
else
wait = 0
end
return vlc.net.accept( listen, wait )
return listen:accept( wait )
end
local function fd_client( client )
......@@ -130,14 +115,14 @@ function host()
end
local function write( client, data )
return vlc.fd.write( client.wfd, data or client.buffer )
return vlc.net.write( client.wfd, data or client.buffer )
end
local function read( client, len )
if len then
return vlc.fd.read( client.rfd, len )
return vlc.net.read( client.rfd, len )
else
return vlc.fd.read( client.rfd )
return vlc.net.read( client.rfd )
end
end
......@@ -200,7 +185,7 @@ function host()
switch_status = switch_status,
append = append,
}
client:send( "VLC media player "..vlc.version().."\n" )
client:send( "VLC media player "..vlc.misc.version().."\n" )
table.insert(clients, client)
client:switch_status(status.password)
end
......@@ -274,7 +259,7 @@ function host()
wait = 0
end
for _, listener in pairs(listeners.tcp.list) do
local fd = vlc.net.accept( listener, wait )
local fd = listener:accept( wait )
new_client( h, fd, fd, client_type.net )
end
end
......@@ -283,7 +268,7 @@ function host()
local function _select( h, timeout )
local nfds = math.max( filter_client( fds_read, status.read, status.password ),
filter_client( fds_write, status.write ) ) + 1
local ret = vlc.net.select( nfds, fds_read.fds, fds_write.fds,
local ret = vlc.net.select( nfds, fds_read, fds_write,
timeout or 0.5 )
local wclients = {}
local rclients = {}
......@@ -311,12 +296,6 @@ function host()
vlc.net.close(client.wfd)
end
end
if listeners.tcp then
for _, listener in pairs(listeners.tcp.list) do
vlc.net.listen_close( listener )
end
end
end
local function _broadcast( h, msg )
......
......@@ -143,7 +143,7 @@ function shutdown(name,client)
client:append("Bye-bye!")
h:broadcast("Shutting down.")
vlc.msg.info("Requested shutdown.")
vlc.quit()
vlc.misc.quit()
end
function quit(name,client)
......@@ -323,7 +323,7 @@ function playlist_status(name,client)
end
function is_playing(name,client)
if vlc.is_playing() then client:append "1" else client:append "0" end
if vlc.input.is_playing() then client:append "1" else client:append "0" end
end
function ret_print(foo,start,stop)
......@@ -438,11 +438,11 @@ commands_ordered = {
{ "faster"; { func = rate; help = "faster playing of stream" } };
{ "slower"; { func = rate; help = "slower playing of stream" } };
{ "normal"; { func = rate; help = "normal playing of stream" } };
{ "fullscreen"; { func = skip2(vlc.fullscreen); args = "[on|off]"; help = "toggle fullscreen"; aliases = { "f", "F" } } };
{ "fullscreen"; { func = skip2(vlc.video.fullscreen); args = "[on|off]"; help = "toggle fullscreen"; aliases = { "f", "F" } } };
{ "info"; { func = input_info; help = "information about the current stream" } };
{ "get_time"; { func = get_time("time"); help = "seconds elapsed since stream's beginning" } };
{ "is_playing"; { func = is_playing; help = "1 if a stream plays, 0 otherwise" } };
{ "get_title"; { func = ret_print(vlc.get_title); help = "the title of the current stream" } };
{ "get_title"; { func = ret_print(vlc.input.get_title); help = "the title of the current stream" } };
{ "get_length"; { func = get_time("length"); help = "the length of the current stream" } };
{ "" };
{ "volume"; { func = volume; args = "[X]"; help = "set/get audio volume" } };
......@@ -465,7 +465,7 @@ commands_ordered = {
{ "alias"; { func = skip(alias); args = "[cmd]"; help = "set/get command aliases"; adv = true } };
{ "eval"; { func = skip(eval); help = "eval some lua (*debug*)"; adv =true } }; -- FIXME: comment out if you're not debugging
{ "description"; { func = print_text("Description",description); help = "describe this module" } };
{ "license"; { func = print_text("License message",vlc.license()); help = "print VLC's license message"; adv = true } };
{ "license"; { func = print_text("License message",vlc.misc.license()); help = "print VLC's license message"; adv = true } };
{ "help"; { func = help; args = "[pattern]"; help = "a help message"; aliases = { "?" } } };
{ "longhelp"; { func = help; args = "[pattern]"; help = "a longer help message" } };
{ "logout"; { func = logout; help = "exit (if in a socket connection)" } };
......@@ -542,7 +542,7 @@ function call_command(cmd,client,arg)
end
function call_libvlc_command(cmd,client,arg)
local ok, vlcerr, vlcmsg = pcall( vlc.libvlc_command, cmd, arg )
local ok, vlcerr, vlcmsg = pcall( vlc.var.libvlc_command, cmd, arg )
if not ok then
local a = arg or ""
if a ~= "" then a = " " .. a end
......@@ -568,7 +568,7 @@ end
h:listen( config.hosts or config.host or "*console" )
--[[ The main loop ]]
while not vlc.should_die() do
while not vlc.misc.should_die() do
h:accept()
local write, read = h:select(0.1)
......
......@@ -101,13 +101,13 @@ h:listen( config.hosts or config.host or "localhost:4212" )
password = config.password or "admin"
--[[ Launch vlm ]]
vlm = vlc.vlm.new()
vlm = vlc.vlm()
--[[ Commands ]]
function shutdown(client)
h:broadcast("Shutting down.\r\n")
vlc.msg.err("shutdown requested")
vlc.quit()
vlc.misc.quit()
return true
end
function logout(client)
......@@ -146,7 +146,7 @@ commands = {
["logout"] = { func = logout, help = "logout" },
["lock"] = { func = lock, help = "lock the telnet prompt" },
["description"] = { func = print_text(description), help = "describe this module" },
["license"] = { func = print_text(vlc.license()), help = "print VLC's license message" },
["license"] = { func = print_text(vlc.misc.license()), help = "print VLC's license message" },
["help"] = { func = help, help = "show this help", dovlm = true },
}
......@@ -155,7 +155,7 @@ function client_command( client )
client.buffer = ""
if not commands[cmd] or not commands[cmd].func or commands[cmd].dovlm then
-- if it's not an interface specific command, it has to be a VLM command
local message, vlc_err = vlc.vlm.execute_command( vlm, cmd )
local message, vlc_err = vlm:execute_command( cmd )
vlm_message_to_string( client, message )
if not commands[cmd] or not commands[cmd].func and not commands[cmd].dovlm then
if vlc_err ~= 0 then client:append( "Type `help' for help." ) end
......@@ -171,7 +171,7 @@ function client_command( client )
end
--[[ The main loop ]]
while not vlc.should_die() do
while not vlc.misc.should_die() do
h:accept()
local w, r = h:select( 0.1 )
......@@ -219,4 +219,4 @@ while not vlc.should_die() do
end
--[[ Clean up ]]
vlc.vlm.delete( vlm )
vlm = nil
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