Direct media with PJSIP

Hi all,
I am using Asterisk 14 and PJSIP driver. I would like to send direct data between endpoints. I have set directmedia=yes and direct_media_method=reinvite as you can see in pjsip.conf
For example the call 100 -> 101. First, Asterisk received INVITE from endpoint 100 and than resend it to endpoint 101, but it replaced sender’s address and port with the Asterix ones. Is it possible to resend INVITE without modification caused by Asterisk ? In old sip driver sip.conf there is option directrtpsetup. Is there anything similar in pjsip? I did not find it.

Thank you





The PJSIP functionality has no “directrtpsetup” option. It will only re-invite after the calls are established and bridging.

Asterisk is a back to back user agent. You are asking for SIP proxy functionality.


I have similar problem.

I am trying to send 3 audio and 5 video streams in SDP offer and have direct media for all streams. This fails for multiple reasons. Seems like whenever having more then 5 streams asterisk prints:
== Everyone is busy/congested at this time (1:0/1/0)
– Auto fallthrough, channel ‘PJSIP/3009-00000010’ status is ‘CONGESTION’
Is there a limit in number of streams pjsip will handle in SDP?

Second issue is that even with re-invite enabled for direct media I am not getting direct media. At most I get first media stream direct and all others are still going through the asterisk. Is this limitation of asterisk or this is supported and my problem is probably in conflagration or construction of my SDP.



Direct media of multiple streams is not supported. There is a limit in PJSIP itself for streams in an SDP that I do not recall, and there is a limit configurable in pjsip.conf for the Asterisk side.

Thanks for a quick response.

With original SIP stack there is no support for multiple media streams at all but there is for direct media. If I am to make changes to the asterisk to support my scenario do you recommend staying with pjsip or going with original SIP stack?


If you use chan_sip then you’d have to modify its SDP code to support multiple streams, as well as its media code, as well as the core direct media code, as well as its specific direct media code.

If you use chan_pjsip then you’d have to modify the core direct media code, and its specific direct media code.

Either way you have to mess with the core code for direct media and RTP engine API to support such a thing.

Thanks. I’ll take a look.