blob: 6832bbe29417cbf4712db88fb40395007f3c9307 [file] [log] [blame]
Paulina Hensman11b34f42018-04-09 14:24:52 +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
11#include "api/audio_options.h"
12
Yves Gerey3e707812018-11-28 16:47:49 +010013#include "api/array_view.h"
Danil Chapovalov21652332018-08-31 10:29:07 +020014#include "rtc_base/strings/string_builder.h"
15
Paulina Hensman11b34f42018-04-09 14:24:52 +020016namespace cricket {
Danil Chapovalov21652332018-08-31 10:29:07 +020017namespace {
18
19template <class T>
20void ToStringIfSet(rtc::SimpleStringBuilder* result,
21 const char* key,
22 const absl::optional<T>& val) {
23 if (val) {
24 (*result) << key << ": " << *val << ", ";
25 }
26}
27
28template <typename T>
29void SetFrom(absl::optional<T>* s, const absl::optional<T>& o) {
30 if (o) {
31 *s = o;
32 }
33}
34
35} // namespace
Paulina Hensman11b34f42018-04-09 14:24:52 +020036
37AudioOptions::AudioOptions() = default;
38AudioOptions::~AudioOptions() = default;
39
Danil Chapovalov21652332018-08-31 10:29:07 +020040void AudioOptions::SetAll(const AudioOptions& change) {
41 SetFrom(&echo_cancellation, change.echo_cancellation);
42#if defined(WEBRTC_IOS)
43 SetFrom(&ios_force_software_aec_HACK, change.ios_force_software_aec_HACK);
44#endif
45 SetFrom(&auto_gain_control, change.auto_gain_control);
46 SetFrom(&noise_suppression, change.noise_suppression);
47 SetFrom(&highpass_filter, change.highpass_filter);
48 SetFrom(&stereo_swapping, change.stereo_swapping);
49 SetFrom(&audio_jitter_buffer_max_packets,
50 change.audio_jitter_buffer_max_packets);
51 SetFrom(&audio_jitter_buffer_fast_accelerate,
52 change.audio_jitter_buffer_fast_accelerate);
Jakob Ivarsson10403ae2018-11-27 15:45:20 +010053 SetFrom(&audio_jitter_buffer_min_delay_ms,
54 change.audio_jitter_buffer_min_delay_ms);
Jakob Ivarsson53eae872019-01-10 15:58:36 +010055 SetFrom(&audio_jitter_buffer_enable_rtx_handling,
56 change.audio_jitter_buffer_enable_rtx_handling);
Danil Chapovalov21652332018-08-31 10:29:07 +020057 SetFrom(&typing_detection, change.typing_detection);
Danil Chapovalov21652332018-08-31 10:29:07 +020058 SetFrom(&experimental_agc, change.experimental_agc);
Danil Chapovalov21652332018-08-31 10:29:07 +020059 SetFrom(&experimental_ns, change.experimental_ns);
60 SetFrom(&residual_echo_detector, change.residual_echo_detector);
61 SetFrom(&tx_agc_target_dbov, change.tx_agc_target_dbov);
62 SetFrom(&tx_agc_digital_compression_gain,
63 change.tx_agc_digital_compression_gain);
64 SetFrom(&tx_agc_limiter, change.tx_agc_limiter);
65 SetFrom(&combined_audio_video_bwe, change.combined_audio_video_bwe);
66 SetFrom(&audio_network_adaptor, change.audio_network_adaptor);
67 SetFrom(&audio_network_adaptor_config, change.audio_network_adaptor_config);
68}
69
70bool AudioOptions::operator==(const AudioOptions& o) const {
71 return echo_cancellation == o.echo_cancellation &&
72#if defined(WEBRTC_IOS)
73 ios_force_software_aec_HACK == o.ios_force_software_aec_HACK &&
74#endif
75 auto_gain_control == o.auto_gain_control &&
76 noise_suppression == o.noise_suppression &&
77 highpass_filter == o.highpass_filter &&
78 stereo_swapping == o.stereo_swapping &&
79 audio_jitter_buffer_max_packets == o.audio_jitter_buffer_max_packets &&
80 audio_jitter_buffer_fast_accelerate ==
81 o.audio_jitter_buffer_fast_accelerate &&
Jakob Ivarsson10403ae2018-11-27 15:45:20 +010082 audio_jitter_buffer_min_delay_ms ==
83 o.audio_jitter_buffer_min_delay_ms &&
Jakob Ivarsson53eae872019-01-10 15:58:36 +010084 audio_jitter_buffer_enable_rtx_handling ==
85 o.audio_jitter_buffer_enable_rtx_handling &&
Danil Chapovalov21652332018-08-31 10:29:07 +020086 typing_detection == o.typing_detection &&
Danil Chapovalov21652332018-08-31 10:29:07 +020087 experimental_agc == o.experimental_agc &&
Danil Chapovalov21652332018-08-31 10:29:07 +020088 experimental_ns == o.experimental_ns &&
89 residual_echo_detector == o.residual_echo_detector &&
90 tx_agc_target_dbov == o.tx_agc_target_dbov &&
91 tx_agc_digital_compression_gain == o.tx_agc_digital_compression_gain &&
92 tx_agc_limiter == o.tx_agc_limiter &&
93 combined_audio_video_bwe == o.combined_audio_video_bwe &&
94 audio_network_adaptor == o.audio_network_adaptor &&
95 audio_network_adaptor_config == o.audio_network_adaptor_config;
96}
97
98std::string AudioOptions::ToString() const {
99 char buffer[1024];
100 rtc::SimpleStringBuilder result(buffer);
101 result << "AudioOptions {";
102 ToStringIfSet(&result, "aec", echo_cancellation);
103#if defined(WEBRTC_IOS)
104 ToStringIfSet(&result, "ios_force_software_aec_HACK",
105 ios_force_software_aec_HACK);
106#endif
107 ToStringIfSet(&result, "agc", auto_gain_control);
108 ToStringIfSet(&result, "ns", noise_suppression);
109 ToStringIfSet(&result, "hf", highpass_filter);
110 ToStringIfSet(&result, "swap", stereo_swapping);
111 ToStringIfSet(&result, "audio_jitter_buffer_max_packets",
112 audio_jitter_buffer_max_packets);
113 ToStringIfSet(&result, "audio_jitter_buffer_fast_accelerate",
114 audio_jitter_buffer_fast_accelerate);
Jakob Ivarsson10403ae2018-11-27 15:45:20 +0100115 ToStringIfSet(&result, "audio_jitter_buffer_min_delay_ms",
116 audio_jitter_buffer_min_delay_ms);
Jakob Ivarsson53eae872019-01-10 15:58:36 +0100117 ToStringIfSet(&result, "audio_jitter_buffer_enable_rtx_handling",
118 audio_jitter_buffer_enable_rtx_handling);
Danil Chapovalov21652332018-08-31 10:29:07 +0200119 ToStringIfSet(&result, "typing", typing_detection);
Danil Chapovalov21652332018-08-31 10:29:07 +0200120 ToStringIfSet(&result, "experimental_agc", experimental_agc);
Danil Chapovalov21652332018-08-31 10:29:07 +0200121 ToStringIfSet(&result, "experimental_ns", experimental_ns);
122 ToStringIfSet(&result, "residual_echo_detector", residual_echo_detector);
123 ToStringIfSet(&result, "tx_agc_target_dbov", tx_agc_target_dbov);
124 ToStringIfSet(&result, "tx_agc_digital_compression_gain",
125 tx_agc_digital_compression_gain);
126 ToStringIfSet(&result, "tx_agc_limiter", tx_agc_limiter);
127 ToStringIfSet(&result, "combined_audio_video_bwe", combined_audio_video_bwe);
128 ToStringIfSet(&result, "audio_network_adaptor", audio_network_adaptor);
129 result << "}";
130 return result.str();
131}
132
Paulina Hensman11b34f42018-04-09 14:24:52 +0200133} // namespace cricket