当前位置:网站首页>freeswitch使用mod_shout模块播放mp3
freeswitch使用mod_shout模块播放mp3
2022-06-28 06:20:00 【求真得真】

概述
freeswitch 在对VOIP语音通话中,可以通过playback命令播放IVR语音文件。
默认情况下,freeswitch支持wav文件,也可以直接播放VOIP中常见编解码的G711文件、G729文件等,但是对mp3是不支持的。
通过查询freeswitch的官方文档,发现mod_shout模块是可以支持MP3文件的播放。
mod_shout模块默认不安装,可以根据需求来决定是否编译安装。
环境
centos:CentOS release 7.0 (Final)或以上版本
freeswitch:v1.6.19
GCC:4.8.5
依赖
mod_shout模块安装需要第三方库支持,centos的yum源设置方法参见文档“freeswitch自带yum源配置方式”。
sudo yum install libshout-devel lame-devel libmpg123-devel
安装
回到freeswitch源码根目录,重新生成makefile。
./bootstrap.sh -j
./configure
编译安装mod_shout模块
cd src/mod/formats/mod_shout/
make
sudo make install
ll /usr/local/freeswitch/mod/mod_shout*
-rwxr-xr-x. 1 root root 1322 May 19 11:43 /usr/local/freeswitch/mod/mod_shout.la
-rwxr-xr-x. 1 root root 168560 May 19 11:43 /usr/local/freeswitch/mod/mod_shout.so
配置
mod_shout模块安装好后,修改fs的配置。
上传MP3放音文件。
ll /usr/local/freeswitch/sounds/101-baidu-mp3.mp3
-rw-r--r--. 1 root root 12096 May 17 17:55 /usr/local/freeswitch/sounds/101-baidu-mp3.mp3
修改 /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml文件。
<load module="mod_shout"/>
修改 /usr/local/freeswitch/conf/dialplan/test.xml文件。
<include>
<context name="default">
<extension name="test" continue="false">
<condition field="destination_number" expression="^(\d+)$">
<action application="answer"/>
<action application="playback" data="/usr/local/freeswitch/sounds/101-baidu-mp3.mp3"/>
<action application="hangup" data="CALL_REJECTED"/>
</condition>
</extension>
</context>
</include>
配置好后,启动freeswitch,并确认mod_shout模块启动正常。
[email protected]> module_exists mod_shout
true
测试
使用eyebeam注册1001账号到fs,并发起呼叫到1002,1001可以听到fs的IVR放音。
当我们不加载mod_shout模块的时候,日志如下。
EXECUTE sofia/internal/[email protected] playback(/usr/local/freeswitch/sounds/101-baidu-mp3.mp3)
2022-05-19 13:49:55.573314 [ERR] switch_core_file.c:272 Invalid file format [mp3] for [/usr/local/freeswitch/sounds/101-baidu-mp3.mp3]!
EXECUTE sofia/internal/[email protected] hangup(CALL_REJECTED)
重新加载了mod_shout模块,并发起呼叫,查看日志如下。
EXECUTE sofia/internal/[email protected] playback(/usr/local/freeswitch/sounds/101-baidu-mp3.mp3)
2022-05-19 11:57:20.393239 [DEBUG] switch_ivr_play_say.c:1498 Codec Activated [email protected] 1 channels 20ms
2022-05-19 11:57:20.473273 [DEBUG] switch_rtp.c:7273 Correct audio ip/port confirmed.
2022-05-19 11:57:20.613239 [DEBUG] sofia.c:7084 Channel sofia/internal/[email protected] entering state [ready][200]
2022-05-19 11:57:26.433297 [DEBUG] switch_ivr_play_say.c:1942 done playing file /usr/local/freeswitch/sounds/101-baidu-mp3.mp3
EXECUTE sofia/internal/[email protected] hangup(CALL_REJECTED)
总结
MP3文件是压缩格式,比常见的wav(pcm)小8倍左右,在空间占用和传输带宽上有较大的优势。
我们应该多一些不同的工具,在不同的应用场景下选择最合适的方案。
空空如常
求真得真
边栏推荐
- Error reporting - resolve core JS / modules / es error. cause. JS error
- How popular are FB and WhatsApp mass messages in 2022?
- Valueerror: iterative over raw text documents expected, string object received
- 异常处理(一)——空指针和数组索引越界
- Small ball playing
- Differences between basic types and packaging classes
- Integer promotion and size side byte order
- Use of JDBC
- 整型提昇和大小端字節序
- AutoCAD C# 多段線小銳角檢測
猜你喜欢

CAD二次开发+NetTopologySuite+PGIS 引用多版本DLL问题

Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes

YYGH-BUG-02

What is the e-commerce conversion rate so abstract?

YOLOv5增加小目标检测层

How to open UMD, KMD log and dump diagrams in CAMX architecture

High quality domestic stereo codec cjc8988, pin to pin replaces wm8988

Oracle fundamentals summary

Oracle condition, circular statement

FPGA - 7系列 FPGA SelectIO -07- 高级逻辑资源之ISERDESE2
随机推荐
整型提昇和大小端字節序
ImportError: cannot import name 'ensure_dir_exists'的可解决办法
Working principle of es9023 audio decoding chip
[staff] arpeggio mark
Note that JPA uses a custom VO to receive jpql query results
socke.io長連接實現推送、版本控制、實時活躍用戶量統計
Yolact++ Pytorch环境
Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
No one can only use foreach to traverse arrays, right?
Create a gson object that formats the time zone. JSON parsing time formatting zoneddatetime
Socket. Io long Connection Push, version Control, Real - Time Active user volume Statistics
AutoCAD C# 多段线自相交检测
Simple handwritten debounce function
The length of pytorch dataloader the difference between epoch and iteration
YYGH-BUG-03
Independent station sellers are using the five e-mail marketing skills, do you know?
职场IT老鸟的几点小习惯
深度學習19種損失函數
创建格式化时间,格式化时区的gson对象。json解析时间格式化 ZonedDateTime
easyui下拉框选中触发事件