<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13903">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; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_pjsip: Check audio frame when remote SSRC changes.<br><br>If the SSRC of a received RTP packet differed from the previous SSRC<br>an SSRC change control frame would be queued ahead of the media<br>frame. In the case of audio this would result in the format of the<br>audio frame not being checked, and if it differed or was not allowed<br>then it could cause the call to drop due to failure to set up a<br>translation path.<br><br>The chan_pjsip module will now no longer assume the first frame<br>will be the audio frame and instead goes through the complete list<br>to find it.<br><br>ASTERISK-28759<br><br>Change-Id: I6d854cc523f343e299a615636fc65bdbd5f809ec<br>---<br>M channels/chan_pjsip.c<br>1 file changed, 17 insertions(+), 11 deletions(-)<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 72075b7..98eb6c9 100644</span><br><span>--- a/channels/chan_pjsip.c</span><br><span>+++ b/channels/chan_pjsip.c</span><br><span>@@ -829,6 +829,7 @@</span><br><span> struct ast_sip_session_media_read_callback_state *callback_state;</span><br><span> struct ast_frame *f;</span><br><span> int fdno = ast_channel_fdno(ast) - AST_EXTENDED_FDS;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_frame *cur;</span><br><span> </span><br><span> if (fdno >= AST_VECTOR_SIZE(&session->active_media_state->read_callbacks)) {</span><br><span> return &ast_null_frame;</span><br><span>@@ -841,8 +842,13 @@</span><br><span> return f;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (f->frametype != AST_FRAME_VOICE ||</span><br><span style="color: hsl(0, 100%, 40%);">- callback_state->session != session->active_media_state->default_session[callback_state->session->type]) {</span><br><span style="color: hsl(120, 100%, 40%);">+ for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (cur->frametype == AST_FRAME_VOICE) {</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!cur || callback_state->session != session->active_media_state->default_session[callback_state->session->type]) {</span><br><span> return f;</span><br><span> }</span><br><span> </span><br><span>@@ -854,36 +860,36 @@</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(0, 100%, 40%);">- is_compatible_format(session, f)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_format_cmp(ast_channel_rawwriteformat(ast), cur->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL &&</span><br><span style="color: hsl(120, 100%, 40%);">+ is_compatible_format(session, cur)) {</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> ast_debug(1, "Oooh, got a frame with format of %s on channel '%s' when we're sending '%s', switching to match\n",</span><br><span style="color: hsl(0, 100%, 40%);">- ast_format_get_name(f->subclass.format), ast_channel_name(ast),</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_format_get_name(cur->subclass.format), ast_channel_name(ast),</span><br><span> ast_format_get_name(ast_channel_rawwriteformat(ast)));</span><br><span> </span><br><span> caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);</span><br><span> if (caps) {</span><br><span> ast_format_cap_append_from_cap(caps, ast_channel_nativeformats(ast), AST_MEDIA_TYPE_UNKNOWN);</span><br><span> ast_format_cap_remove_by_type(caps, AST_MEDIA_TYPE_AUDIO);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_format_cap_append(caps, f->subclass.format, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_format_cap_append(caps, cur->subclass.format, 0);</span><br><span> ast_channel_nativeformats_set(ast, caps);</span><br><span> ao2_ref(caps, -1);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_set_write_format_path(ast, ast_channel_writeformat(ast), f->subclass.format);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_set_read_format_path(ast, ast_channel_readformat(ast), f->subclass.format);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_set_write_format_path(ast, ast_channel_writeformat(ast), cur->subclass.format);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_set_read_format_path(ast, ast_channel_readformat(ast), cur->subclass.format);</span><br><span> </span><br><span> if (ast_channel_is_bridged(ast)) {</span><br><span> ast_channel_set_unbridged_nolock(ast, 1);</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), f->subclass.format) == AST_FORMAT_CMP_NOT_EQUAL) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), cur->subclass.format)</span><br><span style="color: hsl(120, 100%, 40%);">+ == AST_FORMAT_CMP_NOT_EQUAL) {</span><br><span> ast_debug(1, "Oooh, got a frame with format of %s on channel '%s' when it has not been negotiated\n",</span><br><span style="color: hsl(0, 100%, 40%);">- ast_format_get_name(f->subclass.format), ast_channel_name(ast));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_format_get_name(cur->subclass.format), ast_channel_name(ast));</span><br><span> ast_frfree(f);</span><br><span> return &ast_null_frame;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13903">change 13903</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/+/13903"/><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: I6d854cc523f343e299a615636fc65bdbd5f809ec </div>
<div style="display:none"> Gerrit-Change-Number: 13903 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Paulo Vicentini <paulo.vicentini@gmail.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>