blob: cbf893b9fca79df2fdf6fc8699ec2e267d3716fa [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);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200174 }
175
176 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
177 ReadParam(section, "main", &cfg.filter.main);
178 ReadParam(section, "shadow", &cfg.filter.shadow);
179 ReadParam(section, "main_initial", &cfg.filter.main_initial);
180 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
181 ReadParam(section, "config_change_duration_blocks",
182 &cfg.filter.config_change_duration_blocks);
183 ReadParam(section, "initial_state_seconds",
184 &cfg.filter.initial_state_seconds);
185 ReadParam(section, "conservative_initial_phase",
186 &cfg.filter.conservative_initial_phase);
187 ReadParam(section, "enable_shadow_filter_output_usage",
188 &cfg.filter.enable_shadow_filter_output_usage);
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200189 ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200190 }
191
192 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
193 ReadParam(section, "min", &cfg.erle.min);
194 ReadParam(section, "max_l", &cfg.erle.max_l);
195 ReadParam(section, "max_h", &cfg.erle.max_h);
196 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100197 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200198 }
199
200 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100201 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200202 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200203 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
204 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
205 }
206
Sam Zackrissona4c85142018-10-10 10:44:43 +0200207 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
208 ReadParam(section, "low_render_limit",
209 &cfg.echo_audibility.low_render_limit);
210 ReadParam(section, "normal_render_limit",
211 &cfg.echo_audibility.normal_render_limit);
212
213 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
214 ReadParam(section, "audibility_threshold_lf",
215 &cfg.echo_audibility.audibility_threshold_lf);
216 ReadParam(section, "audibility_threshold_mf",
217 &cfg.echo_audibility.audibility_threshold_mf);
218 ReadParam(section, "audibility_threshold_hf",
219 &cfg.echo_audibility.audibility_threshold_hf);
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200220 ReadParam(section, "use_stationarity_properties",
221 &cfg.echo_audibility.use_stationarity_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200222 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200223 &cfg.echo_audibility.use_stationarity_properties_at_init);
224 }
225
Per Åhgren01cf44d2018-10-20 00:17:13 +0200226 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
227 ReadParam(section, "active_render_limit",
228 &cfg.render_levels.active_render_limit);
229 ReadParam(section, "poor_excitation_render_limit",
230 &cfg.render_levels.poor_excitation_render_limit);
231 ReadParam(section, "poor_excitation_render_limit_ds8",
232 &cfg.render_levels.poor_excitation_render_limit_ds8);
233 }
234
Sam Zackrissona4c85142018-10-10 10:44:43 +0200235 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
236 &section)) {
Sam Zackrissona4c85142018-10-10 10:44:43 +0200237 ReadParam(section, "has_clock_drift",
238 &cfg.echo_removal_control.has_clock_drift);
239 ReadParam(section, "linear_and_stable_echo_path",
240 &cfg.echo_removal_control.linear_and_stable_echo_path);
241 }
242
243 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
244 Json::Value subsection;
245 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
246 ReadParam(section, "min_noise_floor_power",
247 &cfg.echo_model.min_noise_floor_power);
248 ReadParam(section, "stationary_gate_slope",
249 &cfg.echo_model.stationary_gate_slope);
250 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
251 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
252 ReadParam(section, "render_pre_window_size",
253 &cfg.echo_model.render_pre_window_size);
254 ReadParam(section, "render_post_window_size",
255 &cfg.echo_model.render_post_window_size);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200256 }
257
258 Json::Value subsection;
259 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
260 ReadParam(section, "nearend_average_blocks",
261 &cfg.suppressor.nearend_average_blocks);
262
263 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
264 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
265 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
266 ReadParam(subsection, "max_inc_factor",
267 &cfg.suppressor.normal_tuning.max_inc_factor);
268 ReadParam(subsection, "max_dec_factor_lf",
269 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
270 }
271
272 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
273 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
274 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
275 ReadParam(subsection, "max_inc_factor",
276 &cfg.suppressor.nearend_tuning.max_inc_factor);
277 ReadParam(subsection, "max_dec_factor_lf",
278 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
279 }
280
281 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
282 &subsection)) {
283 ReadParam(subsection, "enr_threshold",
284 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200285 ReadParam(subsection, "enr_exit_threshold",
286 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200287 ReadParam(subsection, "snr_threshold",
288 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
289 ReadParam(subsection, "hold_duration",
290 &cfg.suppressor.dominant_nearend_detection.hold_duration);
291 ReadParam(subsection, "trigger_threshold",
292 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200293 ReadParam(
294 subsection, "use_during_initial_phase",
295 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200296 }
297
298 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
299 &subsection)) {
300 ReadParam(subsection, "enr_threshold",
301 &cfg.suppressor.high_bands_suppression.enr_threshold);
302 ReadParam(subsection, "max_gain_during_echo",
303 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
304 }
305
306 ReadParam(section, "floor_first_increase",
307 &cfg.suppressor.floor_first_increase);
308 ReadParam(section, "enforce_transparent",
309 &cfg.suppressor.enforce_transparent);
310 ReadParam(section, "enforce_empty_higher_bands",
311 &cfg.suppressor.enforce_empty_higher_bands);
312 }
Per Åhgren370bae42018-10-25 11:32:39 +0200313}
314
315EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
316 EchoCanceller3Config cfg;
317 bool not_used;
318 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200319 return cfg;
320}
321
322std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
323 rtc::StringBuilder ost;
324 ost << "{";
325 ost << "\"aec3\": {";
Per Åhgrenc1d20922019-04-22 23:36:58 +0200326 ost << "\"buffering\": {";
327 ost << "\"excess_render_detection_interval_blocks\": "
328 << config.buffering.excess_render_detection_interval_blocks << ",";
329 ost << "\"max_allowed_excess_render_blocks\": "
330 << config.buffering.max_allowed_excess_render_blocks;
331 ost << "},";
332
Sam Zackrissona4c85142018-10-10 10:44:43 +0200333 ost << "\"delay\": {";
334 ost << "\"default_delay\": " << config.delay.default_delay << ",";
335 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
336 << ",";
337 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100338 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200339 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100340 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
341 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200342 ost << "\"fixed_capture_delay_samples\": "
343 << config.delay.fixed_capture_delay_samples << ",";
344 ost << "\"delay_estimate_smoothing\": "
345 << config.delay.delay_estimate_smoothing << ",";
346 ost << "\"delay_candidate_detection_threshold\": "
347 << config.delay.delay_candidate_detection_threshold << ",";
348
349 ost << "\"delay_selection_thresholds\": {";
350 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
351 << ",";
352 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
353 ost << "}";
354
355 ost << "},";
356
357 ost << "\"filter\": {";
358 ost << "\"main\": [";
359 ost << config.filter.main.length_blocks << ",";
360 ost << config.filter.main.leakage_converged << ",";
361 ost << config.filter.main.leakage_diverged << ",";
362 ost << config.filter.main.error_floor << ",";
363 ost << config.filter.main.error_ceil << ",";
364 ost << config.filter.main.noise_gate;
365 ost << "],";
366
367 ost << "\"shadow\": [";
368 ost << config.filter.shadow.length_blocks << ",";
369 ost << config.filter.shadow.rate << ",";
370 ost << config.filter.shadow.noise_gate;
371 ost << "],";
372
373 ost << "\"main_initial\": [";
374 ost << config.filter.main_initial.length_blocks << ",";
375 ost << config.filter.main_initial.leakage_converged << ",";
376 ost << config.filter.main_initial.leakage_diverged << ",";
377 ost << config.filter.main_initial.error_floor << ",";
378 ost << config.filter.main_initial.error_ceil << ",";
379 ost << config.filter.main_initial.noise_gate;
380 ost << "],";
381
382 ost << "\"shadow_initial\": [";
383 ost << config.filter.shadow_initial.length_blocks << ",";
384 ost << config.filter.shadow_initial.rate << ",";
385 ost << config.filter.shadow_initial.noise_gate;
386 ost << "],";
387
388 ost << "\"config_change_duration_blocks\": "
389 << config.filter.config_change_duration_blocks << ",";
390 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
391 << ",";
392 ost << "\"conservative_initial_phase\": "
393 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
394 ost << "\"enable_shadow_filter_output_usage\": "
395 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
396
397 ost << "},";
398
399 ost << "\"erle\": {";
400 ost << "\"min\": " << config.erle.min << ",";
401 ost << "\"max_l\": " << config.erle.max_l << ",";
402 ost << "\"max_h\": " << config.erle.max_h << ",";
403 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100404 << (config.erle.onset_detection ? "true" : "false") << ",";
405 ost << "\"num_sections\": " << config.erle.num_sections;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200406 ost << "},";
407
408 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100409 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200410 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200411 ost << "\"echo_can_saturate\": "
412 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
413 ost << "\"bounded_erl\": "
414 << (config.ep_strength.bounded_erl ? "true" : "false");
415
416 ost << "},";
417
Sam Zackrissona4c85142018-10-10 10:44:43 +0200418 ost << "\"echo_audibility\": {";
419 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
420 << ",";
421 ost << "\"normal_render_limit\": "
422 << config.echo_audibility.normal_render_limit << ",";
423 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
424 ost << "\"audibility_threshold_lf\": "
425 << config.echo_audibility.audibility_threshold_lf << ",";
426 ost << "\"audibility_threshold_mf\": "
427 << config.echo_audibility.audibility_threshold_mf << ",";
428 ost << "\"audibility_threshold_hf\": "
429 << config.echo_audibility.audibility_threshold_hf << ",";
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200430 ost << "\"use_stationarity_properties\": "
431 << (config.echo_audibility.use_stationarity_properties ? "true" : "false")
Sam Zackrissona4c85142018-10-10 10:44:43 +0200432 << ",";
433 ost << "\"use_stationarity_properties_at_init\": "
434 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
435 : "false");
436 ost << "},";
437
438 ost << "\"render_levels\": {";
439 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
440 << ",";
441 ost << "\"poor_excitation_render_limit\": "
442 << config.render_levels.poor_excitation_render_limit << ",";
443 ost << "\"poor_excitation_render_limit_ds8\": "
444 << config.render_levels.poor_excitation_render_limit_ds8;
445 ost << "},";
446
447 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200448 ost << "\"has_clock_drift\": "
449 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
450 << ",";
451 ost << "\"linear_and_stable_echo_path\": "
452 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
453 : "false");
454
455 ost << "},";
456
457 ost << "\"echo_model\": {";
458 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
459 ost << "\"min_noise_floor_power\": "
460 << config.echo_model.min_noise_floor_power << ",";
461 ost << "\"stationary_gate_slope\": "
462 << config.echo_model.stationary_gate_slope << ",";
463 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
464 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
465 ost << "\"render_pre_window_size\": "
466 << config.echo_model.render_pre_window_size << ",";
467 ost << "\"render_post_window_size\": "
Gustaf Ullbergec51ce02019-04-04 13:38:52 +0200468 << config.echo_model.render_post_window_size;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200469 ost << "},";
470
471 ost << "\"suppressor\": {";
472 ost << "\"nearend_average_blocks\": "
473 << config.suppressor.nearend_average_blocks << ",";
474 ost << "\"normal_tuning\": {";
475 ost << "\"mask_lf\": [";
476 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
477 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
478 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
479 ost << "],";
480 ost << "\"mask_hf\": [";
481 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
482 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
483 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
484 ost << "],";
485 ost << "\"max_inc_factor\": "
486 << config.suppressor.normal_tuning.max_inc_factor << ",";
487 ost << "\"max_dec_factor_lf\": "
488 << config.suppressor.normal_tuning.max_dec_factor_lf;
489 ost << "},";
490 ost << "\"nearend_tuning\": {";
491 ost << "\"mask_lf\": [";
492 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
493 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
494 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
495 ost << "],";
496 ost << "\"mask_hf\": [";
497 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
498 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
499 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
500 ost << "],";
501 ost << "\"max_inc_factor\": "
502 << config.suppressor.nearend_tuning.max_inc_factor << ",";
503 ost << "\"max_dec_factor_lf\": "
504 << config.suppressor.nearend_tuning.max_dec_factor_lf;
505 ost << "},";
506 ost << "\"dominant_nearend_detection\": {";
507 ost << "\"enr_threshold\": "
508 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200509 ost << "\"enr_exit_threshold\": "
510 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200511 ost << "\"snr_threshold\": "
512 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
513 ost << "\"hold_duration\": "
514 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
515 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200516 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
517 ost << "\"use_during_initial_phase\": "
518 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200519 ost << "},";
520 ost << "\"high_bands_suppression\": {";
521 ost << "\"enr_threshold\": "
522 << config.suppressor.high_bands_suppression.enr_threshold << ",";
523 ost << "\"max_gain_during_echo\": "
524 << config.suppressor.high_bands_suppression.max_gain_during_echo;
525 ost << "},";
526 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
527 << ",";
528 ost << "\"enforce_transparent\": "
529 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
530 ost << "\"enforce_empty_higher_bands\": "
531 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
532 ost << "}";
533 ost << "}";
534 ost << "}";
535
536 return ost.Release();
537}
538} // namespace webrtc