【问题标题】:Play audio file from Freeswitch after call is bridged呼叫桥接后从 Freeswitch 播放音频文件
【发布时间】:2020-03-06 16:50:43
【问题描述】:

我正在从 WebRTC 浏览器和 SIP 客户端发起呼叫,并希望在呼叫通过 PTSN 桥接到另一方后使用 never_playback 播放 .wav 文件。我尝试了两件事,但都不行。

a) 使用拨号方案

<action application="endless_playback" data="the path of wav file"/> //option 1
<action application="bridge" data="the call info"/>
<action application="endless_playback" data="the path of wav file"/> //option 2

问题在于,在选项 1 中,文件播放但呼叫从未桥接,而在选项 2 中,文件在接收呼叫挂断后播放。

b) 使用 LUA 脚本

local TheSound = "the path of the wav file"

if (session:ready() == true) then

    session:execute("playback", TheSound)

end

这似乎更有可能奏效,但它没有因为我需要在桥接发生后执行播放。

我想我需要把LUA脚本行改成下面的伪代码

listen for call connected event and then

    session:execute("playback", TheSound)

我该怎么做?

【问题讨论】:

    标签: lua freeswitch


    【解决方案1】:

    我使用uuid_broadcast找到了一个可行的解决方案

    第 1 步:在拨号方案中,将这一行添加到网桥之前

    <action application="export" data="nolocal:execute_on_answer=lua somescript.lua"/>
    <action application="bridge" data="the bridge info"/>
    

    请注意,如果您在桥接之前设置变量的值,并且需要在桥接之后从 lua 脚本访问它,请务必添加以下行:

    <action application="export" data="thevariable=${thevariable}"/>
    

    第二步:在 somescript.lua 文件中,你需要先确定通话的 uuid,然后你可以在通话中播放声音,甚至可以选择你正在播放文件的哪条腿:

    local theuuid = session:getVariable('uuid')
    
    api = freeswitch.API()
    
    local thesoundcast = "uuid_broadcast "..theuuid.."pathofsoundfile.wav aleg"
    api:executeString(thesoundcast)
    

    然后瞧。

    【讨论】:

      猜你喜欢
      • 2015-01-19
      • 2020-12-30
      • 1970-01-01
      • 2018-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多