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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip: Adjust outgoing offer call pref.<br><br>This changes the outgoing offer call preference<br>default option to match the behavior of previous<br>versions of Asterisk.<br><br>The additional advanced codec negotiation options<br>have also been removed from the sample configuration<br>and marked as reserved for future functionality in<br>XML documentation.<br><br>The codec preference options have also been fixed to<br>enforce local codec configuration.<br><br>ASTERISK-29109<br><br>Change-Id: Iad19347bd5f3d89900c15ecddfebf5e20950a1c2<br>---<br>M configs/samples/pjsip.conf.sample<br>M res/res_pjsip.c<br>M res/res_pjsip/pjsip_configuration.c<br>M res/res_pjsip_session/pjsip_session_caps.c<br>M tests/test_res_pjsip_session_caps.c<br>5 files changed, 36 insertions(+), 77 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample</span><br><span>index 506583e..cded743 100644</span><br><span>--- a/configs/samples/pjsip.conf.sample</span><br><span>+++ b/configs/samples/pjsip.conf.sample</span><br><span>@@ -828,69 +828,17 @@</span><br><span>                            ; local - Include all codecs in the local list that</span><br><span>                            ; are also in the remote list preserving the local</span><br><span>                            ; order.</span><br><span style="color: hsl(0, 100%, 40%);">-                           ; local_merge - Include all codecs in BOTH lists</span><br><span style="color: hsl(0, 100%, 40%);">-                           ; preserving the local list order.  Codes in the</span><br><span style="color: hsl(0, 100%, 40%);">-                           ; remote list not in the local list will be placed</span><br><span style="color: hsl(0, 100%, 40%);">-                           ; at the end of the joint list.</span><br><span style="color: hsl(120, 100%, 40%);">+                           ; local_merge - Include all codecs in the local list</span><br><span style="color: hsl(120, 100%, 40%);">+                           ; preserving the local order.</span><br><span>                            ; local_first - Include only the first codec in the</span><br><span>                            ; local list.</span><br><span>                            ; remote - Include all codecs in the remote list that</span><br><span>                            ; are also in the local list preserving remote list</span><br><span style="color: hsl(0, 100%, 40%);">-                           ; order. (default)</span><br><span style="color: hsl(0, 100%, 40%);">-                           ; remote_merge - Include all codecs in BOTH lists</span><br><span style="color: hsl(0, 100%, 40%);">-                           ; preserving the remote list order.  Codes in the</span><br><span style="color: hsl(0, 100%, 40%);">-                           ; local list not in the remote list will be placed</span><br><span style="color: hsl(0, 100%, 40%);">-                           ; at the end of the joint list.</span><br><span style="color: hsl(0, 100%, 40%);">-                           ; remote_first - Include only the first codec in</span><br><span style="color: hsl(0, 100%, 40%);">-                           ; the remote list.</span><br><span style="color: hsl(0, 100%, 40%);">-;codec_prefs_incoming_offer=; This is a string that describes how the codecs</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; specified on an incoming SDP offer (pending) are</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; reconciled with the codecs specified on an endpoint</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; (configured) before being sent to the Asterisk core.</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; The string actually specifies 4 name:value pair</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; parameters separated by commas. Whitespace is</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; ignored and they may be specified in any order.</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; prefer: <pending | configured>,</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; operation: <intersect | only_preferred</span><br><span style="color: hsl(0, 100%, 40%);">-                            ;    | only_nonpreferred>,</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; keep: <first | all>,</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; transcode: <allow | prevent></span><br><span style="color: hsl(0, 100%, 40%);">-;codec_prefs_outgoing_offer=; This is a string that describes how the codecs</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; specified in the topology that comes from the</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; Asterisk core (pending) are reconciled with the</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; codecs specified on an endpoint (configured)</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; when sending an SDP offer.</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; The string actually specifies 4 name:value pair</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; parameters separated by commas. Whitespace is</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; ignored and they may be specified in any order.</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; prefer: <pending | configured>,</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; operation: <intersect | union</span><br><span style="color: hsl(0, 100%, 40%);">-                            ;    | only_preferred | only_nonpreferred>,</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; keep: <first | all>,</span><br><span style="color: hsl(0, 100%, 40%);">-                            ; transcode: <allow | prevent></span><br><span style="color: hsl(0, 100%, 40%);">-;codec_prefs_incoming_answer=; This is a string that describes how the codecs</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; specified in an incoming SDP answer (pending)</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; are reconciled with the codecs specified on an</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; endpoint (configured) when receiving an SDP</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; answer.</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; The string actually specifies 4 name:value pair</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; parameters separated by commas. Whitespace is</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; ignored and they may be specified in any order.</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; prefer: <pending | configured>,</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; operation: <intersect | union</span><br><span style="color: hsl(0, 100%, 40%);">-                             ;    | only_preferred | only_nonpreferred>,</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; keep: <first | all></span><br><span style="color: hsl(0, 100%, 40%);">-;codec_prefs_outgoing_answer=; This is a string that describes how the codecs</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; that come from the core (pending) are reconciled</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; with the codecs specified on an endpoint</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; (configured) when sending an SDP answer.</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; The string actually specifies 4 name:value pair</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; parameters separated by commas. Whitespace is</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; ignored and they may be specified in any order.</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; prefer: <pending | configured>,</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; operation: <intersect | union</span><br><span style="color: hsl(0, 100%, 40%);">-                             ;    | only_preferred | only_nonpreferred>,</span><br><span style="color: hsl(0, 100%, 40%);">-                             ; keep: <first | all></span><br><span style="color: hsl(120, 100%, 40%);">+                           ; order.</span><br><span style="color: hsl(120, 100%, 40%);">+                           ; remote_merge - Include all codecs in the local list</span><br><span style="color: hsl(120, 100%, 40%);">+                           ; preserving the remote list order. (default)</span><br><span style="color: hsl(120, 100%, 40%);">+                           ; remote_first - Include only the first codec in the</span><br><span style="color: hsl(120, 100%, 40%);">+                           ; remote list that is also in the local list.</span><br><span> ;preferred_codec_only=no   ; Respond to a SIP invite with the single most</span><br><span>                            ; preferred codec rather than advertising all joint</span><br><span>                            ; codec capabilities. This limits the other side's</span><br><span>diff --git a/res/res_pjsip.c b/res/res_pjsip.c</span><br><span>index 9d3a6c2..cfc97b6 100644</span><br><span>--- a/res/res_pjsip.c</span><br><span>+++ b/res/res_pjsip.c</span><br><span>@@ -111,6 +111,7 @@</span><br><span>                                                      on an endpoint (configured) before being sent to the Asterisk core.</span><br><span>                                                  The string actually specifies 4 <literal>name:value</literal> pair parameters</span><br><span>                                                    separated by commas. Whitespace is ignored and they may be specified in any order.</span><br><span style="color: hsl(120, 100%, 40%);">+                                                    Note that this option is reserved for future functionality.</span><br><span> </span><br><span>                                              </para></span><br><span>                                                <para></span><br><span>@@ -171,6 +172,7 @@</span><br><span>                                                   endpoint (configured) when sending an SDP offer.</span><br><span>                                                     The string actually specifies 4 <literal>name:value</literal> pair parameters</span><br><span>                                                    separated by commas. Whitespace is ignored and they may be specified in any order.</span><br><span style="color: hsl(120, 100%, 40%);">+                                                    Note that this option is reserved for future functionality.</span><br><span> </span><br><span>                                              </para></span><br><span>                                                <para></span><br><span>@@ -232,6 +234,8 @@</span><br><span>                                                   when receiving an SDP answer.</span><br><span>                                                        The string actually specifies 4 <literal>name:value</literal> pair parameters</span><br><span>                                                    separated by commas. Whitespace is ignored and they may be specified in any order.</span><br><span style="color: hsl(120, 100%, 40%);">+                                                    Note that this option is reserved for future functionality.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                                                </para></span><br><span>                                                <para></span><br><span>                                                         Parameters:</span><br><span>@@ -288,6 +292,8 @@</span><br><span>                                                    when sending an SDP answer.</span><br><span>                                                  The string actually specifies 4 <literal>name:value</literal> pair parameters</span><br><span>                                                    separated by commas. Whitespace is ignored and they may be specified in any order.</span><br><span style="color: hsl(120, 100%, 40%);">+                                                    Note that this option is reserved for future functionality.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                                                </para></span><br><span>                                                <para></span><br><span>                                                         Parameters:</span><br><span>@@ -1214,7 +1220,7 @@</span><br><span>                                          </enumlist></span><br><span>                                    </description></span><br><span>                                 </configOption></span><br><span style="color: hsl(0, 100%, 40%);">-                           <configOption name="outgoing_call_offer_pref" default="local"></span><br><span style="color: hsl(120, 100%, 40%);">+                              <configOption name="outgoing_call_offer_pref" default="remote_merge"></span><br><span>                                      <synopsis>Preferences for selecting codecs for an outgoing call.</synopsis></span><br><span>                                      <description></span><br><span>                                          <para>Based on this setting, a joint list of preferred codecs between</span><br><span>@@ -1227,24 +1233,20 @@</span><br><span>                                                                preserving the local order.</span><br><span>                                                  </para></enum></span><br><span>                                                   <enum name="local_merge"><para></span><br><span style="color: hsl(0, 100%, 40%);">-                                                           Include all codecs in BOTH lists preserving the local order.</span><br><span style="color: hsl(0, 100%, 40%);">-                                                            Remote codecs not in the local list will be placed at the end</span><br><span style="color: hsl(0, 100%, 40%);">-                                                           of the joint list.</span><br><span style="color: hsl(120, 100%, 40%);">+                                                            Include all codecs in the local list preserving the local order.</span><br><span>                                                     </para></enum></span><br><span>                                                   <enum name="local_first"><para></span><br><span>                                                                Include only the first codec in the local list.</span><br><span>                                                      </para></enum></span><br><span>                                                   <enum name="remote"><para></span><br><span>                                                             Include all codecs in the remote list that are also in the local list</span><br><span style="color: hsl(0, 100%, 40%);">-                                                           preserving the remote order. (default)</span><br><span style="color: hsl(120, 100%, 40%);">+                                                                preserving the remote order.</span><br><span>                                                         </para></enum></span><br><span>                                                   <enum name="remote_merge"><para></span><br><span style="color: hsl(0, 100%, 40%);">-                                                          Include all codecs in BOTH lists preserving the remote order.</span><br><span style="color: hsl(0, 100%, 40%);">-                                                           Local codecs not in the remote list will be placed at the end</span><br><span style="color: hsl(0, 100%, 40%);">-                                                           of the joint list.</span><br><span style="color: hsl(120, 100%, 40%);">+                                                                Include all codecs in the local list preserving the remote order. (default)</span><br><span>                                                      </para></enum></span><br><span>                                                   <enum name="remote_first"><para></span><br><span style="color: hsl(0, 100%, 40%);">-                                                          Include only the first codec in the remote list.</span><br><span style="color: hsl(120, 100%, 40%);">+                                                              Include only the first codec in the remote list that is also in the local list.</span><br><span>                                                      </para></enum></span><br><span>                                           </enumlist></span><br><span>                                    </description></span><br><span>diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c</span><br><span>index 344f319..80bad02 100644</span><br><span>--- a/res/res_pjsip/pjsip_configuration.c</span><br><span>+++ b/res/res_pjsip/pjsip_configuration.c</span><br><span>@@ -2138,7 +2138,7 @@</span><br><span>        ast_sorcery_object_field_register(sip_sorcery, "endpoint", "ignore_183_without_sdp", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, ignore_183_without_sdp));</span><br><span>    ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "incoming_call_offer_pref", "local",</span><br><span>                 call_offer_pref_handler, incoming_call_offer_pref_to_str, NULL, 0, 0);</span><br><span style="color: hsl(0, 100%, 40%);">-  ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "outgoing_call_offer_pref", "remote",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "outgoing_call_offer_pref", "remote_merge",</span><br><span>          call_offer_pref_handler, outgoing_call_offer_pref_to_str, NULL, 0, 0);</span><br><span>       ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "codec_prefs_incoming_offer",</span><br><span>          "prefer: pending, operation: intersect, keep: all, transcode: allow",</span><br><span>diff --git a/res/res_pjsip_session/pjsip_session_caps.c b/res/res_pjsip_session/pjsip_session_caps.c</span><br><span>index ca7ef44..d44f1a6 100644</span><br><span>--- a/res/res_pjsip_session/pjsip_session_caps.c</span><br><span>+++ b/res/res_pjsip_session/pjsip_session_caps.c</span><br><span>@@ -68,34 +68,43 @@</span><br><span> {</span><br><span>      struct ast_format_cap *joint = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);</span><br><span>    struct ast_format_cap *local_filtered = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);</span><br><span style="color: hsl(120, 100%, 40%);">+    struct ast_format_cap *remote_filtered = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!joint || !local_filtered) {</span><br><span style="color: hsl(120, 100%, 40%);">+      if (!joint || !local_filtered || !remote_filtered) {</span><br><span>                 ast_log(LOG_ERROR, "Failed to allocate %s call offer capabilities\n",</span><br><span>                              ast_codec_media_type2str(media_type));</span><br><span>               ao2_cleanup(joint);</span><br><span>          ao2_cleanup(local_filtered);</span><br><span style="color: hsl(120, 100%, 40%);">+          ao2_cleanup(remote_filtered);</span><br><span>                return NULL;</span><br><span>         }</span><br><span> </span><br><span>        ast_format_cap_append_from_cap(local_filtered, local, media_type);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+        /* Remote should always be a subset of local, as local is what defines the underlying</span><br><span style="color: hsl(120, 100%, 40%);">+  * permitted formats.</span><br><span style="color: hsl(120, 100%, 40%);">+  */</span><br><span style="color: hsl(120, 100%, 40%);">+   ast_format_cap_get_compatible(remote, local_filtered, remote_filtered);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>    if (ast_sip_call_codec_pref_test(codec_pref, LOCAL)) {</span><br><span>               if (ast_sip_call_codec_pref_test(codec_pref, INTERSECT)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                      ast_format_cap_get_compatible(local_filtered, remote, joint); /* Get common, prefer local */</span><br><span style="color: hsl(120, 100%, 40%);">+                  ast_format_cap_get_compatible(local_filtered, remote_filtered, joint); /* Get common, prefer local */</span><br><span>                } else {</span><br><span>                     ast_format_cap_append_from_cap(joint, local_filtered, media_type); /* Add local */</span><br><span style="color: hsl(0, 100%, 40%);">-                      ast_format_cap_append_from_cap(joint, remote, media_type); /* Then remote */</span><br><span style="color: hsl(120, 100%, 40%);">+                  ast_format_cap_append_from_cap(joint, remote_filtered, media_type); /* Then remote */</span><br><span>                }</span><br><span>    } else {</span><br><span>             if (ast_sip_call_codec_pref_test(codec_pref, INTERSECT)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                      ast_format_cap_get_compatible(remote, local_filtered, joint); /* Get common, prefer remote */</span><br><span style="color: hsl(120, 100%, 40%);">+                 joint = remote_filtered; /* Get common, prefer remote - as was done when filtering initially */</span><br><span style="color: hsl(120, 100%, 40%);">+                       remote_filtered = NULL;</span><br><span>              } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                        ast_format_cap_append_from_cap(joint, remote, media_type); /* Add remote */</span><br><span style="color: hsl(120, 100%, 40%);">+                   ast_format_cap_append_from_cap(joint, remote_filtered, media_type); /* Add remote */</span><br><span>                         ast_format_cap_append_from_cap(joint, local_filtered, media_type); /* Then local */</span><br><span>          }</span><br><span>    }</span><br><span> </span><br><span>        ao2_ref(local_filtered, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+  ao2_cleanup(remote_filtered);</span><br><span> </span><br><span>    if (ast_format_cap_empty(joint)) {</span><br><span>           return joint;</span><br><span>diff --git a/tests/test_res_pjsip_session_caps.c b/tests/test_res_pjsip_session_caps.c</span><br><span>index 54438f5..a97c214 100644</span><br><span>--- a/tests/test_res_pjsip_session_caps.c</span><br><span>+++ b/tests/test_res_pjsip_session_caps.c</span><br><span>@@ -147,11 +147,11 @@</span><br><span>       ast_test_status_update(test, "Testing outgoing expected pass\n");</span><br><span>  RUN_CREATE_JOINT("ulaw,alaw,g722",    "g722,g729,alaw",     "local",              1,      "alaw,g722",                  AST_TEST_PASS);</span><br><span>      RUN_CREATE_JOINT("ulaw,alaw,g722",    "g722,g729,alaw",     "local_first",        1,      "alaw",                                       AST_TEST_PASS);</span><br><span style="color: hsl(0, 100%, 40%);">- RUN_CREATE_JOINT("ulaw,alaw,g722",    "g722,g729,alaw",     "local_merge",        1,      "ulaw,alaw,g722,g729",        AST_TEST_PASS);</span><br><span style="color: hsl(120, 100%, 40%);">+       RUN_CREATE_JOINT("ulaw,alaw,g722",    "g722,g729,alaw",     "local_merge",        1,      "ulaw,alaw,g722",     AST_TEST_PASS);</span><br><span>      RUN_CREATE_JOINT("ulaw,alaw,g722",    "g722,g729,alaw",     "remote",             1,      "g722,alaw",                  AST_TEST_PASS);</span><br><span>      RUN_CREATE_JOINT("ulaw,alaw,g722",    "g722,g729,alaw",     "remote_first",       1,      "g722",                                       AST_TEST_PASS);</span><br><span style="color: hsl(0, 100%, 40%);">- RUN_CREATE_JOINT("ulaw,alaw,g722",    "g722,g729,alaw",     "remote_merge",       1,      "g722,g729,alaw,ulaw",        AST_TEST_PASS);</span><br><span style="color: hsl(0, 100%, 40%);">- RUN_CREATE_JOINT("!all",                      "g722,g729,alaw",     "remote_merge",       1,      "g722,g729,alaw",             AST_TEST_PASS);</span><br><span style="color: hsl(120, 100%, 40%);">+       RUN_CREATE_JOINT("ulaw,alaw,g722",    "g722,g729,alaw",     "remote_merge",       1,      "g722,alaw,ulaw",     AST_TEST_PASS);</span><br><span style="color: hsl(120, 100%, 40%);">+       RUN_CREATE_JOINT("!all",                      "g722,g729,alaw",     "remote_merge",       1,      "nothing",            AST_TEST_PASS);</span><br><span> </span><br><span>  return rc >= 1 ? AST_TEST_FAIL : AST_TEST_PASS;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15040">change 15040</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/+/15040"/><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: Iad19347bd5f3d89900c15ecddfebf5e20950a1c2 </div>
<div style="display:none"> Gerrit-Change-Number: 15040 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.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: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>