Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: content/renderer/media/media_stream_audio_processor.cc

Issue 2560173002: Add new experiment code for TunedClippingLevelMin (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/feature_list.h"
12 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/optional.h"
14 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
16 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
17 #include "base/trace_event/trace_event.h" 19 #include "base/trace_event/trace_event.h"
18 #include "build/build_config.h" 20 #include "build/build_config.h"
19 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
20 #include "content/renderer/media/media_stream_audio_processor_options.h" 22 #include "content/renderer/media/media_stream_audio_processor_options.h"
21 #include "content/renderer/media/webrtc_audio_device_impl.h" 23 #include "content/renderer/media/webrtc_audio_device_impl.h"
22 #include "media/base/audio_converter.h" 24 #include "media/base/audio_converter.h"
23 #include "media/base/audio_fifo.h" 25 #include "media/base/audio_fifo.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 AUDIO_PROCESSING_MAX 101 AUDIO_PROCESSING_MAX
100 }; 102 };
101 103
102 void RecordProcessingState(AudioTrackProcessingStates state) { 104 void RecordProcessingState(AudioTrackProcessingStates state) {
103 UMA_HISTOGRAM_ENUMERATION("Media.AudioTrackProcessingStates", 105 UMA_HISTOGRAM_ENUMERATION("Media.AudioTrackProcessingStates",
104 state, AUDIO_PROCESSING_MAX); 106 state, AUDIO_PROCESSING_MAX);
105 } 107 }
106 108
107 // Checks if the default minimum starting volume value for the AGC is overridden 109 // Checks if the default minimum starting volume value for the AGC is overridden
108 // on the command line. 110 // on the command line.
109 bool GetStartupMinVolumeForAgc(int* startup_min_volume) { 111 base::Optional<int> GetStartupMinVolumeForAgc() {
110 DCHECK(startup_min_volume);
111 std::string min_volume_str( 112 std::string min_volume_str(
112 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 113 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
113 switches::kAgcStartupMinVolume)); 114 switches::kAgcStartupMinVolume));
114 return !min_volume_str.empty() && 115 int startup_min_volume;
115 base::StringToInt(min_volume_str, startup_min_volume); 116 if (min_volume_str.empty() ||
117 !base::StringToInt(min_volume_str, &startup_min_volume)) {
118 return base::Optional<int>();
119 }
120 return base::Optional<int>(startup_min_volume);
121 }
122
123 // Features for http://crbug.com/672476. These values will be given to WebRTC's
124 // gain control (AGC) as lower bounds for the gain reduction during clipping.
125 const base::Feature kTunedClippingLevelMin30{
126 "TunedClippingLevelMin30", base::FEATURE_DISABLED_BY_DEFAULT};
127 const base::Feature kTunedClippingLevelMin70{
128 "TunedClippingLevelMin70", base::FEATURE_DISABLED_BY_DEFAULT};
129 const base::Feature kTunedClippingLevelMin110{
130 "TunedClippingLevelMin110", base::FEATURE_DISABLED_BY_DEFAULT};
131 const base::Feature kTunedClippingLevelMin150{
132 "TunedClippingLevelMin150", base::FEATURE_DISABLED_BY_DEFAULT};
133 const base::Feature kTunedClippingLevelMin170{
134 "TunedClippingLevelMin170", base::FEATURE_DISABLED_BY_DEFAULT};
135
136 base::Optional<int> GetClippingLevelMin() {
137 if (base::FeatureList::IsEnabled(kTunedClippingLevelMin30))
138 return base::Optional<int>(30);
139 if (base::FeatureList::IsEnabled(kTunedClippingLevelMin70))
140 return base::Optional<int>(70);
141 if (base::FeatureList::IsEnabled(kTunedClippingLevelMin110))
142 return base::Optional<int>(110);
143 if (base::FeatureList::IsEnabled(kTunedClippingLevelMin150))
144 return base::Optional<int>(150);
145 if (base::FeatureList::IsEnabled(kTunedClippingLevelMin170))
146 return base::Optional<int>(170);
147 return base::Optional<int>();
116 } 148 }
117 149
118 // Checks if the AEC's refined adaptive filter tuning was enabled on the command 150 // Checks if the AEC's refined adaptive filter tuning was enabled on the command
119 // line. 151 // line.
120 bool UseAecRefinedAdaptiveFilter() { 152 bool UseAecRefinedAdaptiveFilter() {
121 return base::CommandLine::ForCurrentProcess()->HasSwitch( 153 return base::CommandLine::ForCurrentProcess()->HasSwitch(
122 switches::kAecRefinedAdaptiveFilter); 154 switches::kAecRefinedAdaptiveFilter);
123 } 155 }
124 156
125 } // namespace 157 } // namespace
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 const auto& geometry = 645 const auto& geometry =
614 GetArrayGeometryPreferringConstraints(audio_constraints, input_params); 646 GetArrayGeometryPreferringConstraints(audio_constraints, input_params);
615 647
616 // Only enable beamforming if we have at least two mics. 648 // Only enable beamforming if we have at least two mics.
617 config.Set<webrtc::Beamforming>( 649 config.Set<webrtc::Beamforming>(
618 new webrtc::Beamforming(geometry.size() > 1, geometry)); 650 new webrtc::Beamforming(geometry.size() > 1, geometry));
619 } 651 }
620 652
621 // If the experimental AGC is enabled, check for overridden config params. 653 // If the experimental AGC is enabled, check for overridden config params.
622 if (audio_constraints.GetGoogExperimentalAutoGainControl()) { 654 if (audio_constraints.GetGoogExperimentalAutoGainControl()) {
623 int startup_min_volume = 0; 655 auto startup_min_volume = GetStartupMinVolumeForAgc();
624 if (GetStartupMinVolumeForAgc(&startup_min_volume)) { 656 auto clipping_level_min = GetClippingLevelMin();
625 config.Set<webrtc::ExperimentalAgc>( 657 if (startup_min_volume || clipping_level_min) {
626 new webrtc::ExperimentalAgc(true, startup_min_volume)); 658 config.Set<webrtc::ExperimentalAgc>(new webrtc::ExperimentalAgc(
659 true, startup_min_volume.value_or(0),
660 clipping_level_min.value_or(webrtc::kClippedLevelMin)));
627 } 661 }
628 } 662 }
629 663
630 // Create and configure the webrtc::AudioProcessing. 664 // Create and configure the webrtc::AudioProcessing.
631 audio_processing_.reset(webrtc::AudioProcessing::Create(config)); 665 audio_processing_.reset(webrtc::AudioProcessing::Create(config));
632 666
633 // Enable the audio processing components. 667 // Enable the audio processing components.
634 webrtc::AudioProcessing::Config apm_config; 668 webrtc::AudioProcessing::Config apm_config;
635 669
636 if (echo_cancellation) { 670 if (echo_cancellation) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 0 : agc->stream_analog_level(); 863 0 : agc->stream_analog_level();
830 } 864 }
831 865
832 void MediaStreamAudioProcessor::UpdateAecStats() { 866 void MediaStreamAudioProcessor::UpdateAecStats() {
833 DCHECK(main_thread_runner_->BelongsToCurrentThread()); 867 DCHECK(main_thread_runner_->BelongsToCurrentThread());
834 if (echo_information_) 868 if (echo_information_)
835 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation()); 869 echo_information_->UpdateAecStats(audio_processing_->echo_cancellation());
836 } 870 }
837 871
838 } // namespace content 872 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698