[SOLVED] How to disable directmedia in all pjsip endpoints

Hello,

By default pjsip extensions are configured with directmedia=yes. Now I need to disable this option because I need the RTP streams going through the pbx, but I can’t find any parameter in Freepbx to do it.
Also I tried to find a global parameter in pjsip.conf to disable it but directmedia parameter is only accepted as individual endpoint parameter and I can’t rewrite them because they are automatically generated by Freepbx.
Can you help me?

I’m using Freepbx 14 - Asterisk 13

Thanks in advance,

Direct media defaults to no for trunks. I believe that pjsip is smart enough not to attempt direct media if the call is recorded, transcoded, encrypted, monitored for DTMF or if the extension is behind a NAT.

So you should only see direct media on internal calls with both endpoints on your LAN, when the PBX does not need to monitor the audio at all.

Is direct media being used inappropriately? Or, do you have a special requirement, e.g. capture all packets with tcpdump for later analysis?

Hi Stewart,

I need to capture all RTP packets for recording purposes. I’m using a 3rd party software to record calls capturing SIP and RTP on Asterisk interface.
There is another scenario where is needed disable directmedia. It is when, for example, two extensions belongs to two differents networks not routed between them, in this scenario, with directmedia=yes audio can’t be routed directly between endpoints and is mandatory to go through Asterisk.

Thanks,

Hi,

No one has this need? I think it’s not uncommon the need to endpoint voice trafic going throught Asterisk interface.

Regards,

Asterisk is a Back to Back User Agent, so all media is routed through the PBX unless specifically directed to use Direct Media. You are asking us how to enable a feature that is the default.

Hi Dave,

Default value for directmedia parameter in pjsip is ‘yes’.
From pjsip.conf.sample:

;direct_media=yes ; Determines whether media may flow directly between
; endpoints (default: “yes”)

After configuring a new pjsip extension, a ‘pjsip show endpoint 106’ shows:

direct_media : true
direct_media_glare_mitigation : none
direct_media_method : invite
disable_direct_media_on_nat : false

I’ve made several packet captures and I can say that, by default, the media goes directly between endpoints.
I found a workaround configuring direct_media parameter in pjsip.endpoint_custom_post.conf for each endpoint available.

[106](+)
type=endpoint
direct_media=no

After doing this, I can see the change in the endpoint

direct_media : false
direct_media_glare_mitigation : none
direct_media_method : invite
disable_direct_media_on_nat : false

Now the packet capture shows how the media goes through the asterisk interface.
But it’s not a good solution from an administration point of view.
There is a way to configure it globally? Or using a mask in pjsip.endpoint_custom_post.conf?

Thanks.

No one knows a better workaround to solve this problem?

Last call for a community solution. I hope more people could understand the issue and they could suggest a possible solution in the future.

Thanks for the answers,

Expecting righteous fury here but maybe just use chan_sip it has worked for years, 100% ( some erroneously think it stopped working and you can only use pjsip) and you can stop directmedia easily, I’m sure that pjsip can also do that in FPBX , but so far . . . . (Crickets)

I already used chan_sip in other situations to solve the same issue, but now I also need multiple endpoint registrations under the same sip user feature, only available in pjsip.
I think that it’s easy enough add direct_media configuration to FPBX extension options, I hope FPBX developers will see this need in comming versions.

Thanks for your time,

Look at the Bulk Handler. It was like a dev went “we need to allow bulk updates/adds for a few things…”

Multipoint trunks?

No, different endpoints with the same extension number. Similar to Users&Devices, but in a easy way.

What do you mean?

@Quarea are you aware that directmedia can be controlled per pjsip endpoint on the advanced tab? Reading back thru this, it’s not clear that you do.

Do you mean the extension advanced tab? I can’t find any directmedia option in this tab.
In “Settings” --> “Advanced settings” there is an option “SIP canrenivite (directmedia)”, but it only applies to chan_sip extensions, this option doesn’t modify the endpoint pjsip direct_media option in pjsip.endpoint.conf.

Thanks,

PJSIP extension, advanced tab:

image

I’m using Freepbx 14.0.11 (I think is the newest in 14 branch), and I can’t find the option that you show in your screenshot. In the below screenshot you can see that there isn’t Direct Media option after “Session Timers”.

Thanks in advance,

In the asterisk advanced settings there is a section for device defaults.

Reinvite is disabled there by defualt.

This option only applies to chan_sip devices. Pjsip sends media directly between endpoints by default.