当前位置:网站首页>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执行之后,并不会马上发送,而是要等待有媒体流发送的同时开始发送。
本来想把源代码的流程一起讲完,但是跟踪了源代码之后,发现代码调用的逻辑比较复杂,在不同模块之间跳转较多,后面单独开一章讲代码流程。
空空如常
求真得真
边栏推荐
- 云盘里资料被和谐了,怎么办?
- What if the data in the cloud disk is harmonious?
- TiDB单机模拟部署生产环境集群(闭坑实践,亲测有效)
- 可动的机械挂钟
- OpenGL ES: (3) EGL、EGL绘图的基本步骤、EGLSurface、ANativeWindow
- OneFlow源码解析:算子签名的自动推断
- SystemVerilog学习-07-类的继承和包的使用
- It's not that you have a bad mind, but that you haven't found the right tool
- FPGA - 7系列 FPGA内部结构之Clocking -01- 时钟架构概述
- 论文学习记录随笔 多标签之GLOCAL
猜你喜欢

为什么用葫芦儿派盘取代U盘?

My experience from technology to product manager

excel動態圖錶

Crossing sect · paipan + Siyuan notes = private notebook

HCM 初学 ( 一 ) - 简介

Seven major technical updates that developers should pay most attention to on build 2022

QT write custom control - self drawn battery

How to transmit and share 4GB large files remotely in real time?

TIDB数据库特性总结

芯片,建立在沙粒上的帝国!
随机推荐
Leetcode Max rectangle, Max square series 84 85. 221. 1277. 1725. (monotonic stack, dynamic programming)
MySQL数据迁移遇到的一些错误
Advanced cross platform application development (II): uni app practice
Codeforces Round #803 (Div. 2)vp
Chip, an empire built on sand!
El tooltip in the table realizes line breaking display
栈题目:解析布尔表达式
TiDB单机模拟部署生产环境集群(闭坑实践,亲测有效)
OpenGL es: (5) basic concepts of OpenGL, the process of OpenGL es generating pictures on the screen, and OpenGL pipeline
ONEFLOW source code parsing: automatic inference of operator signature
LeetCode 最大矩形,最大正方形系列 84. 85. 221. 1277. 1725. (单调栈,动态规划)
MySQL converts milliseconds to time string
skywalking集成nacos动态配置
SQL必会题之留存率
FPGA - 7系列 FPGA内部结构之Clocking -02- 时钟布线资源
tese_ Time_ 2h
srpingboot security demo
scope 数据导出mat
论文学习记录随笔 多标签之GLOCAL
OpenGL ES: (1) OpenGL ES的由来 (转)