当前位置:网站首页>freeswitch拨打分机号
freeswitch拨打分机号
2022-07-01 05:54:00 【求真得真】
概述
电话语音服务中,有一种稍微复杂的场景,就是总机分机的落地场景,客户拨打总机号码之后,需要再拨打分机号转接到指定的话机。
分机号的拨打一般在总机接通之后,会有语音提示,总机收号之后转接分机。
分机号转接的实现方式其实和IVR的实现方式是一致的,都是通过DTMF码收号。
本篇文档不讲总机分机怎么落地,而是讲怎么通过fs自动拨打分机。
环境
centos:CentOS release 7.0 (Final)或以上版本
freeswitch:v1.8.7
GCC:4.8.5
APP接口
Freeswitch有app接口“send_dtmf”,可以很方便的发送DTMF码,源代码在mod_dptools模块。
使用方法很简单,格式如下。
send_dtmf <dtmf digits>[@<tone_duration>]
实例,拨号计划
<action application="send_dtmf" data="0123456789ABCD*#@100"/>
实例,C++代码。
char *extnum = "123456";
if (SWITCH_STATUS_SUCCESS != switch_core_session_execute_application(session, "send_dtmf", extnum))
{
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"send_dtmf failed, extnum = %s\n", extnum);
}
拨号计划配置
修改fs配置文件/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="987654321"/>
<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,日志如下。
2022-06-10 15:57:57.810985 [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(987654321)
Dialplan: sofia/external/[email protected]:5080 Action endless_playback(/usr/local/freeswitch/sounds/101-baidu-mp3.mp3)
...
EXECUTE sofia/external/[email protected]:5080 send_dtmf(987654321)
2022-06-10 15:57:57.810985 [DEBUG] switch_core_io.c:1918 sofia/external/[email protected]:5080 send dtmf
digit=9 ms=250 samples=2000
2022-06-10 15:57:57.810985 [DEBUG] switch_core_io.c:1918 sofia/external/[email protected]:5080 send dtmf
digit=8 ms=250 samples=2000
...
EXECUTE sofia/external/[email protected]:5080 endless_playback(/usr/local/freeswitch/sounds/101-baidu-mp3.mp3)
2022-06-10 15:57:57.810985 [DEBUG] switch_ivr_play_say.c:1498 Codec Activated [email protected] 1 channels 20ms
2022-06-10 15:57:57.820986 [DEBUG] switch_rtp.c:5237 Send start packet for [9] ts=160 dur=160/160/2000 seq=65154 lw=160
2022-06-10 15:57:57.820986 [DEBUG] switch_rtp.c:5136 Send middle packet for [9] ts=160 dur=320/320/2000 seq=65155 lw=320
2022-06-10 15:57:57.841015 [DEBUG] switch_rtp.c:5136 Send middle packet for [9] ts=160 dur=480/480/2000 seq=65156 lw=480
2022-06-10 15:57:57.841015 [DEBUG] switch_rtp.c:5136 Send middle packet for [9] ts=160 dur=640/640/2000 seq=65157 lw=640
2022-06-10 15:57:57.861013 [DEBUG] switch_rtp.c:5136 Send middle packet for [9] ts=160 dur=800/800/2000 seq=65158 lw=800
2022-06-10 15:57:57.861013 [DEBUG] switch_rtp.c:5136 Send middle packet for [9] ts=160 dur=960/960/2000 seq=65159 lw=960
2022-06-10 15:57:57.881025 [DEBUG] switch_rtp.c:5136 Send middle packet for [9] ts=160 dur=1120/1120/2000 seq=65160 lw=1120
2022-06-10 15:57:57.881025 [DEBUG] switch_rtp.c:5136 Send middle packet for [9] ts=160 dur=1280/1280/2000 seq=65161 lw=1280
2022-06-10 15:57:57.901015 [DEBUG] switch_rtp.c:5136 Send middle packet for [9] ts=160 dur=1440/1440/2000 seq=65162 lw=1440
2022-06-10 15:57:57.901015 [DEBUG] switch_rtp.c:5136 Send middle packet for [9] ts=160 dur=1600/1600/2000 seq=65163 lw=1600
2022-06-10 15:57:57.921012 [DEBUG] switch_rtp.c:5136 Send middle packet for [9] ts=160 dur=1760/1760/2000 seq=65164 lw=1760
2022-06-10 15:57:57.921012 [DEBUG] switch_rtp.c:5136 Send middle packet for [9] ts=160 dur=1920/1920/2000 seq=65165 lw=1920
2022-06-10 15:57:57.941013 [DEBUG] switch_rtp.c:5136 Send end packet for [9] ts=160 dur=2080/2080/2000 seq=65166 lw=1920
2022-06-10 15:57:57.941013 [DEBUG] switch_rtp.c:5136 Send end packet for [9] ts=160 dur=2080/2080/2000 seq=65167 lw=1920
2022-06-10 15:57:57.941013 [DEBUG] switch_rtp.c:5136 Send end packet for [9] ts=160 dur=2080/2080/2000 seq=65168 lw=1920
2022-06-10 15:57:57.941013 [DEBUG] switch_rtp.c:5084 Queue digit delay of 40ms
2022-06-10 15:57:57.980986 [DEBUG] switch_rtp.c:5237 Send start packet for [8] ts=1440 dur=160/160/2000 seq=65171 lw=1440
2022-06-10 15:57:57.980986 [DEBUG] switch_rtp.c:5136 Send middle packet for [8] ts=1440 dur=320/320/2000 seq=65172 lw=1600
2022-06-10 15:57:57.991013 [DEBUG] switch_rtp.c:5136 Send middle packet for [8] ts=1440 dur=480/480/2000 seq=65173 lw=1760
2022-06-10 15:57:57.991013 [DEBUG] switch_rtp.c:5136 Send middle packet for [8] ts=1440 dur=640/640/2000 seq=65174 lw=1920
2022-06-10 15:57:58.021023 [DEBUG] switch_rtp.c:5136 Send middle packet for [8] ts=1440 dur=800/800/2000 seq=65175 lw=2080
2022-06-10 15:57:58.021023 [DEBUG] switch_rtp.c:5136 Send middle packet for [8] ts=1440 dur=960/960/2000 seq=65176 lw=2240
2022-06-10 15:57:58.041014 [DEBUG] switch_rtp.c:5136 Send middle packet for [8] ts=1440 dur=1120/1120/2000 seq=65177 lw=2400
2022-06-10 15:57:58.041014 [DEBUG] switch_rtp.c:5136 Send middle packet for [8] ts=1440 dur=1280/1280/2000 seq=65178 lw=2560
2022-06-10 15:57:58.061012 [DEBUG] switch_rtp.c:5136 Send middle packet for [8] ts=1440 dur=1440/1440/2000 seq=65179 lw=2720
2022-06-10 15:57:58.061012 [DEBUG] switch_rtp.c:5136 Send middle packet for [8] ts=1440 dur=1600/1600/2000 seq=65180 lw=2880
2022-06-10 15:57:58.081014 [DEBUG] switch_rtp.c:5136 Send middle packet for [8] ts=1440 dur=1760/1760/2000 seq=65181 lw=3040
2022-06-10 15:57:58.081014 [DEBUG] switch_rtp.c:5136 Send middle packet for [8] ts=1440 dur=1920/1920/2000 seq=65182 lw=3200
2022-06-10 15:57:58.101024 [DEBUG] switch_rtp.c:5136 Send end packet for [8] ts=1440 dur=2080/2080/2000 seq=65183 lw=3200
2022-06-10 15:57:58.101024 [DEBUG] switch_rtp.c:5136 Send end packet for [8] ts=1440 dur=2080/2080/2000 seq=65184 lw=3200
2022-06-10 15:57:58.101024 [DEBUG] switch_rtp.c:5136 Send end packet for [8] ts=1440 dur=2080/2080/2000 seq=65185 lw=3200
2022-06-10 15:57:58.101024 [DEBUG] switch_rtp.c:5084 Queue digit delay of 40ms
...
总结
在呼叫接通之后,使用send_dtmf发送DTMF码,但是实际使用过程中,发现俩个问题。
第一个问题,发送DTMF码会和放音语音叠加。
第二个问题,发送DTMF码app执行之后,并不会马上发送,而是要等待有媒体流发送的同时开始发送。
本来想把源代码的流程一起讲完,但是跟踪了源代码之后,发现代码调用的逻辑比较复杂,在不同模块之间跳转较多,后面单独开一章讲代码流程。
空空如常
求真得真
边栏推荐
- SystemVerilog学习-07-类的继承和包的使用
- He struggled day and night to protect his data
- QT write custom control - self drawn battery
- 数据库er图组成要素
- In win10 and win11, the scroll direction of Elan touch panel is reversed, and "double finger click to open the right-click menu" and "double finger scroll" are started“
- 输入一个表达式(用字符串表示),求这个表达式的值。
- Through cooperation with the University of international trade, we can increase efficiency for college students
- 【考研高数 自用】高数第一章基础阶段思维导图
- OpenGL es: (2) relationship between OpenGL es, EGL and glsl
- C语言初阶——牛客网精选好题
猜你喜欢
随机推荐
excel可视化
码蹄集 - MT3149 · AND - 数据不是很强,暴力剪枝就能骗AC
运行时候的导包搜索路径虽然pycharm中标红但不影响程序的执行
Data governance: data governance management (Part V)
穿越派与贸大合作,为大学生增添效率
Some errors encountered in MySQL data migration
Oracle sequence + trigger
Code shoe set - mt3114 · interesting balance - explain it with examples
Crossing sect · paipan + Siyuan notes = private notebook
Debug details under pycharm
C language beginner level - realize the minesweeping game
PLA不粘贴在床上:6个简单的解决方案
【知识点总结】卡方分布,t分布,F分布
无限水平大理石游戏
从MLPerf谈起:如何引领AI加速器的下一波浪潮
POL8901 LVDS转MIPI DSI 支持旋转图像处理芯片
It's not that you have a bad mind, but that you haven't found the right tool
3D printer threading: five simple solutions
Oracle create user + Role
HCM 初学 ( 三 ) - 快速输入PA70、PA71 浏览员工信息PA10