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 | |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 13 | #include "rtc_base/strings/string_builder.h" |
| 14 | |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 15 | namespace cricket { |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 16 | namespace { |
| 17 | |
| 18 | template <class T> |
| 19 | void ToStringIfSet(rtc::SimpleStringBuilder* result, |
| 20 | const char* key, |
| 21 | const absl::optional<T>& val) { |
| 22 | if (val) { |
| 23 | (*result) << key << ": " << *val << ", "; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | template <typename T> |
| 28 | void SetFrom(absl::optional<T>* s, const absl::optional<T>& o) { |
| 29 | if (o) { |
| 30 | *s = o; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | } // namespace |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 35 | |
| 36 | AudioOptions::AudioOptions() = default; |
| 37 | AudioOptions::~AudioOptions() = default; |
| 38 | |
Danil Chapovalov | 2165233 | 2018-08-31 10:29:07 +0200 | [diff] [blame] | 39 | void AudioOptions::SetAll(const AudioOptions& change) { |
| 40 | SetFrom(&echo_cancellation, change.echo_cancellation); |
| 41 | #if defined(WEBRTC_IOS) |
| 42 | SetFrom(&ios_force_software_aec_HACK, change.ios_force_software_aec_HACK); |
| 43 | #endif |
| 44 | SetFrom(&auto_gain_control, change.auto_gain_control); |
| 45 | SetFrom(&noise_suppression, change.noise_suppression); |
| 46 | SetFrom(&highpass_filter, change.highpass_filter); |
| 47 | SetFrom(&stereo_swapping, change.stereo_swapping); |
| 48 | SetFrom(&audio_jitter_buffer_max_packets, |
| 49 | change.audio_jitter_buffer_max_packets); |
| 50 | SetFrom(&audio_jitter_buffer_fast_accelerate, |
| 51 | change.audio_jitter_buffer_fast_accelerate); |
| 52 | SetFrom(&typing_detection, change.typing_detection); |
| 53 | SetFrom(&aecm_generate_comfort_noise, change.aecm_generate_comfort_noise); |
| 54 | SetFrom(&experimental_agc, change.experimental_agc); |
| 55 | SetFrom(&extended_filter_aec, change.extended_filter_aec); |
| 56 | SetFrom(&delay_agnostic_aec, change.delay_agnostic_aec); |
| 57 | SetFrom(&experimental_ns, change.experimental_ns); |
| 58 | SetFrom(&residual_echo_detector, change.residual_echo_detector); |
| 59 | SetFrom(&tx_agc_target_dbov, change.tx_agc_target_dbov); |
| 60 | SetFrom(&tx_agc_digital_compression_gain, |
| 61 | change.tx_agc_digital_compression_gain); |
| 62 | SetFrom(&tx_agc_limiter, change.tx_agc_limiter); |
| 63 | SetFrom(&combined_audio_video_bwe, change.combined_audio_video_bwe); |
| 64 | SetFrom(&audio_network_adaptor, change.audio_network_adaptor); |
| 65 | SetFrom(&audio_network_adaptor_config, change.audio_network_adaptor_config); |
| 66 | } |
| 67 | |
| 68 | bool AudioOptions::operator==(const AudioOptions& o) const { |
| 69 | return echo_cancellation == o.echo_cancellation && |
| 70 | #if defined(WEBRTC_IOS) |
| 71 | ios_force_software_aec_HACK == o.ios_force_software_aec_HACK && |
| 72 | #endif |
| 73 | auto_gain_control == o.auto_gain_control && |
| 74 | noise_suppression == o.noise_suppression && |
| 75 | highpass_filter == o.highpass_filter && |
| 76 | stereo_swapping == o.stereo_swapping && |
| 77 | audio_jitter_buffer_max_packets == o.audio_jitter_buffer_max_packets && |
| 78 | audio_jitter_buffer_fast_accelerate == |
| 79 | o.audio_jitter_buffer_fast_accelerate && |
| 80 | typing_detection == o.typing_detection && |
| 81 | aecm_generate_comfort_noise == o.aecm_generate_comfort_noise && |
| 82 | experimental_agc == o.experimental_agc && |
| 83 | extended_filter_aec == o.extended_filter_aec && |
| 84 | delay_agnostic_aec == o.delay_agnostic_aec && |
| 85 | experimental_ns == o.experimental_ns && |
| 86 | residual_echo_detector == o.residual_echo_detector && |
| 87 | tx_agc_target_dbov == o.tx_agc_target_dbov && |
| 88 | tx_agc_digital_compression_gain == o.tx_agc_digital_compression_gain && |
| 89 | tx_agc_limiter == o.tx_agc_limiter && |
| 90 | combined_audio_video_bwe == o.combined_audio_video_bwe && |
| 91 | audio_network_adaptor == o.audio_network_adaptor && |
| 92 | audio_network_adaptor_config == o.audio_network_adaptor_config; |
| 93 | } |
| 94 | |
| 95 | std::string AudioOptions::ToString() const { |
| 96 | char buffer[1024]; |
| 97 | rtc::SimpleStringBuilder result(buffer); |
| 98 | result << "AudioOptions {"; |
| 99 | ToStringIfSet(&result, "aec", echo_cancellation); |
| 100 | #if defined(WEBRTC_IOS) |
| 101 | ToStringIfSet(&result, "ios_force_software_aec_HACK", |
| 102 | ios_force_software_aec_HACK); |
| 103 | #endif |
| 104 | ToStringIfSet(&result, "agc", auto_gain_control); |
| 105 | ToStringIfSet(&result, "ns", noise_suppression); |
| 106 | ToStringIfSet(&result, "hf", highpass_filter); |
| 107 | ToStringIfSet(&result, "swap", stereo_swapping); |
| 108 | ToStringIfSet(&result, "audio_jitter_buffer_max_packets", |
| 109 | audio_jitter_buffer_max_packets); |
| 110 | ToStringIfSet(&result, "audio_jitter_buffer_fast_accelerate", |
| 111 | audio_jitter_buffer_fast_accelerate); |
| 112 | ToStringIfSet(&result, "typing", typing_detection); |
| 113 | ToStringIfSet(&result, "comfort_noise", aecm_generate_comfort_noise); |
| 114 | ToStringIfSet(&result, "experimental_agc", experimental_agc); |
| 115 | ToStringIfSet(&result, "extended_filter_aec", extended_filter_aec); |
| 116 | ToStringIfSet(&result, "delay_agnostic_aec", delay_agnostic_aec); |
| 117 | ToStringIfSet(&result, "experimental_ns", experimental_ns); |
| 118 | ToStringIfSet(&result, "residual_echo_detector", residual_echo_detector); |
| 119 | ToStringIfSet(&result, "tx_agc_target_dbov", tx_agc_target_dbov); |
| 120 | ToStringIfSet(&result, "tx_agc_digital_compression_gain", |
| 121 | tx_agc_digital_compression_gain); |
| 122 | ToStringIfSet(&result, "tx_agc_limiter", tx_agc_limiter); |
| 123 | ToStringIfSet(&result, "combined_audio_video_bwe", combined_audio_video_bwe); |
| 124 | ToStringIfSet(&result, "audio_network_adaptor", audio_network_adaptor); |
| 125 | result << "}"; |
| 126 | return result.str(); |
| 127 | } |
| 128 | |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 129 | } // namespace cricket |