blob: 39713a1fb47b619884aeda2d86e350532bc97f8a [file] [log] [blame]
Sam Zackrissona4c85142018-10-10 10:44:43 +02001/*
2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10#include "api/audio/echo_canceller3_config_json.h"
11
Yves Gerey3e707812018-11-28 16:47:49 +010012#include <stddef.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020013
Sam Zackrissona4c85142018-10-10 10:44:43 +020014#include <string>
15#include <vector>
16
Yves Gerey3e707812018-11-28 16:47:49 +010017#include "rtc_base/checks.h"
Sam Zackrissona4c85142018-10-10 10:44:43 +020018#include "rtc_base/logging.h"
19#include "rtc_base/strings/json.h"
20#include "rtc_base/strings/string_builder.h"
21
22namespace webrtc {
23namespace {
24void ReadParam(const Json::Value& root, std::string param_name, bool* param) {
25 RTC_DCHECK(param);
26 bool v;
27 if (rtc::GetBoolFromJsonObject(root, param_name, &v)) {
28 *param = v;
29 }
30}
31
32void ReadParam(const Json::Value& root, std::string param_name, size_t* param) {
33 RTC_DCHECK(param);
34 int v;
Sam Zackrisson528a0342019-10-22 11:36:17 +020035 if (rtc::GetIntFromJsonObject(root, param_name, &v) && v >= 0) {
Sam Zackrissona4c85142018-10-10 10:44:43 +020036 *param = v;
37 }
38}
39
40void ReadParam(const Json::Value& root, std::string param_name, int* param) {
41 RTC_DCHECK(param);
42 int v;
43 if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
44 *param = v;
45 }
46}
47
48void ReadParam(const Json::Value& root, std::string param_name, float* param) {
49 RTC_DCHECK(param);
50 double v;
51 if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) {
52 *param = static_cast<float>(v);
53 }
54}
55
56void ReadParam(const Json::Value& root,
57 std::string param_name,
Per Åhgrenff045112020-03-20 11:20:39 +010058 EchoCanceller3Config::Filter::RefinedConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020059 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020060 Json::Value json_array;
61 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
62 std::vector<double> v;
63 rtc::JsonArrayToDoubleVector(json_array, &v);
64 if (v.size() != 6) {
65 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +020066 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020067 }
68 param->length_blocks = static_cast<size_t>(v[0]);
69 param->leakage_converged = static_cast<float>(v[1]);
70 param->leakage_diverged = static_cast<float>(v[2]);
71 param->error_floor = static_cast<float>(v[3]);
72 param->error_ceil = static_cast<float>(v[4]);
73 param->noise_gate = static_cast<float>(v[5]);
74 }
75}
76
77void ReadParam(const Json::Value& root,
78 std::string param_name,
Per Åhgren9d661982020-03-20 11:26:48 +010079 EchoCanceller3Config::Filter::CoarseConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020080 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020081 Json::Value json_array;
82 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
83 std::vector<double> v;
84 rtc::JsonArrayToDoubleVector(json_array, &v);
85 if (v.size() != 3) {
86 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +020087 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020088 }
89 param->length_blocks = static_cast<size_t>(v[0]);
90 param->rate = static_cast<float>(v[1]);
91 param->noise_gate = static_cast<float>(v[2]);
92 }
93}
94
Per Åhgren6a05bb12019-12-03 11:24:59 +010095void ReadParam(const Json::Value& root,
96 std::string param_name,
97 EchoCanceller3Config::Delay::AlignmentMixing* param) {
98 RTC_DCHECK(param);
99
100 Json::Value subsection;
101 if (rtc::GetValueFromJsonObject(root, param_name, &subsection)) {
102 ReadParam(subsection, "downmix", &param->downmix);
103 ReadParam(subsection, "adaptive_selection", &param->adaptive_selection);
104 ReadParam(subsection, "activity_power_threshold",
105 &param->activity_power_threshold);
106 ReadParam(subsection, "prefer_first_two_channels",
107 &param->prefer_first_two_channels);
108 }
109}
110
Gustaf Ullbergf534a642019-11-25 16:13:58 +0100111void ReadParam(
112 const Json::Value& root,
113 std::string param_name,
114 EchoCanceller3Config::Suppressor::SubbandNearendDetection::SubbandRegion*
115 param) {
116 RTC_DCHECK(param);
117 Json::Value json_array;
118 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
119 std::vector<int> v;
120 rtc::JsonArrayToIntVector(json_array, &v);
121 if (v.size() != 2) {
122 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
123 return;
124 }
125 param->low = static_cast<size_t>(v[0]);
126 param->high = static_cast<size_t>(v[1]);
127 }
128}
129
Sam Zackrissona4c85142018-10-10 10:44:43 +0200130void ReadParam(const Json::Value& root,
131 std::string param_name,
132 EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +0200133 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200134 Json::Value json_array;
135 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
136 std::vector<double> v;
137 rtc::JsonArrayToDoubleVector(json_array, &v);
138 if (v.size() != 3) {
139 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +0200140 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200141 }
142 param->enr_transparent = static_cast<float>(v[0]);
143 param->enr_suppress = static_cast<float>(v[1]);
144 param->emr_transparent = static_cast<float>(v[2]);
145 }
146}
147} // namespace
148
Per Åhgren370bae42018-10-25 11:32:39 +0200149void Aec3ConfigFromJsonString(absl::string_view json_string,
150 EchoCanceller3Config* config,
151 bool* parsing_successful) {
152 RTC_DCHECK(config);
153 RTC_DCHECK(parsing_successful);
154 EchoCanceller3Config& cfg = *config;
155 cfg = EchoCanceller3Config();
156 *parsing_successful = true;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200157
158 Json::Value root;
159 bool success = Json::Reader().parse(std::string(json_string), root);
160 if (!success) {
161 RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200162 *parsing_successful = false;
163 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200164 }
165
166 Json::Value aec3_root;
167 success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
168 if (!success) {
169 RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200170 *parsing_successful = false;
171 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200172 }
173
174 Json::Value section;
Per Åhgrenc1d20922019-04-22 23:36:58 +0200175 if (rtc::GetValueFromJsonObject(aec3_root, "buffering", &section)) {
Gustaf Ullberg11539f02018-10-15 13:40:29 +0200176 ReadParam(section, "excess_render_detection_interval_blocks",
177 &cfg.buffering.excess_render_detection_interval_blocks);
178 ReadParam(section, "max_allowed_excess_render_blocks",
179 &cfg.buffering.max_allowed_excess_render_blocks);
180 }
181
Sam Zackrissona4c85142018-10-10 10:44:43 +0200182 if (rtc::GetValueFromJsonObject(aec3_root, "delay", &section)) {
183 ReadParam(section, "default_delay", &cfg.delay.default_delay);
184 ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
185 ReadParam(section, "num_filters", &cfg.delay.num_filters);
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100186 ReadParam(section, "delay_headroom_samples",
187 &cfg.delay.delay_headroom_samples);
188 ReadParam(section, "hysteresis_limit_blocks",
189 &cfg.delay.hysteresis_limit_blocks);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200190 ReadParam(section, "fixed_capture_delay_samples",
191 &cfg.delay.fixed_capture_delay_samples);
192 ReadParam(section, "delay_estimate_smoothing",
193 &cfg.delay.delay_estimate_smoothing);
Gustaf Ullbergaeb8ce82021-05-19 14:26:31 +0200194 ReadParam(section, "delay_estimate_smoothing_delay_found",
195 &cfg.delay.delay_estimate_smoothing_delay_found);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200196 ReadParam(section, "delay_candidate_detection_threshold",
197 &cfg.delay.delay_candidate_detection_threshold);
198
199 Json::Value subsection;
200 if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
201 &subsection)) {
202 ReadParam(subsection, "initial",
203 &cfg.delay.delay_selection_thresholds.initial);
204 ReadParam(subsection, "converged",
205 &cfg.delay.delay_selection_thresholds.converged);
206 }
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200207
208 ReadParam(section, "use_external_delay_estimator",
209 &cfg.delay.use_external_delay_estimator);
Sam Zackrissonffc84522019-10-15 13:43:02 +0200210 ReadParam(section, "log_warning_on_delay_changes",
211 &cfg.delay.log_warning_on_delay_changes);
Per Åhgren6a05bb12019-12-03 11:24:59 +0100212
213 ReadParam(section, "render_alignment_mixing",
214 &cfg.delay.render_alignment_mixing);
215 ReadParam(section, "capture_alignment_mixing",
216 &cfg.delay.capture_alignment_mixing);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200217 }
218
219 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
Per Åhgrenff045112020-03-20 11:20:39 +0100220 ReadParam(section, "refined", &cfg.filter.refined);
Per Åhgren9d661982020-03-20 11:26:48 +0100221 ReadParam(section, "coarse", &cfg.filter.coarse);
Per Åhgrenff045112020-03-20 11:20:39 +0100222 ReadParam(section, "refined_initial", &cfg.filter.refined_initial);
Per Åhgren9d661982020-03-20 11:26:48 +0100223 ReadParam(section, "coarse_initial", &cfg.filter.coarse_initial);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200224 ReadParam(section, "config_change_duration_blocks",
225 &cfg.filter.config_change_duration_blocks);
226 ReadParam(section, "initial_state_seconds",
227 &cfg.filter.initial_state_seconds);
Gustaf Ullberg992a96f2020-12-08 13:03:55 +0100228 ReadParam(section, "coarse_reset_hangover_blocks",
229 &cfg.filter.coarse_reset_hangover_blocks);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200230 ReadParam(section, "conservative_initial_phase",
231 &cfg.filter.conservative_initial_phase);
Per Åhgren9d661982020-03-20 11:26:48 +0100232 ReadParam(section, "enable_coarse_filter_output_usage",
233 &cfg.filter.enable_coarse_filter_output_usage);
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200234 ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter);
Gustaf Ullberg09226fc2021-02-19 13:03:14 +0100235 ReadParam(section, "high_pass_filter_echo_reference",
236 &cfg.filter.high_pass_filter_echo_reference);
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100237 ReadParam(section, "export_linear_aec_output",
238 &cfg.filter.export_linear_aec_output);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200239 }
240
241 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
242 ReadParam(section, "min", &cfg.erle.min);
243 ReadParam(section, "max_l", &cfg.erle.max_l);
244 ReadParam(section, "max_h", &cfg.erle.max_h);
245 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100246 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Per Åhgren8be669f2019-10-11 23:02:26 +0200247 ReadParam(section, "clamp_quality_estimate_to_zero",
248 &cfg.erle.clamp_quality_estimate_to_zero);
249 ReadParam(section, "clamp_quality_estimate_to_one",
250 &cfg.erle.clamp_quality_estimate_to_one);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200251 }
252
253 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100254 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200255 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200256 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
257 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
Gustaf Ullberg437d1292021-04-20 13:48:57 +0200258 ReadParam(section, "erle_onset_compensation_in_dominant_nearend",
259 &cfg.ep_strength.erle_onset_compensation_in_dominant_nearend);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200260 }
261
Sam Zackrissona4c85142018-10-10 10:44:43 +0200262 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
263 ReadParam(section, "low_render_limit",
264 &cfg.echo_audibility.low_render_limit);
265 ReadParam(section, "normal_render_limit",
266 &cfg.echo_audibility.normal_render_limit);
267
268 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
269 ReadParam(section, "audibility_threshold_lf",
270 &cfg.echo_audibility.audibility_threshold_lf);
271 ReadParam(section, "audibility_threshold_mf",
272 &cfg.echo_audibility.audibility_threshold_mf);
273 ReadParam(section, "audibility_threshold_hf",
274 &cfg.echo_audibility.audibility_threshold_hf);
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200275 ReadParam(section, "use_stationarity_properties",
276 &cfg.echo_audibility.use_stationarity_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200277 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200278 &cfg.echo_audibility.use_stationarity_properties_at_init);
279 }
280
Per Åhgren01cf44d2018-10-20 00:17:13 +0200281 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
282 ReadParam(section, "active_render_limit",
283 &cfg.render_levels.active_render_limit);
284 ReadParam(section, "poor_excitation_render_limit",
285 &cfg.render_levels.poor_excitation_render_limit);
286 ReadParam(section, "poor_excitation_render_limit_ds8",
287 &cfg.render_levels.poor_excitation_render_limit_ds8);
Per Åhgrenae40e192019-10-29 22:54:05 +0100288 ReadParam(section, "render_power_gain_db",
289 &cfg.render_levels.render_power_gain_db);
Per Åhgren01cf44d2018-10-20 00:17:13 +0200290 }
291
Sam Zackrissona4c85142018-10-10 10:44:43 +0200292 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
293 &section)) {
Sam Zackrissona4c85142018-10-10 10:44:43 +0200294 ReadParam(section, "has_clock_drift",
295 &cfg.echo_removal_control.has_clock_drift);
296 ReadParam(section, "linear_and_stable_echo_path",
297 &cfg.echo_removal_control.linear_and_stable_echo_path);
298 }
299
300 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
301 Json::Value subsection;
302 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
303 ReadParam(section, "min_noise_floor_power",
304 &cfg.echo_model.min_noise_floor_power);
305 ReadParam(section, "stationary_gate_slope",
306 &cfg.echo_model.stationary_gate_slope);
307 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
308 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
309 ReadParam(section, "render_pre_window_size",
310 &cfg.echo_model.render_pre_window_size);
311 ReadParam(section, "render_post_window_size",
312 &cfg.echo_model.render_post_window_size);
Sam Zackrisson389bf0f2020-10-02 21:13:13 +0200313 ReadParam(section, "model_reverb_in_nonlinear_mode",
314 &cfg.echo_model.model_reverb_in_nonlinear_mode);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200315 }
316
Per Åhgrena388b752020-03-25 07:31:47 +0100317 if (rtc::GetValueFromJsonObject(aec3_root, "comfort_noise", &section)) {
318 ReadParam(section, "noise_floor_dbfs", &cfg.comfort_noise.noise_floor_dbfs);
319 }
320
Sam Zackrissona4c85142018-10-10 10:44:43 +0200321 Json::Value subsection;
322 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
323 ReadParam(section, "nearend_average_blocks",
324 &cfg.suppressor.nearend_average_blocks);
325
326 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
327 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
328 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
329 ReadParam(subsection, "max_inc_factor",
330 &cfg.suppressor.normal_tuning.max_inc_factor);
331 ReadParam(subsection, "max_dec_factor_lf",
332 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
333 }
334
335 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
336 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
337 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
338 ReadParam(subsection, "max_inc_factor",
339 &cfg.suppressor.nearend_tuning.max_inc_factor);
340 ReadParam(subsection, "max_dec_factor_lf",
341 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
342 }
343
344 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
345 &subsection)) {
346 ReadParam(subsection, "enr_threshold",
347 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200348 ReadParam(subsection, "enr_exit_threshold",
349 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200350 ReadParam(subsection, "snr_threshold",
351 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
352 ReadParam(subsection, "hold_duration",
353 &cfg.suppressor.dominant_nearend_detection.hold_duration);
354 ReadParam(subsection, "trigger_threshold",
355 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200356 ReadParam(
357 subsection, "use_during_initial_phase",
358 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200359 }
360
Gustaf Ullbergf534a642019-11-25 16:13:58 +0100361 if (rtc::GetValueFromJsonObject(section, "subband_nearend_detection",
362 &subsection)) {
363 ReadParam(
364 subsection, "nearend_average_blocks",
365 &cfg.suppressor.subband_nearend_detection.nearend_average_blocks);
366 ReadParam(subsection, "subband1",
367 &cfg.suppressor.subband_nearend_detection.subband1);
368 ReadParam(subsection, "subband2",
369 &cfg.suppressor.subband_nearend_detection.subband2);
370 ReadParam(subsection, "nearend_threshold",
371 &cfg.suppressor.subband_nearend_detection.nearend_threshold);
372 ReadParam(subsection, "snr_threshold",
373 &cfg.suppressor.subband_nearend_detection.snr_threshold);
374 }
375
376 ReadParam(section, "use_subband_nearend_detection",
377 &cfg.suppressor.use_subband_nearend_detection);
378
Sam Zackrissona4c85142018-10-10 10:44:43 +0200379 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
380 &subsection)) {
381 ReadParam(subsection, "enr_threshold",
382 &cfg.suppressor.high_bands_suppression.enr_threshold);
383 ReadParam(subsection, "max_gain_during_echo",
384 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
Per Åhgren17e4c582019-11-27 08:13:24 +0100385 ReadParam(subsection, "anti_howling_activation_threshold",
386 &cfg.suppressor.high_bands_suppression
387 .anti_howling_activation_threshold);
388 ReadParam(subsection, "anti_howling_gain",
389 &cfg.suppressor.high_bands_suppression.anti_howling_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200390 }
391
392 ReadParam(section, "floor_first_increase",
393 &cfg.suppressor.floor_first_increase);
Gustaf Ullberg7e4ad822020-10-22 14:36:37 +0200394 ReadParam(section, "conservative_hf_suppression",
395 &cfg.suppressor.conservative_hf_suppression);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200396 }
Per Åhgren370bae42018-10-25 11:32:39 +0200397}
398
399EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
400 EchoCanceller3Config cfg;
401 bool not_used;
402 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200403 return cfg;
404}
405
406std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
407 rtc::StringBuilder ost;
408 ost << "{";
409 ost << "\"aec3\": {";
Per Åhgrenc1d20922019-04-22 23:36:58 +0200410 ost << "\"buffering\": {";
411 ost << "\"excess_render_detection_interval_blocks\": "
412 << config.buffering.excess_render_detection_interval_blocks << ",";
413 ost << "\"max_allowed_excess_render_blocks\": "
414 << config.buffering.max_allowed_excess_render_blocks;
415 ost << "},";
416
Sam Zackrissona4c85142018-10-10 10:44:43 +0200417 ost << "\"delay\": {";
418 ost << "\"default_delay\": " << config.delay.default_delay << ",";
419 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
420 << ",";
421 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100422 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200423 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100424 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
425 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200426 ost << "\"fixed_capture_delay_samples\": "
427 << config.delay.fixed_capture_delay_samples << ",";
428 ost << "\"delay_estimate_smoothing\": "
429 << config.delay.delay_estimate_smoothing << ",";
Gustaf Ullbergaeb8ce82021-05-19 14:26:31 +0200430 ost << "\"delay_estimate_smoothing_delay_found\": "
431 << config.delay.delay_estimate_smoothing_delay_found << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200432 ost << "\"delay_candidate_detection_threshold\": "
433 << config.delay.delay_candidate_detection_threshold << ",";
434
435 ost << "\"delay_selection_thresholds\": {";
436 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
437 << ",";
438 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200439 ost << "},";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200440
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200441 ost << "\"use_external_delay_estimator\": "
442 << (config.delay.use_external_delay_estimator ? "true" : "false") << ",";
Sam Zackrissonffc84522019-10-15 13:43:02 +0200443 ost << "\"log_warning_on_delay_changes\": "
Per Åhgren6a05bb12019-12-03 11:24:59 +0100444 << (config.delay.log_warning_on_delay_changes ? "true" : "false") << ",";
445
446 ost << "\"render_alignment_mixing\": {";
447 ost << "\"downmix\": "
448 << (config.delay.render_alignment_mixing.downmix ? "true" : "false")
449 << ",";
450 ost << "\"adaptive_selection\": "
451 << (config.delay.render_alignment_mixing.adaptive_selection ? "true"
452 : "false")
453 << ",";
454 ost << "\"activity_power_threshold\": "
455 << config.delay.render_alignment_mixing.activity_power_threshold << ",";
456 ost << "\"prefer_first_two_channels\": "
457 << (config.delay.render_alignment_mixing.prefer_first_two_channels
458 ? "true"
459 : "false");
460 ost << "},";
461
462 ost << "\"capture_alignment_mixing\": {";
463 ost << "\"downmix\": "
464 << (config.delay.capture_alignment_mixing.downmix ? "true" : "false")
465 << ",";
466 ost << "\"adaptive_selection\": "
467 << (config.delay.capture_alignment_mixing.adaptive_selection ? "true"
468 : "false")
469 << ",";
470 ost << "\"activity_power_threshold\": "
471 << config.delay.capture_alignment_mixing.activity_power_threshold << ",";
472 ost << "\"prefer_first_two_channels\": "
473 << (config.delay.capture_alignment_mixing.prefer_first_two_channels
474 ? "true"
475 : "false");
476 ost << "}";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200477 ost << "},";
478
479 ost << "\"filter\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200480
Per Åhgrenff045112020-03-20 11:20:39 +0100481 ost << "\"refined\": [";
482 ost << config.filter.refined.length_blocks << ",";
483 ost << config.filter.refined.leakage_converged << ",";
484 ost << config.filter.refined.leakage_diverged << ",";
485 ost << config.filter.refined.error_floor << ",";
486 ost << config.filter.refined.error_ceil << ",";
487 ost << config.filter.refined.noise_gate;
488 ost << "],";
489
Per Åhgren9d661982020-03-20 11:26:48 +0100490 ost << "\"coarse\": [";
491 ost << config.filter.coarse.length_blocks << ",";
492 ost << config.filter.coarse.rate << ",";
493 ost << config.filter.coarse.noise_gate;
494 ost << "],";
495
Per Åhgrenff045112020-03-20 11:20:39 +0100496 ost << "\"refined_initial\": [";
497 ost << config.filter.refined_initial.length_blocks << ",";
498 ost << config.filter.refined_initial.leakage_converged << ",";
499 ost << config.filter.refined_initial.leakage_diverged << ",";
500 ost << config.filter.refined_initial.error_floor << ",";
501 ost << config.filter.refined_initial.error_ceil << ",";
502 ost << config.filter.refined_initial.noise_gate;
503 ost << "],";
504
Per Åhgren9d661982020-03-20 11:26:48 +0100505 ost << "\"coarse_initial\": [";
506 ost << config.filter.coarse_initial.length_blocks << ",";
507 ost << config.filter.coarse_initial.rate << ",";
508 ost << config.filter.coarse_initial.noise_gate;
509 ost << "],";
510
Sam Zackrissona4c85142018-10-10 10:44:43 +0200511 ost << "\"config_change_duration_blocks\": "
512 << config.filter.config_change_duration_blocks << ",";
513 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
514 << ",";
Gustaf Ullberg992a96f2020-12-08 13:03:55 +0100515 ost << "\"coarse_reset_hangover_blocks\": "
516 << config.filter.coarse_reset_hangover_blocks << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200517 ost << "\"conservative_initial_phase\": "
518 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
Per Åhgren9d661982020-03-20 11:26:48 +0100519 ost << "\"enable_coarse_filter_output_usage\": "
520 << (config.filter.enable_coarse_filter_output_usage ? "true" : "false")
521 << ",";
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100522 ost << "\"use_linear_filter\": "
523 << (config.filter.use_linear_filter ? "true" : "false") << ",";
Gustaf Ullberg09226fc2021-02-19 13:03:14 +0100524 ost << "\"high_pass_filter_echo_reference\": "
525 << (config.filter.high_pass_filter_echo_reference ? "true" : "false")
526 << ",";
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100527 ost << "\"export_linear_aec_output\": "
Per Åhgrene1562872020-04-09 13:12:08 +0200528 << (config.filter.export_linear_aec_output ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200529
530 ost << "},";
531
532 ost << "\"erle\": {";
533 ost << "\"min\": " << config.erle.min << ",";
534 ost << "\"max_l\": " << config.erle.max_l << ",";
535 ost << "\"max_h\": " << config.erle.max_h << ",";
536 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100537 << (config.erle.onset_detection ? "true" : "false") << ",";
Per Åhgren8be669f2019-10-11 23:02:26 +0200538 ost << "\"num_sections\": " << config.erle.num_sections << ",";
539 ost << "\"clamp_quality_estimate_to_zero\": "
540 << (config.erle.clamp_quality_estimate_to_zero ? "true" : "false") << ",";
541 ost << "\"clamp_quality_estimate_to_one\": "
542 << (config.erle.clamp_quality_estimate_to_one ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200543 ost << "},";
544
545 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100546 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200547 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200548 ost << "\"echo_can_saturate\": "
549 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
550 ost << "\"bounded_erl\": "
Gustaf Ullberg437d1292021-04-20 13:48:57 +0200551 << (config.ep_strength.bounded_erl ? "true" : "false") << ",";
552 ost << "\"erle_onset_compensation_in_dominant_nearend\": "
553 << (config.ep_strength.erle_onset_compensation_in_dominant_nearend
554 ? "true"
555 : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200556 ost << "},";
557
Sam Zackrissona4c85142018-10-10 10:44:43 +0200558 ost << "\"echo_audibility\": {";
559 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
560 << ",";
561 ost << "\"normal_render_limit\": "
562 << config.echo_audibility.normal_render_limit << ",";
563 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
564 ost << "\"audibility_threshold_lf\": "
565 << config.echo_audibility.audibility_threshold_lf << ",";
566 ost << "\"audibility_threshold_mf\": "
567 << config.echo_audibility.audibility_threshold_mf << ",";
568 ost << "\"audibility_threshold_hf\": "
569 << config.echo_audibility.audibility_threshold_hf << ",";
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200570 ost << "\"use_stationarity_properties\": "
571 << (config.echo_audibility.use_stationarity_properties ? "true" : "false")
Sam Zackrissona4c85142018-10-10 10:44:43 +0200572 << ",";
573 ost << "\"use_stationarity_properties_at_init\": "
574 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
575 : "false");
576 ost << "},";
577
578 ost << "\"render_levels\": {";
579 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
580 << ",";
581 ost << "\"poor_excitation_render_limit\": "
582 << config.render_levels.poor_excitation_render_limit << ",";
583 ost << "\"poor_excitation_render_limit_ds8\": "
Per Åhgrenae40e192019-10-29 22:54:05 +0100584 << config.render_levels.poor_excitation_render_limit_ds8 << ",";
585 ost << "\"render_power_gain_db\": "
586 << config.render_levels.render_power_gain_db;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200587 ost << "},";
588
589 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200590 ost << "\"has_clock_drift\": "
591 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
592 << ",";
593 ost << "\"linear_and_stable_echo_path\": "
594 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
595 : "false");
596
597 ost << "},";
598
599 ost << "\"echo_model\": {";
600 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
601 ost << "\"min_noise_floor_power\": "
602 << config.echo_model.min_noise_floor_power << ",";
603 ost << "\"stationary_gate_slope\": "
604 << config.echo_model.stationary_gate_slope << ",";
605 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
606 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
607 ost << "\"render_pre_window_size\": "
608 << config.echo_model.render_pre_window_size << ",";
609 ost << "\"render_post_window_size\": "
Sam Zackrisson389bf0f2020-10-02 21:13:13 +0200610 << config.echo_model.render_post_window_size << ",";
611 ost << "\"model_reverb_in_nonlinear_mode\": "
612 << (config.echo_model.model_reverb_in_nonlinear_mode ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200613 ost << "},";
614
Per Åhgrena388b752020-03-25 07:31:47 +0100615 ost << "\"comfort_noise\": {";
616 ost << "\"noise_floor_dbfs\": " << config.comfort_noise.noise_floor_dbfs;
617 ost << "},";
618
Sam Zackrissona4c85142018-10-10 10:44:43 +0200619 ost << "\"suppressor\": {";
620 ost << "\"nearend_average_blocks\": "
621 << config.suppressor.nearend_average_blocks << ",";
622 ost << "\"normal_tuning\": {";
623 ost << "\"mask_lf\": [";
624 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
625 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
626 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
627 ost << "],";
628 ost << "\"mask_hf\": [";
629 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
630 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
631 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
632 ost << "],";
633 ost << "\"max_inc_factor\": "
634 << config.suppressor.normal_tuning.max_inc_factor << ",";
635 ost << "\"max_dec_factor_lf\": "
636 << config.suppressor.normal_tuning.max_dec_factor_lf;
637 ost << "},";
638 ost << "\"nearend_tuning\": {";
639 ost << "\"mask_lf\": [";
640 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
641 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
642 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
643 ost << "],";
644 ost << "\"mask_hf\": [";
645 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
646 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
647 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
648 ost << "],";
649 ost << "\"max_inc_factor\": "
650 << config.suppressor.nearend_tuning.max_inc_factor << ",";
651 ost << "\"max_dec_factor_lf\": "
652 << config.suppressor.nearend_tuning.max_dec_factor_lf;
653 ost << "},";
654 ost << "\"dominant_nearend_detection\": {";
655 ost << "\"enr_threshold\": "
656 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200657 ost << "\"enr_exit_threshold\": "
658 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200659 ost << "\"snr_threshold\": "
660 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
661 ost << "\"hold_duration\": "
662 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
663 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200664 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
665 ost << "\"use_during_initial_phase\": "
666 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200667 ost << "},";
Gustaf Ullbergf534a642019-11-25 16:13:58 +0100668 ost << "\"subband_nearend_detection\": {";
669 ost << "\"nearend_average_blocks\": "
670 << config.suppressor.subband_nearend_detection.nearend_average_blocks
671 << ",";
672 ost << "\"subband1\": [";
673 ost << config.suppressor.subband_nearend_detection.subband1.low << ",";
674 ost << config.suppressor.subband_nearend_detection.subband1.high;
675 ost << "],";
676 ost << "\"subband2\": [";
677 ost << config.suppressor.subband_nearend_detection.subband2.low << ",";
678 ost << config.suppressor.subband_nearend_detection.subband2.high;
679 ost << "],";
680 ost << "\"nearend_threshold\": "
681 << config.suppressor.subband_nearend_detection.nearend_threshold << ",";
682 ost << "\"snr_threshold\": "
683 << config.suppressor.subband_nearend_detection.snr_threshold;
684 ost << "},";
685 ost << "\"use_subband_nearend_detection\": "
686 << config.suppressor.use_subband_nearend_detection << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200687 ost << "\"high_bands_suppression\": {";
688 ost << "\"enr_threshold\": "
689 << config.suppressor.high_bands_suppression.enr_threshold << ",";
690 ost << "\"max_gain_during_echo\": "
Per Åhgren17e4c582019-11-27 08:13:24 +0100691 << config.suppressor.high_bands_suppression.max_gain_during_echo << ",";
692 ost << "\"anti_howling_activation_threshold\": "
693 << config.suppressor.high_bands_suppression
694 .anti_howling_activation_threshold
695 << ",";
696 ost << "\"anti_howling_gain\": "
697 << config.suppressor.high_bands_suppression.anti_howling_gain;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200698 ost << "},";
Gustaf Ullberg7e4ad822020-10-22 14:36:37 +0200699 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
700 << ",";
701 ost << "\"conservative_hf_suppression\": "
702 << config.suppressor.conservative_hf_suppression;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200703 ost << "}";
704 ost << "}";
705 ost << "}";
706
707 return ost.Release();
708}
709} // namespace webrtc