Allow media to bypass asterisk

Hi guys,

I am finding this super confusing!

How do i configure asterisk so that media is directly connected between 2 endpoints without having asterisk in the way?

My setup like this:

Phone A + Asterisk <=> NAT <-> INTERNET <-> NAT <=> Phone B

How would i achieve this?
The reason i would like to do this is G722 is supported on both phone A and B , but i dont want the asterisk server to transcode.

directmedia=yes, and don’t use any features (monitor, features transfer, etc., etc.) that requires Asterisk to inspect the RTP.

In this case you will also need an unusually NAT aware router, as the router will need to rewrite the SDP to use the external address and translated port number of the phone. I think you may find that this is difficult to achieve. Asterisk can only compensate for NAT in relation to its own address.

Note that Asterisk should not transcode, if G.722 is the preferred or only codec for the incoming leg.

Thanks, does that mean if i use a phone to initiate a call using only g722 as the only codec asterisk should just let it go straight to the end point?

If the end point also supports G.722, it should not translate. If you meet the conditions for direct media, but don’t enable it, Asterisk will do packet to packet bridging, where it will simply relay the RTP packets, unchanged.

I’m not 100% sure, but I think it might do packet to packet bridging even if G.722 wasn’t the first choice on the incoming side, as long as it is the only one in common.

Thanks for your reply David,

I am using Freepbx, i am not sure where i can configure directmedia, but when i force my phone to use only G722, the other side can pick up and converse without problems, BUT the sound quality is really bad when i use G722 it cuts in and out compared with uLaw or alaw , these two work without issues.

I am wondering if this is because the processing that is happening on asterisk is causing the choppiness or because G722 just doesn’t go well with the latency that i have between the asterisk and phone B is about 300-400ms.

That delay is too long for comfortable use of any codec! Jitter, however, is what will cause poor audio quality (other than echo).

For configuring FreePBX, you need to ask on a FreePBX forum, but note that directmedia used to be called canreinvite.

It is also quite likely that FreePBX uses Dial options that require Asterisk to inspect the RTP stream and are therefore incompatible with native bridging, whether external (complete bypass) or packet to packet. In particular, it may enable “features.conf” syle transfers.

Yes, i would agree as well, but it seems to sound “Okay” when i am using alaw or ulaw.

When i use the sip show channels command, i see it using alaw for phone a and alaw for phone b sounds good.

When i use the same command and it says G722 on one side and alaw on the other side.

Does that mean it is transcoding?

What is the asterisk cli command for checking if transcoding is taking place?

There is no specific command to detect transcoding. If the outgoing codecs on the two sides are different, it is likely that there is transcoding. If you have recording in a different format, there will be transcoding (and bypassing is impossible.

Note that transcoding can, in theory go on and off without any further SIP interactions, if you give a choice of codecs. Asterisk negotiatees acceptable codecs, but it is the remote party that selects which acceptable codec to actually use, and change it just by changing hte codec ID in the RTP.

Actually, I think there is enough information in core show channel xxx to determine whether transcoding is happening on that channel. I think it is the outgoing channel for a direction that will show the transcoding. You will have to trace through any local channels, etc.