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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res/res_pjsip_session.c: Check that media type matches in<br>function ast_sip_session_media_state_add.<br><br>Check ast_media_type matches when a ast_sip_session_media is found<br>otherwise when transitioning from say image to audio, the wrong<br>session is returned in the first if statement.<br><br>ASTERISK-29220 #close<br><br>Change-Id: I6f6efa9b821ebe8881bb4c8c957f8802ddcb4b5d<br>---<br>M res/res_pjsip_session.c<br>1 file changed, 6 insertions(+), 3 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 960b72d..1d26309 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -490,15 +490,16 @@</span><br><span>      struct ast_sip_session_media_state *media_state, enum ast_media_type type, int position)</span><br><span> {</span><br><span>        struct ast_sip_session_media *session_media = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+   struct ast_sip_session_media *current_session_media = NULL;</span><br><span>  SCOPE_ENTER(1, "%s Adding position %d\n", ast_sip_session_get_name(session), position);</span><br><span> </span><br><span>        /* It is possible for this media state to already contain a session for the stream. If this</span><br><span>   * is the case we simply return it.</span><br><span>   */</span><br><span>  if (position < AST_VECTOR_SIZE(&media_state->sessions)) {</span><br><span style="color: hsl(0, 100%, 40%);">-             session_media = AST_VECTOR_GET(&media_state->sessions, position);</span><br><span style="color: hsl(0, 100%, 40%);">-                if (session_media) {</span><br><span style="color: hsl(0, 100%, 40%);">-                    SCOPE_EXIT_RTN_VALUE(session_media, "Using existing media_session\n");</span><br><span style="color: hsl(120, 100%, 40%);">+              current_session_media = AST_VECTOR_GET(&media_state->sessions, position);</span><br><span style="color: hsl(120, 100%, 40%);">+              if (current_session_media && current_session_media->type == type) {</span><br><span style="color: hsl(120, 100%, 40%);">+                        SCOPE_EXIT_RTN_VALUE(current_session_media, "Using existing media_session\n");</span><br><span>             }</span><br><span>    }</span><br><span> </span><br><span>@@ -575,6 +576,8 @@</span><br><span>          SCOPE_EXIT_RTN_VALUE(NULL, "Couldn't replace media_session\n");</span><br><span>        }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(current_session_media);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>        /* If this stream will be active in some way and it is the first of this type then consider this the default media session to match */</span><br><span>       if (!media_state->default_session[type] && ast_stream_get_state(ast_stream_topology_get_stream(media_state->topology, position)) != AST_STREAM_STATE_REMOVED) {</span><br><span>                ast_trace(1, "Setting media session as default for %s\n", ast_codec_media_type2str(session_media->type));</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15230">change 15230</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/+/15230"/><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: I6f6efa9b821ebe8881bb4c8c957f8802ddcb4b5d </div>
<div style="display:none"> Gerrit-Change-Number: 15230 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: Robert Cripps <rcripps@voxbone.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-Reviewer: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>