login | register
Wed 01 of Aug, 2007 [09:13 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.

Web www.voip-info.org
Shoutbox
  • Aykut, Wed 01 of Aug, 2007 [07:53 UTC]: Hi all, does anybody know about Thomson ST2030 SIP phone. I have upgraded it to latest version (1.56) but "Hold" and "Conf" features are not working after the upgrade ?? Do you know any solution or do you have Ver. 1.52 ?? Where can I find it?
  • Edward J Brown, Tue 31 of Jul, 2007 [23:33 UTC]: Has anybody experienced Choppy voice quality when using a Linksys SPA942 in an Asterisk Conference bridge? It works fine with my polycom and Cisco, but sucks with my Linksys.
  • www.astawerks.com, Fri 27 of Jul, 2007 [18:00 UTC]: does anyone use asterisk on top of clark connect? does it work good?
  • simon, Fri 27 of Jul, 2007 [14:16 UTC]: Hi All, Has anyone here managed to get the Cisco79x1 to successfully fail over to the backup proxy. I have 2 asterisk servers , handsets all register and function, except that backup proxy function doesn't work. Any working example would be very apprecia
  • Matthew Richmond, Thu 26 of Jul, 2007 [03:40 UTC]: using the page() application to page across our building...often the meetme conferences don't disconnect after the caller hangs up. Anyone else having this problem. (using Polycom phones)
  • Matthew Richmond, Wed 25 of Jul, 2007 [02:58 UTC]: thanks Nicholas Blasgen! I haven't worked with AGI before, but there's always a first! Thanks again!
  • Nicholas Blasgen, Tue 24 of Jul, 2007 [19:18 UTC]: Matthew Richmond, AGI will handle all that for you.
  • sam, Mon 23 of Jul, 2007 [16:39 UTC]: need help - certain voicemail extension will stop working and recording voicemail on asterisk - anyone know why and how to fix it? Thanks
  • john haji, Mon 23 of Jul, 2007 [14:55 UTC]: free calls to pakistan
  • bong, Sat 21 of Jul, 2007 [19:09 UTC]: hi good day to all can anyone help me how to configured the nortel sip to the signaling server and how to activate in mobile w/ sip compatible without mcs
Server Stats
  • Execution time: 0.34s
  • Memory usage: 2.27MB
  • Database queries: 29
  • GZIP: Disabled
  • Server load: 3.57

Asterisk config musiconhold.conf

MusicOnHold Configuration

Asterisk 1.2

In Asterisk 1.2.x and above you no longer need to use the mpg123 player (which is good because its no longer developed and has known security holes).

Note (rcfa): the latest release is 15 January 2007, which looks like active development to me. For more information visit: http://www.mpg123.de/

Note (rchadwel): Format_MP3, Asterisk's mpg123 replacement, will play the MOH file from the beginning each time a caller is put on hold or each time the musiconhold command is invoked from extension.conf. If you have one file (mp3, ul, wav, raw, etc) as your source, they will hear the first part of it over and over again - driving them insane.

In order to use Asterisk's built in MOH playback support with the default MOH mp3 files (fpm-calm-river.mp3, fpm-sunshine.mp3, fpm-world-mix.mp3) you must have installed the asterisk-addons package! It contains a utility called format_mp3 which is required for mp3 playback.
Note: in Asterisk 1.4 the default file format is changed to wav which does not require format_mp3

File format

The format for this file has changed in Asterisk 1.2.
The format up to Asterisk 1.0 was with one line per class under the [classes] section
[classes]
classname => mode:directory,application

The new format in Asterisk 1.2 and above is with each class in it's own section, like this
[classname]
mode => mode
directory => directory
application => application

For using a streaming source, use the "streamplayer" tool that comes with Asterisk (see musiconhold.conf.sample for more info)
[default]
mode=custom
application=/usr/sbin/streamplayer 192.168.100.52 888
format=ulaw


Note (rchadwel): Streamplayer only works with a RAW TCP stream and will not stream from Shoutcast or Slimserver. For those you need to continue to use mpg123 or madplay.

Asterisk 1.2 Custom Applications

If you are using a custom application, you will need to ensure it outputs in mono, at 8kHz (samples/second), 8 bits per sample, in ulaw format.

madplay

application=/usr/bin/madplay -Qzr -o raw:- --mono -R 8000 -a -12

Note: you need to specify the full path to madplay (this may be /usr/local/bin/madplay on some systems)

Some users report success with snd (ulaw) output:
application=/usr/bin/madplay --mono -R 8000 --output=snd:-

madplay parameter meaning
-Q quiet mode
-z shuffle
-r repeat forever
-o raw:- 'raw' output to stdout
--mono convert to mono
-R 8000 8kHz sample rate
-a -12 amplify -12dB


Example using icecast & shoutcast streams

I use a one-line shell-script to run the stream. This has the advantage of being able to make changes without reloading or restarting Asterisk. Simply do a 'killall -9 ogg123 sox madplay' and the stream will restart automatically. I've also tested network interruption... the stream restarts automatically.
musiconhold.conf
[default]
mode=custom
dir=/var/lib/asterisk/mohmp3-empty
application=/etc/asterisk/mohstream.sh

mohstream.sh
Note: If you use the sox example, the first sampling rate (shown below as "-r 16000" ) will have to match the input stream rate. It's trivial to tweak this.
#!/bin/bash
#Uncomment one of the lines below, they both sound great:
/usr/bin/ogg123 -q -b 128 -p 32 -d wav -f - http://typical.icecast.net:80/moo.ogg| sox -r 16000 -t wav - -r 8000 -c 1 -t raw - vol 0.10
#/usr/bin/wget -q -O - http://another.icecast.net:8001/somemusic.mp3 | /usr/local/bin/madplay -Q -z -o raw:- --mono -R 8000 -a -12 -


Example using asx (mms://)(.wmv) streams. (or "anything" that mplayer can play).

Here is the script to play mms:// stream for MOH in Asterisk PBX (needs mplayer to be installed)
Thanks to Steve!

mohstream.sh
#!/bin/bash
if -n "`ls /tmp/asterisk-moh-pipe.*`" ; then
     rm /tmp/asterisk-moh-pipe.*
fi
PIPE="/tmp/asterisk-moh-pipe"
mknod $PIPE p

mplayer mms://stream.rfn.ru/mayak -really-quiet -quiet -shuffle -ao pcm -format 0x2000 -channels 1 -af resample=8000 -ao pcm:file=$PIPE | cat $PIPE
rm $PIPE


Servers using newer versions of mplayer, might have better luck using this to invoke mplayer:

mplayer mms://stream.rfn.ru/mayak -really-quiet -quiet -ao pcm:nowaveheader,file=$PIPE -af resample=8000,channels=1,format=mulaw | cat $PIPE


It's seems the format of command line arguments have changed with newever versions.


Pre-Asterisk 1.2 Information Below

Using madplay

If you want to keep the original distributed mpg321, you can use madplay to generate the mp3 in the same way that mpg123 does.

Just use a custom player like this one and you are done:
default => custom:/var/lib/asterisk/mohmp3/,/usr/bin/madplay --mono -R 8000 --output=raw:-

Installing mpg123

You must first compile and install mpg123. Make sure that you don't previously have mpg321 installed. You can do a "whereis mpg321" and an "rpm -q mpg321" if you are using RedHat.


--Edit Note(rchadwel): Version 0.59r is the best version to use with Asterisk - don't be tempted by 0.60x versions.

  • tar -zxvf mpg123-<version>.tar.gz
  • cd mpg123
  • as of May 2004 this note from the site front page seems to apply the current version, so you may want to make the suggested edit:
    • 16. Jan. 2003
    • Important information about the Gobble Exploit: It seems, that only the pre0.59s version is vulnerable. The hotfix is to increase the MAX_INPUT_FRAMESIZE to a big value. Ie 4096. I will review the whole code this weekend. I will also try to supply an mp3 checker this weekend. So it is not necessary to remove all your mp3s. Just do not play them with a potentially vulnerable player and check them later. Thanx.
  • type "make" to see a list of supported hardware platforms and operating systems, then type the make command that best fits your system.
    • If your make fails, try a "make clean" first. Also note that there is a "make linux-devel" which I needed to use to make it work (on debian 2.4.26-1-686 against devel sources) , YMMV.
  • If compilation was successful, type "make install" to install the binary and the manual page in /usr/local
  • ln -s /usr/local/bin/mpg123 /usr/bin/mpg123 << this creates a symlink in the /usr/bin directory, which is where asterisk searches for mpg123 (this should no longer be necessary as asterisk checks both)

Editing your files to enable MusicOnHold

  • In /etc/asterisk/zapata.conf, add the line "musiconhold=default" under [channels] context
  • In /etc/asterisk/musiconhold.conf, uncomment the line that says "default => mp3:/var/lib/asterisk/mohmp3"
  • You must restart Asterisk in order to reload the musiconhold.conf settings.

Specifying the Music

The sample music on hold file (/etc/asterisk/musiconhold.conf) will contain:
[classes]
;default => quietmp3:/var/lib/asterisk/mohmp3
;loud => mp3:/var/lib/asterisk/mohmp3
;random => quietmp3:/var/lib/asterisk/mohmp3,-z

Uncommment the 'default =>' line.
Then MP3 files in the directory: /var/lib/asterisk/mohmp3 will be played for music on hold. If there are multiple files in the directory, they will be played sequentially. Strip out the ID3 tags from any files you add to this directory with http://www.dakotacom.net/~donut/programs/id3ed.html.

Defining Your Own Music for Music On Hold

If you would like to have music of your choosing available for music on hold, create a subdirectory in the path /var/lib/asterisk/mohmp3, named what you want your class name for this music to be.

For example: I would like make the tune "Tip Toe Through the Tulips" available as hold music. I would create a folder named "Tiny_Tim" in the path /var/lib/asterisk/mohmp3. In other words, I would create the path /var/lib/asterisk/mohmp3/Tiny_Tim. Next, add the line:
Tiny_Tim => quietmp3:/var/lib/asterisk/mohmp3/Tiny_Tim
to your musiconhold.conf file. Next, I would put the MP3 file "Tip Toe Through the Tulips" in my newly created "Tiny_Tim" folder. I could also put other MP3 files in my "Tiny_Tim" folder, and the files would be played in sequential order. If I also had "It's a Small World" in the "Tiny_Tim" folder, the music on hold system would first play "It's a Small World", then "Tip Toe Through the Tulips", then (assuming the victim - er caller - was still there), loop back around and play "It's a Small World". The way you would specify what hold music would be used is by calling SetMusicOnHold() before your Dial statement, like this:
exten => 100,1,SetMusicOnHold(Tiny_Tim)
Exten => 100,2,Dial(Zap/2)

You can define as many classes of music on hold as you want using the example above with different class names and subdirectory names.

There is a post-1.0 patch pending to allow support of native formats other than mp3. See: http://bugs.digium.com/bug_view_page.php?bug_id=0002379

Error in MusicOnHold - Warning, flexibel rate not heavily tested!
This warning shows due to the coding method of your MP3 music. Variable bitrate is not supported by Asterisk (infact sometimes it won't play ANY music and will just mute your speakers, while letting the other caller STILL hear you), so use your favorite MP3 editing tool and convert the file to constant bitrate encoding. And since you are going to play this music through the phone you for sure won't need anything higher than 128 bit/s ...

# lame -b 128 input.mp3 output.mp3

Tutorials


Examples


Setup extension in extensions.conf to test MusicOnHold


[local]
; Answer required as Music On Hold does not answer the call (Updated By Matthew1471 to Answer)
exten => 6000,1,Answer
exten => 6000,2,MusicOnHold()


Shoutcast Music On Hold


You can have asterisk use a streaming source for on-hold music.

Make a directory and put a 0 size file ending in .mp3.
I called my directory: /var/lib/asterisk/mohmp3-empty

in musiconhold.conf, add a line such as:
default => mp3:/var/lib/asterisk/mohmp3-empty,http://www.waixwave.com:8000/


Alternative method --

The initial method seems to not work in 1.2 & +. You can use the method below, doing a custom application and calling mpg123, and specifying your shoutcast source.

default
mode=custom
dir=/var/lib/asterisk/mohmp3-empty
application=/usr/local/bin/mpg123 -q -r 8000 -f 8192 -s --mono http://213.186.41.160:8000/


Using native Asterisk format_mp3 for Music on Hold*


* In my experiance this does not work with the stable 1.x tree. I could only get it working with the CVS Head (Umar)

You may also use the format_mp3 module available within the asterisk-addons package. Simply download asterisk-addons and do a make; make install of /usr/src/asterisk-addons/format_mp3.

Make a directory called /var/lib/asterisk/moh-native.

Drop your MP3 files into the new diretory you created above.

Put this in your musiconhold.conf file:

[classes]
[moh_files]
default => /var/lib/asterisk/moh-native

If you want random playback order, add ",r" to the end of your lines, like this:

[classes]
[moh_files]
default => /var/lib/asterisk/moh-native,r

Be sure to remove mpg123 from your system (this may attribute to 'Request to schedule in the past!?!?!' messages). Now you are set!

For Asterisk 1.2 or greater i suggest:
[default]
mode=files
directory=/var/lib/asterisk/moh-native
random=yes


Note: It was previously required with format_mp3 that you convert your mp3 files as follows:

lame -q -p --mp3input -a --preset 8 -m mono in.mp3 8kout.mp3

It appears per bug report 3316 these audio format may actually be causing an Asterisk segmentation fault, this is being investigated. It appears that mp3 files not formatted in this way work fine and that the above conversion is no longer necessary.



Answer and then Hold IAX clients


After a bit of googling i figured out how to enable hold feature with music in asterisk. You need to open up the iax client library and send quelch/unquelch with music on hold.If you figure out what quelch is, it is easy to send the command. Once asterisk recieve the command it will put the channel in hold. The music is from the default context of musiconhold.conf.
 
Thanks,
boneyM


Using a sound card as the source.


This is usefull for such things as FM tuners or other external audio feeds (XM Satellite Radio anyone?).

1. Add the following into musiconhold.conf:

[default]
mode=custom
directory=/var/lib/asterisk/mohmp3
application=/usr/sbin/ast-playlinein

In /var/lib/asterisk/mohmp3 therre should be at least one mp3 file.

2. Create script file /usr/sbin/ast-playlinein and make it executable:

#!/bin/bash
/usr/bin/arecord -q -c 1 -r 8000 --buffer-size=2048 -f S16_LE -t raw

3. Then you need to configure your mixer to turn on LINE-IN capturing.
You can then plug into the line-in port your FM-tuner or external audio player.

Don't forget to reload (should be enough) asterisk.

Additional note by crees (at) bearrivernet (dot) net
Trixbox users may notice that this does not work. Your MOH will start and stop immediatly. This is due to asterisk not having rights to the /dev/snd folder and files. You will need to create a new group (i called audio) and then allow root and asterisk to be part of it. then chmod the directory so everyone can have access to read and write these files. (in /dev/snd ) You then will need to adjust the mixer via alsamixer command. I ended up using the mic in on my sound card since line in on mine was not working. Look for the line in capt and line in or mic in , mic capture levels and adjust them accordingly. You may want to unmute (pushing m on slider) and move all sliders up and see which one controls the volume.




See also



Asterisk | Configuration | FAQ
Created by oej, Last modification by Martin Swaczyna on Thu 26 of Jul, 2007 [12:00 UTC]

Comments Filter

Aastra 480I and MOH stopping

by ianplain on Tuesday 20 of March, 2007 [20:40:45 UTC]
Hi
I have started getting complaints that native MOH would stop playing to held callers.

On investigation this seemed to be linked to the sip message
"Using INVITE request as basis request -"

So this seems to tie in with the session timer. and by adding sip session timer = 0 to the aastra.cfg and rebooting the set has solved the problem.

With this new version, is it always random?

by Luis Vazquez on Saturday 13 of January, 2007 [14:15:43 UTC]
Please use comments section for questions and responses!!
Question: With this new version, is it always random? I think so, but not 100% positive.
Matthew1471 : No it's not always random.. for random add
random => yes

e.g.
[default]
mode => files
directory => /etc/asterisk/musiconhold
random => yes


by Blumagic on Friday 27 of October, 2006 [03:01:17 UTC]

Re: Music on Hold Immediately Stopping

by Blumagic on Friday 27 of October, 2006 [02:53:22 UTC]
Yea I figured it tonight... Maybe had some lost bus due to silent-hangups but what ya gonna do?

I'll tell you what you do:
1. Make sure your asterisk user has read access to the files/folder
2. Set your moh conf up as mentioned above
3. Go into asterisk -r and do 'reload res_musiconhold.so' and a 'moh reload'
4. Then do 'moh classes show' and ensure your classes took correctly
5. Then do 'moh files show' and ensure your files are set correctly for each class
6. Finally, call your pbx and check that moh is working, or you'll get hangups everytime!

Using Soundcard

by www.astawerks.com on Wednesday 30 of August, 2006 [14:35:20 UTC]
I followed the instructions above to stream audio fromn a radio through the soundcard but it does not seem to work. I am using Trixbox 1.1.1 has anyone been able to do this?

music on hold for answered call

by boneym on Tuesday 22 of August, 2006 [10:30:49 UTC]
After a bit of googling i figured out how to enable hold feature with music in asterisk. You need to open up the iax client library and send quelch/unquelch with music on hold.If you figure out what quelch is, it is easy to send the command. Once asterisk recieve the command it will put the channel in hold. The music is will be from the default context of musiconhold.conf.
  
Thanks,
boneyM

Music on Hold Immediately Stopping

by Mike on Thursday 20 of July, 2006 [07:25:32 UTC]
Anyone figure out how to fix this problem? I've seen it asked several times, but never answered.

-- Executing Answer("SIP/1001-b7e073c8", "") in new stack
   — Executing Wait("SIP/1001-b7e073c8", "1") in new stack
   — Executing MusicOnHold("SIP/1001-b7e073c8", "") in new stack
   — Started music on hold, class 'default', on channel 'SIP/1001-b7e073c8'
   — Stopped music on hold on SIP/1001-b7e073c8

The music on hold just stops right after it starts. I never hear any music onthe phone.

Any help would be greatly appreciated. My e-mail address is mazarian@gmail.com

Thanks,
  Michael

Re: Streaming radio music on hold

by Steve on Tuesday 14 of February, 2006 [09:38:29 UTC]
I wanted to use mplayer because mpg123 wasn't outputting in the right format — old version or something. So I came up with a way to use mplayer. This script doesn't clean up properly if you 'moh reload', but otherwise it seems to work ok. Put the following in a shell script, make it executable, and set it as the custom application:

#!/bin/bash
if [ -n "`ls /tmp/asterisk-moh-pipe.*`" ]; then
       rm /tmp/asterisk-moh-pipe.*
fi
PIPE="/tmp/asterisk-moh-pipe.$$"
mknod $PIPE p

mplayer -really-quiet -nowaveheader -quiet -shuffle -ao pcm -format 8192 -channels 1 -af resample=8000 -aofile $PIPE "$@" 2>/dev/null | cat $PIPE 2>/dev/null

rm $PIPE

--
Steve

Streaming radio music on hold

by Trond Solem on Monday 30 of January, 2006 [13:11:34 UTC]
I have tried to get streaming radio broadcast as source for MusicOnHold, but these days many of the streams are in the ASF format.
This complicates this project a bit since I can't find a suitable player. <br><br>

I have tried mplayer, but it won't play to standard output. I also outputs some lines of text before starting the play.<br>

mpg123 will play mp3 streams, but that isn't exactly what I am looking for. <br><br>

Anyone who has a solution to this?

Native MOH does not rotate

by Chip Schweiss on Wednesday 25 of January, 2006 [18:19:15 UTC]
When using Native MOH the playback starts in the same place for each caller. If they call again they will hear the same MOH from the beginning. The random setting doesn't help the random order is picked when MOH is loaded.

This may be good if you want every caller to hear the same MOH, but not if you want callers to be exposed to different MOH files every time they call.

Please update this page with new information, just login and click on the "Edit" or "Add Comment" button above. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

Sponsored by:

Terms of Service Privacy Policy
© 2003-2007 Arte Marketing, Inc.

Powered by bitweaver