<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/6575">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Joshua Colp: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_session: Reduce (and improve) SDP renegotiation.<br><br>When pruning a request to change the topology of a channel be<br>more intelligent about the resulting topology that is actually<br>used for SDP renegotiation.<br><br>In a case where a stream has not already been negotiated we<br>don't need to renegotiate and offer a declined stream. This can<br>occur if something in Asterisk (such as ConfBridge) requests<br>to add video to a PJSIP channel that has no video codecs configured.<br>In this case since the stream did not already exist we can safely<br>remove the stream from the requested topology, resulting in no<br>renegotiation occurring.<br><br>In a case where a renegotiation is requested with a codec that is<br>not supported we can reuse the formats of the existing stream if<br>it exists to ensure that the stream continues to flow, instead of<br>removing it.<br><br>Change-Id: I636540798d55922377318fe619c510fb6ed125fb<br>---<br>M res/res_pjsip_session.c<br>1 file changed, 29 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c<br>index 461ed8e..4dcf83e 100644<br>--- a/res/res_pjsip_session.c<br>+++ b/res/res_pjsip_session.c<br>@@ -1482,7 +1482,14 @@<br> * are configurable on the endpoint.<br> */<br> for (index = 0; index < ast_stream_topology_get_count(media_state->topology); ++index) {<br>+ struct ast_stream *existing_stream = NULL;<br>+<br> stream = ast_stream_topology_get_stream(media_state->topology, index);<br>+<br>+ if (session->active_media_state->topology &&<br>+ index < ast_stream_topology_get_count(session->active_media_state->topology)) {<br>+ existing_stream = ast_stream_topology_get_stream(session->active_media_state->topology, index);<br>+ }<br> <br> if (is_stream_limitation_reached(ast_stream_get_type(stream), session->endpoint, type_streams)) {<br> if (index < AST_VECTOR_SIZE(&media_state->sessions)) {<br>@@ -1516,8 +1523,28 @@<br> ast_format_cap_get_compatible(ast_stream_get_formats(stream), session->endpoint->media.codecs, joint_cap);<br> if (!ast_format_cap_count(joint_cap)) {<br> ao2_ref(joint_cap, -1);<br>- ast_stream_set_state(stream, AST_STREAM_STATE_REMOVED);<br>- continue;<br>+<br>+ if (!existing_stream) {<br>+ /* If there is no existing stream we can just not have this stream in the topology<br>+ * at all.<br>+ */<br>+ ast_stream_topology_del_stream(media_state->topology, index);<br>+ index -= 1;<br>+ continue;<br>+ } else if (ast_stream_get_state(stream) != ast_stream_get_state(existing_stream) ||<br>+ strcmp(ast_stream_get_name(stream), ast_stream_get_name(existing_stream))) {<br>+ /* If the underlying stream is a different type or different name then we have to<br>+ * mark it as removed, as it is replacing an existing stream. We do this so order<br>+ * is preserved.<br>+ */<br>+ ast_stream_set_state(stream, AST_STREAM_STATE_REMOVED);<br>+ continue;<br>+ } else {<br>+ /* However if the stream is otherwise remaining the same we can keep the formats<br>+ * that exist on it already which allows media to continue to flow.<br>+ */<br>+ joint_cap = ao2_bump(ast_stream_get_formats(existing_stream));<br>+ }<br> }<br> ast_stream_set_formats(stream, joint_cap);<br> }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6575">change 6575</a>. To unsubscribe, 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/6575"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15.0 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I636540798d55922377318fe619c510fb6ed125fb </div>
<div style="display:none"> Gerrit-Change-Number: 6575 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>