OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/media_stream_audio_processor.h" | 5 #include "content/renderer/media/media_stream_audio_processor.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 114 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
115 switches::kAgcStartupMinVolume)); | 115 switches::kAgcStartupMinVolume)); |
116 int startup_min_volume; | 116 int startup_min_volume; |
117 if (min_volume_str.empty() || | 117 if (min_volume_str.empty() || |
118 !base::StringToInt(min_volume_str, &startup_min_volume)) { | 118 !base::StringToInt(min_volume_str, &startup_min_volume)) { |
119 return base::Optional<int>(); | 119 return base::Optional<int>(); |
120 } | 120 } |
121 return base::Optional<int>(startup_min_volume); | 121 return base::Optional<int>(startup_min_volume); |
122 } | 122 } |
123 | 123 |
124 // Features for http://crbug.com/672476. These values will be given to WebRTC's | |
125 // gain control (AGC) as lower bounds for the gain reduction during clipping. | |
126 const base::Feature kTunedClippingLevelMin30{ | |
127 "TunedClippingLevelMin30", base::FEATURE_DISABLED_BY_DEFAULT}; | |
128 const base::Feature kTunedClippingLevelMin70{ | |
129 "TunedClippingLevelMin70", base::FEATURE_DISABLED_BY_DEFAULT}; | |
130 const base::Feature kTunedClippingLevelMin110{ | |
131 "TunedClippingLevelMin110", base::FEATURE_DISABLED_BY_DEFAULT}; | |
132 const base::Feature kTunedClippingLevelMin150{ | |
133 "TunedClippingLevelMin150", base::FEATURE_DISABLED_BY_DEFAULT}; | |
134 const base::Feature kTunedClippingLevelMin170{ | |
135 "TunedClippingLevelMin170", base::FEATURE_DISABLED_BY_DEFAULT}; | |
136 | |
137 base::Optional<int> GetClippingLevelMin() { | |
138 if (base::FeatureList::IsEnabled(kTunedClippingLevelMin30)) | |
139 return base::Optional<int>(30); | |
140 if (base::FeatureList::IsEnabled(kTunedClippingLevelMin70)) | |
141 return base::Optional<int>(70); | |
142 if (base::FeatureList::IsEnabled(kTunedClippingLevelMin110)) | |
143 return base::Optional<int>(110); | |
144 if (base::FeatureList::IsEnabled(kTunedClippingLevelMin150)) | |
145 return base::Optional<int>(150); | |
146 if (base::FeatureList::IsEnabled(kTunedClippingLevelMin170)) | |
147 return base::Optional<int>(170); | |
148 return base::Optional<int>(); | |
149 } | |
150 | |
151 // Checks if the AEC's refined adaptive filter tuning was enabled on the command | 124 // Checks if the AEC's refined adaptive filter tuning was enabled on the command |
152 // line. | 125 // line. |
153 bool UseAecRefinedAdaptiveFilter() { | 126 bool UseAecRefinedAdaptiveFilter() { |
154 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 127 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
155 switches::kAecRefinedAdaptiveFilter); | 128 switches::kAecRefinedAdaptiveFilter); |
156 } | 129 } |
157 | 130 |
158 } // namespace | 131 } // namespace |
159 | 132 |
160 // Wraps AudioBus to provide access to the array of channel pointers, since this | 133 // Wraps AudioBus to provide access to the array of channel pointers, since this |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 GetArrayGeometryPreferringConstraints(audio_constraints, input_params); | 639 GetArrayGeometryPreferringConstraints(audio_constraints, input_params); |
667 | 640 |
668 // Only enable beamforming if we have at least two mics. | 641 // Only enable beamforming if we have at least two mics. |
669 config.Set<webrtc::Beamforming>( | 642 config.Set<webrtc::Beamforming>( |
670 new webrtc::Beamforming(geometry.size() > 1, geometry)); | 643 new webrtc::Beamforming(geometry.size() > 1, geometry)); |
671 } | 644 } |
672 | 645 |
673 // If the experimental AGC is enabled, check for overridden config params. | 646 // If the experimental AGC is enabled, check for overridden config params. |
674 if (audio_constraints.GetGoogExperimentalAutoGainControl()) { | 647 if (audio_constraints.GetGoogExperimentalAutoGainControl()) { |
675 auto startup_min_volume = GetStartupMinVolumeForAgc(); | 648 auto startup_min_volume = GetStartupMinVolumeForAgc(); |
676 auto clipping_level_min = GetClippingLevelMin(); | 649 constexpr int kClippingLevelMin = 70; |
677 if (startup_min_volume || clipping_level_min) { | 650 // TODO(hlundin) Make this value default in WebRTC and clean up here. |
678 config.Set<webrtc::ExperimentalAgc>(new webrtc::ExperimentalAgc( | 651 config.Set<webrtc::ExperimentalAgc>(new webrtc::ExperimentalAgc( |
679 true, startup_min_volume.value_or(0), | 652 true, startup_min_volume.value_or(0), kClippingLevelMin)); |
680 clipping_level_min.value_or(webrtc::kClippedLevelMin))); | |
681 } | |
682 } | 653 } |
683 | 654 |
684 // Create and configure the webrtc::AudioProcessing. | 655 // Create and configure the webrtc::AudioProcessing. |
685 audio_processing_.reset(webrtc::AudioProcessing::Create(config)); | 656 audio_processing_.reset(webrtc::AudioProcessing::Create(config)); |
686 | 657 |
687 // Enable the audio processing components. | 658 // Enable the audio processing components. |
688 webrtc::AudioProcessing::Config apm_config; | 659 webrtc::AudioProcessing::Config apm_config; |
689 | 660 |
690 if (playout_data_source_) { | 661 if (playout_data_source_) { |
691 playout_data_source_->AddPlayoutSink(this); | 662 playout_data_source_->AddPlayoutSink(this); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 0 : agc->stream_analog_level(); | 860 0 : agc->stream_analog_level(); |
890 } | 861 } |
891 | 862 |
892 void MediaStreamAudioProcessor::UpdateAecStats() { | 863 void MediaStreamAudioProcessor::UpdateAecStats() { |
893 DCHECK(main_thread_runner_->BelongsToCurrentThread()); | 864 DCHECK(main_thread_runner_->BelongsToCurrentThread()); |
894 if (echo_information_) | 865 if (echo_information_) |
895 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation()); | 866 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation()); |
896 } | 867 } |
897 | 868 |
898 } // namespace content | 869 } // namespace content |
OLD | NEW |