ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Freeswitch使用originate转dialplan

2022-06-24 15:34:28  阅读:154  来源: 互联网

标签:originate 5080 sofia 55.138 10.55 external Freeswitch dialplan 1001


 

 

概述

Freeswitch是一款非常好用的开源VOIP软交换平台。

最近在对fs做一些功能测试,测试的过程中产生的一个需求,如何从fs发起呼叫并把后续的呼叫流程转到某一个dialplan上,这样在测试时会非常方便好用,可以随时修改dialplan定制业务流程。

通过对fs官方文档搜索后,排除了“transfer”、“execute_extension”、“bind_meta_app”,偶然发现“originate”接口可以直接实现这样的功能需求。

 

环境

centos:CentOS  release 7.0 (Final)或以上版本

freeswitch:v1.8.7

GCC:4.8.5

 

originate

originate是一个API接口,接口格式如下。

originate <call url> <exten>|&<application_name>(<app_args>) [<dialplan>] [<context>] [<cid_name>] [<cid_num>] [<timeout_sec>]

 

接口实例。

originate {origination_caller_id_number=9005551212}sofia/default/whatever@wherever &bridge({origination_caller_id_number=8001234567}sofia/profile/someother@destination.com)

 

从接口格式来看,originate接口可以使用“&”接一个APP接口,在呼叫接通之后继续处理流程,但是有时候一个APP是不够用的,这样我们就需要在“originate”之后把呼叫流程转到dialplan中继续处理。

 

转dialplan的接口实例。

originate {origination_caller_id_number=9005551212}sofia/default/whatever@wherever 19005551212 XML default CALLER_ID_NAME CALLER_ID_NUMBER

这个实例中,使用originate接口发起呼叫,然后转到XML类型的拨号计划“default”中。

 

配置

修改配置文件“/usr/local/freeswitch/conf/dialplan/test.xml”。

<include>

        <context name="ext_test">

                <extension name="test" continue="false">

                        <condition field="destination_number" expression="^(\d+)$">

                                <action application="sched_hangup" data="+10"/>

                                <action application="send_dtmf" data="1234"/>

                                <action application="sleep" data="5000"/>

                                <action application="endless_playback" data="/usr/local/freeswitch/sounds/101-baidu-mp3.mp3"/>

                        </condition>

                </extension>

        </context>

</include>

 

测试

在freeswitch命令行中使用originate发起呼叫,再转到拨号计划ext_test发送DTMF。

freeswitch@localhost.localdomain> originate {originator_codec=PCMA,origination_caller_id_number=0755110}sofia/external/sip:1001@10.55.55.138:5080 1001 XML ext_test

 

fs呼叫138服务器上的1001,呼叫接通之后,发送DTMF并播放提示语音,日志如下。

freeswitch@localhost.localdomain> originate {originator_codec=PCMA,origination_caller_id_number=0755110}sofia/external/sip:1001@10.55.55.138:5080 1001 XML ext_test

...

2022-06-13 11:37:15.601015 [DEBUG] sofia.c:7084 Channel sofia/external/1001@10.55.55.138:5080 entering state [ready][200]

...

2022-06-13 11:37:15.610983 [INFO] mod_dialplan_xml.c:637 Processing  <0755110>->1001 in context ext_test

Dialplan: sofia/external/1001@10.55.55.138:5080 parsing [ext_test->test] continue=false

Dialplan: sofia/external/1001@10.55.55.138:5080 Regex (PASS) [test] destination_number(1001) =~ /^(\d+)$/ break=on-false

Dialplan: sofia/external/1001@10.55.55.138:5080 Action sched_hangup(+10)

Dialplan: sofia/external/1001@10.55.55.138:5080 Action send_dtmf(1234)

Dialplan: sofia/external/1001@10.55.55.138:5080 Action sleep(5000)

Dialplan: sofia/external/1001@10.55.55.138:5080 Action endless_playback(/usr/local/freeswitch/sounds/101-baidu-mp3.mp3)

...

EXECUTE sofia/external/1001@10.55.55.138:5080 sched_hangup(+10)

EXECUTE sofia/external/1001@10.55.55.138:5080 send_dtmf(1234)

2022-06-13 11:37:15.610983 [DEBUG] switch_core_io.c:1918 sofia/external/1001@10.55.55.138:5080 send dtmf digit=1 ms=250 samples=2000

...

EXECUTE sofia/external/1001@10.55.55.138:5080 sleep(5000)

...

EXECUTE sofia/external/1001@10.55.55.138:5080 endless_playback(/usr/local/freeswitch/sounds/101-baidu-mp3.mp3)

...

2022-06-13 11:37:25.121013 [DEBUG] switch_ivr_play_say.c:1942 done playing file /usr/local/freeswitch/sounds/101-baidu-mp3.mp3

...

2022-06-13 11:37:25.121013 [DEBUG] mod_sofia.c:440 Channel sofia/external/1001@10.55.55.138:5080 hanging up, cause: ALLOTTED_TIMEOUT

 

总结

使用originate接口,可以直接实现呼叫转dialplan的业务流程。

仔细想一想,通过bridge转接到某一个dailplan应该也有实现的可行性。具体情况未详细深入了解。

 

空空如常

求真得真

标签:originate,5080,sofia,55.138,10.55,external,Freeswitch,dialplan,1001
来源: https://www.cnblogs.com/qiuzhendezhen/p/16409016.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有