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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 audio_processor->PushCaptureData(data_bus.get()); | 79 audio_processor->PushCaptureData(data_bus.get()); |
80 | 80 |
81 // |audio_processor| does nothing when the audio processing is off in | 81 // |audio_processor| does nothing when the audio processing is off in |
82 // the processor. | 82 // the processor. |
83 audio_processor->PushRenderData( | 83 audio_processor->PushRenderData( |
84 data_ptr, | 84 data_ptr, |
85 params_.sample_rate(), params_.channels(), | 85 params_.sample_rate(), params_.channels(), |
86 params_.frames_per_buffer(), base::TimeDelta::FromMilliseconds(10)); | 86 params_.frames_per_buffer(), base::TimeDelta::FromMilliseconds(10)); |
87 | 87 |
88 int16* output = NULL; | 88 int16* output = NULL; |
| 89 int new_volume = 0; |
89 while(audio_processor->ProcessAndConsumeData( | 90 while(audio_processor->ProcessAndConsumeData( |
90 base::TimeDelta::FromMilliseconds(10), 255, false, &output)) { | 91 base::TimeDelta::FromMilliseconds(10), 255, false, &new_volume, |
| 92 &output)) { |
91 EXPECT_TRUE(output != NULL); | 93 EXPECT_TRUE(output != NULL); |
92 EXPECT_EQ(audio_processor->OutputFormat().sample_rate(), | 94 EXPECT_EQ(audio_processor->OutputFormat().sample_rate(), |
93 expected_output_sample_rate); | 95 expected_output_sample_rate); |
94 EXPECT_EQ(audio_processor->OutputFormat().channels(), | 96 EXPECT_EQ(audio_processor->OutputFormat().channels(), |
95 expected_output_channels); | 97 expected_output_channels); |
96 EXPECT_EQ(audio_processor->OutputFormat().frames_per_buffer(), | 98 EXPECT_EQ(audio_processor->OutputFormat().frames_per_buffer(), |
97 expected_output_buffer_size); | 99 expected_output_buffer_size); |
98 } | 100 } |
99 | 101 |
100 data_ptr += params_.frames_per_buffer() * params_.channels(); | 102 data_ptr += params_.frames_per_buffer() * params_.channels(); |
101 } | 103 } |
102 } | 104 } |
103 | 105 |
| 106 void VerifyDefaultComponents(MediaStreamAudioProcessor* audio_processor) { |
| 107 webrtc::AudioProcessing* audio_processing = |
| 108 audio_processor->audio_processing_.get(); |
| 109 #if defined(OS_ANDROID) |
| 110 EXPECT_TRUE(audio_processing->echo_control_mobile()->is_enabled()); |
| 111 EXPECT_TRUE(audio_processing->echo_control_mobile()->routing_mode() == |
| 112 webrtc::EchoControlMobile::kSpeakerphone); |
| 113 EXPECT_FALSE(audio_processing->echo_cancellation()->is_enabled()); |
| 114 #elif !defined(OS_IOS) |
| 115 EXPECT_TRUE(audio_processing->echo_cancellation()->is_enabled()); |
| 116 EXPECT_TRUE(audio_processing->echo_cancellation()->suppression_level() == |
| 117 webrtc::EchoCancellation::kHighSuppression); |
| 118 EXPECT_TRUE(audio_processing->echo_cancellation()->are_metrics_enabled()); |
| 119 EXPECT_TRUE( |
| 120 audio_processing->echo_cancellation()->is_delay_logging_enabled()); |
| 121 #endif |
| 122 |
| 123 EXPECT_TRUE(audio_processing->noise_suppression()->is_enabled()); |
| 124 EXPECT_TRUE(audio_processing->noise_suppression()->level() == |
| 125 webrtc::NoiseSuppression::kHigh); |
| 126 EXPECT_TRUE(audio_processing->high_pass_filter()->is_enabled()); |
| 127 EXPECT_TRUE(audio_processing->gain_control()->is_enabled()); |
| 128 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 129 EXPECT_TRUE(audio_processing->gain_control()->mode() == |
| 130 webrtc::GainControl::kFixedDigital); |
| 131 EXPECT_FALSE(audio_processing->voice_detection()->is_enabled()); |
| 132 #else |
| 133 EXPECT_TRUE(audio_processing->gain_control()->mode() == |
| 134 webrtc::GainControl::kAdaptiveAnalog); |
| 135 EXPECT_TRUE(audio_processing->voice_detection()->is_enabled()); |
| 136 EXPECT_TRUE(audio_processing->voice_detection()->likelihood() == |
| 137 webrtc::VoiceDetection::kVeryLowLikelihood); |
| 138 #endif |
| 139 } |
| 140 |
104 media::AudioParameters params_; | 141 media::AudioParameters params_; |
105 }; | 142 }; |
106 | 143 |
107 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { | 144 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { |
108 // Setup the audio processor without enabling the flag. | 145 // Setup the audio processor without enabling the flag. |
109 blink::WebMediaConstraints constraints; | 146 blink::WebMediaConstraints constraints; |
110 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 147 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
111 new MediaStreamAudioProcessor(params_, constraints, 0)); | 148 new MediaStreamAudioProcessor(params_, constraints, 0)); |
112 EXPECT_FALSE(audio_processor->has_audio_processing()); | 149 EXPECT_FALSE(audio_processor->has_audio_processing()); |
113 | 150 |
114 ProcessDataAndVerifyFormat(audio_processor, | 151 ProcessDataAndVerifyFormat(audio_processor, |
115 params_.sample_rate(), | 152 params_.sample_rate(), |
116 params_.channels(), | 153 params_.channels(), |
117 params_.sample_rate() / 100); | 154 params_.sample_rate() / 100); |
118 } | 155 } |
119 | 156 |
120 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { | 157 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { |
121 // Setup the audio processor with enabling the flag. | 158 // Setup the audio processor with enabling the flag. |
122 CommandLine::ForCurrentProcess()->AppendSwitch( | 159 CommandLine::ForCurrentProcess()->AppendSwitch( |
123 switches::kEnableAudioTrackProcessing); | 160 switches::kEnableAudioTrackProcessing); |
124 blink::WebMediaConstraints constraints; | 161 blink::WebMediaConstraints constraints; |
125 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 162 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
126 new MediaStreamAudioProcessor(params_, constraints, 0)); | 163 new MediaStreamAudioProcessor(params_, constraints, 0)); |
127 EXPECT_TRUE(audio_processor->has_audio_processing()); | 164 EXPECT_TRUE(audio_processor->has_audio_processing()); |
| 165 VerifyDefaultComponents(audio_processor); |
128 | 166 |
129 ProcessDataAndVerifyFormat(audio_processor, | 167 ProcessDataAndVerifyFormat(audio_processor, |
130 kAudioProcessingSampleRate, | 168 kAudioProcessingSampleRate, |
131 kAudioProcessingNumberOfChannel, | 169 kAudioProcessingNumberOfChannel, |
132 kAudioProcessingSampleRate / 100); | 170 kAudioProcessingSampleRate / 100); |
133 } | 171 } |
134 | 172 |
135 } // namespace content | 173 } // namespace content |
OLD | NEW |