Early Media and Music on hold

Source: Internet
Author: User

Early media refers to any media that's played to the initial caller's phone before the remote party have picked up the pho Ne. That "brrrrrrrring!" noise your hear before the person you called have picked up the phone was an example of early media.

That ringing noise was not actually the other person's phone, but a tone that's generated by the system that's setting up T He call. Theoretically that ring can be anything, including music or audio files.

Asterisk can set up calls while generating early media. In fact, the "R" flag in the Dial command tells Asterisk to generate the necessary tones for the "rrrrring!" audio.

Exten = S,1,dial (sip/flowroute/16466429000,30,r); <---that "r" flag would generate ringing while Asterisk was setting up the call.

One of the great things about Asterisk is, it tries to "abstract" out the notion of a phone call. In other words, virtually all of Asterisk's commands work, the same-out-of-the-regardless of whether, the actual call was SIP, IAX, H323, SS7, or any other crazy VoIP protocol.

However, this doesn ' t work perfectly in practice. Each VoIP protocol behaves in slightly different ways, and sometimes the conflicts with Asterisk commands. SIP and IAX would allow early media but others. Also, some VoIP providers would block early media and replace it with their own.

There is a couple of ways to use early media. The first-on IS-to-play a message before initiating the call. An example of this would is a message that says "Please stay on the line while I am complete that call" followed by ringing T He other caller ' s phone. The other-is-basically replace the preset ringing tone with an audio stream. An example might are to play music to the initial caller as the remote phone is ringing. As soon as the remote party picks up the phone the song would stop.

How to play early media to a caller before ringing the phone:

Exten = _1nxxnxxxxxx,1,progress () Exten = _1nxxnxxxxxx,n,playback (demo-abouttotry,noanswer) Exten = _ 1nxxnxxxxxx,n,dial (Sip/flowroute/${exten},30,r)
    • Progress () would let the phone system know, we are on to forward, the call to another line. This is a important for SIP calls and may be optional for IAX calls. Just to is on the safe side, use it whenever is about to generate early media.
    • Playback () needs to include the "noanswer", flag so, it won ' t automatically answer the channel when it plays the media. The remote phone won ' t ring until this audio file has fully played.
    • Dial () works as you would expect.

How to play early media to a caller while ringing the phone:

Exten = s,1,progress () Exten = S,n,dial (Iax2/ck987_iax,30,m (CK987_MOH))
    • Progress () would let the phone system know, we are on to forward, the call to another line. This is a important for SIP calls and may be optional for IAX calls. Just to is on the safe side, use it whenever is about to generate early media.
    • Dial () uses the "M (music_on_hold_class)" Flag to play back audio while generating the call. See below for information on what to set up Music on hold.

More information on Early Media

Music on hold

The most obvious use for Music on hold (or "MoH") is to give a caller something to listen to while they be on hold or in A queue. You can set up various Music on the "classes" in your musiconhold.conf files. Here's what the mine looks like:

[Ck987_moh]mode=filesdirectory=/home/ck987/asterisk_sounds/mohsort=random
    • mode=files means that this MOH class would use the audio files as its source.
    • Directory=/home/ck987/asterisk_sounds/moh tells Asterisk to play any file that's in the This directory
    • Sort=random would randomly play a file in this directory. The other option would is "alpha" which would go through the list in alphabetical order.

In your dialplan, you can set a channel's music on hold like this:

Exten = S,n,set (CHANNEL (Musicclass) =ck987_moh); <---Replace Ck987_moh with your MoH class.

If a SIP or IAX phone is placed on hold, the other caller should start to hear the audio defined by the active MoH class. There is a musiconhold () command which would force Music on hold to start, but you really should avoid the this command. If you want to play a audio file, use Playback or Background. Music on Hold is a service, that other commands can use. For example, Music on hold can is used to play "early media" to a phone while it tries to connect another phone. See above for more info.

Advanced:streaming External Audio for Music on hold
Don ' t try this unless it all makes sense to you!
A music On hold class can accept properly formatted audio streams as input. The audio must be 8000 Hz, with a bit, mono, PCM (uncompressed). The data is streamed through ' standard out ' (STDOUT).

When you make a class of uses an external process and do "module reload", it'll start the process at that exact mo ment. This means, which is sitting in the background, with the using up resources on the system. That's fine for a few streams, but could become an issue if there's a lot of them.

Here's a Music on hold class where I use an app called mpg123 to reformat and output the NPR Radio MP3 stream. Feel free to use the This class in your own Dialplans:

[Ck987_stream]mode=customapplication=/usr/bin/mpg123-q-R 8000-0-S Http://nprdmp.ic.llnwd.net/stream/nprdmp_live01_mp3
    • -Q stops the app from listing the name of the stream at the beginning of playback
    • -R 8000 Resamples the audio to 8000Hz
    • -0 uses only the "left" channel, which are fine since we need mono and NPR isn ' t in stereo. (-M would mix down a stereo stream to mono.)
    • -S sends the data to STDOUT
    • Http://nprdmp.ic.llnwd.net/stream/nprdmp_live01_mp3 is the URL to national public Radio ' s realtime MP3 stream.

Early Media and Music on hold

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.