Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 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 | |
| 11 | #include "api/audio_options.h" |
| 12 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 13 | #include "api/array_view.h" |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 14 | #include "rtc_base/strings/string_builder.h" |
| 15 | |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 16 | namespace cricket { |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 17 | namespace { |
| 18 | |
| 19 | template <class T> |
| 20 | void ToStringIfSet(rtc::SimpleStringBuilder* result, |
| 21 | const char* key, |
| 22 | const absl::optional<T>& val) { |
| 23 | if (val) { |
| 24 | (*result) << key << ": " << *val << ", "; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | template <typename T> |
| 29 | void SetFrom(absl::optional<T>* s, const absl::optional<T>& o) { |
| 30 | if (o) { |
| 31 | *s = o; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | } // namespace |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 36 | |
| 37 | AudioOptions::AudioOptions() = default; |
| 38 | AudioOptions::~AudioOptions() = default; |
| 39 | |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 40 | void 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 Ivarsson | 10403ae | 2018-11-27 15:45:20 +0100 | [diff] [blame] | 53 | SetFrom(&audio_jitter_buffer_min_delay_ms, |
| 54 | change.audio_jitter_buffer_min_delay_ms); |
Jakob Ivarsson | 53eae87 | 2019-01-10 15:58:36 +0100 | [diff] [blame] | 55 | SetFrom(&audio_jitter_buffer_enable_rtx_handling, |
| 56 | change.audio_jitter_buffer_enable_rtx_handling); |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 57 | SetFrom(&typing_detection, change.typing_detection); |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 58 | SetFrom(&experimental_agc, change.experimental_agc); |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 59 | 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 | |
| 70 | bool 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 Ivarsson | 10403ae | 2018-11-27 15:45:20 +0100 | [diff] [blame] | 82 | audio_jitter_buffer_min_delay_ms == |
| 83 | o.audio_jitter_buffer_min_delay_ms && |
Jakob Ivarsson | 53eae87 | 2019-01-10 15:58:36 +0100 | [diff] [blame] | 84 | audio_jitter_buffer_enable_rtx_handling == |
| 85 | o.audio_jitter_buffer_enable_rtx_handling && |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 86 | typing_detection == o.typing_detection && |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 87 | experimental_agc == o.experimental_agc && |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 88 | 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 | |
| 98 | std::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 Ivarsson | 10403ae | 2018-11-27 15:45:20 +0100 | [diff] [blame] | 115 | ToStringIfSet(&result, "audio_jitter_buffer_min_delay_ms", |
| 116 | audio_jitter_buffer_min_delay_ms); |
Jakob Ivarsson | 53eae87 | 2019-01-10 15:58:36 +0100 | [diff] [blame] | 117 | ToStringIfSet(&result, "audio_jitter_buffer_enable_rtx_handling", |
| 118 | audio_jitter_buffer_enable_rtx_handling); |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 119 | ToStringIfSet(&result, "typing", typing_detection); |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 120 | ToStringIfSet(&result, "experimental_agc", experimental_agc); |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 121 | 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 Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 133 | } // namespace cricket |