blob: c17497a3358e6501bea85423468f1caa4ba223b1 [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 Zackrissona4c85142018-10-10 10:44:43 +0200176 }
177
178 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
179 ReadParam(section, "main", &cfg.filter.main);
180 ReadParam(section, "shadow", &cfg.filter.shadow);
181 ReadParam(section, "main_initial", &cfg.filter.main_initial);
182 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
183 ReadParam(section, "config_change_duration_blocks",
184 &cfg.filter.config_change_duration_blocks);
185 ReadParam(section, "initial_state_seconds",
186 &cfg.filter.initial_state_seconds);
187 ReadParam(section, "conservative_initial_phase",
188 &cfg.filter.conservative_initial_phase);
189 ReadParam(section, "enable_shadow_filter_output_usage",
190 &cfg.filter.enable_shadow_filter_output_usage);
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200191 ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200192 }
193
194 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
195 ReadParam(section, "min", &cfg.erle.min);
196 ReadParam(section, "max_l", &cfg.erle.max_l);
197 ReadParam(section, "max_h", &cfg.erle.max_h);
198 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100199 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Per Åhgren8be669f2019-10-11 23:02:26 +0200200 ReadParam(section, "clamp_quality_estimate_to_zero",
201 &cfg.erle.clamp_quality_estimate_to_zero);
202 ReadParam(section, "clamp_quality_estimate_to_one",
203 &cfg.erle.clamp_quality_estimate_to_one);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200204 }
205
206 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100207 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200208 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200209 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
210 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
211 }
212
Sam Zackrissona4c85142018-10-10 10:44:43 +0200213 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
214 ReadParam(section, "low_render_limit",
215 &cfg.echo_audibility.low_render_limit);
216 ReadParam(section, "normal_render_limit",
217 &cfg.echo_audibility.normal_render_limit);
218
219 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
220 ReadParam(section, "audibility_threshold_lf",
221 &cfg.echo_audibility.audibility_threshold_lf);
222 ReadParam(section, "audibility_threshold_mf",
223 &cfg.echo_audibility.audibility_threshold_mf);
224 ReadParam(section, "audibility_threshold_hf",
225 &cfg.echo_audibility.audibility_threshold_hf);
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200226 ReadParam(section, "use_stationarity_properties",
227 &cfg.echo_audibility.use_stationarity_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200228 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200229 &cfg.echo_audibility.use_stationarity_properties_at_init);
230 }
231
Per Åhgren01cf44d2018-10-20 00:17:13 +0200232 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
233 ReadParam(section, "active_render_limit",
234 &cfg.render_levels.active_render_limit);
235 ReadParam(section, "poor_excitation_render_limit",
236 &cfg.render_levels.poor_excitation_render_limit);
237 ReadParam(section, "poor_excitation_render_limit_ds8",
238 &cfg.render_levels.poor_excitation_render_limit_ds8);
239 }
240
Sam Zackrissona4c85142018-10-10 10:44:43 +0200241 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
242 &section)) {
Sam Zackrissona4c85142018-10-10 10:44:43 +0200243 ReadParam(section, "has_clock_drift",
244 &cfg.echo_removal_control.has_clock_drift);
245 ReadParam(section, "linear_and_stable_echo_path",
246 &cfg.echo_removal_control.linear_and_stable_echo_path);
247 }
248
249 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
250 Json::Value subsection;
251 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
252 ReadParam(section, "min_noise_floor_power",
253 &cfg.echo_model.min_noise_floor_power);
254 ReadParam(section, "stationary_gate_slope",
255 &cfg.echo_model.stationary_gate_slope);
256 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
257 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
258 ReadParam(section, "render_pre_window_size",
259 &cfg.echo_model.render_pre_window_size);
260 ReadParam(section, "render_post_window_size",
261 &cfg.echo_model.render_post_window_size);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200262 }
263
264 Json::Value subsection;
265 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
266 ReadParam(section, "nearend_average_blocks",
267 &cfg.suppressor.nearend_average_blocks);
268
269 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
270 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
271 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
272 ReadParam(subsection, "max_inc_factor",
273 &cfg.suppressor.normal_tuning.max_inc_factor);
274 ReadParam(subsection, "max_dec_factor_lf",
275 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
276 }
277
278 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
279 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
280 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
281 ReadParam(subsection, "max_inc_factor",
282 &cfg.suppressor.nearend_tuning.max_inc_factor);
283 ReadParam(subsection, "max_dec_factor_lf",
284 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
285 }
286
287 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
288 &subsection)) {
289 ReadParam(subsection, "enr_threshold",
290 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200291 ReadParam(subsection, "enr_exit_threshold",
292 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200293 ReadParam(subsection, "snr_threshold",
294 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
295 ReadParam(subsection, "hold_duration",
296 &cfg.suppressor.dominant_nearend_detection.hold_duration);
297 ReadParam(subsection, "trigger_threshold",
298 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200299 ReadParam(
300 subsection, "use_during_initial_phase",
301 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200302 }
303
304 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
305 &subsection)) {
306 ReadParam(subsection, "enr_threshold",
307 &cfg.suppressor.high_bands_suppression.enr_threshold);
308 ReadParam(subsection, "max_gain_during_echo",
309 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
310 }
311
312 ReadParam(section, "floor_first_increase",
313 &cfg.suppressor.floor_first_increase);
314 ReadParam(section, "enforce_transparent",
315 &cfg.suppressor.enforce_transparent);
316 ReadParam(section, "enforce_empty_higher_bands",
317 &cfg.suppressor.enforce_empty_higher_bands);
318 }
Per Åhgren370bae42018-10-25 11:32:39 +0200319}
320
321EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
322 EchoCanceller3Config cfg;
323 bool not_used;
324 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200325 return cfg;
326}
327
328std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
329 rtc::StringBuilder ost;
330 ost << "{";
331 ost << "\"aec3\": {";
Per Åhgrenc1d20922019-04-22 23:36:58 +0200332 ost << "\"buffering\": {";
333 ost << "\"excess_render_detection_interval_blocks\": "
334 << config.buffering.excess_render_detection_interval_blocks << ",";
335 ost << "\"max_allowed_excess_render_blocks\": "
336 << config.buffering.max_allowed_excess_render_blocks;
337 ost << "},";
338
Sam Zackrissona4c85142018-10-10 10:44:43 +0200339 ost << "\"delay\": {";
340 ost << "\"default_delay\": " << config.delay.default_delay << ",";
341 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
342 << ",";
343 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100344 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200345 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100346 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
347 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200348 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;
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200359 ost << "},";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200360
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200361 ost << "\"use_external_delay_estimator\": "
362 << (config.delay.use_external_delay_estimator ? "true" : "false") << ",";
363 ost << "\"downmix_before_delay_estimation\": "
364 << (config.delay.downmix_before_delay_estimation ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200365 ost << "},";
366
367 ost << "\"filter\": {";
368 ost << "\"main\": [";
369 ost << config.filter.main.length_blocks << ",";
370 ost << config.filter.main.leakage_converged << ",";
371 ost << config.filter.main.leakage_diverged << ",";
372 ost << config.filter.main.error_floor << ",";
373 ost << config.filter.main.error_ceil << ",";
374 ost << config.filter.main.noise_gate;
375 ost << "],";
376
377 ost << "\"shadow\": [";
378 ost << config.filter.shadow.length_blocks << ",";
379 ost << config.filter.shadow.rate << ",";
380 ost << config.filter.shadow.noise_gate;
381 ost << "],";
382
383 ost << "\"main_initial\": [";
384 ost << config.filter.main_initial.length_blocks << ",";
385 ost << config.filter.main_initial.leakage_converged << ",";
386 ost << config.filter.main_initial.leakage_diverged << ",";
387 ost << config.filter.main_initial.error_floor << ",";
388 ost << config.filter.main_initial.error_ceil << ",";
389 ost << config.filter.main_initial.noise_gate;
390 ost << "],";
391
392 ost << "\"shadow_initial\": [";
393 ost << config.filter.shadow_initial.length_blocks << ",";
394 ost << config.filter.shadow_initial.rate << ",";
395 ost << config.filter.shadow_initial.noise_gate;
396 ost << "],";
397
398 ost << "\"config_change_duration_blocks\": "
399 << config.filter.config_change_duration_blocks << ",";
400 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
401 << ",";
402 ost << "\"conservative_initial_phase\": "
403 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
404 ost << "\"enable_shadow_filter_output_usage\": "
405 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
406
407 ost << "},";
408
409 ost << "\"erle\": {";
410 ost << "\"min\": " << config.erle.min << ",";
411 ost << "\"max_l\": " << config.erle.max_l << ",";
412 ost << "\"max_h\": " << config.erle.max_h << ",";
413 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100414 << (config.erle.onset_detection ? "true" : "false") << ",";
Per Åhgren8be669f2019-10-11 23:02:26 +0200415 ost << "\"num_sections\": " << config.erle.num_sections << ",";
416 ost << "\"clamp_quality_estimate_to_zero\": "
417 << (config.erle.clamp_quality_estimate_to_zero ? "true" : "false") << ",";
418 ost << "\"clamp_quality_estimate_to_one\": "
419 << (config.erle.clamp_quality_estimate_to_one ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200420 ost << "},";
421
422 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100423 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200424 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200425 ost << "\"echo_can_saturate\": "
426 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
427 ost << "\"bounded_erl\": "
428 << (config.ep_strength.bounded_erl ? "true" : "false");
429
430 ost << "},";
431
Sam Zackrissona4c85142018-10-10 10:44:43 +0200432 ost << "\"echo_audibility\": {";
433 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
434 << ",";
435 ost << "\"normal_render_limit\": "
436 << config.echo_audibility.normal_render_limit << ",";
437 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
438 ost << "\"audibility_threshold_lf\": "
439 << config.echo_audibility.audibility_threshold_lf << ",";
440 ost << "\"audibility_threshold_mf\": "
441 << config.echo_audibility.audibility_threshold_mf << ",";
442 ost << "\"audibility_threshold_hf\": "
443 << config.echo_audibility.audibility_threshold_hf << ",";
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200444 ost << "\"use_stationarity_properties\": "
445 << (config.echo_audibility.use_stationarity_properties ? "true" : "false")
Sam Zackrissona4c85142018-10-10 10:44:43 +0200446 << ",";
447 ost << "\"use_stationarity_properties_at_init\": "
448 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
449 : "false");
450 ost << "},";
451
452 ost << "\"render_levels\": {";
453 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
454 << ",";
455 ost << "\"poor_excitation_render_limit\": "
456 << config.render_levels.poor_excitation_render_limit << ",";
457 ost << "\"poor_excitation_render_limit_ds8\": "
458 << config.render_levels.poor_excitation_render_limit_ds8;
459 ost << "},";
460
461 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200462 ost << "\"has_clock_drift\": "
463 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
464 << ",";
465 ost << "\"linear_and_stable_echo_path\": "
466 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
467 : "false");
468
469 ost << "},";
470
471 ost << "\"echo_model\": {";
472 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
473 ost << "\"min_noise_floor_power\": "
474 << config.echo_model.min_noise_floor_power << ",";
475 ost << "\"stationary_gate_slope\": "
476 << config.echo_model.stationary_gate_slope << ",";
477 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
478 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
479 ost << "\"render_pre_window_size\": "
480 << config.echo_model.render_pre_window_size << ",";
481 ost << "\"render_post_window_size\": "
Gustaf Ullbergec51ce02019-04-04 13:38:52 +0200482 << config.echo_model.render_post_window_size;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200483 ost << "},";
484
485 ost << "\"suppressor\": {";
486 ost << "\"nearend_average_blocks\": "
487 << config.suppressor.nearend_average_blocks << ",";
488 ost << "\"normal_tuning\": {";
489 ost << "\"mask_lf\": [";
490 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
491 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
492 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
493 ost << "],";
494 ost << "\"mask_hf\": [";
495 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
496 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
497 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
498 ost << "],";
499 ost << "\"max_inc_factor\": "
500 << config.suppressor.normal_tuning.max_inc_factor << ",";
501 ost << "\"max_dec_factor_lf\": "
502 << config.suppressor.normal_tuning.max_dec_factor_lf;
503 ost << "},";
504 ost << "\"nearend_tuning\": {";
505 ost << "\"mask_lf\": [";
506 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
507 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
508 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
509 ost << "],";
510 ost << "\"mask_hf\": [";
511 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
512 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
513 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
514 ost << "],";
515 ost << "\"max_inc_factor\": "
516 << config.suppressor.nearend_tuning.max_inc_factor << ",";
517 ost << "\"max_dec_factor_lf\": "
518 << config.suppressor.nearend_tuning.max_dec_factor_lf;
519 ost << "},";
520 ost << "\"dominant_nearend_detection\": {";
521 ost << "\"enr_threshold\": "
522 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200523 ost << "\"enr_exit_threshold\": "
524 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200525 ost << "\"snr_threshold\": "
526 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
527 ost << "\"hold_duration\": "
528 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
529 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200530 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
531 ost << "\"use_during_initial_phase\": "
532 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200533 ost << "},";
534 ost << "\"high_bands_suppression\": {";
535 ost << "\"enr_threshold\": "
536 << config.suppressor.high_bands_suppression.enr_threshold << ",";
537 ost << "\"max_gain_during_echo\": "
538 << config.suppressor.high_bands_suppression.max_gain_during_echo;
539 ost << "},";
540 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
541 << ",";
542 ost << "\"enforce_transparent\": "
543 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
544 ost << "\"enforce_empty_higher_bands\": "
545 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
546 ost << "}";
547 ost << "}";
548 ost << "}";
549
550 return ost.Release();
551}
552} // namespace webrtc