FreeSWITCH的moh使用笔记
source link: https://www.cnblogs.com/MikeZhang/p/fsMoh20231029.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
操作系统 :CentOS 7.6_x64
FreeSWITCH版本 :1.10.9
之前写过FreeSWITCH安装的文章,今天整理下moh使用过程中遇到的问题及解决方案,并提供moh音频下载途径。FreeSWITCH安装的文章可参考如下链接:
docker构建FreeSWITCH编译环境及打包
使用docker构建可动态启动的FreeSWITCH实例
CentOS7环境源码安装freeswitch1.10
一、问题描述
FreeSWITCH有hold_music功能,在hold时会触发,体现在sdp里面就是a头里面是 sendonly 属性:
如果没有启用local_stream模块,触发moh时会报如下错误:
[ERR] switch_core_file.c:346 Invalid file format [local_stream] for [moh]!
如果没有下载moh音频,触发moh时会报如下错误:
[ERR] mod_local_stream.c:883 Unknown source default
二、安装moh
1、安装local_stream模块
文件:freeswitch-1.10.9.-release/modules.conf
模块名称:formats/mod_local_stream
2、安装moh音频
-
安装8k音频
make moh-install
下载文件路径:
https://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-8000-1.0.52.tar.gz
-
安装16k音频
make hd-moh-install
下载文件路径:
https://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-16000-1.0.52.tar.gz
-
安装32k音频
make uhd-moh-install
下载文件路径:
https://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-32000-1.0.52.tar.gz
-
安装48k音频
make cd-moh-install
下载文件路径:
https://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-48000-1.0.52.tar.gz
安装完毕的目录结构:
/usr/local/freeswitch/sounds/music
如果下载过慢,可以从如下渠道获取:
三、使用moh
1、启用local_stream模块
文件:/usr/local/freeswitch/conf/autoload_configs/modules.conf.xml
模块名称:mod_local_stream
2、配置local_stream模块
配置文件路径:conf/autoload_configs/local_stream.conf.xml
配置文件内容:
<configuration name="local_stream.conf" description="stream files from local dir"> <!-- fallback to default if requested moh class isn't found --> <directory name="default" path="$${sounds_dir}/music/8000"> <param name="rate" value="8000"/> <param name="shuffle" value="true"/> <param name="channels" value="1"/> <param name="interval" value="20"/> <param name="timer-name" value="soft"/> <!-- list of short files to break in with every so often --> <!--<param name="chime-list" value="file1.wav,file2.wav"/>--> <!-- frequency of break-in (seconds)--> <!--<param name="chime-freq" value="30"/>--> <!-- limit to how many seconds the file will play --> <!--<param name="chime-max" value="500"/>--> </directory> <directory name="moh/8000" path="$${sounds_dir}/music/8000"> <param name="rate" value="8000"/> <param name="shuffle" value="true"/> <param name="channels" value="1"/> <param name="interval" value="20"/> <param name="timer-name" value="soft"/> </directory> <directory name="moh/16000" path="$${sounds_dir}/music/16000"> <param name="rate" value="16000"/> <param name="shuffle" value="true"/> <param name="channels" value="1"/> <param name="interval" value="20"/> <param name="timer-name" value="soft"/> </directory> <directory name="moh/32000" path="$${sounds_dir}/music/32000"> <param name="rate" value="32000"/> <param name="shuffle" value="true"/> <param name="channels" value="1"/> <param name="interval" value="20"/> <param name="timer-name" value="soft"/> </directory> <directory name="moh/48000" path="$${sounds_dir}/music/48000"> <param name="rate" value="48000"/> <param name="shuffle" value="true"/> <param name="channels" value="1"/> <param name="interval" value="10"/> <param name="timer-name" value="soft"/> </directory> </configuration>
3、配置hold_music
文件:/usr/local/freeswitch/conf/vars.xml
配置内容:
<X-PRE-PROCESS cmd="set" data="hold_music=local_stream://moh"/>
四、资源下载
本文涉及的音频文件,可以从如下途径获取:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK