blob: 2b6a329b2902159fc38030d7d55a067784459792 [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
12#include <string>
13#include <vector>
14
15#include "rtc_base/logging.h"
16#include "rtc_base/strings/json.h"
17#include "rtc_base/strings/string_builder.h"
18
19namespace webrtc {
20namespace {
21void ReadParam(const Json::Value& root, std::string param_name, bool* param) {
22 RTC_DCHECK(param);
23 bool v;
24 if (rtc::GetBoolFromJsonObject(root, param_name, &v)) {
25 *param = v;
26 }
27}
28
29void ReadParam(const Json::Value& root, std::string param_name, size_t* param) {
30 RTC_DCHECK(param);
31 int v;
32 if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
33 *param = v;
34 }
35}
36
37void ReadParam(const Json::Value& root, std::string param_name, int* param) {
38 RTC_DCHECK(param);
39 int v;
40 if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
41 *param = v;
42 }
43}
44
45void ReadParam(const Json::Value& root, std::string param_name, float* param) {
46 RTC_DCHECK(param);
47 double v;
48 if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) {
49 *param = static_cast<float>(v);
50 }
51}
52
53void ReadParam(const Json::Value& root,
54 std::string param_name,
55 EchoCanceller3Config::Filter::MainConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020056 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020057 Json::Value json_array;
58 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
59 std::vector<double> v;
60 rtc::JsonArrayToDoubleVector(json_array, &v);
61 if (v.size() != 6) {
62 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +020063 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020064 }
65 param->length_blocks = static_cast<size_t>(v[0]);
66 param->leakage_converged = static_cast<float>(v[1]);
67 param->leakage_diverged = static_cast<float>(v[2]);
68 param->error_floor = static_cast<float>(v[3]);
69 param->error_ceil = static_cast<float>(v[4]);
70 param->noise_gate = static_cast<float>(v[5]);
71 }
72}
73
74void ReadParam(const Json::Value& root,
75 std::string param_name,
76 EchoCanceller3Config::Filter::ShadowConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020077 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020078 Json::Value json_array;
79 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
80 std::vector<double> v;
81 rtc::JsonArrayToDoubleVector(json_array, &v);
82 if (v.size() != 3) {
83 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +020084 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020085 }
86 param->length_blocks = static_cast<size_t>(v[0]);
87 param->rate = static_cast<float>(v[1]);
88 param->noise_gate = static_cast<float>(v[2]);
89 }
90}
91
92void ReadParam(const Json::Value& root,
93 std::string param_name,
94 EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020095 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020096 Json::Value json_array;
97 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
98 std::vector<double> v;
99 rtc::JsonArrayToDoubleVector(json_array, &v);
100 if (v.size() != 3) {
101 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +0200102 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200103 }
104 param->enr_transparent = static_cast<float>(v[0]);
105 param->enr_suppress = static_cast<float>(v[1]);
106 param->emr_transparent = static_cast<float>(v[2]);
107 }
108}
109} // namespace
110
111EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
112 EchoCanceller3Config cfg;
113
114 Json::Value root;
115 bool success = Json::Reader().parse(std::string(json_string), root);
116 if (!success) {
117 RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string;
118 return EchoCanceller3Config();
119 }
120
121 Json::Value aec3_root;
122 success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
123 if (!success) {
124 RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
125 return EchoCanceller3Config();
126 }
127
128 Json::Value section;
Gustaf Ullberg11539f02018-10-15 13:40:29 +0200129 if (rtc::GetValueFromJsonObject(root, "buffering", &section)) {
130 ReadParam(section, "use_new_render_buffering",
131 &cfg.buffering.use_new_render_buffering);
132 ReadParam(section, "excess_render_detection_interval_blocks",
133 &cfg.buffering.excess_render_detection_interval_blocks);
134 ReadParam(section, "max_allowed_excess_render_blocks",
135 &cfg.buffering.max_allowed_excess_render_blocks);
136 }
137
Sam Zackrissona4c85142018-10-10 10:44:43 +0200138 if (rtc::GetValueFromJsonObject(aec3_root, "delay", &section)) {
139 ReadParam(section, "default_delay", &cfg.delay.default_delay);
140 ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
141 ReadParam(section, "num_filters", &cfg.delay.num_filters);
142 ReadParam(section, "api_call_jitter_blocks",
143 &cfg.delay.api_call_jitter_blocks);
144 ReadParam(section, "min_echo_path_delay_blocks",
145 &cfg.delay.min_echo_path_delay_blocks);
146 ReadParam(section, "delay_headroom_blocks",
147 &cfg.delay.delay_headroom_blocks);
148 ReadParam(section, "hysteresis_limit_1_blocks",
149 &cfg.delay.hysteresis_limit_1_blocks);
150 ReadParam(section, "hysteresis_limit_2_blocks",
151 &cfg.delay.hysteresis_limit_2_blocks);
152 ReadParam(section, "skew_hysteresis_blocks",
153 &cfg.delay.skew_hysteresis_blocks);
154 ReadParam(section, "fixed_capture_delay_samples",
155 &cfg.delay.fixed_capture_delay_samples);
156 ReadParam(section, "delay_estimate_smoothing",
157 &cfg.delay.delay_estimate_smoothing);
158 ReadParam(section, "delay_candidate_detection_threshold",
159 &cfg.delay.delay_candidate_detection_threshold);
160
161 Json::Value subsection;
162 if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
163 &subsection)) {
164 ReadParam(subsection, "initial",
165 &cfg.delay.delay_selection_thresholds.initial);
166 ReadParam(subsection, "converged",
167 &cfg.delay.delay_selection_thresholds.converged);
168 }
169 }
170
171 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
172 ReadParam(section, "main", &cfg.filter.main);
173 ReadParam(section, "shadow", &cfg.filter.shadow);
174 ReadParam(section, "main_initial", &cfg.filter.main_initial);
175 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
176 ReadParam(section, "config_change_duration_blocks",
177 &cfg.filter.config_change_duration_blocks);
178 ReadParam(section, "initial_state_seconds",
179 &cfg.filter.initial_state_seconds);
180 ReadParam(section, "conservative_initial_phase",
181 &cfg.filter.conservative_initial_phase);
182 ReadParam(section, "enable_shadow_filter_output_usage",
183 &cfg.filter.enable_shadow_filter_output_usage);
184 }
185
186 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
187 ReadParam(section, "min", &cfg.erle.min);
188 ReadParam(section, "max_l", &cfg.erle.max_l);
189 ReadParam(section, "max_h", &cfg.erle.max_h);
190 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
191 }
192
193 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
194 ReadParam(section, "lf", &cfg.ep_strength.lf);
195 ReadParam(section, "mf", &cfg.ep_strength.mf);
196 ReadParam(section, "hf", &cfg.ep_strength.hf);
197 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
198 ReadParam(section, "reverb_based_on_render",
199 &cfg.ep_strength.reverb_based_on_render);
200 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
201 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
202 }
203
Sam Zackrissona4c85142018-10-10 10:44:43 +0200204 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
205 ReadParam(section, "low_render_limit",
206 &cfg.echo_audibility.low_render_limit);
207 ReadParam(section, "normal_render_limit",
208 &cfg.echo_audibility.normal_render_limit);
209
210 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
211 ReadParam(section, "audibility_threshold_lf",
212 &cfg.echo_audibility.audibility_threshold_lf);
213 ReadParam(section, "audibility_threshold_mf",
214 &cfg.echo_audibility.audibility_threshold_mf);
215 ReadParam(section, "audibility_threshold_hf",
216 &cfg.echo_audibility.audibility_threshold_hf);
217 ReadParam(section, "use_stationary_properties",
218 &cfg.echo_audibility.use_stationary_properties);
Sam Zackrisson848273a2018-10-23 12:13:42 +0000219 ReadParam(section, "use_stationary_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200220 &cfg.echo_audibility.use_stationarity_properties_at_init);
221 }
222
Per Ã…hgren01cf44d2018-10-20 00:17:13 +0200223 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
224 ReadParam(section, "active_render_limit",
225 &cfg.render_levels.active_render_limit);
226 ReadParam(section, "poor_excitation_render_limit",
227 &cfg.render_levels.poor_excitation_render_limit);
228 ReadParam(section, "poor_excitation_render_limit_ds8",
229 &cfg.render_levels.poor_excitation_render_limit_ds8);
230 }
231
Sam Zackrissona4c85142018-10-10 10:44:43 +0200232 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
233 &section)) {
234 Json::Value subsection;
235 if (rtc::GetValueFromJsonObject(section, "gain_rampup", &subsection)) {
236 ReadParam(subsection, "initial_gain",
237 &cfg.echo_removal_control.gain_rampup.initial_gain);
238 ReadParam(subsection, "first_non_zero_gain",
239 &cfg.echo_removal_control.gain_rampup.first_non_zero_gain);
240 ReadParam(subsection, "non_zero_gain_blocks",
241 &cfg.echo_removal_control.gain_rampup.non_zero_gain_blocks);
242 ReadParam(subsection, "full_gain_blocks",
243 &cfg.echo_removal_control.gain_rampup.full_gain_blocks);
244 }
245 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);
264 ReadParam(section, "render_pre_window_size_init",
265 &cfg.echo_model.render_pre_window_size_init);
266 ReadParam(section, "render_post_window_size_init",
267 &cfg.echo_model.render_post_window_size_init);
268 ReadParam(section, "nonlinear_hold", &cfg.echo_model.nonlinear_hold);
269 ReadParam(section, "nonlinear_release", &cfg.echo_model.nonlinear_release);
270 }
271
272 Json::Value subsection;
273 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
274 ReadParam(section, "nearend_average_blocks",
275 &cfg.suppressor.nearend_average_blocks);
276
277 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
278 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
279 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
280 ReadParam(subsection, "max_inc_factor",
281 &cfg.suppressor.normal_tuning.max_inc_factor);
282 ReadParam(subsection, "max_dec_factor_lf",
283 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
284 }
285
286 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
287 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
288 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
289 ReadParam(subsection, "max_inc_factor",
290 &cfg.suppressor.nearend_tuning.max_inc_factor);
291 ReadParam(subsection, "max_dec_factor_lf",
292 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
293 }
294
295 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
296 &subsection)) {
297 ReadParam(subsection, "enr_threshold",
298 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200299 ReadParam(subsection, "enr_exit_threshold",
300 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200301 ReadParam(subsection, "snr_threshold",
302 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
303 ReadParam(subsection, "hold_duration",
304 &cfg.suppressor.dominant_nearend_detection.hold_duration);
305 ReadParam(subsection, "trigger_threshold",
306 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
307 }
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);
319 ReadParam(section, "enforce_transparent",
320 &cfg.suppressor.enforce_transparent);
321 ReadParam(section, "enforce_empty_higher_bands",
322 &cfg.suppressor.enforce_empty_higher_bands);
323 }
324 return cfg;
325}
326
327std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
328 rtc::StringBuilder ost;
329 ost << "{";
330 ost << "\"aec3\": {";
331 ost << "\"delay\": {";
332 ost << "\"default_delay\": " << config.delay.default_delay << ",";
333 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
334 << ",";
335 ost << "\"num_filters\": " << config.delay.num_filters << ",";
336 ost << "\"api_call_jitter_blocks\": " << config.delay.api_call_jitter_blocks
337 << ",";
338 ost << "\"min_echo_path_delay_blocks\": "
339 << config.delay.min_echo_path_delay_blocks << ",";
340 ost << "\"delay_headroom_blocks\": " << config.delay.delay_headroom_blocks
341 << ",";
342 ost << "\"hysteresis_limit_1_blocks\": "
343 << config.delay.hysteresis_limit_1_blocks << ",";
344 ost << "\"hysteresis_limit_2_blocks\": "
345 << config.delay.hysteresis_limit_2_blocks << ",";
346 ost << "\"skew_hysteresis_blocks\": " << config.delay.skew_hysteresis_blocks
347 << ",";
348 ost << "\"fixed_capture_delay_samples\": "
349 << config.delay.fixed_capture_delay_samples << ",";
350 ost << "\"delay_estimate_smoothing\": "
351 << config.delay.delay_estimate_smoothing << ",";
352 ost << "\"delay_candidate_detection_threshold\": "
353 << config.delay.delay_candidate_detection_threshold << ",";
354
355 ost << "\"delay_selection_thresholds\": {";
356 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
357 << ",";
358 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
359 ost << "}";
360
361 ost << "},";
362
363 ost << "\"filter\": {";
364 ost << "\"main\": [";
365 ost << config.filter.main.length_blocks << ",";
366 ost << config.filter.main.leakage_converged << ",";
367 ost << config.filter.main.leakage_diverged << ",";
368 ost << config.filter.main.error_floor << ",";
369 ost << config.filter.main.error_ceil << ",";
370 ost << config.filter.main.noise_gate;
371 ost << "],";
372
373 ost << "\"shadow\": [";
374 ost << config.filter.shadow.length_blocks << ",";
375 ost << config.filter.shadow.rate << ",";
376 ost << config.filter.shadow.noise_gate;
377 ost << "],";
378
379 ost << "\"main_initial\": [";
380 ost << config.filter.main_initial.length_blocks << ",";
381 ost << config.filter.main_initial.leakage_converged << ",";
382 ost << config.filter.main_initial.leakage_diverged << ",";
383 ost << config.filter.main_initial.error_floor << ",";
384 ost << config.filter.main_initial.error_ceil << ",";
385 ost << config.filter.main_initial.noise_gate;
386 ost << "],";
387
388 ost << "\"shadow_initial\": [";
389 ost << config.filter.shadow_initial.length_blocks << ",";
390 ost << config.filter.shadow_initial.rate << ",";
391 ost << config.filter.shadow_initial.noise_gate;
392 ost << "],";
393
394 ost << "\"config_change_duration_blocks\": "
395 << config.filter.config_change_duration_blocks << ",";
396 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
397 << ",";
398 ost << "\"conservative_initial_phase\": "
399 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
400 ost << "\"enable_shadow_filter_output_usage\": "
401 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
402
403 ost << "},";
404
405 ost << "\"erle\": {";
406 ost << "\"min\": " << config.erle.min << ",";
407 ost << "\"max_l\": " << config.erle.max_l << ",";
408 ost << "\"max_h\": " << config.erle.max_h << ",";
409 ost << "\"onset_detection\": "
410 << (config.erle.onset_detection ? "true" : "false");
411 ost << "},";
412
413 ost << "\"ep_strength\": {";
414 ost << "\"lf\": " << config.ep_strength.lf << ",";
415 ost << "\"mf\": " << config.ep_strength.mf << ",";
416 ost << "\"hf\": " << config.ep_strength.hf << ",";
417 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
418 ost << "\"reverb_based_on_render\": "
419 << (config.ep_strength.reverb_based_on_render ? "true" : "false") << ",";
420 ost << "\"echo_can_saturate\": "
421 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
422 ost << "\"bounded_erl\": "
423 << (config.ep_strength.bounded_erl ? "true" : "false");
424
425 ost << "},";
426
Sam Zackrissona4c85142018-10-10 10:44:43 +0200427 ost << "\"echo_audibility\": {";
428 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
429 << ",";
430 ost << "\"normal_render_limit\": "
431 << config.echo_audibility.normal_render_limit << ",";
432 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
433 ost << "\"audibility_threshold_lf\": "
434 << config.echo_audibility.audibility_threshold_lf << ",";
435 ost << "\"audibility_threshold_mf\": "
436 << config.echo_audibility.audibility_threshold_mf << ",";
437 ost << "\"audibility_threshold_hf\": "
438 << config.echo_audibility.audibility_threshold_hf << ",";
439 ost << "\"use_stationary_properties\": "
440 << (config.echo_audibility.use_stationary_properties ? "true" : "false")
441 << ",";
442 ost << "\"use_stationarity_properties_at_init\": "
443 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
444 : "false");
445 ost << "},";
446
447 ost << "\"render_levels\": {";
448 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
449 << ",";
450 ost << "\"poor_excitation_render_limit\": "
451 << config.render_levels.poor_excitation_render_limit << ",";
452 ost << "\"poor_excitation_render_limit_ds8\": "
453 << config.render_levels.poor_excitation_render_limit_ds8;
454 ost << "},";
455
456 ost << "\"echo_removal_control\": {";
457 ost << "\"gain_rampup\": {";
458 ost << "\"initial_gain\": "
459 << config.echo_removal_control.gain_rampup.initial_gain << ",";
460 ost << "\"first_non_zero_gain\": "
461 << config.echo_removal_control.gain_rampup.first_non_zero_gain << ",";
462 ost << "\"non_zero_gain_blocks\": "
463 << config.echo_removal_control.gain_rampup.non_zero_gain_blocks << ",";
464 ost << "\"full_gain_blocks\": "
465 << config.echo_removal_control.gain_rampup.full_gain_blocks;
466 ost << "},";
467 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\": "
487 << config.echo_model.render_post_window_size << ",";
488 ost << "\"render_pre_window_size_init\": "
489 << config.echo_model.render_pre_window_size_init << ",";
490 ost << "\"render_post_window_size_init\": "
491 << config.echo_model.render_post_window_size_init << ",";
492 ost << "\"nonlinear_hold\": " << config.echo_model.nonlinear_hold << ",";
493 ost << "\"nonlinear_release\": " << config.echo_model.nonlinear_release;
494 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\": "
541 << config.suppressor.dominant_nearend_detection.trigger_threshold;
542 ost << "},";
543 ost << "\"high_bands_suppression\": {";
544 ost << "\"enr_threshold\": "
545 << config.suppressor.high_bands_suppression.enr_threshold << ",";
546 ost << "\"max_gain_during_echo\": "
547 << config.suppressor.high_bands_suppression.max_gain_during_echo;
548 ost << "},";
549 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
550 << ",";
551 ost << "\"enforce_transparent\": "
552 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
553 ost << "\"enforce_empty_higher_bands\": "
554 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
555 ost << "}";
556 ost << "}";
557 ost << "}";
558
559 return ost.Release();
560}
561} // namespace webrtc