How to disable codec transcoding?

Hi everyone!

I use Asterisk 1.4 + FreePBX on Ubuntu x64 10.04.3.

My question is: How can I set Asterisk/FreePBX, so it passes through SDP and RTP? How to disable any codec transcoding?

Now I have some SIP extensions and some SIP trunks defined in FreePBX. Everything works ok, I can make calls.
But now it works this way: if “extension-Asterisk” leg has different codec-preference than “Asterisk-trunk” leg, Asterisk transcodes the audio. It causes big CPU load.

I would like to disable such functionality, and force Asterisk to simply pass-through codec order and description (SDP) from extension to trunk. This way Asterisk would simply pass the RTP from extension to trunk, without transcoding it.

How to achieve it?
Thank you!

If you want to pass through SDP, you should use a SIP proxy. Asterisk is a back to back user agent.

Transcoding only uses a lot of CPU if one or both codecs are low bit rate ones.

Asterisk will try not to transcode, and will not transcode if you force the selection of all codecs, monitoring formats, voice recordings, musiconhold, etc. to be the same, don’t generate any tones within Asterisk itself, and don’t expect Asterisk to watch for DTMF in band (rather than INFO or RFC 2833). One thing that catches people out is Originate/call files, which will default to a signed linear 8kHz 16 bit format.

To have the RTP bypass Asterisk entirely, you must set directmedia to yes (canreinvite on the unsupported version you are using). You must also ensure that you don’t try and monitor the call, use conferencing, expect Asterisk to look for DTMF, not just in band.

Thank you for your answer. I am very unhappy that Asterisk can not act as RTP-proxy.

I did a lot of experiments since your last answer. Unfortunatelly I suppose, that Asterisk always transcodes RTP stream, even if codec on both channels is the same. I tried different scenarios:

  • caller uses G729b, trunk to VoIP supports G729b, but Asterisk doesn’t support it, so it transcodes it to G729 (a) and channel to VoIP provider is G729 (not b)
  • caller uses G729, trunk to VoIP provider uses G729, there should be no transcoding, but there is big CPU load anyway
  • both sides use GSM, but CPU load is bigger than using alaw/ulaw
  • the only way to decrease CPU load is to use alaw/ulaw. But this solution requires much bigger network bandwidth.

I use this Asterisk with A2Billing. I have none of ‘‘t’’, ''T", “h”, “H”, “w”, “W” or “L” in Dial command. I set canreinvite=yes.
I have about 150 active calls in peak. Server has 1xDualCore Xeon 2.33 GHz. During the peak time CPU load is about 70% when all channels are alaw. When I change some channels to for example GSM, CPU increases.

That is why I think Asterisk always transcodes bridged channels… unfortunatelly. Or not transcoding causes the CPU load, but simply big network traffic.
What about canreinvite=update?

Asterisk can RTP proxy. What it cannot do is SIP proxy, which is what is required to pass the SDP through unchanged.

Asterisk definitely does not transcode unless it needs to.

We rely heavily on directmedia, which it does do properly, including for G.729.

Where you might get caught out is with Originate or call files. By default, both legs are started with a signed linear codec. If you want to avoid transcoding in that case, you must specify a suitable codec with the respect to both sides.

I’m not familiar with A2Billing, but it may well be that the problem lies with that. Do you do callbacks? As well as callbacks, it is possible that it de-optimises the call in order to get better call detail records.

Hi david55,
I’ve got a similar doubt: I’m using an application to get moh and in the musiconhold.conf file i set “format= ulaw”. If my devices in a meetme conference also support ulaw (and sdp decides so) asterisk won’t do any treatment to the stream coming from the application? or it would decode it and encode it again?

And in the case it does nothing, could I use this feature to do a little trick:
If my end devices support 8 bit 24 kHz codecs and I’m able to get that output stream in the application, would it work fine? Would there be any speed problems ?

I know it’s kind of weird but, I’d like to get the quality a little better!

If the device uses SDP (e.g. SIP), Asterisk will tell the device which codec it actually thinks you are using.

At the very least you will need to write a format module for the codec, and add the codec name to the right places in the source code. The format module knows how to parse the actual media stream out of the file, and how to wrap the media stream to form the RTP packets.

in the source code, is there any “.h” file where all the supported formats are listed? or I just make it listing all the format_xxx.c files that are in the formats directory?

Use grep. I believe there is a bit map of codecs.