blob: fa5815566b45aef57153cfbbbe12f2b8cf026be6 [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;
129 if (rtc::GetValueFromJsonObject(aec3_root, "delay", &section)) {
130 ReadParam(section, "default_delay", &cfg.delay.default_delay);
131 ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
132 ReadParam(section, "num_filters", &cfg.delay.num_filters);
133 ReadParam(section, "api_call_jitter_blocks",
134 &cfg.delay.api_call_jitter_blocks);
135 ReadParam(section, "min_echo_path_delay_blocks",
136 &cfg.delay.min_echo_path_delay_blocks);
137 ReadParam(section, "delay_headroom_blocks",
138 &cfg.delay.delay_headroom_blocks);
139 ReadParam(section, "hysteresis_limit_1_blocks",
140 &cfg.delay.hysteresis_limit_1_blocks);
141 ReadParam(section, "hysteresis_limit_2_blocks",
142 &cfg.delay.hysteresis_limit_2_blocks);
143 ReadParam(section, "skew_hysteresis_blocks",
144 &cfg.delay.skew_hysteresis_blocks);
145 ReadParam(section, "fixed_capture_delay_samples",
146 &cfg.delay.fixed_capture_delay_samples);
147 ReadParam(section, "delay_estimate_smoothing",
148 &cfg.delay.delay_estimate_smoothing);
149 ReadParam(section, "delay_candidate_detection_threshold",
150 &cfg.delay.delay_candidate_detection_threshold);
151
152 Json::Value subsection;
153 if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
154 &subsection)) {
155 ReadParam(subsection, "initial",
156 &cfg.delay.delay_selection_thresholds.initial);
157 ReadParam(subsection, "converged",
158 &cfg.delay.delay_selection_thresholds.converged);
159 }
160 }
161
162 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
163 ReadParam(section, "main", &cfg.filter.main);
164 ReadParam(section, "shadow", &cfg.filter.shadow);
165 ReadParam(section, "main_initial", &cfg.filter.main_initial);
166 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
167 ReadParam(section, "config_change_duration_blocks",
168 &cfg.filter.config_change_duration_blocks);
169 ReadParam(section, "initial_state_seconds",
170 &cfg.filter.initial_state_seconds);
171 ReadParam(section, "conservative_initial_phase",
172 &cfg.filter.conservative_initial_phase);
173 ReadParam(section, "enable_shadow_filter_output_usage",
174 &cfg.filter.enable_shadow_filter_output_usage);
175 }
176
177 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
178 ReadParam(section, "min", &cfg.erle.min);
179 ReadParam(section, "max_l", &cfg.erle.max_l);
180 ReadParam(section, "max_h", &cfg.erle.max_h);
181 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
182 }
183
184 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
185 ReadParam(section, "lf", &cfg.ep_strength.lf);
186 ReadParam(section, "mf", &cfg.ep_strength.mf);
187 ReadParam(section, "hf", &cfg.ep_strength.hf);
188 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
189 ReadParam(section, "reverb_based_on_render",
190 &cfg.ep_strength.reverb_based_on_render);
191 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
192 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
193 }
194
Sam Zackrissona4c85142018-10-10 10:44:43 +0200195 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
196 ReadParam(section, "low_render_limit",
197 &cfg.echo_audibility.low_render_limit);
198 ReadParam(section, "normal_render_limit",
199 &cfg.echo_audibility.normal_render_limit);
200
201 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
202 ReadParam(section, "audibility_threshold_lf",
203 &cfg.echo_audibility.audibility_threshold_lf);
204 ReadParam(section, "audibility_threshold_mf",
205 &cfg.echo_audibility.audibility_threshold_mf);
206 ReadParam(section, "audibility_threshold_hf",
207 &cfg.echo_audibility.audibility_threshold_hf);
208 ReadParam(section, "use_stationary_properties",
209 &cfg.echo_audibility.use_stationary_properties);
210 ReadParam(section, "use_stationary_properties_at_init",
211 &cfg.echo_audibility.use_stationarity_properties_at_init);
212 }
213
214 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
215 &section)) {
216 Json::Value subsection;
217 if (rtc::GetValueFromJsonObject(section, "gain_rampup", &subsection)) {
218 ReadParam(subsection, "initial_gain",
219 &cfg.echo_removal_control.gain_rampup.initial_gain);
220 ReadParam(subsection, "first_non_zero_gain",
221 &cfg.echo_removal_control.gain_rampup.first_non_zero_gain);
222 ReadParam(subsection, "non_zero_gain_blocks",
223 &cfg.echo_removal_control.gain_rampup.non_zero_gain_blocks);
224 ReadParam(subsection, "full_gain_blocks",
225 &cfg.echo_removal_control.gain_rampup.full_gain_blocks);
226 }
227 ReadParam(section, "has_clock_drift",
228 &cfg.echo_removal_control.has_clock_drift);
229 ReadParam(section, "linear_and_stable_echo_path",
230 &cfg.echo_removal_control.linear_and_stable_echo_path);
231 }
232
233 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
234 Json::Value subsection;
235 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
236 ReadParam(section, "min_noise_floor_power",
237 &cfg.echo_model.min_noise_floor_power);
238 ReadParam(section, "stationary_gate_slope",
239 &cfg.echo_model.stationary_gate_slope);
240 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
241 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
242 ReadParam(section, "render_pre_window_size",
243 &cfg.echo_model.render_pre_window_size);
244 ReadParam(section, "render_post_window_size",
245 &cfg.echo_model.render_post_window_size);
246 ReadParam(section, "render_pre_window_size_init",
247 &cfg.echo_model.render_pre_window_size_init);
248 ReadParam(section, "render_post_window_size_init",
249 &cfg.echo_model.render_post_window_size_init);
250 ReadParam(section, "nonlinear_hold", &cfg.echo_model.nonlinear_hold);
251 ReadParam(section, "nonlinear_release", &cfg.echo_model.nonlinear_release);
252 }
253
254 Json::Value subsection;
255 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
256 ReadParam(section, "nearend_average_blocks",
257 &cfg.suppressor.nearend_average_blocks);
258
259 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
260 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
261 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
262 ReadParam(subsection, "max_inc_factor",
263 &cfg.suppressor.normal_tuning.max_inc_factor);
264 ReadParam(subsection, "max_dec_factor_lf",
265 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
266 }
267
268 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
269 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
270 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
271 ReadParam(subsection, "max_inc_factor",
272 &cfg.suppressor.nearend_tuning.max_inc_factor);
273 ReadParam(subsection, "max_dec_factor_lf",
274 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
275 }
276
277 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
278 &subsection)) {
279 ReadParam(subsection, "enr_threshold",
280 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
281 ReadParam(subsection, "snr_threshold",
282 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
283 ReadParam(subsection, "hold_duration",
284 &cfg.suppressor.dominant_nearend_detection.hold_duration);
285 ReadParam(subsection, "trigger_threshold",
286 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
287 }
288
289 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
290 &subsection)) {
291 ReadParam(subsection, "enr_threshold",
292 &cfg.suppressor.high_bands_suppression.enr_threshold);
293 ReadParam(subsection, "max_gain_during_echo",
294 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
295 }
296
297 ReadParam(section, "floor_first_increase",
298 &cfg.suppressor.floor_first_increase);
299 ReadParam(section, "enforce_transparent",
300 &cfg.suppressor.enforce_transparent);
301 ReadParam(section, "enforce_empty_higher_bands",
302 &cfg.suppressor.enforce_empty_higher_bands);
303 }
304 return cfg;
305}
306
307std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
308 rtc::StringBuilder ost;
309 ost << "{";
310 ost << "\"aec3\": {";
311 ost << "\"delay\": {";
312 ost << "\"default_delay\": " << config.delay.default_delay << ",";
313 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
314 << ",";
315 ost << "\"num_filters\": " << config.delay.num_filters << ",";
316 ost << "\"api_call_jitter_blocks\": " << config.delay.api_call_jitter_blocks
317 << ",";
318 ost << "\"min_echo_path_delay_blocks\": "
319 << config.delay.min_echo_path_delay_blocks << ",";
320 ost << "\"delay_headroom_blocks\": " << config.delay.delay_headroom_blocks
321 << ",";
322 ost << "\"hysteresis_limit_1_blocks\": "
323 << config.delay.hysteresis_limit_1_blocks << ",";
324 ost << "\"hysteresis_limit_2_blocks\": "
325 << config.delay.hysteresis_limit_2_blocks << ",";
326 ost << "\"skew_hysteresis_blocks\": " << config.delay.skew_hysteresis_blocks
327 << ",";
328 ost << "\"fixed_capture_delay_samples\": "
329 << config.delay.fixed_capture_delay_samples << ",";
330 ost << "\"delay_estimate_smoothing\": "
331 << config.delay.delay_estimate_smoothing << ",";
332 ost << "\"delay_candidate_detection_threshold\": "
333 << config.delay.delay_candidate_detection_threshold << ",";
334
335 ost << "\"delay_selection_thresholds\": {";
336 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
337 << ",";
338 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
339 ost << "}";
340
341 ost << "},";
342
343 ost << "\"filter\": {";
344 ost << "\"main\": [";
345 ost << config.filter.main.length_blocks << ",";
346 ost << config.filter.main.leakage_converged << ",";
347 ost << config.filter.main.leakage_diverged << ",";
348 ost << config.filter.main.error_floor << ",";
349 ost << config.filter.main.error_ceil << ",";
350 ost << config.filter.main.noise_gate;
351 ost << "],";
352
353 ost << "\"shadow\": [";
354 ost << config.filter.shadow.length_blocks << ",";
355 ost << config.filter.shadow.rate << ",";
356 ost << config.filter.shadow.noise_gate;
357 ost << "],";
358
359 ost << "\"main_initial\": [";
360 ost << config.filter.main_initial.length_blocks << ",";
361 ost << config.filter.main_initial.leakage_converged << ",";
362 ost << config.filter.main_initial.leakage_diverged << ",";
363 ost << config.filter.main_initial.error_floor << ",";
364 ost << config.filter.main_initial.error_ceil << ",";
365 ost << config.filter.main_initial.noise_gate;
366 ost << "],";
367
368 ost << "\"shadow_initial\": [";
369 ost << config.filter.shadow_initial.length_blocks << ",";
370 ost << config.filter.shadow_initial.rate << ",";
371 ost << config.filter.shadow_initial.noise_gate;
372 ost << "],";
373
374 ost << "\"config_change_duration_blocks\": "
375 << config.filter.config_change_duration_blocks << ",";
376 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
377 << ",";
378 ost << "\"conservative_initial_phase\": "
379 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
380 ost << "\"enable_shadow_filter_output_usage\": "
381 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
382
383 ost << "},";
384
385 ost << "\"erle\": {";
386 ost << "\"min\": " << config.erle.min << ",";
387 ost << "\"max_l\": " << config.erle.max_l << ",";
388 ost << "\"max_h\": " << config.erle.max_h << ",";
389 ost << "\"onset_detection\": "
390 << (config.erle.onset_detection ? "true" : "false");
391 ost << "},";
392
393 ost << "\"ep_strength\": {";
394 ost << "\"lf\": " << config.ep_strength.lf << ",";
395 ost << "\"mf\": " << config.ep_strength.mf << ",";
396 ost << "\"hf\": " << config.ep_strength.hf << ",";
397 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
398 ost << "\"reverb_based_on_render\": "
399 << (config.ep_strength.reverb_based_on_render ? "true" : "false") << ",";
400 ost << "\"echo_can_saturate\": "
401 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
402 ost << "\"bounded_erl\": "
403 << (config.ep_strength.bounded_erl ? "true" : "false");
404
405 ost << "},";
406
Sam Zackrissona4c85142018-10-10 10:44:43 +0200407 ost << "\"echo_audibility\": {";
408 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
409 << ",";
410 ost << "\"normal_render_limit\": "
411 << config.echo_audibility.normal_render_limit << ",";
412 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
413 ost << "\"audibility_threshold_lf\": "
414 << config.echo_audibility.audibility_threshold_lf << ",";
415 ost << "\"audibility_threshold_mf\": "
416 << config.echo_audibility.audibility_threshold_mf << ",";
417 ost << "\"audibility_threshold_hf\": "
418 << config.echo_audibility.audibility_threshold_hf << ",";
419 ost << "\"use_stationary_properties\": "
420 << (config.echo_audibility.use_stationary_properties ? "true" : "false")
421 << ",";
422 ost << "\"use_stationarity_properties_at_init\": "
423 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
424 : "false");
425 ost << "},";
426
427 ost << "\"render_levels\": {";
428 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
429 << ",";
430 ost << "\"poor_excitation_render_limit\": "
431 << config.render_levels.poor_excitation_render_limit << ",";
432 ost << "\"poor_excitation_render_limit_ds8\": "
433 << config.render_levels.poor_excitation_render_limit_ds8;
434 ost << "},";
435
436 ost << "\"echo_removal_control\": {";
437 ost << "\"gain_rampup\": {";
438 ost << "\"initial_gain\": "
439 << config.echo_removal_control.gain_rampup.initial_gain << ",";
440 ost << "\"first_non_zero_gain\": "
441 << config.echo_removal_control.gain_rampup.first_non_zero_gain << ",";
442 ost << "\"non_zero_gain_blocks\": "
443 << config.echo_removal_control.gain_rampup.non_zero_gain_blocks << ",";
444 ost << "\"full_gain_blocks\": "
445 << config.echo_removal_control.gain_rampup.full_gain_blocks;
446 ost << "},";
447 ost << "\"has_clock_drift\": "
448 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
449 << ",";
450 ost << "\"linear_and_stable_echo_path\": "
451 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
452 : "false");
453
454 ost << "},";
455
456 ost << "\"echo_model\": {";
457 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
458 ost << "\"min_noise_floor_power\": "
459 << config.echo_model.min_noise_floor_power << ",";
460 ost << "\"stationary_gate_slope\": "
461 << config.echo_model.stationary_gate_slope << ",";
462 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
463 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
464 ost << "\"render_pre_window_size\": "
465 << config.echo_model.render_pre_window_size << ",";
466 ost << "\"render_post_window_size\": "
467 << config.echo_model.render_post_window_size << ",";
468 ost << "\"render_pre_window_size_init\": "
469 << config.echo_model.render_pre_window_size_init << ",";
470 ost << "\"render_post_window_size_init\": "
471 << config.echo_model.render_post_window_size_init << ",";
472 ost << "\"nonlinear_hold\": " << config.echo_model.nonlinear_hold << ",";
473 ost << "\"nonlinear_release\": " << config.echo_model.nonlinear_release;
474 ost << "},";
475
476 ost << "\"suppressor\": {";
477 ost << "\"nearend_average_blocks\": "
478 << config.suppressor.nearend_average_blocks << ",";
479 ost << "\"normal_tuning\": {";
480 ost << "\"mask_lf\": [";
481 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
482 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
483 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
484 ost << "],";
485 ost << "\"mask_hf\": [";
486 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
487 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
488 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
489 ost << "],";
490 ost << "\"max_inc_factor\": "
491 << config.suppressor.normal_tuning.max_inc_factor << ",";
492 ost << "\"max_dec_factor_lf\": "
493 << config.suppressor.normal_tuning.max_dec_factor_lf;
494 ost << "},";
495 ost << "\"nearend_tuning\": {";
496 ost << "\"mask_lf\": [";
497 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
498 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
499 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
500 ost << "],";
501 ost << "\"mask_hf\": [";
502 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
503 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
504 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
505 ost << "],";
506 ost << "\"max_inc_factor\": "
507 << config.suppressor.nearend_tuning.max_inc_factor << ",";
508 ost << "\"max_dec_factor_lf\": "
509 << config.suppressor.nearend_tuning.max_dec_factor_lf;
510 ost << "},";
511 ost << "\"dominant_nearend_detection\": {";
512 ost << "\"enr_threshold\": "
513 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
514 ost << "\"snr_threshold\": "
515 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
516 ost << "\"hold_duration\": "
517 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
518 ost << "\"trigger_threshold\": "
519 << config.suppressor.dominant_nearend_detection.trigger_threshold;
520 ost << "},";
521 ost << "\"high_bands_suppression\": {";
522 ost << "\"enr_threshold\": "
523 << config.suppressor.high_bands_suppression.enr_threshold << ",";
524 ost << "\"max_gain_during_echo\": "
525 << config.suppressor.high_bands_suppression.max_gain_during_echo;
526 ost << "},";
527 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
528 << ",";
529 ost << "\"enforce_transparent\": "
530 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
531 ost << "\"enforce_empty_higher_bands\": "
532 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
533 ost << "}";
534 ost << "}";
535 ost << "}";
536
537 return ost.Release();
538}
539} // namespace webrtc