如何从 freeswitch 拨出电话并在目标接听电话后播放文件?
how to make outgoing call from freeswitch and play file after destination answer call?
我想编写一个网络应用程序连接到 freeswitch 并向某个目标号码(固定电话或内部 sip 设备的网关)发出传出呼叫并播放一些声音(可能在 lua 脚本中执行一些逻辑).
阅读 freeswitch wiki 后,我找到了 originate
命令,但它对我不起作用(我只是测试内部 sip 号码 - sofia/internal/username@ip )。如果 originate
命令可以做到这一点,如何正确使用它?如果有其他方法请告诉我。
我测试的一种方法是 运行 来自 freeswitch 控制台或 ESL 的 lua 脚本:(ex "luarun test.lua")
obSession = freeswitch.Session("sofia/192.168.0.4/1002")
-- Check to see if the call was answered
if obSession:ready() then
-- Play file here
else
-- This means the call was not answered ... Check for the reason
local obCause = obSession:hangupCause()
freeswitch.consoleLog("info", "obSession:hangupCause() = " .. obCause )
if ( obCause == "USER_BUSY" ) then -- SIP 486
-- For BUSY you may reschedule the call for later
elseif ( obCause == "NO_ANSWER" ) then
-- Call them back in an hour
elseif ( obCause == "ORIGINATOR_CANCEL" ) then -- SIP 487
-- May need to check for network congestion or problems
else
-- Log these issues
end
end
您可以通过拨号计划很容易地做到这一点:
<action function="play-file" data="myfile.wav"/>
您可以在有人开始通话时播放 wav,请按照以下步骤操作。
- 将您的 wave 放入 freeswitch/conf 文件夹。
将下面的代码添加到您的 freeswitch/conf/autoload_configs
运行 HTTP 服务器接收 POST 请求和 returns 您的拨号方案(告诉 freeswitch 播放您的 wav)。
- 确保您的 freeswitch/conf/autoload_configs/xml_curl.conf.xml 看起来像这样
<param name="gateway-url" value="http://yourIP:yourServerPort/dialplan.xml" bindings="dialplan"/>
希望对您有所帮助。
你可以通过使用套接字[ESL]应用程序来实现。
Originate命令用于拨打电话,bridge
命令用于桥接电话。您可以使用esl socket从外部调用originate
命令。
示例:
originate {ignore_early_media=true,originate_timeout=60}sofia/gateway/name/number &playback(message)
node.js写的esl参考这个
https://github.com/englercj/node-esl
我想编写一个网络应用程序连接到 freeswitch 并向某个目标号码(固定电话或内部 sip 设备的网关)发出传出呼叫并播放一些声音(可能在 lua 脚本中执行一些逻辑).
阅读 freeswitch wiki 后,我找到了 originate
命令,但它对我不起作用(我只是测试内部 sip 号码 - sofia/internal/username@ip )。如果 originate
命令可以做到这一点,如何正确使用它?如果有其他方法请告诉我。
我测试的一种方法是 运行 来自 freeswitch 控制台或 ESL 的 lua 脚本:(ex "luarun test.lua")
obSession = freeswitch.Session("sofia/192.168.0.4/1002")
-- Check to see if the call was answered
if obSession:ready() then
-- Play file here
else
-- This means the call was not answered ... Check for the reason
local obCause = obSession:hangupCause()
freeswitch.consoleLog("info", "obSession:hangupCause() = " .. obCause )
if ( obCause == "USER_BUSY" ) then -- SIP 486
-- For BUSY you may reschedule the call for later
elseif ( obCause == "NO_ANSWER" ) then
-- Call them back in an hour
elseif ( obCause == "ORIGINATOR_CANCEL" ) then -- SIP 487
-- May need to check for network congestion or problems
else
-- Log these issues
end
end
您可以通过拨号计划很容易地做到这一点:
<action function="play-file" data="myfile.wav"/>
您可以在有人开始通话时播放 wav,请按照以下步骤操作。
- 将您的 wave 放入 freeswitch/conf 文件夹。
将下面的代码添加到您的 freeswitch/conf/autoload_configs
运行 HTTP 服务器接收 POST 请求和 returns 您的拨号方案(告诉 freeswitch 播放您的 wav)。
- 确保您的 freeswitch/conf/autoload_configs/xml_curl.conf.xml 看起来像这样
<param name="gateway-url" value="http://yourIP:yourServerPort/dialplan.xml" bindings="dialplan"/>
希望对您有所帮助。
你可以通过使用套接字[ESL]应用程序来实现。
Originate命令用于拨打电话,bridge
命令用于桥接电话。您可以使用esl socket从外部调用originate
命令。
示例:
originate {ignore_early_media=true,originate_timeout=60}sofia/gateway/name/number &playback(message)
node.js写的esl参考这个 https://github.com/englercj/node-esl