<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14371">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">fax: Fix crashes in PJSIP re-negotiation scenarios.<br><br>This change fixes a few re-negotiation issues<br>uncovered with fax.<br><br>1. The fax support uses its own mechanism for<br>re-negotiation by conveying T.38 information in<br>its own frames. The new support for re-negotiating<br>when adding/removing/changing streams was also<br>being triggered for this causing multiple re-INVITEs.<br>The new support will no longer trigger when<br>transitioning between fax.<br><br>2. In off-nominal re-negotiation cases it was<br>possible for some state information to be left<br>over and used by the next re-negotiation. This<br>is now cleared.<br><br>ASTERISK-28811<br>ASTERISK-28839<br><br>Change-Id: I8ed5924b53be9fe06a385c58817e5584b0f25cc2<br>(cherry picked from commit f3ac42b9bd0d436ce2128e5bbb0502ddb587f98a)<br>---<br>M res/res_pjsip_session.c<br>1 file changed, 15 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c</span><br><span>index 9cc62ce..1bbc6fa 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -1066,11 +1066,14 @@</span><br><span> if (topology) {</span><br><span> ast_channel_set_stream_topology(session->channel, topology);</span><br><span> /* If this is a remotely done renegotiation that has changed the stream topology notify what is</span><br><span style="color: hsl(0, 100%, 40%);">- * currently handling this channel.</span><br><span style="color: hsl(120, 100%, 40%);">+ * currently handling this channel. Note that fax uses its own process, so if we are transitioning</span><br><span style="color: hsl(120, 100%, 40%);">+ * between audio and fax or vice versa we don't notify.</span><br><span> */</span><br><span> if (pjmedia_sdp_neg_was_answer_remote(session->inv_session->neg) == PJ_FALSE &&</span><br><span> session->active_media_state && session->active_media_state->topology &&</span><br><span style="color: hsl(0, 100%, 40%);">- !ast_stream_topology_equal(session->active_media_state->topology, topology)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ !ast_stream_topology_equal(session->active_media_state->topology, topology) &&</span><br><span style="color: hsl(120, 100%, 40%);">+ !session->active_media_state->default_session[AST_MEDIA_TYPE_IMAGE] &&</span><br><span style="color: hsl(120, 100%, 40%);">+ !session->pending_media_state->default_session[AST_MEDIA_TYPE_IMAGE]) {</span><br><span> changed = 2;</span><br><span> }</span><br><span> }</span><br><span>@@ -2046,6 +2049,7 @@</span><br><span> pjsip_dialog *dlg;</span><br><span> RAII_VAR(struct ast_sip_session *, session, NULL, ao2_cleanup);</span><br><span> pjsip_rdata_sdp_info *sdp_info;</span><br><span style="color: hsl(120, 100%, 40%);">+ int deferred;</span><br><span> </span><br><span> if (rdata->msg_info.msg->line.req.method.id != PJSIP_INVITE_METHOD ||</span><br><span> !(dlg = pjsip_ua_find_dialog(&rdata->msg_info.cid->id, &rdata->msg_info.to->tag, &rdata->msg_info.from->tag, PJ_FALSE)) ||</span><br><span>@@ -2135,7 +2139,11 @@</span><br><span> return PJ_FALSE;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!sdp_requires_deferral(session, sdp_info->sdp)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ deferred = sdp_requires_deferral(session, sdp_info->sdp);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (deferred == -1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sip_session_media_state_reset(session->pending_media_state);</span><br><span style="color: hsl(120, 100%, 40%);">+ return PJ_FALSE;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!deferred) {</span><br><span> return PJ_FALSE;</span><br><span> }</span><br><span> </span><br><span>@@ -4251,6 +4259,7 @@</span><br><span> </span><br><span> session = inv->mod_data[session_module.id];</span><br><span> if (handle_incoming_sdp(session, offer)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sip_session_media_state_reset(session->pending_media_state);</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span>@@ -4329,7 +4338,9 @@</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- handle_negotiated_sdp(session, local, remote);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (handle_negotiated_sdp(session, local, remote)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sip_session_media_state_reset(session->pending_media_state);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> static pjsip_redirect_op session_inv_on_redirected(pjsip_inv_session *inv, const pjsip_uri *target, const pjsip_event *e)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14371">change 14371</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/+/14371"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: certified/16.8 </div>
<div style="display:none"> Gerrit-Change-Id: I8ed5924b53be9fe06a385c58817e5584b0f25cc2 </div>
<div style="display:none"> Gerrit-Change-Number: 14371 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.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>