# \[SOLVED\] How to disable directmedia in all pjsip endpoints

**URL:** <https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533>\
**Category:** FreePBX\
**Tags:** pjsip, endpoint, configuration, freepbx\
**Created:** [May 7, 2019, 4:17pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533 "2019-05-07T16:17:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 7, 2019, 4:17pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/1 "2019-05-07T16:17:09Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![Stewart1](https://community.freepbx.org/letter_avatar_proxy/v4/letter/s/bc79bd/32.png) [@Stewart1](https://community.freepbx.org/u/Stewart1)\
**Post date:** [May 7, 2019, 4:37pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/2 "2019-05-07T16:37:32Z")

</div>

> [@Quarea](#):
>
> Now I need to disable this option because I need the RTP streams going through the pbx …

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?

---

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 7, 2019, 4:47pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/3 "2019-05-07T16:47:23Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 9, 2019, 10:38am UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/4 "2019-05-09T10:38:13Z")

</div>

Hi,

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

Regards,

---

<div class="post-metadata">

**Author:** ![cynjut](https://community.freepbx.org/user_avatar/community.freepbx.org/cynjut/32/5840_2.png) [@cynjut](https://community.freepbx.org/u/cynjut)\
**Post date:** [May 9, 2019, 3:15pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/5 "2019-05-09T15:15:19Z")

</div>

> [@Quarea](#):
>
> No one has this need? I think it’s not uncommon the need to endpoint voice trafic going throught Asterisk interface.

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.

---

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 9, 2019, 3:49pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/6 "2019-05-09T15:49:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 16, 2019, 2:50pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/7 "2019-05-16T14:50:37Z")

</div>

No one knows a better workaround to solve this problem?

---

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 21, 2019, 10:05am UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/8 "2019-05-21T10:05:28Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![dicko](https://community.freepbx.org/user_avatar/community.freepbx.org/dicko/32/8712_2.png) [@dicko](https://community.freepbx.org/u/dicko)\
**Post date:** [May 21, 2019, 10:47am UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/9 "2019-05-21T10:47:13Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 21, 2019, 11:12am UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/10 "2019-05-21T11:12:24Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![BlazeStudios](https://community.freepbx.org/letter_avatar_proxy/v4/letter/b/e0b2c6/32.png) [@BlazeStudios](https://community.freepbx.org/u/BlazeStudios)\
**Post date:** [May 21, 2019, 11:34am UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/11 "2019-05-21T11:34:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dicko](https://community.freepbx.org/user_avatar/community.freepbx.org/dicko/32/8712_2.png) [@dicko](https://community.freepbx.org/u/dicko)\
**Post date:** [May 21, 2019, 11:38am UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/12 "2019-05-21T11:38:28Z")

</div>

Multipoint trunks?

---

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 21, 2019, 11:59am UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/13 "2019-05-21T11:59:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 21, 2019, 2:52pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/14 "2019-05-21T14:52:45Z")

</div>

What do you mean?

---

<div class="post-metadata">

**Author:** ![lgaetz](https://community.freepbx.org/user_avatar/community.freepbx.org/lgaetz/32/22393_2.png) [@lgaetz](https://community.freepbx.org/u/lgaetz)\
**Post date:** [May 21, 2019, 2:59pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/15 "2019-05-21T14:59:25Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 21, 2019, 3:13pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/16 "2019-05-21T15:13:43Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![lgaetz](https://community.freepbx.org/user_avatar/community.freepbx.org/lgaetz/32/22393_2.png) [@lgaetz](https://community.freepbx.org/u/lgaetz)\
**Post date:** [May 21, 2019, 3:31pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/17 "2019-05-21T15:31:45Z")

</div>

PJSIP extension, advanced tab:

![image](https://community.freepbx.org/uploads/default/original/2X/c/c9c415c985eee3b4f5d4cdcc4e09fb1311e87a62.png)

---

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 21, 2019, 3:46pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/18 "2019-05-21T15:46:59Z")

</div>

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”.

 ![image](https://community.freepbx.org/uploads/default/original/2X/f/fab5d7b615c40c8ba11aa141dc7e019110a4225f.png)

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![sorvani](https://community.freepbx.org/user_avatar/community.freepbx.org/sorvani/32/19434_2.png) [@sorvani](https://community.freepbx.org/u/sorvani)\
**Post date:** [May 21, 2019, 3:53pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/19 "2019-05-21T15:53:21Z")

</div>

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

Reinvite is disabled there by defualt.

 ![image](https://community.freepbx.org/uploads/default/original/2X/2/29313a99b0175fe30d11b21f2bde1adf79f9b736.png)

---

<div class="post-metadata">

**Author:** ![Quarea](https://community.freepbx.org/user_avatar/community.freepbx.org/quarea/32/18226_2.png) [@Quarea](https://community.freepbx.org/u/Quarea)\
**Post date:** [May 21, 2019, 3:55pm UTC](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533/20 "2019-05-21T15:55:06Z")

</div>

This option only applies to chan\_sip devices. Pjsip sends media directly between endpoints by default.

[Next page](https://community.freepbx.org/t/solved-how-to-disable-directmedia-in-all-pjsip-endpoints/58533.md?page=2)
