Setting up rtpengine with Kamailio for transcoding
In my previous posts, you will have discovered the power of rtpengine, from the installation procedure to the configuration for using it with kamailio. Here we will go further into the functionality of rtpengine, using it as an audio transcoder, i.e. to adapt the audio streams generated by two RTP endpoints that use different audio codecs.
For my test scenario I will use a client which proposes PCMU, GSM, G729 and OPUS as codecs, while the target only supports PCMA. Kamailio with rtpengine is in the middle handling both SIP traffic and RTP audio, and specifically transcoding between PCMU and PCMA.
rtpengine at work
First we can check the codecs supported by rtpengine using the command rtpengine --codecs
.
# rtpengine --codecs
PCMA: fully supported
PCMU: fully supported
G723: fully supported
G722: fully supported
QCELP: supported for decoding only
G729: fully supported
G729a: fully supported
speex: fully supported
GSM: fully supported
iLBC: not supported
opus: fully supported
vorbis: codec supported but lacks RTP definition
ac3: codec supported but lacks RTP definition
eac3: codec supported but lacks RTP definition
ATRAC3: supported for decoding only
ATRAC-X: supported for decoding only
EVRC: supported for decoding only
EVRC0: supported for decoding only
EVRC1: supported for decoding only
AMR: fully supported
AMR-WB: fully supported
telephone-event: fully supported
CN: fully supported
PCM-S16LE: codec supported but lacks RTP definition
PCM-U8: codec supported but lacks RTP definition
MP3: codec supported but lacks RTP definition
Once we are sure that the codecs we need are supported, all we have to do is modify the Kamailio configuration to enable rtpengine with transcoding capabilities. In particular, the rtpengine_manage() function must contain specific parameters to activate transcoding.
if (has_body("application/sdp")) {
rtpengine_manage("codec-mask-all codec-transcode-PCMA codec-transcode-telephone-event");
}
In this case we are configuring the system to pass the media control to rtpengine, which will use PCMA and telephone-event codecs on the destination leg, and negotiate one of the proposed codecs on the incoming leg.