Early Media
About
The concept of "early media" can sometimes confuse those new to telephony. RFC 3960 defines it this way:
Early media refers to media (e.g., audio and video) that is exchanged before a particular session is accepted by the called user. Within a dialog, early media occurs from the moment the initial INVITE is sent until the User Agent Server (UAS) generates a final response. It may be unidirectional or bidirectional, and can be generated by the caller, the callee, or both.
The expression "early media" seems to be quite SIP-oriented but the concept of early media is not. Everyone who has ever used a telephone and heard a ring signal or a busy signal is familiar with the concept of early media. Circuit-switched telephony used the term 'supervision' to indicate start of billing and beginning of the telephony session (connection). In simple terms:
Early media is the exchange of information before establishment of a connection
The best way to illustrate that is by looking at a traditional telephone call where party A calls party B:
- Party A picks up her phone, hears dial-tone, and enters a phone number
- After a few moments, she hears ringing. (This is "early" media because the call hasn't been answered yet)
- Meanwhile party B's phone starts to ring
- After a few rings, party B picks up, and a call is established.
- Party A and party B can now hear each other speak.
Another good example is what happens on a busy signal. Using the same parties from the previous example:
- Party A picks up her phone, hears dial-tone, and enters a phone number
- After a few moments, she hears a busy signal. (This is "early" media - no call has been established)
- Party A hangs up
The busy signal is an audible signal - a form of audio media if you will - that lets the calling party know that the call has not gone through. It is an unconnected call, but it still had sound. In a case of per-call billing, this call would not be billed (usually) because it was never connected. The same holds true for calls that are ring/no answer. It even holds true for calls to disconnected numbers where you hear the Special Information Tones (SIT) and a recorded message.
Click here to expand Table of Contents
- 1 Triggering early media
- 2 Early Media And Dialing Out
- 2.1 A "Successful" Call Attempt
- 2.1.1 Ignoring Early Media
- 2.1.2 Ignoring Ring Ready (180)
- 2.1.3 Monitoring Early Media
- 2.1.1 Ignoring Early Media
- 2.1 A "Successful" Call Attempt
- 3 Early Media and "Late Negotiation"
- 4 Troubleshooting
- 5 See also
Triggering early media
On an inbound call you can execute pre_answer to trigger early media. After this you can do ringback, play a file or whatever.
Early Media And Dialing Out
FreeSWITCH has many options for handling early media. The one to use will depend greatly on your needs. By default FreeSWITCH "listens" for early media and acts accordingly. You may also ignore early media altogether. Finally, there is new hybrid functionality that can offer some of the benefits of both listening to and ignoring early media.
A "Successful" Call Attempt
In the default mode, a call attempt is "successful" if it returns early media. Conversely, if the call does not return early media at all or returns some specific error then the call attempt is not successful. Consider some examples:
- Ringing - successful
- Busy - successful
- Invalid phone number - unsuccessful
- All circuits busy - unsuccessful
As you can see, there is a difference between successfully attempting a call and successfully connecting a call.
Ignoring Early Media
In some cases you don't care whether the call attempt was successful - you simply need to know if the call was connected or not. In those cases, it is possible to ignore early media when dialing.
{ignore_early_media=consume}sofia/internal/user@domain
If you want block early media from remote end then
{ignore_early_media=true}sofia/internal/user@domain
Without ignore_early_media, the originate will be considered success when it gets early media.
Ignoring Ring Ready (180)
You can ignore ring ready (180) but still "react" when receiving a 183 with media:
{ignore_early_media=ring_ready}sofia/internal/user@domain
ignore_early_media=ring_ready works the same way as ignore_early_media=true, but it also sends 180 to the inbound leg when the first 183 is caught.
Monitoring Early Media
As of FreeSWITCH 1.0.3, a new method is available: monitoring early media. As its name implies, it does not ignore early media outright, nor does it assume any early media is a successful call attempt. See:
Early Media and "Late Negotiation"
Stub - more to come
Troubleshooting
- Be certain that you have inbound-bypass-media turned off
See also
- ignore_early_media channel variable
- draft-barnes-sip-em-ps-req-sol-00 - Early Media in SIP: Problem Statement, Requirements, and Analysis of Solutions