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

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">channel.c:  Allow generic plc then channel formats are equal<br><br>If the two formats on a channel are equal, we don't transcode and since<br>the generic plc needs slin to work, it doesn't get invoked.<br><br>* A new configuration option "genericplc_on_equal_codecs" was added<br>  to the "plc" section of codecs.conf to allow generic packet loss<br>  concealment even if no transcoding was originally needed.<br>  Transcoding via SLIN is forced in this case.<br><br>ASTERISK-27743<br><br>Change-Id: I0577026a179dea34232e63123254b4e0508378f4<br>---<br>M CHANGES<br>M configs/samples/codecs.conf.sample<br>M include/asterisk/options.h<br>M main/asterisk.c<br>M main/channel.c<br>5 files changed, 35 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/CHANGES b/CHANGES<br>index 84c302a..fcd1516 100644<br>--- a/CHANGES<br>+++ b/CHANGES<br>@@ -12,6 +12,13 @@<br> --- Functionality changes from Asterisk 15.3.0 to Asterisk 15.4.0 ------------<br> ------------------------------------------------------------------------------<br> <br>+Core<br>+------------------<br>+ * A new configuration option "genericplc_on_equal_codecs" was added to the<br>+   "plc" section of codecs.conf to allow generic packet loss concealment even<br>+   if no transcoding was originally needed.  Transcoding via SLIN is forced<br>+   in this case.<br>+<br> res_pjproject<br> ------------------<br>  * Added the "cache_pools" option to pjproject.conf.  Disabling the option<br>diff --git a/configs/samples/codecs.conf.sample b/configs/samples/codecs.conf.sample<br>index 8457fb5..8c9ce66 100644<br>--- a/configs/samples/codecs.conf.sample<br>+++ b/configs/samples/codecs.conf.sample<br>@@ -64,8 +64,15 @@<br> [plc]<br> ; for all codecs which do not support native PLC<br> ; this determines whether to perform generic PLC<br>-; there is a minor performance penalty for this<br>+; there is a minor performance penalty for this.<br>+; By default plc is applied only when the 2 codecs<br>+; in a channel are different.<br> genericplc => true<br>+; Apply generic plc to channels even if the 2 codecs<br>+; are the same.  This forces transcoding via slin so<br>+; the performance impact should be considered.<br>+; Ignored if genericplc is not also enabled.<br>+genericplc_on_equal_codecs => false<br> <br> ; Generate custom formats for formats requiring attributes.<br> ; After defining the custom format, the name used in defining<br>diff --git a/include/asterisk/options.h b/include/asterisk/options.h<br>index 78f596a..fc366ca 100644<br>--- a/include/asterisk/options.h<br>+++ b/include/asterisk/options.h<br>@@ -98,6 +98,8 @@<br>     AST_OPT_FLAG_LOCK_CONFIG_DIR = (1 << 29),<br>       /*! Generic PLC */<br>    AST_OPT_FLAG_GENERIC_PLC = (1 << 30),<br>+  /*! Generic PLC onm equal codecs */<br>+  AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS = (1 << 31),<br> };<br> <br> /*! These are the options that set by default when Asterisk starts */<br>@@ -134,6 +136,7 @@<br> #define ast_opt_lock_confdir         ast_test_flag(&ast_options, AST_OPT_FLAG_LOCK_CONFIG_DIR)<br> #define ast_opt_generic_plc         ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC)<br> #define ast_opt_ref_debug           ast_test_flag(&ast_options, AST_OPT_FLAG_REF_DEBUG)<br>+#define ast_opt_generic_plc_on_equal_codecs  ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS)<br> <br> /*! Maximum log level defined by PJPROJECT. */<br> #define MAX_PJ_LOG_MAX_LEVEL         6<br>diff --git a/main/asterisk.c b/main/asterisk.c<br>index f5d1c21..46ea61f 100644<br>--- a/main/asterisk.c<br>+++ b/main/asterisk.c<br>@@ -607,6 +607,7 @@<br>   ast_cli(a->fd, "  Transcode via SLIN:          %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN) ? "Enabled" : "Disabled");<br>    ast_cli(a->fd, "  Transmit silence during rec: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) ? "Enabled" : "Disabled");<br>      ast_cli(a->fd, "  Generic PLC:                 %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC) ? "Enabled" : "Disabled");<br>+  ast_cli(a->fd, "  Generic PLC on equal codecs: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS) ? "Enabled" : "Disabled");<br>   ast_cli(a->fd, "  Min DTMF duration::          %u\n", option_dtmfminduration);<br> #if !defined(LOW_MEMORY)<br>        ast_cli(a->fd, "  Cache media frames:          %s\n", ast_opt_cache_media_frames ? "Enabled" : "Disabled");<br>diff --git a/main/channel.c b/main/channel.c<br>index 304fae1..874f7f6 100644<br>--- a/main/channel.c<br>+++ b/main/channel.c<br>@@ -6485,11 +6485,15 @@<br>         * to use SLINEAR between channels, but only if there is<br>       * no direct conversion available. If generic PLC is<br>   * desired, then transcoding via SLINEAR is a requirement<br>+     * even if the formats are the same.<br>   */<br>-  if (ast_format_cmp(best_dst_fmt, best_src_fmt) == AST_FORMAT_CMP_NOT_EQUAL<br>-           && (ast_opt_generic_plc || ast_opt_transcode_via_slin)) {<br>+    if (ast_opt_generic_plc_on_equal_codecs<br>+              || (ast_format_cmp(best_dst_fmt, best_src_fmt) == AST_FORMAT_CMP_NOT_EQUAL<br>+                   && (ast_opt_generic_plc || ast_opt_transcode_via_slin))) {<br>+<br>                 int use_slin = (ast_format_cache_is_slinear(best_src_fmt)<br>-                    || ast_format_cache_is_slinear(best_dst_fmt)) ? 1 : 0;<br>+                       || ast_format_cache_is_slinear(best_dst_fmt))<br>+                        ? 1 : ast_opt_generic_plc_on_equal_codecs;<br> <br>                 if (use_slin || ast_translate_path_steps(best_dst_fmt, best_src_fmt) != 1) {<br>                  int best_sample_rate = (ast_format_get_sample_rate(best_src_fmt) > ast_format_get_sample_rate(best_dst_fmt)) ?<br>@@ -7591,8 +7595,17 @@<br>     for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {<br>              if (!strcasecmp(var->name, "genericplc")) {<br>                      ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC);<br>+          } else if (!strcasecmp(var->name, "genericplc_on_equal_codecs")) {<br>+                      ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS);<br>           }<br>     }<br>+<br>+ /*<br>+    * Force on_equal_codecs to false if generic_plc is false.<br>+    */<br>+  if (!ast_opt_generic_plc) {<br>+          ast_set2_flag(&ast_options, 0, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS);<br>+        }<br>     ast_config_destroy(cfg);<br>      return 0;<br> }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8554">change 8554</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/8554"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I0577026a179dea34232e63123254b4e0508378f4 </div>
<div style="display:none"> Gerrit-Change-Number: 8554 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@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: Richard Mudgett <rmudgett@digium.com> </div>