<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13503">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_pjsip: Ignore RTP that we haven't negotiated<br><br>If chan_pjsip receives an RTP packet whose payload differs from the<br>channel's native format, and asymmetric_rtp_codec is disabled (the<br>default), Asterisk will switch the channel's native format to match<br>that of the incoming packet without regard to the negotiated payloads.<br><br>We now keep track of the formats that have been negotiated and check<br>before switching payloads which results in these packets being dropped<br>instead of causing the session to terminate.<br><br>ASTERISK-28139 #close<br>Reported by: Paul Brooks<br><br>Change-Id: Icc3b85cee1772026cee5dc1b68459bf9431c14a3<br>---<br>M channels/chan_pjsip.c<br>M include/asterisk/res_pjsip_session.h<br>M res/res_pjsip_sdp_rtp.c<br>M res/res_pjsip_session.c<br>4 files changed, 11 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/03/13503/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c</span><br><span>index 33abe03..c4281c3 100644</span><br><span>--- a/channels/chan_pjsip.c</span><br><span>+++ b/channels/chan_pjsip.c</span><br><span>@@ -771,7 +771,8 @@</span><br><span> * raw read format BEFORE the native format check</span><br><span> */</span><br><span> if (!session->endpoint->asymmetric_rtp_codec &&</span><br><span style="color: hsl(0, 100%, 40%);">- ast_format_cmp(ast_channel_rawwriteformat(ast), f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_format_cmp(ast_channel_rawwriteformat(ast), f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL &&</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_format_cap_iscompatible_format(session->joint_caps, f->subclass.format) == AST_FORMAT_CMP_EQUAL) {</span><br><span> struct ast_format_cap *caps;</span><br><span> </span><br><span> /* For maximum compatibility we ensure that the formats match that of the received media */</span><br><span>diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h</span><br><span>index 9ae1883..676a335 100644</span><br><span>--- a/include/asterisk/res_pjsip_session.h</span><br><span>+++ b/include/asterisk/res_pjsip_session.h</span><br><span>@@ -143,6 +143,8 @@</span><br><span> struct ast_party_id id;</span><br><span> /*! Requested capabilities */</span><br><span> struct ast_format_cap *req_caps;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! Joint capabilities */</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_format_cap *joint_caps;</span><br><span> /*! Optional DSP, used only for inband DTMF/Fax-CNG detection if configured */</span><br><span> struct ast_dsp *dsp;</span><br><span> /*! Whether the termination of the session should be deferred */</span><br><span>diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c</span><br><span>index 98e9819..78c19aa 100644</span><br><span>--- a/res/res_pjsip_sdp_rtp.c</span><br><span>+++ b/res/res_pjsip_sdp_rtp.c</span><br><span>@@ -401,6 +401,8 @@</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ast_format_cap_append_from_cap(session->joint_caps, joint, media_type);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_rtp_codecs_payloads_copy(&codecs, ast_rtp_instance_get_codecs(session_media->rtp),</span><br><span> session_media->rtp);</span><br><span> </span><br><span>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c</span><br><span>index bbdb8d1..b61b0fd 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -1351,6 +1351,7 @@</span><br><span> ao2_cleanup(session->aor);</span><br><span> ao2_cleanup(session->contact);</span><br><span> ao2_cleanup(session->req_caps);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(session->joint_caps);</span><br><span> ao2_cleanup(session->direct_media_cap);</span><br><span> </span><br><span> ast_dsp_free(session->dsp);</span><br><span>@@ -1433,6 +1434,10 @@</span><br><span> if (!session->req_caps) {</span><br><span> return NULL;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+ session->joint_caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!session->joint_caps) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> session->datastores = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,</span><br><span> DATASTORE_BUCKETS, datastore_hash, NULL, datastore_cmp);</span><br><span> if (!session->datastores) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13503">change 13503</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13503"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Icc3b85cee1772026cee5dc1b68459bf9431c14a3 </div>
<div style="display:none"> Gerrit-Change-Number: 13503 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>