<p>Alexander Traud has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15412">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_sip: Filter pass-through audio/video formats away, again.<br><br>Instead of looking for pass-through formats in the list of transcodable<br>formats (which is going to find nothing), go through the result which<br>is going to be the jointcaps of the tech_pvt of the channel. Finally,<br>only with that list, ast_format_cap_remove(.) is going to succeed.<br><br>This restores the behaviour of Asterisk 1.8. However, it does not fix<br>ASTERISK_29282 because that issue report is about chan_sip and PJSIP.<br>Here, only chan_sip is fixed because PJSIP does not even call<br>ast_rtp_instance_available_formats -> ast_translate_available_format.<br><br>Change-Id: Icade2366ac2b82935b95a9981678c987da2e8c34<br>---<br>M channels/chan_sip.c<br>M main/translate.c<br>2 files changed, 18 insertions(+), 32 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/12/15412/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_sip.c b/channels/chan_sip.c</span><br><span>index e5d6cb6..c957f4f 100644</span><br><span>--- a/channels/chan_sip.c</span><br><span>+++ b/channels/chan_sip.c</span><br><span>@@ -13609,10 +13609,6 @@</span><br><span> </span><br><span>                /* Check if we need audio in this call */</span><br><span>            needaudio = ast_format_cap_has_type(tmpcap, AST_MEDIA_TYPE_AUDIO);</span><br><span style="color: hsl(0, 100%, 40%);">-              if (!needaudio && p->outgoing_call) {</span><br><span style="color: hsl(0, 100%, 40%);">-                        /* p->caps are added conditionally, see below "Finally our remain..." */</span><br><span style="color: hsl(0, 100%, 40%);">-                   needaudio = ast_format_cap_has_type(p->caps, AST_MEDIA_TYPE_AUDIO);</span><br><span style="color: hsl(0, 100%, 40%);">-          }</span><br><span> </span><br><span>                /* Check if we need video in this call */</span><br><span>            if ((ast_format_cap_has_type(tmpcap, AST_MEDIA_TYPE_VIDEO)) && !p->novideo) {</span><br><span>@@ -13743,7 +13739,6 @@</span><br><span>           /* Now, start adding audio codecs. These are added in this order:</span><br><span>               - First what was requested by the calling channel</span><br><span>                    - Then our mutually shared capabilities, determined previous in tmpcap</span><br><span style="color: hsl(0, 100%, 40%);">-                  - Then preferences in order from sip.conf device config for this peer/user</span><br><span>                */</span><br><span> </span><br><span> </span><br><span>@@ -13787,27 +13782,6 @@</span><br><span>                        ao2_ref(tmp_fmt, -1);</span><br><span>                }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-           /* Finally our remaining audio/video codecs */</span><br><span style="color: hsl(0, 100%, 40%);">-          for (x = 0; p->outgoing_call && x < ast_format_cap_count(p->caps); x++) {</span><br><span style="color: hsl(0, 100%, 40%);">-                      tmp_fmt = ast_format_cap_get_format(p->caps, x);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-                     if (ast_format_cap_iscompatible_format(alreadysent, tmp_fmt) != AST_FORMAT_CMP_NOT_EQUAL) {</span><br><span style="color: hsl(0, 100%, 40%);">-                             ao2_ref(tmp_fmt, -1);</span><br><span style="color: hsl(0, 100%, 40%);">-                           continue;</span><br><span style="color: hsl(0, 100%, 40%);">-                       }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-                       if (ast_format_get_type(tmp_fmt) == AST_MEDIA_TYPE_AUDIO) {</span><br><span style="color: hsl(0, 100%, 40%);">-                             add_codec_to_sdp(p, tmp_fmt, &m_audio, &a_audio, debug, &min_audio_packet_size, &max_audio_packet_size);</span><br><span style="color: hsl(0, 100%, 40%);">-                        } else if (needvideo && ast_format_get_type(tmp_fmt) == AST_MEDIA_TYPE_VIDEO) {</span><br><span style="color: hsl(0, 100%, 40%);">-                         add_vcodec_to_sdp(p, tmp_fmt, &m_video, &a_video, debug, &min_video_packet_size);</span><br><span style="color: hsl(0, 100%, 40%);">-                   } else if (needtext && ast_format_get_type(tmp_fmt) == AST_MEDIA_TYPE_TEXT) {</span><br><span style="color: hsl(0, 100%, 40%);">-                           add_tcodec_to_sdp(p, tmp_fmt, &m_text, &a_text, debug, &min_text_packet_size);</span><br><span style="color: hsl(0, 100%, 40%);">-                      }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-                       ast_format_cap_append(alreadysent, tmp_fmt, 0);</span><br><span style="color: hsl(0, 100%, 40%);">-                 ao2_ref(tmp_fmt, -1);</span><br><span style="color: hsl(0, 100%, 40%);">-           }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>            /* Now add DTMF RFC2833 telephony-event as a codec */</span><br><span>                for (x = 1LL; x <= AST_RTP_MAX; x <<= 1) {</span><br><span>                  if (!(p->jointnoncodeccapability & x))</span><br><span>diff --git a/main/translate.c b/main/translate.c</span><br><span>index 6648931..a9665ae 100644</span><br><span>--- a/main/translate.c</span><br><span>+++ b/main/translate.c</span><br><span>@@ -1509,16 +1509,19 @@</span><br><span>         struct ast_format_cap *result, struct ast_format *src_fmt,</span><br><span>   enum ast_media_type type)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-  int index, src_index = format2index(src_fmt);</span><br><span style="color: hsl(120, 100%, 40%);">+ int i;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      if (ast_format_get_type(src_fmt) != type) {</span><br><span style="color: hsl(120, 100%, 40%);">+           return;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  /* For a given source format, traverse the list of</span><br><span>      known formats to determine whether there exists</span><br><span>      a translation path from the source format to the</span><br><span>     destination format. */</span><br><span style="color: hsl(0, 100%, 40%);">-       for (index = 0; (src_index >= 0) && index < cur_max_index; index++) {</span><br><span style="color: hsl(0, 100%, 40%);">-             struct ast_codec *codec = index2codec(index);</span><br><span style="color: hsl(0, 100%, 40%);">-           RAII_VAR(struct ast_format *, fmt, ast_format_create(codec), ao2_cleanup);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-              ao2_ref(codec, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+   for (i = ast_format_cap_count(result) - 1; 0 <= i; i--) {</span><br><span style="color: hsl(120, 100%, 40%);">+          int index, src_index;</span><br><span style="color: hsl(120, 100%, 40%);">+         struct ast_format *fmt = ast_format_cap_get_format(result, i);</span><br><span> </span><br><span>           if (ast_format_get_type(fmt) != type) {</span><br><span>                      continue;</span><br><span>@@ -1535,6 +1538,15 @@</span><br><span>                   continue;</span><br><span>            }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+         /* if this is a pass-through format, not in the source,</span><br><span style="color: hsl(120, 100%, 40%);">+                  we cannot transcode. Therefore, remove it from the result */</span><br><span style="color: hsl(120, 100%, 40%);">+               src_index = format2index(src_fmt);</span><br><span style="color: hsl(120, 100%, 40%);">+            index = format2index(fmt);</span><br><span style="color: hsl(120, 100%, 40%);">+            if (src_index < 0 || index < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                       ast_format_cap_remove(result, fmt);</span><br><span style="color: hsl(120, 100%, 40%);">+                   continue;</span><br><span style="color: hsl(120, 100%, 40%);">+             }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>          /* if we don't have a translation path from the src</span><br><span>                 to this format, remove it from the result */</span><br><span>              if (!matrix_get(src_index, index)->step) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15412">change 15412</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/+/15412"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: Icade2366ac2b82935b95a9981678c987da2e8c34 </div>
<div style="display:none"> Gerrit-Change-Number: 15412 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexander Traud <pabstraud@compuserve.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>