作業系統 :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
檔案:freeswitch-1.10.9.-release/modules.conf
模組名稱:formats/mod_local_stream
安裝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
如果下載過慢,可以從如下渠道獲取:
檔案:/usr/local/freeswitch/conf/autoload_configs/modules.conf.xml
模組名稱:mod_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"/>
文涉及原始碼和檔案,可以從如下途徑獲取: