From 564b5f4a79cad6366f4853e64b7fbb3115773766 Mon Sep 17 00:00:00 2001 From: Brian West Date: Wed, 10 Sep 2008 14:05:48 +0000 Subject: [PATCH] create example of using the inputcallback to influence the playback of a file. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9501 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- scripts/lua/callback.lua | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 scripts/lua/callback.lua diff --git a/scripts/lua/callback.lua b/scripts/lua/callback.lua new file mode 100644 index 0000000000..6e46699e14 --- /dev/null +++ b/scripts/lua/callback.lua @@ -0,0 +1,57 @@ +function all_done(s, how) + io.write("done: " .. how .. "\n"); +end + +function my_cb(s, type, obj, arg) + if (arg) then + io.write("type: " .. type .. "\n" .. "arg: " .. arg .. "\n"); + else + io.write("type: " .. type .. "\n"); + end + + if (type == "dtmf") then + io.write("digit: [" .. obj['digit'] .. "]\nduration: [" .. obj['duration'] .. "]\n"); + + if (obj['digit'] == "1") then + return "pause"; + end + + if (obj['digit'] == "2") then + return "seek:+3000"; + end + + if (obj['digit'] == "3") then + return "seek:-3000"; + end + + if (obj['digit'] == "4") then + return "seek:+3000"; + end + + if (obj['digit'] == "5") then + return "speed:+1"; + end + if (obj['digit'] == "6") then + return "speed:0"; + end + if (obj['digit'] == "7") then + return "speed:-1"; + end + + if (obj['digit'] == "8") then + return "stop"; + end + + if (obj['digit'] == "9") then + return "break"; + end + else + io.write(obj:serialize("xml")); + + end +end + +blah = "args"; +session:setHangupHook("all_done"); +session:setInputCallback("my_cb", "blah"); +session:streamFile("/tmp/swimp.raw");