如何打出手机电话并播放音频

问题描述 投票:1回答:1

我是FreeSWITCH的新手,我想打一个电话并播放音频,但是Lua脚本遇到问题。

方案是:

  • 首先:我使用运行fs_cli -x命令的bash脚本开始对扩展的调用。

    /root/Scripts/teste.sh

    这是bash脚本:

    fs_cli -x "originate {origination_caller_id_number=xxxxxxxxx}sofia/internal/9999@my_freeswitch_IP &park()"
  • 第二:当脚本转到dialplan时,调用Lua脚本。

    这是dialplan

    <extension name="call_forward" continue="true">
      <condition field="destination_number" expression="9999">
        <action application="lua" data="makecall11.lua"/>
      </condition>
    </extension>

    这是Lua脚本:

    new_session = freeswitch.Session();
    new_session.originate(session,sofia/gateway/duxus_gateway/985.......,60);
    session:answer();
    session:sleep(1000);
    session:execute("playback","/etc/freeswitch/sounds/audio.wav");
    session:hangup();
    

但是Lua脚本有错误。

fs_cli中的日志具有此:

2019-10-09 09:51:08.421058 [ERR] mod_lua.cpp:203 /usr/share/freeswitch/scripts/makecall11.lua:10: attempt to perform arithmetic on global 'sofia' (a nil value)
stack traceback:
    /usr/share/freeswitch/scripts/makecall11.lua:10: in main chunk

第10行就是这个:

new_session.originate(session,sofia/gateway/duxus_gateway/mobile_phone_number,60);

我在做什么错?

我的网关配置是:

[freeswitch_HOME]/sip_profiles/external/gateway.xml

<include>
  <gateway name="duxus_gateway">
    <param name="proxy" value="my_firewall_IP"/>
    <param name="register" value="false"/>
    <param name="outbound_caller_id_number" value="xxxxxxxxxx"/>
    <param name="caller-id-in-from" value="true"/> 
  </gateway>
</include>

这是我来自sofia statusfs_cli

freeswitch@fsduxus> sofia status

                     Name      Type                                       Data  State
=================================================================================================
            external-ipv6   profile                   sip:mod_sofia@[::1]:5080  RUNNING (0)
                 external   profile         sip:mod_sofia@my_freeswitch_IP:5080 RUNNING (0)
  external::duxus_gateway   gateway               sip:FreeSWITCH@my_firewall_IP NOREG
            internal-ipv6   profile                   sip:mod_sofia@[::1]:5060  RUNNING (0)
                 internal   profile         sip:mod_sofia@my_freeswitch_IP:5060 RUNNING (0)
=================================================================================================
4 profiles 0 aliases
bash lua freeswitch
1个回答
0
投票

如下所示的lua脚本,我可以拨打电话:

freeswitch.console_log("info", "starting a call\n");

local session = freeswitch.Session("{origination_caller_id_number=xxxxxxxx}sofia/external/mobile_number@my_audicodes_IP");



session:answer();


session:sleep(1000);
session:execute("playback","/etc/freeswitch/sounds/audio.wav");
session:hangup();

但是电话挂断8秒后,有人可以帮我解决这个问题吗?

我可以找到fs_cli的日志:

nta.c:7554 nta_outgoing_tcancel() nta_outgoing_tcancel: trying to cancel cancelled request
nta.c:7554 nta_outgoing_tcancel() nta_outgoing_tcancel: trying to cancel cancelled request
2019-10-09 11:30:47.015247 [NOTICE] switch_ivr_originate.c:3612 Hangup sofia/internal/9999@my_freeswitch_IP [CS_CONSUME_MEDIA] [NO_ANSWER]
2019-10-09 11:30:47.015247 [DEBUG] switch_core_state_machine.c:584 (sofia/internal/9999@my_freeswitch_IP) Running State Change CS_HANGUP (Cur 7 Tot 18)
2019-10-09 11:30:47.015247 [DEBUG] switch_core_state_machine.c:850 (sofia/internal/9999@my_freeswitch_IP) Callstate Change DOWN -> HANGUP
2019-10-09 11:30:47.015247 [DEBUG] switch_core_state_machine.c:852 (sofia/internal/9999@my_freeswitch_IP) State HANGUP
2019-10-09 11:30:47.015247 [DEBUG] mod_sofia.c:438 Channel sofia/internal/9999@my_freeswitch_IP hanging up, cause: NO_ANSWER
2019-10-09 11:30:47.015247 [DEBUG] mod_sofia.c:502 Sending CANCEL to sofia/internal/9999@my_freeswitch_IP
2019-10-09 11:30:47.015247 [DEBUG] switch_core_state_machine.c:60 sofia/internal/9999@my_freeswitch_IP Standard HANGUP, cause: NO_ANSWER
2019-10-09 11:30:47.015247 [DEBUG] switch_core_state_machine.c:852 (sofia/internal/9999@my_freeswitch_IP) State HANGUP going to sleep

当分机9999挂断时,所有呼叫也都结束了?

© www.soinside.com 2019 - 2024. All rights reserved.