1 /*
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 <stddef.h>
13
14 #include <memory>
15 #include <string>
16 #include <vector>
17
18 #include "rtc_base/checks.h"
19 #include "rtc_base/logging.h"
20 #include "rtc_base/strings/json.h"
21 #include "rtc_base/strings/string_builder.h"
22
23 namespace webrtc {
24 namespace {
ReadParam(const Json::Value & root,std::string param_name,bool * param)25 void ReadParam(const Json::Value& root, std::string param_name, bool* param) {
26 RTC_DCHECK(param);
27 bool v;
28 if (rtc::GetBoolFromJsonObject(root, param_name, &v)) {
29 *param = v;
30 }
31 }
32
ReadParam(const Json::Value & root,std::string param_name,size_t * param)33 void ReadParam(const Json::Value& root, std::string param_name, size_t* param) {
34 RTC_DCHECK(param);
35 int v;
36 if (rtc::GetIntFromJsonObject(root, param_name, &v) && v >= 0) {
37 *param = v;
38 }
39 }
40
ReadParam(const Json::Value & root,std::string param_name,int * param)41 void 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
ReadParam(const Json::Value & root,std::string param_name,float * param)49 void 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
ReadParam(const Json::Value & root,std::string param_name,EchoCanceller3Config::Filter::RefinedConfiguration * param)57 void ReadParam(const Json::Value& root,
58 std::string param_name,
59 EchoCanceller3Config::Filter::RefinedConfiguration* param) {
60 RTC_DCHECK(param);
61 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;
67 return;
68 }
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
ReadParam(const Json::Value & root,std::string param_name,EchoCanceller3Config::Filter::CoarseConfiguration * param)78 void ReadParam(const Json::Value& root,
79 std::string param_name,
80 EchoCanceller3Config::Filter::CoarseConfiguration* param) {
81 RTC_DCHECK(param);
82 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;
88 return;
89 }
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
ReadParam(const Json::Value & root,std::string param_name,EchoCanceller3Config::Delay::AlignmentMixing * param)96 void ReadParam(const Json::Value& root,
97 std::string param_name,
98 EchoCanceller3Config::Delay::AlignmentMixing* param) {
99 RTC_DCHECK(param);
100
101 Json::Value subsection;
102 if (rtc::GetValueFromJsonObject(root, param_name, &subsection)) {
103 ReadParam(subsection, "downmix", ¶m->downmix);
104 ReadParam(subsection, "adaptive_selection", ¶m->adaptive_selection);
105 ReadParam(subsection, "activity_power_threshold",
106 ¶m->activity_power_threshold);
107 ReadParam(subsection, "prefer_first_two_channels",
108 ¶m->prefer_first_two_channels);
109 }
110 }
111
ReadParam(const Json::Value & root,std::string param_name,EchoCanceller3Config::Suppressor::SubbandNearendDetection::SubbandRegion * param)112 void ReadParam(
113 const Json::Value& root,
114 std::string param_name,
115 EchoCanceller3Config::Suppressor::SubbandNearendDetection::SubbandRegion*
116 param) {
117 RTC_DCHECK(param);
118 Json::Value json_array;
119 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
120 std::vector<int> v;
121 rtc::JsonArrayToIntVector(json_array, &v);
122 if (v.size() != 2) {
123 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
124 return;
125 }
126 param->low = static_cast<size_t>(v[0]);
127 param->high = static_cast<size_t>(v[1]);
128 }
129 }
130
ReadParam(const Json::Value & root,std::string param_name,EchoCanceller3Config::Suppressor::MaskingThresholds * param)131 void ReadParam(const Json::Value& root,
132 std::string param_name,
133 EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
134 RTC_DCHECK(param);
135 Json::Value json_array;
136 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
137 std::vector<double> v;
138 rtc::JsonArrayToDoubleVector(json_array, &v);
139 if (v.size() != 3) {
140 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
141 return;
142 }
143 param->enr_transparent = static_cast<float>(v[0]);
144 param->enr_suppress = static_cast<float>(v[1]);
145 param->emr_transparent = static_cast<float>(v[2]);
146 }
147 }
148 } // namespace
149
Aec3ConfigFromJsonString(absl::string_view json_string,EchoCanceller3Config * config,bool * parsing_successful)150 void Aec3ConfigFromJsonString(absl::string_view json_string,
151 EchoCanceller3Config* config,
152 bool* parsing_successful) {
153 RTC_DCHECK(config);
154 RTC_DCHECK(parsing_successful);
155 EchoCanceller3Config& cfg = *config;
156 cfg = EchoCanceller3Config();
157 *parsing_successful = true;
158
159 Json::Value root;
160 Json::CharReaderBuilder builder;
161 std::string error_message;
162 std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
163 bool success =
164 reader->parse(json_string.data(), json_string.data() + json_string.size(),
165 &root, &error_message);
166 if (!success) {
167 RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << error_message;
168 *parsing_successful = false;
169 return;
170 }
171
172 Json::Value aec3_root;
173 success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
174 if (!success) {
175 RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
176 *parsing_successful = false;
177 return;
178 }
179
180 Json::Value section;
181 if (rtc::GetValueFromJsonObject(aec3_root, "buffering", §ion)) {
182 ReadParam(section, "excess_render_detection_interval_blocks",
183 &cfg.buffering.excess_render_detection_interval_blocks);
184 ReadParam(section, "max_allowed_excess_render_blocks",
185 &cfg.buffering.max_allowed_excess_render_blocks);
186 }
187
188 if (rtc::GetValueFromJsonObject(aec3_root, "delay", §ion)) {
189 ReadParam(section, "default_delay", &cfg.delay.default_delay);
190 ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
191 ReadParam(section, "num_filters", &cfg.delay.num_filters);
192 ReadParam(section, "delay_headroom_samples",
193 &cfg.delay.delay_headroom_samples);
194 ReadParam(section, "hysteresis_limit_blocks",
195 &cfg.delay.hysteresis_limit_blocks);
196 ReadParam(section, "fixed_capture_delay_samples",
197 &cfg.delay.fixed_capture_delay_samples);
198 ReadParam(section, "delay_estimate_smoothing",
199 &cfg.delay.delay_estimate_smoothing);
200 ReadParam(section, "delay_estimate_smoothing_delay_found",
201 &cfg.delay.delay_estimate_smoothing_delay_found);
202 ReadParam(section, "delay_candidate_detection_threshold",
203 &cfg.delay.delay_candidate_detection_threshold);
204
205 Json::Value subsection;
206 if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
207 &subsection)) {
208 ReadParam(subsection, "initial",
209 &cfg.delay.delay_selection_thresholds.initial);
210 ReadParam(subsection, "converged",
211 &cfg.delay.delay_selection_thresholds.converged);
212 }
213
214 ReadParam(section, "use_external_delay_estimator",
215 &cfg.delay.use_external_delay_estimator);
216 ReadParam(section, "log_warning_on_delay_changes",
217 &cfg.delay.log_warning_on_delay_changes);
218
219 ReadParam(section, "render_alignment_mixing",
220 &cfg.delay.render_alignment_mixing);
221 ReadParam(section, "capture_alignment_mixing",
222 &cfg.delay.capture_alignment_mixing);
223 ReadParam(section, "detect_pre_echo", &cfg.delay.detect_pre_echo);
224 }
225
226 if (rtc::GetValueFromJsonObject(aec3_root, "filter", §ion)) {
227 ReadParam(section, "refined", &cfg.filter.refined);
228 ReadParam(section, "coarse", &cfg.filter.coarse);
229 ReadParam(section, "refined_initial", &cfg.filter.refined_initial);
230 ReadParam(section, "coarse_initial", &cfg.filter.coarse_initial);
231 ReadParam(section, "config_change_duration_blocks",
232 &cfg.filter.config_change_duration_blocks);
233 ReadParam(section, "initial_state_seconds",
234 &cfg.filter.initial_state_seconds);
235 ReadParam(section, "coarse_reset_hangover_blocks",
236 &cfg.filter.coarse_reset_hangover_blocks);
237 ReadParam(section, "conservative_initial_phase",
238 &cfg.filter.conservative_initial_phase);
239 ReadParam(section, "enable_coarse_filter_output_usage",
240 &cfg.filter.enable_coarse_filter_output_usage);
241 ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter);
242 ReadParam(section, "high_pass_filter_echo_reference",
243 &cfg.filter.high_pass_filter_echo_reference);
244 ReadParam(section, "export_linear_aec_output",
245 &cfg.filter.export_linear_aec_output);
246 }
247
248 if (rtc::GetValueFromJsonObject(aec3_root, "erle", §ion)) {
249 ReadParam(section, "min", &cfg.erle.min);
250 ReadParam(section, "max_l", &cfg.erle.max_l);
251 ReadParam(section, "max_h", &cfg.erle.max_h);
252 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
253 ReadParam(section, "num_sections", &cfg.erle.num_sections);
254 ReadParam(section, "clamp_quality_estimate_to_zero",
255 &cfg.erle.clamp_quality_estimate_to_zero);
256 ReadParam(section, "clamp_quality_estimate_to_one",
257 &cfg.erle.clamp_quality_estimate_to_one);
258 }
259
260 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", §ion)) {
261 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
262 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
263 ReadParam(section, "nearend_len", &cfg.ep_strength.nearend_len);
264 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
265 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
266 ReadParam(section, "erle_onset_compensation_in_dominant_nearend",
267 &cfg.ep_strength.erle_onset_compensation_in_dominant_nearend);
268 ReadParam(section, "use_conservative_tail_frequency_response",
269 &cfg.ep_strength.use_conservative_tail_frequency_response);
270 }
271
272 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", §ion)) {
273 ReadParam(section, "low_render_limit",
274 &cfg.echo_audibility.low_render_limit);
275 ReadParam(section, "normal_render_limit",
276 &cfg.echo_audibility.normal_render_limit);
277
278 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
279 ReadParam(section, "audibility_threshold_lf",
280 &cfg.echo_audibility.audibility_threshold_lf);
281 ReadParam(section, "audibility_threshold_mf",
282 &cfg.echo_audibility.audibility_threshold_mf);
283 ReadParam(section, "audibility_threshold_hf",
284 &cfg.echo_audibility.audibility_threshold_hf);
285 ReadParam(section, "use_stationarity_properties",
286 &cfg.echo_audibility.use_stationarity_properties);
287 ReadParam(section, "use_stationarity_properties_at_init",
288 &cfg.echo_audibility.use_stationarity_properties_at_init);
289 }
290
291 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", §ion)) {
292 ReadParam(section, "active_render_limit",
293 &cfg.render_levels.active_render_limit);
294 ReadParam(section, "poor_excitation_render_limit",
295 &cfg.render_levels.poor_excitation_render_limit);
296 ReadParam(section, "poor_excitation_render_limit_ds8",
297 &cfg.render_levels.poor_excitation_render_limit_ds8);
298 ReadParam(section, "render_power_gain_db",
299 &cfg.render_levels.render_power_gain_db);
300 }
301
302 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
303 §ion)) {
304 ReadParam(section, "has_clock_drift",
305 &cfg.echo_removal_control.has_clock_drift);
306 ReadParam(section, "linear_and_stable_echo_path",
307 &cfg.echo_removal_control.linear_and_stable_echo_path);
308 }
309
310 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", §ion)) {
311 Json::Value subsection;
312 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
313 ReadParam(section, "min_noise_floor_power",
314 &cfg.echo_model.min_noise_floor_power);
315 ReadParam(section, "stationary_gate_slope",
316 &cfg.echo_model.stationary_gate_slope);
317 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
318 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
319 ReadParam(section, "render_pre_window_size",
320 &cfg.echo_model.render_pre_window_size);
321 ReadParam(section, "render_post_window_size",
322 &cfg.echo_model.render_post_window_size);
323 ReadParam(section, "model_reverb_in_nonlinear_mode",
324 &cfg.echo_model.model_reverb_in_nonlinear_mode);
325 }
326
327 if (rtc::GetValueFromJsonObject(aec3_root, "comfort_noise", §ion)) {
328 ReadParam(section, "noise_floor_dbfs", &cfg.comfort_noise.noise_floor_dbfs);
329 }
330
331 Json::Value subsection;
332 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", §ion)) {
333 ReadParam(section, "nearend_average_blocks",
334 &cfg.suppressor.nearend_average_blocks);
335
336 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
337 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
338 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
339 ReadParam(subsection, "max_inc_factor",
340 &cfg.suppressor.normal_tuning.max_inc_factor);
341 ReadParam(subsection, "max_dec_factor_lf",
342 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
343 }
344
345 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
346 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
347 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
348 ReadParam(subsection, "max_inc_factor",
349 &cfg.suppressor.nearend_tuning.max_inc_factor);
350 ReadParam(subsection, "max_dec_factor_lf",
351 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
352 }
353
354 ReadParam(section, "lf_smoothing_during_initial_phase",
355 &cfg.suppressor.lf_smoothing_during_initial_phase);
356 ReadParam(section, "last_permanent_lf_smoothing_band",
357 &cfg.suppressor.last_permanent_lf_smoothing_band);
358 ReadParam(section, "last_lf_smoothing_band",
359 &cfg.suppressor.last_lf_smoothing_band);
360 ReadParam(section, "last_lf_band", &cfg.suppressor.last_lf_band);
361 ReadParam(section, "first_hf_band", &cfg.suppressor.first_hf_band);
362
363 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
364 &subsection)) {
365 ReadParam(subsection, "enr_threshold",
366 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
367 ReadParam(subsection, "enr_exit_threshold",
368 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
369 ReadParam(subsection, "snr_threshold",
370 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
371 ReadParam(subsection, "hold_duration",
372 &cfg.suppressor.dominant_nearend_detection.hold_duration);
373 ReadParam(subsection, "trigger_threshold",
374 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
375 ReadParam(
376 subsection, "use_during_initial_phase",
377 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
378 ReadParam(subsection, "use_unbounded_echo_spectrum",
379 &cfg.suppressor.dominant_nearend_detection
380 .use_unbounded_echo_spectrum);
381 }
382
383 if (rtc::GetValueFromJsonObject(section, "subband_nearend_detection",
384 &subsection)) {
385 ReadParam(
386 subsection, "nearend_average_blocks",
387 &cfg.suppressor.subband_nearend_detection.nearend_average_blocks);
388 ReadParam(subsection, "subband1",
389 &cfg.suppressor.subband_nearend_detection.subband1);
390 ReadParam(subsection, "subband2",
391 &cfg.suppressor.subband_nearend_detection.subband2);
392 ReadParam(subsection, "nearend_threshold",
393 &cfg.suppressor.subband_nearend_detection.nearend_threshold);
394 ReadParam(subsection, "snr_threshold",
395 &cfg.suppressor.subband_nearend_detection.snr_threshold);
396 }
397
398 ReadParam(section, "use_subband_nearend_detection",
399 &cfg.suppressor.use_subband_nearend_detection);
400
401 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
402 &subsection)) {
403 ReadParam(subsection, "enr_threshold",
404 &cfg.suppressor.high_bands_suppression.enr_threshold);
405 ReadParam(subsection, "max_gain_during_echo",
406 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
407 ReadParam(subsection, "anti_howling_activation_threshold",
408 &cfg.suppressor.high_bands_suppression
409 .anti_howling_activation_threshold);
410 ReadParam(subsection, "anti_howling_gain",
411 &cfg.suppressor.high_bands_suppression.anti_howling_gain);
412 }
413
414 ReadParam(section, "floor_first_increase",
415 &cfg.suppressor.floor_first_increase);
416 ReadParam(section, "conservative_hf_suppression",
417 &cfg.suppressor.conservative_hf_suppression);
418 }
419
420 if (rtc::GetValueFromJsonObject(aec3_root, "multi_channel", §ion)) {
421 ReadParam(section, "detect_stereo_content",
422 &cfg.multi_channel.detect_stereo_content);
423 ReadParam(section, "stereo_detection_threshold",
424 &cfg.multi_channel.stereo_detection_threshold);
425 ReadParam(section, "stereo_detection_timeout_threshold_seconds",
426 &cfg.multi_channel.stereo_detection_timeout_threshold_seconds);
427 ReadParam(section, "stereo_detection_hysteresis_seconds",
428 &cfg.multi_channel.stereo_detection_hysteresis_seconds);
429 }
430 }
431
Aec3ConfigFromJsonString(absl::string_view json_string)432 EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
433 EchoCanceller3Config cfg;
434 bool not_used;
435 Aec3ConfigFromJsonString(json_string, &cfg, ¬_used);
436 return cfg;
437 }
438
Aec3ConfigToJsonString(const EchoCanceller3Config & config)439 std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
440 rtc::StringBuilder ost;
441 ost << "{";
442 ost << "\"aec3\": {";
443 ost << "\"buffering\": {";
444 ost << "\"excess_render_detection_interval_blocks\": "
445 << config.buffering.excess_render_detection_interval_blocks << ",";
446 ost << "\"max_allowed_excess_render_blocks\": "
447 << config.buffering.max_allowed_excess_render_blocks;
448 ost << "},";
449
450 ost << "\"delay\": {";
451 ost << "\"default_delay\": " << config.delay.default_delay << ",";
452 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
453 << ",";
454 ost << "\"num_filters\": " << config.delay.num_filters << ",";
455 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
456 << ",";
457 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
458 << ",";
459 ost << "\"fixed_capture_delay_samples\": "
460 << config.delay.fixed_capture_delay_samples << ",";
461 ost << "\"delay_estimate_smoothing\": "
462 << config.delay.delay_estimate_smoothing << ",";
463 ost << "\"delay_estimate_smoothing_delay_found\": "
464 << config.delay.delay_estimate_smoothing_delay_found << ",";
465 ost << "\"delay_candidate_detection_threshold\": "
466 << config.delay.delay_candidate_detection_threshold << ",";
467
468 ost << "\"delay_selection_thresholds\": {";
469 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
470 << ",";
471 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
472 ost << "},";
473
474 ost << "\"use_external_delay_estimator\": "
475 << (config.delay.use_external_delay_estimator ? "true" : "false") << ",";
476 ost << "\"log_warning_on_delay_changes\": "
477 << (config.delay.log_warning_on_delay_changes ? "true" : "false") << ",";
478
479 ost << "\"render_alignment_mixing\": {";
480 ost << "\"downmix\": "
481 << (config.delay.render_alignment_mixing.downmix ? "true" : "false")
482 << ",";
483 ost << "\"adaptive_selection\": "
484 << (config.delay.render_alignment_mixing.adaptive_selection ? "true"
485 : "false")
486 << ",";
487 ost << "\"activity_power_threshold\": "
488 << config.delay.render_alignment_mixing.activity_power_threshold << ",";
489 ost << "\"prefer_first_two_channels\": "
490 << (config.delay.render_alignment_mixing.prefer_first_two_channels
491 ? "true"
492 : "false");
493 ost << "},";
494
495 ost << "\"capture_alignment_mixing\": {";
496 ost << "\"downmix\": "
497 << (config.delay.capture_alignment_mixing.downmix ? "true" : "false")
498 << ",";
499 ost << "\"adaptive_selection\": "
500 << (config.delay.capture_alignment_mixing.adaptive_selection ? "true"
501 : "false")
502 << ",";
503 ost << "\"activity_power_threshold\": "
504 << config.delay.capture_alignment_mixing.activity_power_threshold << ",";
505 ost << "\"prefer_first_two_channels\": "
506 << (config.delay.capture_alignment_mixing.prefer_first_two_channels
507 ? "true"
508 : "false");
509 ost << "},";
510 ost << "\"detect_pre_echo\": "
511 << (config.delay.detect_pre_echo ? "true" : "false");
512 ost << "},";
513
514 ost << "\"filter\": {";
515
516 ost << "\"refined\": [";
517 ost << config.filter.refined.length_blocks << ",";
518 ost << config.filter.refined.leakage_converged << ",";
519 ost << config.filter.refined.leakage_diverged << ",";
520 ost << config.filter.refined.error_floor << ",";
521 ost << config.filter.refined.error_ceil << ",";
522 ost << config.filter.refined.noise_gate;
523 ost << "],";
524
525 ost << "\"coarse\": [";
526 ost << config.filter.coarse.length_blocks << ",";
527 ost << config.filter.coarse.rate << ",";
528 ost << config.filter.coarse.noise_gate;
529 ost << "],";
530
531 ost << "\"refined_initial\": [";
532 ost << config.filter.refined_initial.length_blocks << ",";
533 ost << config.filter.refined_initial.leakage_converged << ",";
534 ost << config.filter.refined_initial.leakage_diverged << ",";
535 ost << config.filter.refined_initial.error_floor << ",";
536 ost << config.filter.refined_initial.error_ceil << ",";
537 ost << config.filter.refined_initial.noise_gate;
538 ost << "],";
539
540 ost << "\"coarse_initial\": [";
541 ost << config.filter.coarse_initial.length_blocks << ",";
542 ost << config.filter.coarse_initial.rate << ",";
543 ost << config.filter.coarse_initial.noise_gate;
544 ost << "],";
545
546 ost << "\"config_change_duration_blocks\": "
547 << config.filter.config_change_duration_blocks << ",";
548 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
549 << ",";
550 ost << "\"coarse_reset_hangover_blocks\": "
551 << config.filter.coarse_reset_hangover_blocks << ",";
552 ost << "\"conservative_initial_phase\": "
553 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
554 ost << "\"enable_coarse_filter_output_usage\": "
555 << (config.filter.enable_coarse_filter_output_usage ? "true" : "false")
556 << ",";
557 ost << "\"use_linear_filter\": "
558 << (config.filter.use_linear_filter ? "true" : "false") << ",";
559 ost << "\"high_pass_filter_echo_reference\": "
560 << (config.filter.high_pass_filter_echo_reference ? "true" : "false")
561 << ",";
562 ost << "\"export_linear_aec_output\": "
563 << (config.filter.export_linear_aec_output ? "true" : "false");
564
565 ost << "},";
566
567 ost << "\"erle\": {";
568 ost << "\"min\": " << config.erle.min << ",";
569 ost << "\"max_l\": " << config.erle.max_l << ",";
570 ost << "\"max_h\": " << config.erle.max_h << ",";
571 ost << "\"onset_detection\": "
572 << (config.erle.onset_detection ? "true" : "false") << ",";
573 ost << "\"num_sections\": " << config.erle.num_sections << ",";
574 ost << "\"clamp_quality_estimate_to_zero\": "
575 << (config.erle.clamp_quality_estimate_to_zero ? "true" : "false") << ",";
576 ost << "\"clamp_quality_estimate_to_one\": "
577 << (config.erle.clamp_quality_estimate_to_one ? "true" : "false");
578 ost << "},";
579
580 ost << "\"ep_strength\": {";
581 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
582 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
583 ost << "\"nearend_len\": " << config.ep_strength.nearend_len << ",";
584 ost << "\"echo_can_saturate\": "
585 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
586 ost << "\"bounded_erl\": "
587 << (config.ep_strength.bounded_erl ? "true" : "false") << ",";
588 ost << "\"erle_onset_compensation_in_dominant_nearend\": "
589 << (config.ep_strength.erle_onset_compensation_in_dominant_nearend
590 ? "true"
591 : "false")
592 << ",";
593 ost << "\"use_conservative_tail_frequency_response\": "
594 << (config.ep_strength.use_conservative_tail_frequency_response
595 ? "true"
596 : "false");
597 ost << "},";
598
599 ost << "\"echo_audibility\": {";
600 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
601 << ",";
602 ost << "\"normal_render_limit\": "
603 << config.echo_audibility.normal_render_limit << ",";
604 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
605 ost << "\"audibility_threshold_lf\": "
606 << config.echo_audibility.audibility_threshold_lf << ",";
607 ost << "\"audibility_threshold_mf\": "
608 << config.echo_audibility.audibility_threshold_mf << ",";
609 ost << "\"audibility_threshold_hf\": "
610 << config.echo_audibility.audibility_threshold_hf << ",";
611 ost << "\"use_stationarity_properties\": "
612 << (config.echo_audibility.use_stationarity_properties ? "true" : "false")
613 << ",";
614 ost << "\"use_stationarity_properties_at_init\": "
615 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
616 : "false");
617 ost << "},";
618
619 ost << "\"render_levels\": {";
620 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
621 << ",";
622 ost << "\"poor_excitation_render_limit\": "
623 << config.render_levels.poor_excitation_render_limit << ",";
624 ost << "\"poor_excitation_render_limit_ds8\": "
625 << config.render_levels.poor_excitation_render_limit_ds8 << ",";
626 ost << "\"render_power_gain_db\": "
627 << config.render_levels.render_power_gain_db;
628 ost << "},";
629
630 ost << "\"echo_removal_control\": {";
631 ost << "\"has_clock_drift\": "
632 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
633 << ",";
634 ost << "\"linear_and_stable_echo_path\": "
635 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
636 : "false");
637
638 ost << "},";
639
640 ost << "\"echo_model\": {";
641 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
642 ost << "\"min_noise_floor_power\": "
643 << config.echo_model.min_noise_floor_power << ",";
644 ost << "\"stationary_gate_slope\": "
645 << config.echo_model.stationary_gate_slope << ",";
646 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
647 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
648 ost << "\"render_pre_window_size\": "
649 << config.echo_model.render_pre_window_size << ",";
650 ost << "\"render_post_window_size\": "
651 << config.echo_model.render_post_window_size << ",";
652 ost << "\"model_reverb_in_nonlinear_mode\": "
653 << (config.echo_model.model_reverb_in_nonlinear_mode ? "true" : "false");
654 ost << "},";
655
656 ost << "\"comfort_noise\": {";
657 ost << "\"noise_floor_dbfs\": " << config.comfort_noise.noise_floor_dbfs;
658 ost << "},";
659
660 ost << "\"suppressor\": {";
661 ost << "\"nearend_average_blocks\": "
662 << config.suppressor.nearend_average_blocks << ",";
663 ost << "\"normal_tuning\": {";
664 ost << "\"mask_lf\": [";
665 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
666 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
667 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
668 ost << "],";
669 ost << "\"mask_hf\": [";
670 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
671 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
672 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
673 ost << "],";
674 ost << "\"max_inc_factor\": "
675 << config.suppressor.normal_tuning.max_inc_factor << ",";
676 ost << "\"max_dec_factor_lf\": "
677 << config.suppressor.normal_tuning.max_dec_factor_lf;
678 ost << "},";
679 ost << "\"nearend_tuning\": {";
680 ost << "\"mask_lf\": [";
681 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
682 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
683 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
684 ost << "],";
685 ost << "\"mask_hf\": [";
686 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
687 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
688 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
689 ost << "],";
690 ost << "\"max_inc_factor\": "
691 << config.suppressor.nearend_tuning.max_inc_factor << ",";
692 ost << "\"max_dec_factor_lf\": "
693 << config.suppressor.nearend_tuning.max_dec_factor_lf;
694 ost << "},";
695 ost << "\"lf_smoothing_during_initial_phase\": "
696 << (config.suppressor.lf_smoothing_during_initial_phase ? "true"
697 : "false")
698 << ",";
699 ost << "\"last_permanent_lf_smoothing_band\": "
700 << config.suppressor.last_permanent_lf_smoothing_band << ",";
701 ost << "\"last_lf_smoothing_band\": "
702 << config.suppressor.last_lf_smoothing_band << ",";
703 ost << "\"last_lf_band\": " << config.suppressor.last_lf_band << ",";
704 ost << "\"first_hf_band\": " << config.suppressor.first_hf_band << ",";
705 {
706 const auto& dnd = config.suppressor.dominant_nearend_detection;
707 ost << "\"dominant_nearend_detection\": {";
708 ost << "\"enr_threshold\": " << dnd.enr_threshold << ",";
709 ost << "\"enr_exit_threshold\": " << dnd.enr_exit_threshold << ",";
710 ost << "\"snr_threshold\": " << dnd.snr_threshold << ",";
711 ost << "\"hold_duration\": " << dnd.hold_duration << ",";
712 ost << "\"trigger_threshold\": " << dnd.trigger_threshold << ",";
713 ost << "\"use_during_initial_phase\": " << dnd.use_during_initial_phase
714 << ",";
715 ost << "\"use_unbounded_echo_spectrum\": "
716 << dnd.use_unbounded_echo_spectrum;
717 ost << "},";
718 }
719 ost << "\"subband_nearend_detection\": {";
720 ost << "\"nearend_average_blocks\": "
721 << config.suppressor.subband_nearend_detection.nearend_average_blocks
722 << ",";
723 ost << "\"subband1\": [";
724 ost << config.suppressor.subband_nearend_detection.subband1.low << ",";
725 ost << config.suppressor.subband_nearend_detection.subband1.high;
726 ost << "],";
727 ost << "\"subband2\": [";
728 ost << config.suppressor.subband_nearend_detection.subband2.low << ",";
729 ost << config.suppressor.subband_nearend_detection.subband2.high;
730 ost << "],";
731 ost << "\"nearend_threshold\": "
732 << config.suppressor.subband_nearend_detection.nearend_threshold << ",";
733 ost << "\"snr_threshold\": "
734 << config.suppressor.subband_nearend_detection.snr_threshold;
735 ost << "},";
736 ost << "\"use_subband_nearend_detection\": "
737 << config.suppressor.use_subband_nearend_detection << ",";
738 ost << "\"high_bands_suppression\": {";
739 ost << "\"enr_threshold\": "
740 << config.suppressor.high_bands_suppression.enr_threshold << ",";
741 ost << "\"max_gain_during_echo\": "
742 << config.suppressor.high_bands_suppression.max_gain_during_echo << ",";
743 ost << "\"anti_howling_activation_threshold\": "
744 << config.suppressor.high_bands_suppression
745 .anti_howling_activation_threshold
746 << ",";
747 ost << "\"anti_howling_gain\": "
748 << config.suppressor.high_bands_suppression.anti_howling_gain;
749 ost << "},";
750 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
751 << ",";
752 ost << "\"conservative_hf_suppression\": "
753 << config.suppressor.conservative_hf_suppression;
754 ost << "},";
755
756 ost << "\"multi_channel\": {";
757 ost << "\"detect_stereo_content\": "
758 << (config.multi_channel.detect_stereo_content ? "true" : "false") << ",";
759 ost << "\"stereo_detection_threshold\": "
760 << config.multi_channel.stereo_detection_threshold << ",";
761 ost << "\"stereo_detection_timeout_threshold_seconds\": "
762 << config.multi_channel.stereo_detection_timeout_threshold_seconds << ",";
763 ost << "\"stereo_detection_hysteresis_seconds\": "
764 << config.multi_channel.stereo_detection_hysteresis_seconds;
765 ost << "}";
766
767 ost << "}";
768 ost << "}";
769
770 return ost.Release();
771 }
772 } // namespace webrtc
773