[Asterisk-code-review] channel.c: Allow generic plc then channel formats are equal (asterisk[13])
Jenkins2
asteriskteam at digium.com
Tue Mar 20 11:03:39 CDT 2018
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8553 )
Change subject: channel.c: Allow generic plc then channel formats are equal
......................................................................
channel.c: Allow generic plc then channel formats are equal
If the two formats on a channel are equal, we don't transcode and since
the generic plc needs slin to work, it doesn't get invoked.
* A new configuration option "genericplc_on_equal_codecs" was added
to the "plc" section of codecs.conf to allow generic packet loss
concealment even if no transcoding was originally needed.
Transcoding via SLIN is forced in this case.
ASTERISK-27743
Change-Id: I0577026a179dea34232e63123254b4e0508378f4
---
M CHANGES
M configs/samples/codecs.conf.sample
M include/asterisk/options.h
M main/asterisk.c
M main/channel.c
5 files changed, 35 insertions(+), 4 deletions(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/CHANGES b/CHANGES
index 037af04..753f6ae 100644
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,13 @@
--- Functionality changes from Asterisk 13.20.0 to Asterisk 13.21.0 ----------
------------------------------------------------------------------------------
+Core
+------------------
+ * A new configuration option "genericplc_on_equal_codecs" was added to the
+ "plc" section of codecs.conf to allow generic packet loss concealment even
+ if no transcoding was originally needed. Transcoding via SLIN is forced
+ in this case.
+
res_pjproject
------------------
* Added the "cache_pools" option to pjproject.conf. Disabling the option
diff --git a/configs/samples/codecs.conf.sample b/configs/samples/codecs.conf.sample
index e1dbd79..a87f23e 100644
--- a/configs/samples/codecs.conf.sample
+++ b/configs/samples/codecs.conf.sample
@@ -61,8 +61,15 @@
[plc]
; for all codecs which do not support native PLC
; this determines whether to perform generic PLC
-; there is a minor performance penalty for this
+; there is a minor performance penalty for this.
+; By default plc is applied only when the 2 codecs
+; in a channel are different.
genericplc => true
+; Apply generic plc to channels even if the 2 codecs
+; are the same. This forces transcoding via slin so
+; the performance impact should be considered.
+; Ignored if genericplc is not also enabled.
+genericplc_on_equal_codecs => false
; Generate custom formats for formats requiring attributes.
; After defining the custom format, the name used in defining
diff --git a/include/asterisk/options.h b/include/asterisk/options.h
index 27f1d91..0e8fb97 100644
--- a/include/asterisk/options.h
+++ b/include/asterisk/options.h
@@ -98,6 +98,8 @@
AST_OPT_FLAG_LOCK_CONFIG_DIR = (1 << 29),
/*! Generic PLC */
AST_OPT_FLAG_GENERIC_PLC = (1 << 30),
+ /*! Generic PLC onm equal codecs */
+ AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS = (1 << 31),
};
/*! These are the options that set by default when Asterisk starts */
@@ -134,6 +136,7 @@
#define ast_opt_hide_connect ast_test_flag(&ast_options, AST_OPT_FLAG_HIDE_CONSOLE_CONNECT)
#define ast_opt_lock_confdir ast_test_flag(&ast_options, AST_OPT_FLAG_LOCK_CONFIG_DIR)
#define ast_opt_generic_plc ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC)
+#define ast_opt_generic_plc_on_equal_codecs ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS)
/*! Maximum log level defined by PJPROJECT. */
#define MAX_PJ_LOG_MAX_LEVEL 6
diff --git a/main/asterisk.c b/main/asterisk.c
index ee17c82..b14f944 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -676,6 +676,7 @@
ast_cli(a->fd, " Transcode via SLIN: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN) ? "Enabled" : "Disabled");
ast_cli(a->fd, " Transmit silence during rec: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) ? "Enabled" : "Disabled");
ast_cli(a->fd, " Generic PLC: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC) ? "Enabled" : "Disabled");
+ 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");
ast_cli(a->fd, " Min DTMF duration:: %u\n", option_dtmfminduration);
#if !defined(LOW_MEMORY)
ast_cli(a->fd, " Cache media frames: %s\n", ast_opt_cache_media_frames ? "Enabled" : "Disabled");
diff --git a/main/channel.c b/main/channel.c
index 70e0bff..8726fc7 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -6568,11 +6568,15 @@
* to use SLINEAR between channels, but only if there is
* no direct conversion available. If generic PLC is
* desired, then transcoding via SLINEAR is a requirement
+ * even if the formats are the same.
*/
- if (ast_format_cmp(best_dst_fmt, best_src_fmt) == AST_FORMAT_CMP_NOT_EQUAL
- && (ast_opt_generic_plc || ast_opt_transcode_via_slin)) {
+ if (ast_opt_generic_plc_on_equal_codecs
+ || (ast_format_cmp(best_dst_fmt, best_src_fmt) == AST_FORMAT_CMP_NOT_EQUAL
+ && (ast_opt_generic_plc || ast_opt_transcode_via_slin))) {
+
int use_slin = (ast_format_cache_is_slinear(best_src_fmt)
- || ast_format_cache_is_slinear(best_dst_fmt)) ? 1 : 0;
+ || ast_format_cache_is_slinear(best_dst_fmt))
+ ? 1 : ast_opt_generic_plc_on_equal_codecs;
if (use_slin || ast_translate_path_steps(best_dst_fmt, best_src_fmt) != 1) {
int best_sample_rate = (ast_format_get_sample_rate(best_src_fmt) > ast_format_get_sample_rate(best_dst_fmt)) ?
@@ -7666,8 +7670,17 @@
for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
if (!strcasecmp(var->name, "genericplc")) {
ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC);
+ } else if (!strcasecmp(var->name, "genericplc_on_equal_codecs")) {
+ ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS);
}
}
+
+ /*
+ * Force on_equal_codecs to false if generic_plc is false.
+ */
+ if (!ast_opt_generic_plc) {
+ ast_set2_flag(&ast_options, 0, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS);
+ }
ast_config_destroy(cfg);
return 0;
}
--
To view, visit https://gerrit.asterisk.org/8553
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I0577026a179dea34232e63123254b4e0508378f4
Gerrit-Change-Number: 8553
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180320/ddafbdc8/attachment-0001.html>
More information about the asterisk-code-review
mailing list