<p>Joshua Colp <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13672">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  George Joseph: Looks good to me, approved

</div><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 check that the received frame is in a format we have negotiated<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>1 file changed, 12 insertions(+), 1 deletion(-)<br><br></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 8ce5630..72075b7 100644</span><br><span>--- a/channels/chan_pjsip.c</span><br><span>+++ b/channels/chan_pjsip.c</span><br><span>@@ -807,6 +807,16 @@</span><br><span>     return f;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Determine if the given frame is in a format we've negotiated */</span><br><span style="color: hsl(120, 100%, 40%);">+static int is_compatible_format(struct ast_sip_session *session, struct ast_frame *f)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  struct ast_stream_topology *topology = session->active_media_state->topology;</span><br><span style="color: hsl(120, 100%, 40%);">+   struct ast_stream *stream = ast_stream_topology_get_stream(topology, f->stream_num);</span><br><span style="color: hsl(120, 100%, 40%);">+       struct ast_format_cap *cap = ast_stream_get_formats(stream);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        return ast_format_cap_iscompatible_format(cap, f->subclass.format) != AST_FORMAT_CMP_NOT_EQUAL;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*!</span><br><span>  * \brief Function called by core to read any waiting frames</span><br><span>  *</span><br><span>@@ -844,7 +854,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%);">+         is_compatible_format(session, f)) {</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></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13672">change 13672</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/+/13672"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Icc3b85cee1772026cee5dc1b68459bf9431c14a3 </div>
<div style="display:none"> Gerrit-Change-Number: 13672 </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-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>