diff --git a/CHANGES b/CHANGES index 0f4ced2afd41ff297fbd8ec2fb755a45057dfcfe..09a7659d46983a681c375a0d946378fb41892cac 100644 --- a/CHANGES +++ b/CHANGES @@ -101,6 +101,13 @@ Core: --- Functionality changes from Asterisk 15.3.0 to Asterisk 15.4.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 8457fb5ac3c0b1affcf988ea7184df833e9bc63d..8c9ce66313126e450d6744d21b59bbb5bed04872 100644 --- a/configs/samples/codecs.conf.sample +++ b/configs/samples/codecs.conf.sample @@ -64,8 +64,15 @@ experimental_rtcp_feedback => false [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 78f596a8847d3d4c63cbc9c946b57967323b76cd..fc366caa544ea70c78df337777590a31eaeccd48 100644 --- a/include/asterisk/options.h +++ b/include/asterisk/options.h @@ -98,6 +98,8 @@ enum ast_option_flags { 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 @@ enum ast_option_flags { #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_ref_debug ast_test_flag(&ast_options, AST_OPT_FLAG_REF_DEBUG) +#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 2a7e3016684412bf3cc8a9aec211d30ea2174abf..89fc441cb082ed95249d9bf371ca99670edb0c5d 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -599,6 +599,7 @@ static char *handle_show_settings(struct ast_cli_entry *e, int cmd, struct ast_c 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 c7847cbd405e574acde57353db7999bff92c2931..8325f19c3595401a6b6586c923b26f7e9e1262c6 100644 --- a/main/channel.c +++ b/main/channel.c @@ -6485,11 +6485,15 @@ static int ast_channel_make_compatible_helper(struct ast_channel *from, struct a * 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)) ? diff --git a/main/plc.c b/main/plc.c index 847ce65b0b85fc90326fc3efb52889bca2afc1ab..369d285a585101580654673a018e557c980fb0c7 100644 --- a/main/plc.c +++ b/main/plc.c @@ -262,10 +262,19 @@ static int reload_module(void) 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); } } ast_config_destroy(cfg); + /* + * 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); + } + return 0; }