blob: da535c14e363f9c29140a8a0a308f73d288080b9 [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>
Sam Zackrissona4c85142018-10-10 10:44:43 +020013#include <string>
14#include <vector>
15
Yves Gerey3e707812018-11-28 16:47:49 +010016#include "rtc_base/checks.h"
Sam Zackrissona4c85142018-10-10 10:44:43 +020017#include "rtc_base/logging.h"
18#include "rtc_base/strings/json.h"
19#include "rtc_base/strings/string_builder.h"
20
21namespace webrtc {
22namespace {
23void ReadParam(const Json::Value& root, std::string param_name, bool* param) {
24 RTC_DCHECK(param);
25 bool v;
26 if (rtc::GetBoolFromJsonObject(root, param_name, &v)) {
27 *param = v;
28 }
29}
30
31void ReadParam(const Json::Value& root, std::string param_name, size_t* param) {
32 RTC_DCHECK(param);
33 int v;
34 if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
Sam Zackrisson877dc892018-10-23 14:17:38 +020035 RTC_DCHECK_GE(v, 0);
Sam Zackrissona4c85142018-10-10 10:44:43 +020036 *param = v;
37 }
38}
39
40void ReadParam(const Json::Value& root, std::string param_name, int* param) {
41 RTC_DCHECK(param);
42 int v;
43 if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
44 *param = v;
45 }
46}
47
48void ReadParam(const Json::Value& root, std::string param_name, float* param) {
49 RTC_DCHECK(param);
50 double v;
51 if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) {
52 *param = static_cast<float>(v);
53 }
54}
55
56void ReadParam(const Json::Value& root,
57 std::string param_name,
58 EchoCanceller3Config::Filter::MainConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020059 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020060 Json::Value json_array;
61 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
62 std::vector<double> v;
63 rtc::JsonArrayToDoubleVector(json_array, &v);
64 if (v.size() != 6) {
65 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +020066 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020067 }
68 param->length_blocks = static_cast<size_t>(v[0]);
69 param->leakage_converged = static_cast<float>(v[1]);
70 param->leakage_diverged = static_cast<float>(v[2]);
71 param->error_floor = static_cast<float>(v[3]);
72 param->error_ceil = static_cast<float>(v[4]);
73 param->noise_gate = static_cast<float>(v[5]);
74 }
75}
76
77void ReadParam(const Json::Value& root,
78 std::string param_name,
79 EchoCanceller3Config::Filter::ShadowConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020080 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020081 Json::Value json_array;
82 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
83 std::vector<double> v;
84 rtc::JsonArrayToDoubleVector(json_array, &v);
85 if (v.size() != 3) {
86 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +020087 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020088 }
89 param->length_blocks = static_cast<size_t>(v[0]);
90 param->rate = static_cast<float>(v[1]);
91 param->noise_gate = static_cast<float>(v[2]);
92 }
93}
94
95void ReadParam(const Json::Value& root,
96 std::string param_name,
97 EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020098 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020099 Json::Value json_array;
100 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
101 std::vector<double> v;
102 rtc::JsonArrayToDoubleVector(json_array, &v);
103 if (v.size() != 3) {
104 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +0200105 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200106 }
107 param->enr_transparent = static_cast<float>(v[0]);
108 param->enr_suppress = static_cast<float>(v[1]);
109 param->emr_transparent = static_cast<float>(v[2]);
110 }
111}
112} // namespace
113
Per Åhgren370bae42018-10-25 11:32:39 +0200114void Aec3ConfigFromJsonString(absl::string_view json_string,
115 EchoCanceller3Config* config,
116 bool* parsing_successful) {
117 RTC_DCHECK(config);
118 RTC_DCHECK(parsing_successful);
119 EchoCanceller3Config& cfg = *config;
120 cfg = EchoCanceller3Config();
121 *parsing_successful = true;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200122
123 Json::Value root;
124 bool success = Json::Reader().parse(std::string(json_string), root);
125 if (!success) {
126 RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200127 *parsing_successful = false;
128 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200129 }
130
131 Json::Value aec3_root;
132 success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
133 if (!success) {
134 RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200135 *parsing_successful = false;
136 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200137 }
138
139 Json::Value section;
Gustaf Ullberg11539f02018-10-15 13:40:29 +0200140 if (rtc::GetValueFromJsonObject(root, "buffering", &section)) {
Gustaf Ullberg11539f02018-10-15 13:40:29 +0200141 ReadParam(section, "excess_render_detection_interval_blocks",
142 &cfg.buffering.excess_render_detection_interval_blocks);
143 ReadParam(section, "max_allowed_excess_render_blocks",
144 &cfg.buffering.max_allowed_excess_render_blocks);
145 }
146
Sam Zackrissona4c85142018-10-10 10:44:43 +0200147 if (rtc::GetValueFromJsonObject(aec3_root, "delay", &section)) {
148 ReadParam(section, "default_delay", &cfg.delay.default_delay);
149 ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
150 ReadParam(section, "num_filters", &cfg.delay.num_filters);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200151 ReadParam(section, "delay_headroom_blocks",
152 &cfg.delay.delay_headroom_blocks);
153 ReadParam(section, "hysteresis_limit_1_blocks",
154 &cfg.delay.hysteresis_limit_1_blocks);
155 ReadParam(section, "hysteresis_limit_2_blocks",
156 &cfg.delay.hysteresis_limit_2_blocks);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200157 ReadParam(section, "fixed_capture_delay_samples",
158 &cfg.delay.fixed_capture_delay_samples);
159 ReadParam(section, "delay_estimate_smoothing",
160 &cfg.delay.delay_estimate_smoothing);
161 ReadParam(section, "delay_candidate_detection_threshold",
162 &cfg.delay.delay_candidate_detection_threshold);
163
164 Json::Value subsection;
165 if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
166 &subsection)) {
167 ReadParam(subsection, "initial",
168 &cfg.delay.delay_selection_thresholds.initial);
169 ReadParam(subsection, "converged",
170 &cfg.delay.delay_selection_thresholds.converged);
171 }
172 }
173
174 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
175 ReadParam(section, "main", &cfg.filter.main);
176 ReadParam(section, "shadow", &cfg.filter.shadow);
177 ReadParam(section, "main_initial", &cfg.filter.main_initial);
178 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
179 ReadParam(section, "config_change_duration_blocks",
180 &cfg.filter.config_change_duration_blocks);
181 ReadParam(section, "initial_state_seconds",
182 &cfg.filter.initial_state_seconds);
183 ReadParam(section, "conservative_initial_phase",
184 &cfg.filter.conservative_initial_phase);
185 ReadParam(section, "enable_shadow_filter_output_usage",
186 &cfg.filter.enable_shadow_filter_output_usage);
187 }
188
189 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
190 ReadParam(section, "min", &cfg.erle.min);
191 ReadParam(section, "max_l", &cfg.erle.max_l);
192 ReadParam(section, "max_h", &cfg.erle.max_h);
193 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100194 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200195 }
196
197 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
198 ReadParam(section, "lf", &cfg.ep_strength.lf);
199 ReadParam(section, "mf", &cfg.ep_strength.mf);
200 ReadParam(section, "hf", &cfg.ep_strength.hf);
201 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
202 ReadParam(section, "reverb_based_on_render",
203 &cfg.ep_strength.reverb_based_on_render);
204 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
205 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
206 }
207
Sam Zackrissona4c85142018-10-10 10:44:43 +0200208 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
209 ReadParam(section, "low_render_limit",
210 &cfg.echo_audibility.low_render_limit);
211 ReadParam(section, "normal_render_limit",
212 &cfg.echo_audibility.normal_render_limit);
213
214 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
215 ReadParam(section, "audibility_threshold_lf",
216 &cfg.echo_audibility.audibility_threshold_lf);
217 ReadParam(section, "audibility_threshold_mf",
218 &cfg.echo_audibility.audibility_threshold_mf);
219 ReadParam(section, "audibility_threshold_hf",
220 &cfg.echo_audibility.audibility_threshold_hf);
221 ReadParam(section, "use_stationary_properties",
222 &cfg.echo_audibility.use_stationary_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200223 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200224 &cfg.echo_audibility.use_stationarity_properties_at_init);
225 }
226
Per Åhgren01cf44d2018-10-20 00:17:13 +0200227 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
228 ReadParam(section, "active_render_limit",
229 &cfg.render_levels.active_render_limit);
230 ReadParam(section, "poor_excitation_render_limit",
231 &cfg.render_levels.poor_excitation_render_limit);
232 ReadParam(section, "poor_excitation_render_limit_ds8",
233 &cfg.render_levels.poor_excitation_render_limit_ds8);
234 }
235
Sam Zackrissona4c85142018-10-10 10:44:43 +0200236 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
237 &section)) {
238 Json::Value subsection;
239 if (rtc::GetValueFromJsonObject(section, "gain_rampup", &subsection)) {
240 ReadParam(subsection, "initial_gain",
241 &cfg.echo_removal_control.gain_rampup.initial_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200242 ReadParam(subsection, "non_zero_gain_blocks",
243 &cfg.echo_removal_control.gain_rampup.non_zero_gain_blocks);
244 ReadParam(subsection, "full_gain_blocks",
245 &cfg.echo_removal_control.gain_rampup.full_gain_blocks);
246 }
247 ReadParam(section, "has_clock_drift",
248 &cfg.echo_removal_control.has_clock_drift);
249 ReadParam(section, "linear_and_stable_echo_path",
250 &cfg.echo_removal_control.linear_and_stable_echo_path);
251 }
252
253 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
254 Json::Value subsection;
255 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
256 ReadParam(section, "min_noise_floor_power",
257 &cfg.echo_model.min_noise_floor_power);
258 ReadParam(section, "stationary_gate_slope",
259 &cfg.echo_model.stationary_gate_slope);
260 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
261 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
262 ReadParam(section, "render_pre_window_size",
263 &cfg.echo_model.render_pre_window_size);
264 ReadParam(section, "render_post_window_size",
265 &cfg.echo_model.render_post_window_size);
266 ReadParam(section, "render_pre_window_size_init",
267 &cfg.echo_model.render_pre_window_size_init);
268 ReadParam(section, "render_post_window_size_init",
269 &cfg.echo_model.render_post_window_size_init);
270 ReadParam(section, "nonlinear_hold", &cfg.echo_model.nonlinear_hold);
271 ReadParam(section, "nonlinear_release", &cfg.echo_model.nonlinear_release);
272 }
273
274 Json::Value subsection;
275 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
276 ReadParam(section, "nearend_average_blocks",
277 &cfg.suppressor.nearend_average_blocks);
278
279 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
280 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
281 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
282 ReadParam(subsection, "max_inc_factor",
283 &cfg.suppressor.normal_tuning.max_inc_factor);
284 ReadParam(subsection, "max_dec_factor_lf",
285 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
286 }
287
288 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
289 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
290 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
291 ReadParam(subsection, "max_inc_factor",
292 &cfg.suppressor.nearend_tuning.max_inc_factor);
293 ReadParam(subsection, "max_dec_factor_lf",
294 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
295 }
296
297 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
298 &subsection)) {
299 ReadParam(subsection, "enr_threshold",
300 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200301 ReadParam(subsection, "enr_exit_threshold",
302 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200303 ReadParam(subsection, "snr_threshold",
304 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
305 ReadParam(subsection, "hold_duration",
306 &cfg.suppressor.dominant_nearend_detection.hold_duration);
307 ReadParam(subsection, "trigger_threshold",
308 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200309 ReadParam(
310 subsection, "use_during_initial_phase",
311 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200312 }
313
314 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
315 &subsection)) {
316 ReadParam(subsection, "enr_threshold",
317 &cfg.suppressor.high_bands_suppression.enr_threshold);
318 ReadParam(subsection, "max_gain_during_echo",
319 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
320 }
321
322 ReadParam(section, "floor_first_increase",
323 &cfg.suppressor.floor_first_increase);
324 ReadParam(section, "enforce_transparent",
325 &cfg.suppressor.enforce_transparent);
326 ReadParam(section, "enforce_empty_higher_bands",
327 &cfg.suppressor.enforce_empty_higher_bands);
328 }
Per Åhgren370bae42018-10-25 11:32:39 +0200329}
330
331EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
332 EchoCanceller3Config cfg;
333 bool not_used;
334 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200335 return cfg;
336}
337
338std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
339 rtc::StringBuilder ost;
340 ost << "{";
341 ost << "\"aec3\": {";
342 ost << "\"delay\": {";
343 ost << "\"default_delay\": " << config.delay.default_delay << ",";
344 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
345 << ",";
346 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200347 ost << "\"delay_headroom_blocks\": " << config.delay.delay_headroom_blocks
348 << ",";
349 ost << "\"hysteresis_limit_1_blocks\": "
350 << config.delay.hysteresis_limit_1_blocks << ",";
351 ost << "\"hysteresis_limit_2_blocks\": "
352 << config.delay.hysteresis_limit_2_blocks << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200353 ost << "\"fixed_capture_delay_samples\": "
354 << config.delay.fixed_capture_delay_samples << ",";
355 ost << "\"delay_estimate_smoothing\": "
356 << config.delay.delay_estimate_smoothing << ",";
357 ost << "\"delay_candidate_detection_threshold\": "
358 << config.delay.delay_candidate_detection_threshold << ",";
359
360 ost << "\"delay_selection_thresholds\": {";
361 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
362 << ",";
363 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
364 ost << "}";
365
366 ost << "},";
367
368 ost << "\"filter\": {";
369 ost << "\"main\": [";
370 ost << config.filter.main.length_blocks << ",";
371 ost << config.filter.main.leakage_converged << ",";
372 ost << config.filter.main.leakage_diverged << ",";
373 ost << config.filter.main.error_floor << ",";
374 ost << config.filter.main.error_ceil << ",";
375 ost << config.filter.main.noise_gate;
376 ost << "],";
377
378 ost << "\"shadow\": [";
379 ost << config.filter.shadow.length_blocks << ",";
380 ost << config.filter.shadow.rate << ",";
381 ost << config.filter.shadow.noise_gate;
382 ost << "],";
383
384 ost << "\"main_initial\": [";
385 ost << config.filter.main_initial.length_blocks << ",";
386 ost << config.filter.main_initial.leakage_converged << ",";
387 ost << config.filter.main_initial.leakage_diverged << ",";
388 ost << config.filter.main_initial.error_floor << ",";
389 ost << config.filter.main_initial.error_ceil << ",";
390 ost << config.filter.main_initial.noise_gate;
391 ost << "],";
392
393 ost << "\"shadow_initial\": [";
394 ost << config.filter.shadow_initial.length_blocks << ",";
395 ost << config.filter.shadow_initial.rate << ",";
396 ost << config.filter.shadow_initial.noise_gate;
397 ost << "],";
398
399 ost << "\"config_change_duration_blocks\": "
400 << config.filter.config_change_duration_blocks << ",";
401 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
402 << ",";
403 ost << "\"conservative_initial_phase\": "
404 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
405 ost << "\"enable_shadow_filter_output_usage\": "
406 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
407
408 ost << "},";
409
410 ost << "\"erle\": {";
411 ost << "\"min\": " << config.erle.min << ",";
412 ost << "\"max_l\": " << config.erle.max_l << ",";
413 ost << "\"max_h\": " << config.erle.max_h << ",";
414 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100415 << (config.erle.onset_detection ? "true" : "false") << ",";
416 ost << "\"num_sections\": " << config.erle.num_sections;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200417 ost << "},";
418
419 ost << "\"ep_strength\": {";
420 ost << "\"lf\": " << config.ep_strength.lf << ",";
421 ost << "\"mf\": " << config.ep_strength.mf << ",";
422 ost << "\"hf\": " << config.ep_strength.hf << ",";
423 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
424 ost << "\"reverb_based_on_render\": "
425 << (config.ep_strength.reverb_based_on_render ? "true" : "false") << ",";
426 ost << "\"echo_can_saturate\": "
427 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
428 ost << "\"bounded_erl\": "
429 << (config.ep_strength.bounded_erl ? "true" : "false");
430
431 ost << "},";
432
Sam Zackrissona4c85142018-10-10 10:44:43 +0200433 ost << "\"echo_audibility\": {";
434 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
435 << ",";
436 ost << "\"normal_render_limit\": "
437 << config.echo_audibility.normal_render_limit << ",";
438 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
439 ost << "\"audibility_threshold_lf\": "
440 << config.echo_audibility.audibility_threshold_lf << ",";
441 ost << "\"audibility_threshold_mf\": "
442 << config.echo_audibility.audibility_threshold_mf << ",";
443 ost << "\"audibility_threshold_hf\": "
444 << config.echo_audibility.audibility_threshold_hf << ",";
445 ost << "\"use_stationary_properties\": "
446 << (config.echo_audibility.use_stationary_properties ? "true" : "false")
447 << ",";
448 ost << "\"use_stationarity_properties_at_init\": "
449 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
450 : "false");
451 ost << "},";
452
453 ost << "\"render_levels\": {";
454 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
455 << ",";
456 ost << "\"poor_excitation_render_limit\": "
457 << config.render_levels.poor_excitation_render_limit << ",";
458 ost << "\"poor_excitation_render_limit_ds8\": "
459 << config.render_levels.poor_excitation_render_limit_ds8;
460 ost << "},";
461
462 ost << "\"echo_removal_control\": {";
463 ost << "\"gain_rampup\": {";
464 ost << "\"initial_gain\": "
465 << config.echo_removal_control.gain_rampup.initial_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200466 ost << "\"non_zero_gain_blocks\": "
467 << config.echo_removal_control.gain_rampup.non_zero_gain_blocks << ",";
468 ost << "\"full_gain_blocks\": "
469 << config.echo_removal_control.gain_rampup.full_gain_blocks;
470 ost << "},";
471 ost << "\"has_clock_drift\": "
472 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
473 << ",";
474 ost << "\"linear_and_stable_echo_path\": "
475 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
476 : "false");
477
478 ost << "},";
479
480 ost << "\"echo_model\": {";
481 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
482 ost << "\"min_noise_floor_power\": "
483 << config.echo_model.min_noise_floor_power << ",";
484 ost << "\"stationary_gate_slope\": "
485 << config.echo_model.stationary_gate_slope << ",";
486 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
487 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
488 ost << "\"render_pre_window_size\": "
489 << config.echo_model.render_pre_window_size << ",";
490 ost << "\"render_post_window_size\": "
491 << config.echo_model.render_post_window_size << ",";
492 ost << "\"render_pre_window_size_init\": "
493 << config.echo_model.render_pre_window_size_init << ",";
494 ost << "\"render_post_window_size_init\": "
495 << config.echo_model.render_post_window_size_init << ",";
496 ost << "\"nonlinear_hold\": " << config.echo_model.nonlinear_hold << ",";
497 ost << "\"nonlinear_release\": " << config.echo_model.nonlinear_release;
498 ost << "},";
499
500 ost << "\"suppressor\": {";
501 ost << "\"nearend_average_blocks\": "
502 << config.suppressor.nearend_average_blocks << ",";
503 ost << "\"normal_tuning\": {";
504 ost << "\"mask_lf\": [";
505 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
506 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
507 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
508 ost << "],";
509 ost << "\"mask_hf\": [";
510 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
511 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
512 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
513 ost << "],";
514 ost << "\"max_inc_factor\": "
515 << config.suppressor.normal_tuning.max_inc_factor << ",";
516 ost << "\"max_dec_factor_lf\": "
517 << config.suppressor.normal_tuning.max_dec_factor_lf;
518 ost << "},";
519 ost << "\"nearend_tuning\": {";
520 ost << "\"mask_lf\": [";
521 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
522 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
523 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
524 ost << "],";
525 ost << "\"mask_hf\": [";
526 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
527 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
528 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
529 ost << "],";
530 ost << "\"max_inc_factor\": "
531 << config.suppressor.nearend_tuning.max_inc_factor << ",";
532 ost << "\"max_dec_factor_lf\": "
533 << config.suppressor.nearend_tuning.max_dec_factor_lf;
534 ost << "},";
535 ost << "\"dominant_nearend_detection\": {";
536 ost << "\"enr_threshold\": "
537 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200538 ost << "\"enr_exit_threshold\": "
539 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200540 ost << "\"snr_threshold\": "
541 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
542 ost << "\"hold_duration\": "
543 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
544 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200545 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
546 ost << "\"use_during_initial_phase\": "
547 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200548 ost << "},";
549 ost << "\"high_bands_suppression\": {";
550 ost << "\"enr_threshold\": "
551 << config.suppressor.high_bands_suppression.enr_threshold << ",";
552 ost << "\"max_gain_during_echo\": "
553 << config.suppressor.high_bands_suppression.max_gain_during_echo;
554 ost << "},";
555 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
556 << ",";
557 ost << "\"enforce_transparent\": "
558 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
559 ost << "\"enforce_empty_higher_bands\": "
560 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
561 ost << "}";
562 ost << "}";
563 ost << "}";
564
565 return ost.Release();
566}
567} // namespace webrtc