7

FreeSWITCH的moh使用笔记

 9 months ago
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.
neoserver,ios ssh client

操作系统 :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 属性:

300959-20231029230838614-2050133337.png

 如果没有启用local_stream模块,触发moh时会报如下错误:

[ERR] switch_core_file.c:346 Invalid file format [local_stream] for [moh]!
300959-20231029230906269-2100157685.png

 如果没有下载moh音频,触发moh时会报如下错误:

[ERR] mod_local_stream.c:883 Unknown source default
300959-20231029230934817-73395890.png

 二、安装moh

1、安装local_stream模块

文件:freeswitch-1.10.9.-release/modules.conf

模块名称:formats/mod_local_stream

300959-20231029231003590-2020581247.png

 2、安装moh音频

  • 安装8k音频

make moh-install

下载文件路径:

https://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-8000-1.0.52.tar.gz

300959-20231029231040603-770171827.png
  • 安装16k音频

make hd-moh-install

下载文件路径:

https://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-16000-1.0.52.tar.gz

300959-20231029231155205-643206719.png
  • 安装32k音频

make uhd-moh-install

下载文件路径:

https://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-32000-1.0.52.tar.gz

300959-20231029231112457-1716877001.png
  • 安装48k音频

make cd-moh-install

下载文件路径:

https://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-48000-1.0.52.tar.gz

300959-20231029231234934-1874073457.png

 安装完毕的目录结构:

/usr/local/freeswitch/sounds/music

300959-20231029231253862-1637541278.png

 如果下载过慢,可以从如下渠道获取:

关注微信公众号(聊聊博文,文末可扫码)后回复 20231029 获取。

三、使用moh

1、启用local_stream模块

文件:/usr/local/freeswitch/conf/autoload_configs/modules.conf.xml

模块名称:mod_local_stream

300959-20231029231408817-1500504506.png

 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"/>
300959-20231029231508274-1152714405.png

四、资源下载

本文涉及的音频文件,可以从如下途径获取:

关注微信公众号(聊聊博文)后回复 20231029 获取。
300959-20231029231607509-2006432605.png

 


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK