How to enable direct media in asterisk?

I have been trying to have direct RTP handover between extensions without relaying via Asterisk. For this, I have enabled directmedia(given “yes” to can reinvite) in the extension’s advanced settings, in Advanced Settings and Advanced SIP settings. ICE is also enabled for extension.

This is my freePBX version : FPBX-13.0.74(13.7.0)

But the audio is still transferring through the asterisk. How can I enable direct RTP communication between my extensions?

Asterisk uses directmedia if the conditions allow it. codec mismatched monitoring, use of DTMF features, and many others reason will not allow direct media, and note careinvite it is deprecated option

I appreciate your quick response. Is there any way to identify the condition that won’t allow directmedia?

Dont think direct media will work on freepbx if you dont tweak it, start by checking on general settings the options on the dial command, setting Tt on Dial will inhibit direct media, also make sure you dont have call recordings enabled, I already described the options who could limit asterisk to use direct media, so now you need to find on your system if these are enabled or not

As you said I have removed “Tt” in Asterisk Dial Options and added “r”.
Recording not enabled in asterisk.
There are no DTMF features enabled.
Both extensions are having same sets of audio codecs, no codec mismatch found.

Still the RTP packets are going via Asterisk. Why?

canreinvite is an obsolete name for directmedia. You may have a conflict between the two names for the option.

Direct media will only work if the peers support it.

There are things that FreePBX might do, like leaving in local channels, but we know little about FreePBX here.

Apart from that, you are going to need to enable the full log, and set verbosity and debug to at least 5, and enable the protocol debugging option for your SIP channel driver.for us to get a good idea why it is not externally bridging.

Hi Arun,
Im running through the same issue for Media Bypass in Asterisk.

Below are the current configurations in my PBX:

• PBX users and SIP trunk are configured with same codecs (g711alaw & g729).
directmedia is set to yes .
• Removed “ Tt ” from Asterisk Dial Options
• Monitoring and Recording has disabled
canreinvite is set to yes for users and trunk
• NATing is not used here.

Still Media is anchored by PBX.

If we apply directrtpsetup in Asterisk SIP settings, PBX will bypass the media. But directrtpsetup is not officially supported by Asterisk.
If you got it worked, could you please help me out here

You appear to be using chan_sip, although you haven’t said that.

canreinvite is a (deprecated) synonym for directmedia, so it is confusing to specify both.

T and t are not the only options that are incompatible with directmedia.

You need to enable the debug log and turn up the debugging level, to get a clue as to why an external native bridge is not being created.

yes, Im using chan_sip channel.

I tried by setting canreinvite = no . Same observation.

Will collect the logs using “core set debug 4”

The last one of directmedia and canreinvite wins. Remove the canreinvite entirely and just use directmedia. Anything else is just confusing.

Please obtain detailed debugging logs if you want further. At the very least provide minimally redacted complete sip and dialplan configurations.

Please confirm that there are no options at all on your Dial application calls.

Also, please confirm that the destination actually answers the call, as direct media will not be engaged until after answer.

Please find the attached logs and SIP configurations.
Yes, dial plan options are empty.
Please let me know, if you want any more logs or configuration details.
Regarding logs: Calling party: 1004 (6.5.93.160), Called Party (12142425989), PBX IP: 6.5.93.2 and trunk IP:10.64.1.72.configurations.txt (966 Bytes)
logs.txt (726.3 KB)

You are using FreePBX. We don’t know the details of their complex dialplans, or the limits on reconfigurability. For peer support, you need to ask your question on https://community.freepbx.org/

Note that you missed extensions.conf from your configuration files, but we wouldn’t have been able to make use of it, anyway.

It looks like this is the final straw: SIP/trunk_to_10.64.1.72_out-0000009b’ has DTMF hooks

My guess is that the FreePBX subroutine, invoked with the b option, is frustrating direct media. directrtpsetup probably doesn’t understand DTMF hooks, so fails to come out of direct media mode.

Hi David, I got Media Bypass working in asterisk after I set DTMFmode to SIP INFO.

If we set directmedia=yes & DTMFmode=RFC2833, Asterisk do not bypass media?

I got a customer requirement where PBX should bypass the media and they also want DTMF (RFC2833) support in PBX.
Please confirm.

As I said, that will be because FreePBX is requesting DTMF be monitored. INFO uses the signalling channel, rather than the the media channel, so DTMF can be detected even when Asterisk is not seeing the media and there is no need to retain the media stream.

In general, though, people only use RFC 4733 (Asterisk rfc2833) these days.

As previously noted, the directrtpsetup logic and the DTMF hook logic probably don’t know about each other, so directrtpsetup allows the DTMF Hook to be broken, losing whatever functionality FreePBX was using it for.

Thank you for the clarification!