blob: c6ee7083b8713ec840c01fc93a6d5a5a359fe374 [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);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200193 }
194
195 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
196 ReadParam(section, "min", &cfg.erle.min);
197 ReadParam(section, "max_l", &cfg.erle.max_l);
198 ReadParam(section, "max_h", &cfg.erle.max_h);
199 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100200 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Per Åhgren8be669f2019-10-11 23:02:26 +0200201 ReadParam(section, "clamp_quality_estimate_to_zero",
202 &cfg.erle.clamp_quality_estimate_to_zero);
203 ReadParam(section, "clamp_quality_estimate_to_one",
204 &cfg.erle.clamp_quality_estimate_to_one);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200205 }
206
207 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100208 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200209 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200210 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
211 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
212 }
213
Sam Zackrissona4c85142018-10-10 10:44:43 +0200214 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
215 ReadParam(section, "low_render_limit",
216 &cfg.echo_audibility.low_render_limit);
217 ReadParam(section, "normal_render_limit",
218 &cfg.echo_audibility.normal_render_limit);
219
220 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
221 ReadParam(section, "audibility_threshold_lf",
222 &cfg.echo_audibility.audibility_threshold_lf);
223 ReadParam(section, "audibility_threshold_mf",
224 &cfg.echo_audibility.audibility_threshold_mf);
225 ReadParam(section, "audibility_threshold_hf",
226 &cfg.echo_audibility.audibility_threshold_hf);
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200227 ReadParam(section, "use_stationarity_properties",
228 &cfg.echo_audibility.use_stationarity_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200229 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200230 &cfg.echo_audibility.use_stationarity_properties_at_init);
231 }
232
Per Åhgren01cf44d2018-10-20 00:17:13 +0200233 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
234 ReadParam(section, "active_render_limit",
235 &cfg.render_levels.active_render_limit);
236 ReadParam(section, "poor_excitation_render_limit",
237 &cfg.render_levels.poor_excitation_render_limit);
238 ReadParam(section, "poor_excitation_render_limit_ds8",
239 &cfg.render_levels.poor_excitation_render_limit_ds8);
Per Åhgrenae40e192019-10-29 22:54:05 +0100240 ReadParam(section, "render_power_gain_db",
241 &cfg.render_levels.render_power_gain_db);
Per Åhgren01cf44d2018-10-20 00:17:13 +0200242 }
243
Sam Zackrissona4c85142018-10-10 10:44:43 +0200244 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
245 &section)) {
Sam Zackrissona4c85142018-10-10 10:44:43 +0200246 ReadParam(section, "has_clock_drift",
247 &cfg.echo_removal_control.has_clock_drift);
248 ReadParam(section, "linear_and_stable_echo_path",
249 &cfg.echo_removal_control.linear_and_stable_echo_path);
250 }
251
252 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
253 Json::Value subsection;
254 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
255 ReadParam(section, "min_noise_floor_power",
256 &cfg.echo_model.min_noise_floor_power);
257 ReadParam(section, "stationary_gate_slope",
258 &cfg.echo_model.stationary_gate_slope);
259 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
260 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
261 ReadParam(section, "render_pre_window_size",
262 &cfg.echo_model.render_pre_window_size);
263 ReadParam(section, "render_post_window_size",
264 &cfg.echo_model.render_post_window_size);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200265 }
266
267 Json::Value subsection;
268 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
269 ReadParam(section, "nearend_average_blocks",
270 &cfg.suppressor.nearend_average_blocks);
271
272 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
273 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
274 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
275 ReadParam(subsection, "max_inc_factor",
276 &cfg.suppressor.normal_tuning.max_inc_factor);
277 ReadParam(subsection, "max_dec_factor_lf",
278 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
279 }
280
281 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
282 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
283 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
284 ReadParam(subsection, "max_inc_factor",
285 &cfg.suppressor.nearend_tuning.max_inc_factor);
286 ReadParam(subsection, "max_dec_factor_lf",
287 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
288 }
289
290 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
291 &subsection)) {
292 ReadParam(subsection, "enr_threshold",
293 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200294 ReadParam(subsection, "enr_exit_threshold",
295 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200296 ReadParam(subsection, "snr_threshold",
297 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
298 ReadParam(subsection, "hold_duration",
299 &cfg.suppressor.dominant_nearend_detection.hold_duration);
300 ReadParam(subsection, "trigger_threshold",
301 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200302 ReadParam(
303 subsection, "use_during_initial_phase",
304 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200305 }
306
307 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
308 &subsection)) {
309 ReadParam(subsection, "enr_threshold",
310 &cfg.suppressor.high_bands_suppression.enr_threshold);
311 ReadParam(subsection, "max_gain_during_echo",
312 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
313 }
314
315 ReadParam(section, "floor_first_increase",
316 &cfg.suppressor.floor_first_increase);
317 ReadParam(section, "enforce_transparent",
318 &cfg.suppressor.enforce_transparent);
319 ReadParam(section, "enforce_empty_higher_bands",
320 &cfg.suppressor.enforce_empty_higher_bands);
321 }
Per Åhgren370bae42018-10-25 11:32:39 +0200322}
323
324EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
325 EchoCanceller3Config cfg;
326 bool not_used;
327 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200328 return cfg;
329}
330
331std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
332 rtc::StringBuilder ost;
333 ost << "{";
334 ost << "\"aec3\": {";
Per Åhgrenc1d20922019-04-22 23:36:58 +0200335 ost << "\"buffering\": {";
336 ost << "\"excess_render_detection_interval_blocks\": "
337 << config.buffering.excess_render_detection_interval_blocks << ",";
338 ost << "\"max_allowed_excess_render_blocks\": "
339 << config.buffering.max_allowed_excess_render_blocks;
340 ost << "},";
341
Sam Zackrissona4c85142018-10-10 10:44:43 +0200342 ost << "\"delay\": {";
343 ost << "\"default_delay\": " << config.delay.default_delay << ",";
344 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
345 << ",";
346 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100347 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200348 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100349 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
350 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200351 ost << "\"fixed_capture_delay_samples\": "
352 << config.delay.fixed_capture_delay_samples << ",";
353 ost << "\"delay_estimate_smoothing\": "
354 << config.delay.delay_estimate_smoothing << ",";
355 ost << "\"delay_candidate_detection_threshold\": "
356 << config.delay.delay_candidate_detection_threshold << ",";
357
358 ost << "\"delay_selection_thresholds\": {";
359 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
360 << ",";
361 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200362 ost << "},";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200363
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200364 ost << "\"use_external_delay_estimator\": "
365 << (config.delay.use_external_delay_estimator ? "true" : "false") << ",";
366 ost << "\"downmix_before_delay_estimation\": "
Sam Zackrissonffc84522019-10-15 13:43:02 +0200367 << (config.delay.downmix_before_delay_estimation ? "true" : "false")
368 << ",";
369 ost << "\"log_warning_on_delay_changes\": "
370 << (config.delay.log_warning_on_delay_changes ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200371 ost << "},";
372
373 ost << "\"filter\": {";
374 ost << "\"main\": [";
375 ost << config.filter.main.length_blocks << ",";
376 ost << config.filter.main.leakage_converged << ",";
377 ost << config.filter.main.leakage_diverged << ",";
378 ost << config.filter.main.error_floor << ",";
379 ost << config.filter.main.error_ceil << ",";
380 ost << config.filter.main.noise_gate;
381 ost << "],";
382
383 ost << "\"shadow\": [";
384 ost << config.filter.shadow.length_blocks << ",";
385 ost << config.filter.shadow.rate << ",";
386 ost << config.filter.shadow.noise_gate;
387 ost << "],";
388
389 ost << "\"main_initial\": [";
390 ost << config.filter.main_initial.length_blocks << ",";
391 ost << config.filter.main_initial.leakage_converged << ",";
392 ost << config.filter.main_initial.leakage_diverged << ",";
393 ost << config.filter.main_initial.error_floor << ",";
394 ost << config.filter.main_initial.error_ceil << ",";
395 ost << config.filter.main_initial.noise_gate;
396 ost << "],";
397
398 ost << "\"shadow_initial\": [";
399 ost << config.filter.shadow_initial.length_blocks << ",";
400 ost << config.filter.shadow_initial.rate << ",";
401 ost << config.filter.shadow_initial.noise_gate;
402 ost << "],";
403
404 ost << "\"config_change_duration_blocks\": "
405 << config.filter.config_change_duration_blocks << ",";
406 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
407 << ",";
408 ost << "\"conservative_initial_phase\": "
409 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
410 ost << "\"enable_shadow_filter_output_usage\": "
411 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
412
413 ost << "},";
414
415 ost << "\"erle\": {";
416 ost << "\"min\": " << config.erle.min << ",";
417 ost << "\"max_l\": " << config.erle.max_l << ",";
418 ost << "\"max_h\": " << config.erle.max_h << ",";
419 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100420 << (config.erle.onset_detection ? "true" : "false") << ",";
Per Åhgren8be669f2019-10-11 23:02:26 +0200421 ost << "\"num_sections\": " << config.erle.num_sections << ",";
422 ost << "\"clamp_quality_estimate_to_zero\": "
423 << (config.erle.clamp_quality_estimate_to_zero ? "true" : "false") << ",";
424 ost << "\"clamp_quality_estimate_to_one\": "
425 << (config.erle.clamp_quality_estimate_to_one ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200426 ost << "},";
427
428 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100429 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200430 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200431 ost << "\"echo_can_saturate\": "
432 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
433 ost << "\"bounded_erl\": "
434 << (config.ep_strength.bounded_erl ? "true" : "false");
435
436 ost << "},";
437
Sam Zackrissona4c85142018-10-10 10:44:43 +0200438 ost << "\"echo_audibility\": {";
439 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
440 << ",";
441 ost << "\"normal_render_limit\": "
442 << config.echo_audibility.normal_render_limit << ",";
443 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
444 ost << "\"audibility_threshold_lf\": "
445 << config.echo_audibility.audibility_threshold_lf << ",";
446 ost << "\"audibility_threshold_mf\": "
447 << config.echo_audibility.audibility_threshold_mf << ",";
448 ost << "\"audibility_threshold_hf\": "
449 << config.echo_audibility.audibility_threshold_hf << ",";
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200450 ost << "\"use_stationarity_properties\": "
451 << (config.echo_audibility.use_stationarity_properties ? "true" : "false")
Sam Zackrissona4c85142018-10-10 10:44:43 +0200452 << ",";
453 ost << "\"use_stationarity_properties_at_init\": "
454 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
455 : "false");
456 ost << "},";
457
458 ost << "\"render_levels\": {";
459 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
460 << ",";
461 ost << "\"poor_excitation_render_limit\": "
462 << config.render_levels.poor_excitation_render_limit << ",";
463 ost << "\"poor_excitation_render_limit_ds8\": "
Per Åhgrenae40e192019-10-29 22:54:05 +0100464 << config.render_levels.poor_excitation_render_limit_ds8 << ",";
465 ost << "\"render_power_gain_db\": "
466 << config.render_levels.render_power_gain_db;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200467 ost << "},";
468
469 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200470 ost << "\"has_clock_drift\": "
471 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
472 << ",";
473 ost << "\"linear_and_stable_echo_path\": "
474 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
475 : "false");
476
477 ost << "},";
478
479 ost << "\"echo_model\": {";
480 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
481 ost << "\"min_noise_floor_power\": "
482 << config.echo_model.min_noise_floor_power << ",";
483 ost << "\"stationary_gate_slope\": "
484 << config.echo_model.stationary_gate_slope << ",";
485 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
486 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
487 ost << "\"render_pre_window_size\": "
488 << config.echo_model.render_pre_window_size << ",";
489 ost << "\"render_post_window_size\": "
Gustaf Ullbergec51ce02019-04-04 13:38:52 +0200490 << config.echo_model.render_post_window_size;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200491 ost << "},";
492
493 ost << "\"suppressor\": {";
494 ost << "\"nearend_average_blocks\": "
495 << config.suppressor.nearend_average_blocks << ",";
496 ost << "\"normal_tuning\": {";
497 ost << "\"mask_lf\": [";
498 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
499 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
500 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
501 ost << "],";
502 ost << "\"mask_hf\": [";
503 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
504 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
505 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
506 ost << "],";
507 ost << "\"max_inc_factor\": "
508 << config.suppressor.normal_tuning.max_inc_factor << ",";
509 ost << "\"max_dec_factor_lf\": "
510 << config.suppressor.normal_tuning.max_dec_factor_lf;
511 ost << "},";
512 ost << "\"nearend_tuning\": {";
513 ost << "\"mask_lf\": [";
514 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
515 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
516 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
517 ost << "],";
518 ost << "\"mask_hf\": [";
519 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
520 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
521 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
522 ost << "],";
523 ost << "\"max_inc_factor\": "
524 << config.suppressor.nearend_tuning.max_inc_factor << ",";
525 ost << "\"max_dec_factor_lf\": "
526 << config.suppressor.nearend_tuning.max_dec_factor_lf;
527 ost << "},";
528 ost << "\"dominant_nearend_detection\": {";
529 ost << "\"enr_threshold\": "
530 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200531 ost << "\"enr_exit_threshold\": "
532 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200533 ost << "\"snr_threshold\": "
534 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
535 ost << "\"hold_duration\": "
536 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
537 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200538 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
539 ost << "\"use_during_initial_phase\": "
540 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200541 ost << "},";
542 ost << "\"high_bands_suppression\": {";
543 ost << "\"enr_threshold\": "
544 << config.suppressor.high_bands_suppression.enr_threshold << ",";
545 ost << "\"max_gain_during_echo\": "
546 << config.suppressor.high_bands_suppression.max_gain_during_echo;
547 ost << "},";
548 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
549 << ",";
550 ost << "\"enforce_transparent\": "
551 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
552 ost << "\"enforce_empty_higher_bands\": "
553 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
554 ost << "}";
555 ost << "}";
556 ost << "}";
557
558 return ost.Release();
559}
560} // namespace webrtc