confbridge: Add support for specifying maximum sample rate.

ConfBridge has the ability to move between different sample
rates for mixing the conference bridge. Up until now there has
only been the ability to set the conference bridge to mix at
a specific sample rate, or to let it move between sample rates
as necessary. This change adds the ability to configure a
conference bridge with a maximum sample rate so it can move
between sample rates but only up to the configured maximum.

ASTERISK-28658

Change-Id: Idff80896ccfb8a58a816e4ce9ac4ebde785963ee
This commit is contained in:
Joshua C. Colp
2019-12-12 00:03:46 +00:00
parent 7e441d6b25
commit 89b7144fbd
8 changed files with 74 additions and 1 deletions

View File

@@ -88,12 +88,16 @@ struct softmix_stats {
unsigned int num_channels[16];
/*! The number of channels above the internal sample rate */
unsigned int num_above_internal_rate;
/*! The number of channels above the maximum sample rate */
unsigned int num_above_maximum_rate;
/*! The number of channels at the internal sample rate */
unsigned int num_at_internal_rate;
/*! The absolute highest sample rate preferred by any channel in the bridge */
unsigned int highest_supported_rate;
/*! Is the sample rate locked by the bridge, if so what is that rate.*/
unsigned int locked_rate;
/*! The maximum sample rate the bridge may use */
unsigned int maximum_rate;
};
struct softmix_translate_helper_entry {
@@ -1541,7 +1545,9 @@ static void gather_softmix_stats(struct softmix_stats *stats,
if (stats->highest_supported_rate < channel_native_rate) {
stats->highest_supported_rate = channel_native_rate;
}
if (softmix_data->internal_rate < channel_native_rate) {
if (stats->maximum_rate && stats->maximum_rate < channel_native_rate) {
stats->num_above_maximum_rate++;
} else if (softmix_data->internal_rate < channel_native_rate) {
int i;
for (i = 0; i < ARRAY_LEN(stats->sample_rates); i++) {
@@ -1593,6 +1599,15 @@ static unsigned int analyse_softmix_stats(struct softmix_stats *stats,
softmix_data->internal_rate = stats->locked_rate;
return 1;
}
} else if (stats->num_above_maximum_rate) {
/* if the bridge has a maximum rate set and channels are above it only
* update if it differs from the current rate we are using. */
if (softmix_data->internal_rate != stats->maximum_rate) {
ast_debug(1, "Locking at new maximum rate. Bridge changed from %u to %u.\n",
softmix_data->internal_rate, stats->maximum_rate);
softmix_data->internal_rate = stats->maximum_rate;
return 1;
}
} else if (stats->num_above_internal_rate >= 2) {
/* the highest rate is just used as a starting point */
unsigned int best_rate = stats->highest_supported_rate;
@@ -1775,6 +1790,7 @@ static int softmix_mixing_loop(struct ast_bridge *bridge)
if (!stat_iteration_counter) {
memset(&stats, 0, sizeof(stats));
stats.locked_rate = bridge->softmix.internal_sample_rate;
stats.maximum_rate = bridge->softmix.maximum_sample_rate;
}
/* If the sample rate has changed, update the translator helper */