当前位置:网站首页>Freeswitch使用originate转dialplan
Freeswitch使用originate转dialplan
2022-06-28 06:20:00 【求真得真】

概述
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/[email protected] &bridge({origination_caller_id_number=8001234567}sofia/profile/[email protected])
从接口格式来看,originate接口可以使用“&”接一个APP接口,在呼叫接通之后继续处理流程,但是有时候一个APP是不够用的,这样我们就需要在“originate”之后把呼叫流程转到dialplan中继续处理。
转dialplan的接口实例。
originate {origination_caller_id_number=9005551212}sofia/default/[email protected] 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。
[email protected]> originate {originator_codec=PCMA,origination_caller_id_number=0755110}sofia/external/sip:[email protected]:5080 1001 XML ext_test
fs呼叫138服务器上的1001,呼叫接通之后,发送DTMF并播放提示语音,日志如下。
[email protected]> originate {originator_codec=PCMA,origination_caller_id_number=0755110}sofia/external/sip:[email protected]:5080 1001 XML ext_test
...
2022-06-13 11:37:15.601015 [DEBUG] sofia.c:7084 Channel sofia/external/[email protected]: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/[email protected]:5080 parsing [ext_test->test] continue=false
Dialplan: sofia/external/[email protected]:5080 Regex (PASS) [test] destination_number(1001) =~ /^(\d+)$/ break=on-false
Dialplan: sofia/external/[email protected]:5080 Action sched_hangup(+10)
Dialplan: sofia/external/[email protected]:5080 Action send_dtmf(1234)
Dialplan: sofia/external/[email protected]:5080 Action sleep(5000)
Dialplan: sofia/external/[email protected]:5080 Action endless_playback(/usr/local/freeswitch/sounds/101-baidu-mp3.mp3)
...
EXECUTE sofia/external/[email protected]:5080 sched_hangup(+10)
EXECUTE sofia/external/[email protected]:5080 send_dtmf(1234)
2022-06-13 11:37:15.610983 [DEBUG] switch_core_io.c:1918 sofia/external/[email protected]:5080 send dtmf digit=1 ms=250 samples=2000
...
EXECUTE sofia/external/[email protected]:5080 sleep(5000)
...
EXECUTE sofia/external/[email protected]: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/[email protected]:5080 hanging up, cause: ALLOTTED_TIMEOUT
总结
使用originate接口,可以直接实现呼叫转dialplan的业务流程。
仔细想一想,通过bridge转接到某一个dailplan应该也有实现的可行性。具体情况未详细深入了解。
空空如常
求真得真
边栏推荐
- Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
- YYGH-7-用户管理
- 【Paper Reading-3D Detection】Fully Convolutional One-Stage 3D Object Detection on LiDAR Range Images
- Sharing tips for efficient scripting
- Xcode13.3.1 error reported after pod install
- Idea automatically adds comments when creating classes
- Linux Mysql 实现root用户不用密码登录
- Yygh-8-appointment registration
- What are the advantages of e-mail marketing? Why do sellers of shopline independent station attach so much importance to it?
- cocoapod中的第三方库怎么引用本地头文件
猜你喜欢

Linked list (II) - Design linked list

Development trend of mobile advertising: Leveraging stock and fine marketing

19 fonctions de perte d'apprentissage profond

YYGH-7-用户管理

Sklearn Feature Engineering (summary)

AutoCAD C# 多段线自相交检测

报错--解决core-js/modules/es.error.cause.js报错

Openharmony gnawing paper growth plan -- json-rpc

Slow content advertising: the long-term principle of brand growth

Example of MVVM framework based on kotlin+jetpack
随机推荐
Taobao seo training video course [22 lectures]
Linux Mysql 实现root用户不用密码登录
Failed to start component [StandardEngine[Catalina]. StandardHost[localhost]]
@The reason why the Autowired annotation is empty
YYGH-6-微信登录
Parsing ng template with let total in NZ Pagination
重载,重写的区别,抽象类,接口的区别
Configure multiple database connections using the SSM framework
Linked list (II) - Design linked list
创建格式化时间,格式化时区的gson对象。json解析时间格式化 ZonedDateTime
Exception handling (I) -- null pointer and array index out of bounds
Enum
Yolact++ Pytorch环境
AutoCAD C # Polyline Small Sharp angle Detection
What is webrtc?
death_ satan/hyperf-validate
Sharing tips for efficient scripting
Caused by: com. fasterxml. jackson. databind. Exc.invalidformatexception: exception resolution
High quality domestic stereo codec cjc8988, pin to pin replaces wm8988
助力涨点 | YOLOv5结合Alpha-IoU