userdoc:tt_external_moh_source

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
userdoc:tt_external_moh_source [2014/02/18 08:22]
droemel [Internet Streaming]
userdoc:tt_external_moh_source [2014/02/19 06:44] (current)
abelbeck [Internet Streaming]
Line 85: Line 85:
 ===== Internet Streaming ===== ===== Internet Streaming =====
  
-You can also easily stream music over the Internet/LAN for MOH with sox:+You can also easily stream music over the Internet/LAN for MOH with sox.  The ''ast-stream-mp3'' script directly supports MP3 streams or MP3 streams indirectly via a ''.pls'' playlist. 
 + 
 +Create file: ''/mnt/kd/bin/ast-stream-mp3'' 
 + 
 +  #!/bin/sh 
 +   
 +  # Set VOLUME variable to linearly multiply the volume by a number. 
 +  # Value: "0.8" is 80%, "1.2" is 120%, default is "1.0" when not defined. 
 +  VOLUME="0.8" 
 +   
 +  URL="$1" 
 +  if [ "$URL" != "${URL%.pls}" ]; then 
 +    PLAYLIST="$(wget -q -O - $URL)" 
 +    if [ $? -ne 0 ]; then 
 +      sleep 10 
 +      exit 1 
 +    fi 
 +    URL="$(echo "$PLAYLIST" | sed -n -r -e 's/^File[0-9]*=(.*)$/\1/p' | head -n1)" 
 +    if [ -z "$URL" ]; then 
 +      sleep 10 
 +      exit 1 
 +    fi 
 +  fi 
 +   
 +  if [ -n "$VOLUME" ]; then 
 +    FOPTS="-v $VOLUME" 
 +  else 
 +    FOPTS="" 
 +  fi 
 +   
 +  wget -q -O - $URL | sox -t mp3 $FOPTS - -t raw -r 8000 -c 1 - 
 + 
 +Make the "''/mnt/kd/bin/ast-stream-mp3''" file executable: 
 + 
 +  chmod 755 /mnt/kd/bin/ast-stream-mp3 
 + 
 +Edit the Asterisk configuration file "''/etc/asterisk/musiconhold.conf''" and add this context:
  
-musiconhold.conf: 
   [internet-stream]   [internet-stream]
   mode=custom   mode=custom
-  application=/mnt/kd/bin/stream-mp3.sh http://wnycfm.streamguys.com:80/+  application=/mnt/kd/bin/ast-stream-mp3 http://wnycfm.streamguys.com:80/
  
-/mnt/kd/bin/stream-mp3.sh+!!Note ->!! The example MP3 source URL shown above is only an example, and does not imply it is legal to use for MOH in your country Choose a MP3 source URL carefully. 
-  #!/bin/bash + 
-  wget --${1} | sox -mp3 - -t raw -r 8000 -c 1 - +Reload the Asterisk MoH module: 
-  + 
 +  asterisk -rx "module unload res_musiconhold.so" 
 +  asterisk -rx "module load res_musiconhold.so" 
 + 
 +!!Tip ->!! Never edit the ''ast-stream-mp3'' script without first unload'ing res_musiconhold.so .
  
  • userdoc/tt_external_moh_source.1392733378.txt.gz
  • Last modified: 2014/02/18 08:22
  • by droemel