Codecs and Media
About
A codec is an encoding and compression scheme for a media stream or file format. The term is an acronym derived from COding and DECoding. See this article for more technical information: http://en.wikipedia.org/wiki/Codec. FreeSWITCH™ has provisions for bypassing the media server altogether to save bandwidth and load on the server as well as proxy media in cases where a particular codec is not supported; this allows devices to exchange media directly between them.
Click to expand Table of Contents
- 1 HD Audio support
- 2 Enabling codecs in modules.conf.xml
- 3 dingaling.conf.xml file
- 4 sofia.conf.xml file
- 5 Media proxying
- 6 Codecs offered by Proxy_Media
- 7 See Also
HD Audio support
FreeSWITCH supports most HD (high definition) audio codecs including Speex, G.722, G.722.1 (Siren) and SILK. BroadVoice codecs were added by Brian (bkw) just 90 minutes after official release.
Enabling codecs in modules.conf.xml
FreeSWITCH supports a large number of VoIP compression codecs out of the box, however the default config does not enable them all for all transport types. Codecs are built from various modules and from the core FreeSWITCH source (no need to load modules for core codecs, they are in CORE_PCM_MODULE, e.g. they're built into the core of FreeSWITCH). For codecs not in core, you need to compile and load the corresponding module.
Some codecs are encumbered by patents, therefore they are not open source and can not be distributed directly. Licenses are available for purchase where applicable.
Executing the fs_cli command "show codec" displays the enabled codecs.
The vars.xml file contains the the following lines that globally control which codecs are negotiated with remote endpoints:
<X-PRE-PROCESS cmd="set" data="global_codec_prefs=G722,PCMA,PCMU,GSM"/>
<X-PRE-PROCESS cmd="set" data="outbound_codec_prefs=G722,PCMA,PCMU,GSM"/>
Note: iLBC@30i configures the iLBC codec to default to 30ms frames instead of 20ms frames which will allow you to receive iLBC calls from Asterisk servers which unfortunately do not correctly send their iLBC codec preferences.
Most transports (channels) have a config block at the top of their configuration file like the following:
<settings>
<param name="codec-prefs" value="XXXXXXX"/>
</settings>
Note: There are generally other lines inside the <settings> block, but you can safely ignore them for now.
dingaling.conf.xml file
The default dingaling.conf.xml config contains the following (codec related) settings:
<settings>
<param name="codec-prefs" value="PCMU"/>
</settings>
While you may use almost any codec you wish when using dingaling to talk between two FreeSWITCH servers, the official Google Talk(tm) client has some very peculiar quirks in its codec handling.
sofia.conf.xml file
The default sofia.conf.xml config contains the following settings related to codecs:
<settings>
<param name="inbound-codec-prefs" value="$${global_codec_prefs}"/>
<param name="outbound-codec-prefs" value="$${global_codec_prefs}"/>
</settings>
This allows Sofia-SIP to inherit the global_codec_prefs which we configured in vars.xml. It's best to leave it that way, however you may manually specify a codec list if you wish.
Media proxying
FreeSWITCH can proxy media between endpoints if is NATed or you want to reduce usage of your CPU
Benefits of proxy media
- Lower CPU usage*
- N.A.T. handling (RTP Side)
- Pass–through not supported Codecs like G721, G728, G719, AMR and some other codecs*
- Video conferencing through external MCU
Codecs offered by Proxy_Media
- PROXY PASS-THROUGH to pass audio media in proxy mode
- PROXY VIDEO PASS-THROUGH to pass video media in proxy mode
See Also
- Audio Codecs
- mod_fsv
- Codec Negotiation
- Proxy Media
- Bypass Media
- Proxy Media (Variable)
- Daala codec — YouTube of Linux 2015 Conference presentation of Daala codec project, includes nice graph at 7:20 plotting capabilities versus bandwidth of various audio codecs