blob: 28aec9eea7139caa3412c1f6bed72cb3f6977474 [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;
35 if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
Sam Zackrisson877dc892018-10-23 14:17:38 +020036 RTC_DCHECK_GE(v, 0);
Sam Zackrissona4c85142018-10-10 10:44:43 +020037 *param = v;
38 }
39}
40
41void ReadParam(const Json::Value& root, std::string param_name, int* param) {
42 RTC_DCHECK(param);
43 int v;
44 if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
45 *param = v;
46 }
47}
48
49void ReadParam(const Json::Value& root, std::string param_name, float* param) {
50 RTC_DCHECK(param);
51 double v;
52 if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) {
53 *param = static_cast<float>(v);
54 }
55}
56
57void ReadParam(const Json::Value& root,
58 std::string param_name,
59 EchoCanceller3Config::Filter::MainConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020060 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020061 Json::Value json_array;
62 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
63 std::vector<double> v;
64 rtc::JsonArrayToDoubleVector(json_array, &v);
65 if (v.size() != 6) {
66 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +020067 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020068 }
69 param->length_blocks = static_cast<size_t>(v[0]);
70 param->leakage_converged = static_cast<float>(v[1]);
71 param->leakage_diverged = static_cast<float>(v[2]);
72 param->error_floor = static_cast<float>(v[3]);
73 param->error_ceil = static_cast<float>(v[4]);
74 param->noise_gate = static_cast<float>(v[5]);
75 }
76}
77
78void ReadParam(const Json::Value& root,
79 std::string param_name,
80 EchoCanceller3Config::Filter::ShadowConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020081 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020082 Json::Value json_array;
83 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
84 std::vector<double> v;
85 rtc::JsonArrayToDoubleVector(json_array, &v);
86 if (v.size() != 3) {
87 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +020088 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020089 }
90 param->length_blocks = static_cast<size_t>(v[0]);
91 param->rate = static_cast<float>(v[1]);
92 param->noise_gate = static_cast<float>(v[2]);
93 }
94}
95
96void ReadParam(const Json::Value& root,
97 std::string param_name,
98 EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020099 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200100 Json::Value json_array;
101 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
102 std::vector<double> v;
103 rtc::JsonArrayToDoubleVector(json_array, &v);
104 if (v.size() != 3) {
105 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +0200106 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200107 }
108 param->enr_transparent = static_cast<float>(v[0]);
109 param->enr_suppress = static_cast<float>(v[1]);
110 param->emr_transparent = static_cast<float>(v[2]);
111 }
112}
113} // namespace
114
Per Åhgren370bae42018-10-25 11:32:39 +0200115void Aec3ConfigFromJsonString(absl::string_view json_string,
116 EchoCanceller3Config* config,
117 bool* parsing_successful) {
118 RTC_DCHECK(config);
119 RTC_DCHECK(parsing_successful);
120 EchoCanceller3Config& cfg = *config;
121 cfg = EchoCanceller3Config();
122 *parsing_successful = true;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200123
124 Json::Value root;
125 bool success = Json::Reader().parse(std::string(json_string), root);
126 if (!success) {
127 RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200128 *parsing_successful = false;
129 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200130 }
131
132 Json::Value aec3_root;
133 success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
134 if (!success) {
135 RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200136 *parsing_successful = false;
137 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200138 }
139
140 Json::Value section;
Per Åhgrenc1d20922019-04-22 23:36:58 +0200141 if (rtc::GetValueFromJsonObject(aec3_root, "buffering", &section)) {
Gustaf Ullberg11539f02018-10-15 13:40:29 +0200142 ReadParam(section, "excess_render_detection_interval_blocks",
143 &cfg.buffering.excess_render_detection_interval_blocks);
144 ReadParam(section, "max_allowed_excess_render_blocks",
145 &cfg.buffering.max_allowed_excess_render_blocks);
146 }
147
Sam Zackrissona4c85142018-10-10 10:44:43 +0200148 if (rtc::GetValueFromJsonObject(aec3_root, "delay", &section)) {
149 ReadParam(section, "default_delay", &cfg.delay.default_delay);
150 ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
151 ReadParam(section, "num_filters", &cfg.delay.num_filters);
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100152 ReadParam(section, "delay_headroom_samples",
153 &cfg.delay.delay_headroom_samples);
154 ReadParam(section, "hysteresis_limit_blocks",
155 &cfg.delay.hysteresis_limit_blocks);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200156 ReadParam(section, "fixed_capture_delay_samples",
157 &cfg.delay.fixed_capture_delay_samples);
158 ReadParam(section, "delay_estimate_smoothing",
159 &cfg.delay.delay_estimate_smoothing);
160 ReadParam(section, "delay_candidate_detection_threshold",
161 &cfg.delay.delay_candidate_detection_threshold);
162
163 Json::Value subsection;
164 if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
165 &subsection)) {
166 ReadParam(subsection, "initial",
167 &cfg.delay.delay_selection_thresholds.initial);
168 ReadParam(subsection, "converged",
169 &cfg.delay.delay_selection_thresholds.converged);
170 }
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200171
172 ReadParam(section, "use_external_delay_estimator",
173 &cfg.delay.use_external_delay_estimator);
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200174 ReadParam(section, "downmix_before_delay_estimation",
175 &cfg.delay.downmix_before_delay_estimation);
Sam Zackrissonffc84522019-10-15 13:43:02 +0200176 ReadParam(section, "log_warning_on_delay_changes",
177 &cfg.delay.log_warning_on_delay_changes);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200178 }
179
180 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
181 ReadParam(section, "main", &cfg.filter.main);
182 ReadParam(section, "shadow", &cfg.filter.shadow);
183 ReadParam(section, "main_initial", &cfg.filter.main_initial);
184 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
185 ReadParam(section, "config_change_duration_blocks",
186 &cfg.filter.config_change_duration_blocks);
187 ReadParam(section, "initial_state_seconds",
188 &cfg.filter.initial_state_seconds);
189 ReadParam(section, "conservative_initial_phase",
190 &cfg.filter.conservative_initial_phase);
191 ReadParam(section, "enable_shadow_filter_output_usage",
192 &cfg.filter.enable_shadow_filter_output_usage);
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200193 ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200194 }
195
196 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
197 ReadParam(section, "min", &cfg.erle.min);
198 ReadParam(section, "max_l", &cfg.erle.max_l);
199 ReadParam(section, "max_h", &cfg.erle.max_h);
200 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100201 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Per Åhgren8be669f2019-10-11 23:02:26 +0200202 ReadParam(section, "clamp_quality_estimate_to_zero",
203 &cfg.erle.clamp_quality_estimate_to_zero);
204 ReadParam(section, "clamp_quality_estimate_to_one",
205 &cfg.erle.clamp_quality_estimate_to_one);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200206 }
207
208 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100209 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200210 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200211 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
212 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
213 }
214
Sam Zackrissona4c85142018-10-10 10:44:43 +0200215 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
216 ReadParam(section, "low_render_limit",
217 &cfg.echo_audibility.low_render_limit);
218 ReadParam(section, "normal_render_limit",
219 &cfg.echo_audibility.normal_render_limit);
220
221 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
222 ReadParam(section, "audibility_threshold_lf",
223 &cfg.echo_audibility.audibility_threshold_lf);
224 ReadParam(section, "audibility_threshold_mf",
225 &cfg.echo_audibility.audibility_threshold_mf);
226 ReadParam(section, "audibility_threshold_hf",
227 &cfg.echo_audibility.audibility_threshold_hf);
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200228 ReadParam(section, "use_stationarity_properties",
229 &cfg.echo_audibility.use_stationarity_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200230 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200231 &cfg.echo_audibility.use_stationarity_properties_at_init);
232 }
233
Per Åhgren01cf44d2018-10-20 00:17:13 +0200234 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
235 ReadParam(section, "active_render_limit",
236 &cfg.render_levels.active_render_limit);
237 ReadParam(section, "poor_excitation_render_limit",
238 &cfg.render_levels.poor_excitation_render_limit);
239 ReadParam(section, "poor_excitation_render_limit_ds8",
240 &cfg.render_levels.poor_excitation_render_limit_ds8);
241 }
242
Sam Zackrissona4c85142018-10-10 10:44:43 +0200243 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
244 &section)) {
Sam Zackrissona4c85142018-10-10 10:44:43 +0200245 ReadParam(section, "has_clock_drift",
246 &cfg.echo_removal_control.has_clock_drift);
247 ReadParam(section, "linear_and_stable_echo_path",
248 &cfg.echo_removal_control.linear_and_stable_echo_path);
249 }
250
251 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
252 Json::Value subsection;
253 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
254 ReadParam(section, "min_noise_floor_power",
255 &cfg.echo_model.min_noise_floor_power);
256 ReadParam(section, "stationary_gate_slope",
257 &cfg.echo_model.stationary_gate_slope);
258 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
259 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
260 ReadParam(section, "render_pre_window_size",
261 &cfg.echo_model.render_pre_window_size);
262 ReadParam(section, "render_post_window_size",
263 &cfg.echo_model.render_post_window_size);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200264 }
265
266 Json::Value subsection;
267 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
268 ReadParam(section, "nearend_average_blocks",
269 &cfg.suppressor.nearend_average_blocks);
270
271 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
272 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
273 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
274 ReadParam(subsection, "max_inc_factor",
275 &cfg.suppressor.normal_tuning.max_inc_factor);
276 ReadParam(subsection, "max_dec_factor_lf",
277 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
278 }
279
280 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
281 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
282 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
283 ReadParam(subsection, "max_inc_factor",
284 &cfg.suppressor.nearend_tuning.max_inc_factor);
285 ReadParam(subsection, "max_dec_factor_lf",
286 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
287 }
288
289 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
290 &subsection)) {
291 ReadParam(subsection, "enr_threshold",
292 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200293 ReadParam(subsection, "enr_exit_threshold",
294 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200295 ReadParam(subsection, "snr_threshold",
296 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
297 ReadParam(subsection, "hold_duration",
298 &cfg.suppressor.dominant_nearend_detection.hold_duration);
299 ReadParam(subsection, "trigger_threshold",
300 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200301 ReadParam(
302 subsection, "use_during_initial_phase",
303 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200304 }
305
306 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
307 &subsection)) {
308 ReadParam(subsection, "enr_threshold",
309 &cfg.suppressor.high_bands_suppression.enr_threshold);
310 ReadParam(subsection, "max_gain_during_echo",
311 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
312 }
313
314 ReadParam(section, "floor_first_increase",
315 &cfg.suppressor.floor_first_increase);
316 ReadParam(section, "enforce_transparent",
317 &cfg.suppressor.enforce_transparent);
318 ReadParam(section, "enforce_empty_higher_bands",
319 &cfg.suppressor.enforce_empty_higher_bands);
320 }
Per Åhgren370bae42018-10-25 11:32:39 +0200321}
322
323EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
324 EchoCanceller3Config cfg;
325 bool not_used;
326 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200327 return cfg;
328}
329
330std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
331 rtc::StringBuilder ost;
332 ost << "{";
333 ost << "\"aec3\": {";
Per Åhgrenc1d20922019-04-22 23:36:58 +0200334 ost << "\"buffering\": {";
335 ost << "\"excess_render_detection_interval_blocks\": "
336 << config.buffering.excess_render_detection_interval_blocks << ",";
337 ost << "\"max_allowed_excess_render_blocks\": "
338 << config.buffering.max_allowed_excess_render_blocks;
339 ost << "},";
340
Sam Zackrissona4c85142018-10-10 10:44:43 +0200341 ost << "\"delay\": {";
342 ost << "\"default_delay\": " << config.delay.default_delay << ",";
343 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
344 << ",";
345 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100346 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200347 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100348 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
349 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200350 ost << "\"fixed_capture_delay_samples\": "
351 << config.delay.fixed_capture_delay_samples << ",";
352 ost << "\"delay_estimate_smoothing\": "
353 << config.delay.delay_estimate_smoothing << ",";
354 ost << "\"delay_candidate_detection_threshold\": "
355 << config.delay.delay_candidate_detection_threshold << ",";
356
357 ost << "\"delay_selection_thresholds\": {";
358 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
359 << ",";
360 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200361 ost << "},";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200362
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200363 ost << "\"use_external_delay_estimator\": "
364 << (config.delay.use_external_delay_estimator ? "true" : "false") << ",";
365 ost << "\"downmix_before_delay_estimation\": "
Sam Zackrissonffc84522019-10-15 13:43:02 +0200366 << (config.delay.downmix_before_delay_estimation ? "true" : "false")
367 << ",";
368 ost << "\"log_warning_on_delay_changes\": "
369 << (config.delay.log_warning_on_delay_changes ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200370 ost << "},";
371
372 ost << "\"filter\": {";
373 ost << "\"main\": [";
374 ost << config.filter.main.length_blocks << ",";
375 ost << config.filter.main.leakage_converged << ",";
376 ost << config.filter.main.leakage_diverged << ",";
377 ost << config.filter.main.error_floor << ",";
378 ost << config.filter.main.error_ceil << ",";
379 ost << config.filter.main.noise_gate;
380 ost << "],";
381
382 ost << "\"shadow\": [";
383 ost << config.filter.shadow.length_blocks << ",";
384 ost << config.filter.shadow.rate << ",";
385 ost << config.filter.shadow.noise_gate;
386 ost << "],";
387
388 ost << "\"main_initial\": [";
389 ost << config.filter.main_initial.length_blocks << ",";
390 ost << config.filter.main_initial.leakage_converged << ",";
391 ost << config.filter.main_initial.leakage_diverged << ",";
392 ost << config.filter.main_initial.error_floor << ",";
393 ost << config.filter.main_initial.error_ceil << ",";
394 ost << config.filter.main_initial.noise_gate;
395 ost << "],";
396
397 ost << "\"shadow_initial\": [";
398 ost << config.filter.shadow_initial.length_blocks << ",";
399 ost << config.filter.shadow_initial.rate << ",";
400 ost << config.filter.shadow_initial.noise_gate;
401 ost << "],";
402
403 ost << "\"config_change_duration_blocks\": "
404 << config.filter.config_change_duration_blocks << ",";
405 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
406 << ",";
407 ost << "\"conservative_initial_phase\": "
408 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
409 ost << "\"enable_shadow_filter_output_usage\": "
410 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
411
412 ost << "},";
413
414 ost << "\"erle\": {";
415 ost << "\"min\": " << config.erle.min << ",";
416 ost << "\"max_l\": " << config.erle.max_l << ",";
417 ost << "\"max_h\": " << config.erle.max_h << ",";
418 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100419 << (config.erle.onset_detection ? "true" : "false") << ",";
Per Åhgren8be669f2019-10-11 23:02:26 +0200420 ost << "\"num_sections\": " << config.erle.num_sections << ",";
421 ost << "\"clamp_quality_estimate_to_zero\": "
422 << (config.erle.clamp_quality_estimate_to_zero ? "true" : "false") << ",";
423 ost << "\"clamp_quality_estimate_to_one\": "
424 << (config.erle.clamp_quality_estimate_to_one ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200425 ost << "},";
426
427 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100428 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200429 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200430 ost << "\"echo_can_saturate\": "
431 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
432 ost << "\"bounded_erl\": "
433 << (config.ep_strength.bounded_erl ? "true" : "false");
434
435 ost << "},";
436
Sam Zackrissona4c85142018-10-10 10:44:43 +0200437 ost << "\"echo_audibility\": {";
438 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
439 << ",";
440 ost << "\"normal_render_limit\": "
441 << config.echo_audibility.normal_render_limit << ",";
442 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
443 ost << "\"audibility_threshold_lf\": "
444 << config.echo_audibility.audibility_threshold_lf << ",";
445 ost << "\"audibility_threshold_mf\": "
446 << config.echo_audibility.audibility_threshold_mf << ",";
447 ost << "\"audibility_threshold_hf\": "
448 << config.echo_audibility.audibility_threshold_hf << ",";
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200449 ost << "\"use_stationarity_properties\": "
450 << (config.echo_audibility.use_stationarity_properties ? "true" : "false")
Sam Zackrissona4c85142018-10-10 10:44:43 +0200451 << ",";
452 ost << "\"use_stationarity_properties_at_init\": "
453 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
454 : "false");
455 ost << "},";
456
457 ost << "\"render_levels\": {";
458 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
459 << ",";
460 ost << "\"poor_excitation_render_limit\": "
461 << config.render_levels.poor_excitation_render_limit << ",";
462 ost << "\"poor_excitation_render_limit_ds8\": "
463 << config.render_levels.poor_excitation_render_limit_ds8;
464 ost << "},";
465
466 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200467 ost << "\"has_clock_drift\": "
468 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
469 << ",";
470 ost << "\"linear_and_stable_echo_path\": "
471 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
472 : "false");
473
474 ost << "},";
475
476 ost << "\"echo_model\": {";
477 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
478 ost << "\"min_noise_floor_power\": "
479 << config.echo_model.min_noise_floor_power << ",";
480 ost << "\"stationary_gate_slope\": "
481 << config.echo_model.stationary_gate_slope << ",";
482 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
483 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
484 ost << "\"render_pre_window_size\": "
485 << config.echo_model.render_pre_window_size << ",";
486 ost << "\"render_post_window_size\": "
Gustaf Ullbergec51ce02019-04-04 13:38:52 +0200487 << config.echo_model.render_post_window_size;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200488 ost << "},";
489
490 ost << "\"suppressor\": {";
491 ost << "\"nearend_average_blocks\": "
492 << config.suppressor.nearend_average_blocks << ",";
493 ost << "\"normal_tuning\": {";
494 ost << "\"mask_lf\": [";
495 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
496 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
497 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
498 ost << "],";
499 ost << "\"mask_hf\": [";
500 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
501 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
502 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
503 ost << "],";
504 ost << "\"max_inc_factor\": "
505 << config.suppressor.normal_tuning.max_inc_factor << ",";
506 ost << "\"max_dec_factor_lf\": "
507 << config.suppressor.normal_tuning.max_dec_factor_lf;
508 ost << "},";
509 ost << "\"nearend_tuning\": {";
510 ost << "\"mask_lf\": [";
511 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
512 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
513 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
514 ost << "],";
515 ost << "\"mask_hf\": [";
516 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
517 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
518 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
519 ost << "],";
520 ost << "\"max_inc_factor\": "
521 << config.suppressor.nearend_tuning.max_inc_factor << ",";
522 ost << "\"max_dec_factor_lf\": "
523 << config.suppressor.nearend_tuning.max_dec_factor_lf;
524 ost << "},";
525 ost << "\"dominant_nearend_detection\": {";
526 ost << "\"enr_threshold\": "
527 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200528 ost << "\"enr_exit_threshold\": "
529 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200530 ost << "\"snr_threshold\": "
531 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
532 ost << "\"hold_duration\": "
533 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
534 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200535 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
536 ost << "\"use_during_initial_phase\": "
537 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200538 ost << "},";
539 ost << "\"high_bands_suppression\": {";
540 ost << "\"enr_threshold\": "
541 << config.suppressor.high_bands_suppression.enr_threshold << ",";
542 ost << "\"max_gain_during_echo\": "
543 << config.suppressor.high_bands_suppression.max_gain_during_echo;
544 ost << "},";
545 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
546 << ",";
547 ost << "\"enforce_transparent\": "
548 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
549 ost << "\"enforce_empty_higher_bands\": "
550 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
551 ost << "}";
552 ost << "}";
553 ost << "}";
554
555 return ost.Release();
556}
557} // namespace webrtc