blob: ab051bd7ea275fc239a9ad16a0165741b66654d3 [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,
58 EchoCanceller3Config::Filter::MainConfiguration* 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,
79 EchoCanceller3Config::Filter::ShadowConfiguration* 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
95void ReadParam(const Json::Value& root,
96 std::string param_name,
97 EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020098 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020099 Json::Value json_array;
100 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
101 std::vector<double> v;
102 rtc::JsonArrayToDoubleVector(json_array, &v);
103 if (v.size() != 3) {
104 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +0200105 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200106 }
107 param->enr_transparent = static_cast<float>(v[0]);
108 param->enr_suppress = static_cast<float>(v[1]);
109 param->emr_transparent = static_cast<float>(v[2]);
110 }
111}
112} // namespace
113
Per Åhgren370bae42018-10-25 11:32:39 +0200114void Aec3ConfigFromJsonString(absl::string_view json_string,
115 EchoCanceller3Config* config,
116 bool* parsing_successful) {
117 RTC_DCHECK(config);
118 RTC_DCHECK(parsing_successful);
119 EchoCanceller3Config& cfg = *config;
120 cfg = EchoCanceller3Config();
121 *parsing_successful = true;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200122
123 Json::Value root;
124 bool success = Json::Reader().parse(std::string(json_string), root);
125 if (!success) {
126 RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200127 *parsing_successful = false;
128 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200129 }
130
131 Json::Value aec3_root;
132 success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
133 if (!success) {
134 RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200135 *parsing_successful = false;
136 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200137 }
138
139 Json::Value section;
Per Åhgrenc1d20922019-04-22 23:36:58 +0200140 if (rtc::GetValueFromJsonObject(aec3_root, "buffering", &section)) {
Gustaf Ullberg11539f02018-10-15 13:40:29 +0200141 ReadParam(section, "excess_render_detection_interval_blocks",
142 &cfg.buffering.excess_render_detection_interval_blocks);
143 ReadParam(section, "max_allowed_excess_render_blocks",
144 &cfg.buffering.max_allowed_excess_render_blocks);
145 }
146
Sam Zackrissona4c85142018-10-10 10:44:43 +0200147 if (rtc::GetValueFromJsonObject(aec3_root, "delay", &section)) {
148 ReadParam(section, "default_delay", &cfg.delay.default_delay);
149 ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
150 ReadParam(section, "num_filters", &cfg.delay.num_filters);
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100151 ReadParam(section, "delay_headroom_samples",
152 &cfg.delay.delay_headroom_samples);
153 ReadParam(section, "hysteresis_limit_blocks",
154 &cfg.delay.hysteresis_limit_blocks);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200155 ReadParam(section, "fixed_capture_delay_samples",
156 &cfg.delay.fixed_capture_delay_samples);
157 ReadParam(section, "delay_estimate_smoothing",
158 &cfg.delay.delay_estimate_smoothing);
159 ReadParam(section, "delay_candidate_detection_threshold",
160 &cfg.delay.delay_candidate_detection_threshold);
161
162 Json::Value subsection;
163 if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
164 &subsection)) {
165 ReadParam(subsection, "initial",
166 &cfg.delay.delay_selection_thresholds.initial);
167 ReadParam(subsection, "converged",
168 &cfg.delay.delay_selection_thresholds.converged);
169 }
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200170
171 ReadParam(section, "use_external_delay_estimator",
172 &cfg.delay.use_external_delay_estimator);
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200173 ReadParam(section, "downmix_before_delay_estimation",
174 &cfg.delay.downmix_before_delay_estimation);
Sam Zackrissonffc84522019-10-15 13:43:02 +0200175 ReadParam(section, "log_warning_on_delay_changes",
176 &cfg.delay.log_warning_on_delay_changes);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200177 }
178
179 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
180 ReadParam(section, "main", &cfg.filter.main);
181 ReadParam(section, "shadow", &cfg.filter.shadow);
182 ReadParam(section, "main_initial", &cfg.filter.main_initial);
183 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
184 ReadParam(section, "config_change_duration_blocks",
185 &cfg.filter.config_change_duration_blocks);
186 ReadParam(section, "initial_state_seconds",
187 &cfg.filter.initial_state_seconds);
188 ReadParam(section, "conservative_initial_phase",
189 &cfg.filter.conservative_initial_phase);
190 ReadParam(section, "enable_shadow_filter_output_usage",
191 &cfg.filter.enable_shadow_filter_output_usage);
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200192 ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter);
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100193 ReadParam(section, "export_linear_aec_output",
194 &cfg.filter.export_linear_aec_output);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200195 }
196
197 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
198 ReadParam(section, "min", &cfg.erle.min);
199 ReadParam(section, "max_l", &cfg.erle.max_l);
200 ReadParam(section, "max_h", &cfg.erle.max_h);
201 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100202 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Per Åhgren8be669f2019-10-11 23:02:26 +0200203 ReadParam(section, "clamp_quality_estimate_to_zero",
204 &cfg.erle.clamp_quality_estimate_to_zero);
205 ReadParam(section, "clamp_quality_estimate_to_one",
206 &cfg.erle.clamp_quality_estimate_to_one);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200207 }
208
209 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100210 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200211 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200212 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
213 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
214 }
215
Sam Zackrissona4c85142018-10-10 10:44:43 +0200216 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
217 ReadParam(section, "low_render_limit",
218 &cfg.echo_audibility.low_render_limit);
219 ReadParam(section, "normal_render_limit",
220 &cfg.echo_audibility.normal_render_limit);
221
222 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
223 ReadParam(section, "audibility_threshold_lf",
224 &cfg.echo_audibility.audibility_threshold_lf);
225 ReadParam(section, "audibility_threshold_mf",
226 &cfg.echo_audibility.audibility_threshold_mf);
227 ReadParam(section, "audibility_threshold_hf",
228 &cfg.echo_audibility.audibility_threshold_hf);
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200229 ReadParam(section, "use_stationarity_properties",
230 &cfg.echo_audibility.use_stationarity_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200231 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200232 &cfg.echo_audibility.use_stationarity_properties_at_init);
233 }
234
Per Åhgren01cf44d2018-10-20 00:17:13 +0200235 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
236 ReadParam(section, "active_render_limit",
237 &cfg.render_levels.active_render_limit);
238 ReadParam(section, "poor_excitation_render_limit",
239 &cfg.render_levels.poor_excitation_render_limit);
240 ReadParam(section, "poor_excitation_render_limit_ds8",
241 &cfg.render_levels.poor_excitation_render_limit_ds8);
Per Åhgrenae40e192019-10-29 22:54:05 +0100242 ReadParam(section, "render_power_gain_db",
243 &cfg.render_levels.render_power_gain_db);
Per Åhgren01cf44d2018-10-20 00:17:13 +0200244 }
245
Sam Zackrissona4c85142018-10-10 10:44:43 +0200246 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
247 &section)) {
Sam Zackrissona4c85142018-10-10 10:44:43 +0200248 ReadParam(section, "has_clock_drift",
249 &cfg.echo_removal_control.has_clock_drift);
250 ReadParam(section, "linear_and_stable_echo_path",
251 &cfg.echo_removal_control.linear_and_stable_echo_path);
252 }
253
254 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
255 Json::Value subsection;
256 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
257 ReadParam(section, "min_noise_floor_power",
258 &cfg.echo_model.min_noise_floor_power);
259 ReadParam(section, "stationary_gate_slope",
260 &cfg.echo_model.stationary_gate_slope);
261 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
262 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
263 ReadParam(section, "render_pre_window_size",
264 &cfg.echo_model.render_pre_window_size);
265 ReadParam(section, "render_post_window_size",
266 &cfg.echo_model.render_post_window_size);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200267 }
268
269 Json::Value subsection;
270 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
271 ReadParam(section, "nearend_average_blocks",
272 &cfg.suppressor.nearend_average_blocks);
273
274 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
275 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
276 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
277 ReadParam(subsection, "max_inc_factor",
278 &cfg.suppressor.normal_tuning.max_inc_factor);
279 ReadParam(subsection, "max_dec_factor_lf",
280 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
281 }
282
283 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
284 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
285 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
286 ReadParam(subsection, "max_inc_factor",
287 &cfg.suppressor.nearend_tuning.max_inc_factor);
288 ReadParam(subsection, "max_dec_factor_lf",
289 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
290 }
291
292 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
293 &subsection)) {
294 ReadParam(subsection, "enr_threshold",
295 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200296 ReadParam(subsection, "enr_exit_threshold",
297 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200298 ReadParam(subsection, "snr_threshold",
299 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
300 ReadParam(subsection, "hold_duration",
301 &cfg.suppressor.dominant_nearend_detection.hold_duration);
302 ReadParam(subsection, "trigger_threshold",
303 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200304 ReadParam(
305 subsection, "use_during_initial_phase",
306 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200307 }
308
309 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
310 &subsection)) {
311 ReadParam(subsection, "enr_threshold",
312 &cfg.suppressor.high_bands_suppression.enr_threshold);
313 ReadParam(subsection, "max_gain_during_echo",
314 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
315 }
316
317 ReadParam(section, "floor_first_increase",
318 &cfg.suppressor.floor_first_increase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200319 }
Per Åhgren370bae42018-10-25 11:32:39 +0200320}
321
322EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
323 EchoCanceller3Config cfg;
324 bool not_used;
325 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200326 return cfg;
327}
328
329std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
330 rtc::StringBuilder ost;
331 ost << "{";
332 ost << "\"aec3\": {";
Per Åhgrenc1d20922019-04-22 23:36:58 +0200333 ost << "\"buffering\": {";
334 ost << "\"excess_render_detection_interval_blocks\": "
335 << config.buffering.excess_render_detection_interval_blocks << ",";
336 ost << "\"max_allowed_excess_render_blocks\": "
337 << config.buffering.max_allowed_excess_render_blocks;
338 ost << "},";
339
Sam Zackrissona4c85142018-10-10 10:44:43 +0200340 ost << "\"delay\": {";
341 ost << "\"default_delay\": " << config.delay.default_delay << ",";
342 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
343 << ",";
344 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100345 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200346 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100347 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
348 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200349 ost << "\"fixed_capture_delay_samples\": "
350 << config.delay.fixed_capture_delay_samples << ",";
351 ost << "\"delay_estimate_smoothing\": "
352 << config.delay.delay_estimate_smoothing << ",";
353 ost << "\"delay_candidate_detection_threshold\": "
354 << config.delay.delay_candidate_detection_threshold << ",";
355
356 ost << "\"delay_selection_thresholds\": {";
357 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
358 << ",";
359 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200360 ost << "},";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200361
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200362 ost << "\"use_external_delay_estimator\": "
363 << (config.delay.use_external_delay_estimator ? "true" : "false") << ",";
364 ost << "\"downmix_before_delay_estimation\": "
Sam Zackrissonffc84522019-10-15 13:43:02 +0200365 << (config.delay.downmix_before_delay_estimation ? "true" : "false")
366 << ",";
367 ost << "\"log_warning_on_delay_changes\": "
368 << (config.delay.log_warning_on_delay_changes ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200369 ost << "},";
370
371 ost << "\"filter\": {";
372 ost << "\"main\": [";
373 ost << config.filter.main.length_blocks << ",";
374 ost << config.filter.main.leakage_converged << ",";
375 ost << config.filter.main.leakage_diverged << ",";
376 ost << config.filter.main.error_floor << ",";
377 ost << config.filter.main.error_ceil << ",";
378 ost << config.filter.main.noise_gate;
379 ost << "],";
380
381 ost << "\"shadow\": [";
382 ost << config.filter.shadow.length_blocks << ",";
383 ost << config.filter.shadow.rate << ",";
384 ost << config.filter.shadow.noise_gate;
385 ost << "],";
386
387 ost << "\"main_initial\": [";
388 ost << config.filter.main_initial.length_blocks << ",";
389 ost << config.filter.main_initial.leakage_converged << ",";
390 ost << config.filter.main_initial.leakage_diverged << ",";
391 ost << config.filter.main_initial.error_floor << ",";
392 ost << config.filter.main_initial.error_ceil << ",";
393 ost << config.filter.main_initial.noise_gate;
394 ost << "],";
395
396 ost << "\"shadow_initial\": [";
397 ost << config.filter.shadow_initial.length_blocks << ",";
398 ost << config.filter.shadow_initial.rate << ",";
399 ost << config.filter.shadow_initial.noise_gate;
400 ost << "],";
401
402 ost << "\"config_change_duration_blocks\": "
403 << config.filter.config_change_duration_blocks << ",";
404 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
405 << ",";
406 ost << "\"conservative_initial_phase\": "
407 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
408 ost << "\"enable_shadow_filter_output_usage\": "
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100409 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false")
410 << ",";
411 ost << "\"use_linear_filter\": "
412 << (config.filter.use_linear_filter ? "true" : "false") << ",";
413 ost << "\"export_linear_aec_output\": "
414 << (config.filter.export_linear_aec_output ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200415
416 ost << "},";
417
418 ost << "\"erle\": {";
419 ost << "\"min\": " << config.erle.min << ",";
420 ost << "\"max_l\": " << config.erle.max_l << ",";
421 ost << "\"max_h\": " << config.erle.max_h << ",";
422 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100423 << (config.erle.onset_detection ? "true" : "false") << ",";
Per Åhgren8be669f2019-10-11 23:02:26 +0200424 ost << "\"num_sections\": " << config.erle.num_sections << ",";
425 ost << "\"clamp_quality_estimate_to_zero\": "
426 << (config.erle.clamp_quality_estimate_to_zero ? "true" : "false") << ",";
427 ost << "\"clamp_quality_estimate_to_one\": "
428 << (config.erle.clamp_quality_estimate_to_one ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200429 ost << "},";
430
431 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100432 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200433 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200434 ost << "\"echo_can_saturate\": "
435 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
436 ost << "\"bounded_erl\": "
437 << (config.ep_strength.bounded_erl ? "true" : "false");
438
439 ost << "},";
440
Sam Zackrissona4c85142018-10-10 10:44:43 +0200441 ost << "\"echo_audibility\": {";
442 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
443 << ",";
444 ost << "\"normal_render_limit\": "
445 << config.echo_audibility.normal_render_limit << ",";
446 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
447 ost << "\"audibility_threshold_lf\": "
448 << config.echo_audibility.audibility_threshold_lf << ",";
449 ost << "\"audibility_threshold_mf\": "
450 << config.echo_audibility.audibility_threshold_mf << ",";
451 ost << "\"audibility_threshold_hf\": "
452 << config.echo_audibility.audibility_threshold_hf << ",";
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200453 ost << "\"use_stationarity_properties\": "
454 << (config.echo_audibility.use_stationarity_properties ? "true" : "false")
Sam Zackrissona4c85142018-10-10 10:44:43 +0200455 << ",";
456 ost << "\"use_stationarity_properties_at_init\": "
457 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
458 : "false");
459 ost << "},";
460
461 ost << "\"render_levels\": {";
462 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
463 << ",";
464 ost << "\"poor_excitation_render_limit\": "
465 << config.render_levels.poor_excitation_render_limit << ",";
466 ost << "\"poor_excitation_render_limit_ds8\": "
Per Åhgrenae40e192019-10-29 22:54:05 +0100467 << config.render_levels.poor_excitation_render_limit_ds8 << ",";
468 ost << "\"render_power_gain_db\": "
469 << config.render_levels.render_power_gain_db;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200470 ost << "},";
471
472 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200473 ost << "\"has_clock_drift\": "
474 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
475 << ",";
476 ost << "\"linear_and_stable_echo_path\": "
477 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
478 : "false");
479
480 ost << "},";
481
482 ost << "\"echo_model\": {";
483 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
484 ost << "\"min_noise_floor_power\": "
485 << config.echo_model.min_noise_floor_power << ",";
486 ost << "\"stationary_gate_slope\": "
487 << config.echo_model.stationary_gate_slope << ",";
488 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
489 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
490 ost << "\"render_pre_window_size\": "
491 << config.echo_model.render_pre_window_size << ",";
492 ost << "\"render_post_window_size\": "
Gustaf Ullbergec51ce02019-04-04 13:38:52 +0200493 << config.echo_model.render_post_window_size;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200494 ost << "},";
495
496 ost << "\"suppressor\": {";
497 ost << "\"nearend_average_blocks\": "
498 << config.suppressor.nearend_average_blocks << ",";
499 ost << "\"normal_tuning\": {";
500 ost << "\"mask_lf\": [";
501 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
502 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
503 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
504 ost << "],";
505 ost << "\"mask_hf\": [";
506 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
507 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
508 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
509 ost << "],";
510 ost << "\"max_inc_factor\": "
511 << config.suppressor.normal_tuning.max_inc_factor << ",";
512 ost << "\"max_dec_factor_lf\": "
513 << config.suppressor.normal_tuning.max_dec_factor_lf;
514 ost << "},";
515 ost << "\"nearend_tuning\": {";
516 ost << "\"mask_lf\": [";
517 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
518 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
519 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
520 ost << "],";
521 ost << "\"mask_hf\": [";
522 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
523 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
524 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
525 ost << "],";
526 ost << "\"max_inc_factor\": "
527 << config.suppressor.nearend_tuning.max_inc_factor << ",";
528 ost << "\"max_dec_factor_lf\": "
529 << config.suppressor.nearend_tuning.max_dec_factor_lf;
530 ost << "},";
531 ost << "\"dominant_nearend_detection\": {";
532 ost << "\"enr_threshold\": "
533 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200534 ost << "\"enr_exit_threshold\": "
535 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200536 ost << "\"snr_threshold\": "
537 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
538 ost << "\"hold_duration\": "
539 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
540 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200541 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
542 ost << "\"use_during_initial_phase\": "
543 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200544 ost << "},";
545 ost << "\"high_bands_suppression\": {";
546 ost << "\"enr_threshold\": "
547 << config.suppressor.high_bands_suppression.enr_threshold << ",";
548 ost << "\"max_gain_during_echo\": "
549 << config.suppressor.high_bands_suppression.max_gain_during_echo;
550 ost << "},";
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100551 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200552 ost << "}";
553 ost << "}";
554 ost << "}";
555
556 return ost.Release();
557}
558} // namespace webrtc