当前位置: 首页 > 工具软件 > Shout > 使用案例 >

ubuntu server 16.04.2 编译使用mod_shout

夔庆
2023-12-01

About

This module allow one to play local and remote mp3 files at any sample rate.

Configure and Install

Install Dependencies

  • libvorbis
  • libogg
  • development libraries for both

On Ubuntu:

apt-get install libvorbis0a libogg0 libogg-dev libvorbis-dev libshout3-dev libmpg123-dev libmp3lame-dev

sudo apt-get install libshout3-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libcurl3
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libshout3 libtheora-dev libtheora0
The following NEW packages will be installed:
  libshout3 libshout3-dev libtheora-dev libtheora0
0 upgraded, 4 newly installed, 0 to remove and 143 not upgraded.
Need to get 420 kB of archives.
After this operation, 2,071 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 libtheora0 amd64 1.1.1+dfsg.1-8 [163 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 libshout3 amd64 2.3.1-3 [38.1 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 libtheora-dev amd64 1.1.1+dfsg.1-8 [178 kB]
Get:4 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 libshout3-dev amd64 2.3.1-3 [40.8 kB]                                                           
Fetched 420 kB in 33s (12.7 kB/s)     
Selecting previously unselected package libtheora0:amd64.
(Reading database ... 77605 files and directories currently installed.)
Preparing to unpack .../libtheora0_1.1.1+dfsg.1-8_amd64.deb ...
Unpacking libtheora0:amd64 (1.1.1+dfsg.1-8) ...
Selecting previously unselected package libshout3:amd64.
Preparing to unpack .../libshout3_2.3.1-3_amd64.deb ...
Unpacking libshout3:amd64 (2.3.1-3) ...
Selecting previously unselected package libtheora-dev:amd64.
Preparing to unpack .../libtheora-dev_1.1.1+dfsg.1-8_amd64.deb ...
Unpacking libtheora-dev:amd64 (1.1.1+dfsg.1-8) ...
Selecting previously unselected package libshout3-dev:amd64.
Preparing to unpack .../libshout3-dev_2.3.1-3_amd64.deb ...
Unpacking libshout3-dev:amd64 (2.3.1-3) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...
Setting up libtheora0:amd64 (1.1.1+dfsg.1-8) ...
Setting up libshout3:amd64 (2.3.1-3) ...
Setting up libtheora-dev:amd64 (1.1.1+dfsg.1-8) ...
Setting up libshout3-dev:amd64 (2.3.1-3) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...

sudo apt-get install libmpg123-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libcurl3
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libmpg123-0
The following NEW packages will be installed:
  libmpg123-0 libmpg123-dev
0 upgraded, 2 newly installed, 0 to remove and 143 not upgraded.
Need to get 151 kB of archives.
After this operation, 470 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 libmpg123-0 amd64 1.22.4-1 [124 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 libmpg123-dev amd64 1.22.4-1 [27.9 kB]
Fetched 151 kB in 0s (260 kB/s)       
Selecting previously unselected package libmpg123-0:amd64.
(Reading database ... 77653 files and directories currently installed.)
Preparing to unpack .../libmpg123-0_1.22.4-1_amd64.deb ...
Unpacking libmpg123-0:amd64 (1.22.4-1) ...
Selecting previously unselected package libmpg123-dev:amd64.
Preparing to unpack .../libmpg123-dev_1.22.4-1_amd64.deb ...
Unpacking libmpg123-dev:amd64 (1.22.4-1) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...
Setting up libmpg123-0:amd64 (1.22.4-1) ...
Setting up libmpg123-dev:amd64 (1.22.4-1) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...

sudo apt-get install libmp3lame-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libcurl3
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libmp3lame0
The following NEW packages will be installed:
  libmp3lame-dev libmp3lame0
0 upgraded, 2 newly installed, 0 to remove and 143 not upgraded.
Need to get 269 kB of archives.
After this operation, 816 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 libmp3lame0 amd64 3.99.5+repack1-9build1 [127 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu xenial/universe amd64 libmp3lame-dev amd64 3.99.5+repack1-9build1 [142 kB]
Fetched 269 kB in 0s (464 kB/s)       
Selecting previously unselected package libmp3lame0:amd64.
(Reading database ... 77673 files and directories currently installed.)
Preparing to unpack .../libmp3lame0_3.99.5+repack1-9build1_amd64.deb ...
Unpacking libmp3lame0:amd64 (3.99.5+repack1-9build1) ...
Selecting previously unselected package libmp3lame-dev:amd64.
Preparing to unpack .../libmp3lame-dev_3.99.5+repack1-9build1_amd64.deb ...
Unpacking libmp3lame-dev:amd64 (3.99.5+repack1-9build1) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...
Setting up libmp3lame0:amd64 (3.99.5+repack1-9build1) ...
Setting up libmp3lame-dev:amd64 (3.99.5+repack1-9build1) ...
Processing triggers for libc-bin (2.23-0ubuntu5) ...


Enable module in build.

Edit modules.conf in source directory to add mod_shout.


formats/mod_sndfile
formats/mod_shout    <--- NEW
#languages/mod_perl

Configure/Make:


./configure && make install

 +---------- FreeSWITCH install Complete ----------+
 + FreeSWITCH has been successfully installed.     +
 +                                                 +
 +       Install sounds:                           +
 +       (uhd-sounds includes hd-sounds, sounds)   +
 +       (hd-sounds includes sounds)               +
 +       ------------------------------------      +
 +                make cd-sounds-install           +
 +                make cd-moh-install              +
 +                                                 +
 +                make uhd-sounds-install          +
 +                make uhd-moh-install             +
 +                                                 +
 +                make hd-sounds-install           +
 +                make hd-moh-install              +
 +                                                 +
 +                make sounds-install              +
 +                make moh-install                 +
 +                                                 +
 +       Install non english sounds:               +
 +       replace XX with language                  +
 +       (ru : Russian)                            +
 +       (fr : French)                             +
 +       ------------------------------------      +
 +                make cd-sounds-XX-install        +
 +                make uhd-sounds-XX-install       +
 +                make hd-sounds-XX-install        +
 +                make sounds-XX-install           +
 +                                                 +
 +       Upgrade to latest:                        +
 +       ----------------------------------        +
 +                make current                     +
 +                                                 +
 +       Rebuild all:                              +
 +       ----------------------------------        +
 +                make sure                        +
 +                                                 +
 +       Install/Re-install default config:        +
 +       ----------------------------------        +
 +                make samples                     +
 +                                                 +
 +                                                 +
 +       Additional resources:                     +
 +       ----------------------------------        +
 +       https://www.freeswitch.org                +
 +       https://freeswitch.org/confluence         +
 +       https://freeswitch.org/jira               +
 +       http://lists.freeswitch.org               +
 +                                                 +
 +       irc.freenode.net / #freeswitch            +
 +                                                 +
 +       Register For ClueCon:                     +
 +       ----------------------------------        +
 +       https://www.cluecon.com                   +
 +                                                 +
 +-------------------------------------------------+

Overview

Play Capabilities

Local MP3 Files

Can play local mp3 files at any sample rate (8khz, 16khz, 44.5khz) in mono/stereo, re-sampling happens on the fly. (note: re-sampling can be expensive for the CPU)

Remote MP3 Files

session.streamFile("shout://some.server.com/file.mp3", "")

Icecast Streams

Can play icecast streams. TODO: example

Shoutcast Streams

?
< extension name = "shout" >
   < condition field = "destination_number" expression = "^750$" >
     < action application = "answer" />
     < action application = "playback" data = "shout://scfire-dll-aa02.stream.aol.com:80/stream/1074" />
   </ condition >
</ extension >
 
 
< extension name = "moh_for_bridges" >
   < condition field = "destination_number" expression = "^(15145555555)$" >
    < action application = "set" data = "hold_music=shout://scfire-dll-aa01.stream.aol.com:80/stream/1018" />
    < action application = "bridge" data = "sofia/default/$1@1.2.3.4" />
   </ condition >
</ extension >

Using shoutcast stream for MOH

To use shoutcast for moh you have to do three things.

NOTE: If you just use "hold_music=shout://url" you will have issues after the first time you place the call on hold.

  • You have to create a folder that contains a single file called "something.loc" with the url of the shoutcast stream. (shout://theserver:8111/the_stream.mp3)
  • You have to edit "autoload_configs/local_stream.conf.xml" to contain a stream that points to the folder you just created.
<directory name="moh/shout" path="$${base_dir}/sounds/music/shout">
    <param name="rate" value="8000"/>
    <param name="shuffle" value="true"/>
    <param name="channels" value="1"/>
    <param name="interval" value="10"/>
    <param name="timer-name" value="soft"/>
  </directory>
  • You have to set your "hold_music" variable to point to the local_stream that you just created. In this case that would be local_stream://moh/shout.
  • You may have to tweak the volume parameters if the hold music is too loud via autoload_configs/shout.conf
<configuration name="shout.conf" description="mod shout config">
  <settings>
    <!-- Don't change these unless you are insane -->
    <!--<param name="decoder" value="i586"/>-->
    <param name="volume" value="0.7"/>
    <!--<param name="outscale" value="8192"/>-->
  </settings>
</configuration>

Using mod_shout for TTS with online services

Using mod_shout for TTS is not recommend in a live environment due to lack of caching. For setup examples see http://wiki.freeswitch.org/wiki/Category:TTS#Via_mod_shout_using_online_TTS

Record Capabilities

Can record to local MP3 files.

Can record to icecast and/or shoutcast streams.

Caveats

Fast Forwarding / Rewind Bugs

Certain things like fast-forwarding and rewinding might not work especially if the mp3 is "badly encoded". If you need those features, one thing to try is to decode the mp3 to a wave, and re-encode it back to an mp3 in order to cleanse it of errors. If this still does not work, consider converting it to a wave and using it in that format.

 

Enable module in runtime

Edit /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml to add mod_shout to the list.

?
< load module = "mod_native_file" />
<!--For icecast/mp3 streams/files-->
< load module = "mod_shout" />          <------- NEW

Load the Module

from the CLI, run "load mod_shout"

Verifying

See Playing/Recording External Media for instructions on how to play an MP3 file into a conference call.

Debugging Problems

If its not working, try the following:

Configure libshout directly

Rather than relying on the overall configure script to invoke this, go to the src/lib/libshout directory and run configure directly. If you get an error like:


checking for libogg... not found
checking for VORBIS... checking for libvorbis... not found
configure: error: requisite Ogg Vorbis library not found

 

Delete lib directories

Also, try deleting both the libs/libshout-2.2.2 and libs/lame-3.97 directory and rerunning make.

Recording to Icecast server

To record to Icecast server from your conference or your call:


< action application = "record" data = "shout://source:pass@10.10.10.10:8000/stream.mp3" />

For conference, I do it from console:


conference 3001-10.10.10.10 record shout://source:pass@10.10.10.10:8000/stream.mp3


https://freeswitch.org/confluence/display/FREESWITCH/mod_shout


 类似资料: