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" |
11 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/common/media_stream_request.h" |
12 #include "content/renderer/media/media_stream_audio_processor.h" | 13 #include "content/renderer/media/media_stream_audio_processor.h" |
13 #include "media/audio/audio_parameters.h" | 14 #include "media/audio/audio_parameters.h" |
14 #include "media/base/audio_bus.h" | 15 #include "media/base/audio_bus.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 18 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
18 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 19 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
19 | 20 |
20 using ::testing::_; | 21 using ::testing::_; |
21 using ::testing::AnyNumber; | 22 using ::testing::AnyNumber; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 media::AudioParameters params_; | 150 media::AudioParameters params_; |
150 }; | 151 }; |
151 | 152 |
152 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { | 153 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { |
153 // Setup the audio processor without enabling the flag. | 154 // Setup the audio processor without enabling the flag. |
154 blink::WebMediaConstraints constraints; | 155 blink::WebMediaConstraints constraints; |
155 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 156 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
156 new WebRtcAudioDeviceImpl()); | 157 new WebRtcAudioDeviceImpl()); |
157 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 158 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
158 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 159 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
159 constraints, 0, webrtc_audio_device.get())); | 160 constraints, 0, MEDIA_DEVICE_AUDIO_CAPTURE, |
| 161 webrtc_audio_device.get())); |
160 EXPECT_FALSE(audio_processor->has_audio_processing()); | 162 EXPECT_FALSE(audio_processor->has_audio_processing()); |
161 audio_processor->OnCaptureFormatChanged(params_); | 163 audio_processor->OnCaptureFormatChanged(params_); |
162 | 164 |
163 ProcessDataAndVerifyFormat(audio_processor, | 165 ProcessDataAndVerifyFormat(audio_processor, |
164 params_.sample_rate(), | 166 params_.sample_rate(), |
165 params_.channels(), | 167 params_.channels(), |
166 params_.sample_rate() / 100); | 168 params_.sample_rate() / 100); |
167 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives | 169 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives |
168 // |audio_processor|. | 170 // |audio_processor|. |
169 audio_processor = NULL; | 171 audio_processor = NULL; |
170 } | 172 } |
171 | 173 |
172 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { | 174 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { |
173 // Setup the audio processor with enabling the flag. | 175 // Setup the audio processor with enabling the flag. |
174 CommandLine::ForCurrentProcess()->AppendSwitch( | 176 CommandLine::ForCurrentProcess()->AppendSwitch( |
175 switches::kEnableAudioTrackProcessing); | 177 switches::kEnableAudioTrackProcessing); |
176 blink::WebMediaConstraints constraints; | 178 blink::WebMediaConstraints constraints; |
177 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 179 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
178 new WebRtcAudioDeviceImpl()); | 180 new WebRtcAudioDeviceImpl()); |
179 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 181 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
180 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 182 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
181 constraints, 0, webrtc_audio_device.get())); | 183 constraints, 0, MEDIA_DEVICE_AUDIO_CAPTURE, |
| 184 webrtc_audio_device.get())); |
182 EXPECT_TRUE(audio_processor->has_audio_processing()); | 185 EXPECT_TRUE(audio_processor->has_audio_processing()); |
183 audio_processor->OnCaptureFormatChanged(params_); | 186 audio_processor->OnCaptureFormatChanged(params_); |
184 VerifyDefaultComponents(audio_processor); | 187 VerifyDefaultComponents(audio_processor); |
185 | 188 |
186 ProcessDataAndVerifyFormat(audio_processor, | 189 ProcessDataAndVerifyFormat(audio_processor, |
187 kAudioProcessingSampleRate, | 190 kAudioProcessingSampleRate, |
188 kAudioProcessingNumberOfChannel, | 191 kAudioProcessingNumberOfChannel, |
189 kAudioProcessingSampleRate / 100); | 192 kAudioProcessingSampleRate / 100); |
190 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives | 193 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives |
191 // |audio_processor|. | 194 // |audio_processor|. |
192 audio_processor = NULL; | 195 audio_processor = NULL; |
193 } | 196 } |
194 | 197 |
| 198 TEST_F(MediaStreamAudioProcessorTest, VerifyTabCaptureWithoutAudioProcessing) { |
| 199 // Setup the audio processor with enabling the flag. |
| 200 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 201 switches::kEnableAudioTrackProcessing); |
| 202 blink::WebMediaConstraints constraints; |
| 203 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
| 204 new WebRtcAudioDeviceImpl()); |
| 205 // Create MediaStreamAudioProcessor instance for MEDIA_TAB_AUDIO_CAPTURE type. |
| 206 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
| 207 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
| 208 constraints, 0, MEDIA_TAB_AUDIO_CAPTURE, |
| 209 webrtc_audio_device.get())); |
| 210 EXPECT_FALSE(audio_processor->has_audio_processing()); |
| 211 audio_processor->OnCaptureFormatChanged(params_); |
| 212 |
| 213 ProcessDataAndVerifyFormat(audio_processor, |
| 214 params_.sample_rate(), |
| 215 params_.channels(), |
| 216 params_.sample_rate() / 100); |
| 217 |
| 218 // Create MediaStreamAudioProcessor instance for MEDIA_LOOPBACK_AUDIO_CAPTURE. |
| 219 audio_processor = |
| 220 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
| 221 constraints, 0, MEDIA_LOOPBACK_AUDIO_CAPTURE, |
| 222 webrtc_audio_device.get()); |
| 223 EXPECT_FALSE(audio_processor->has_audio_processing()); |
| 224 |
| 225 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives |
| 226 // |audio_processor|. |
| 227 audio_processor = NULL; |
| 228 } |
| 229 |
195 } // namespace content | 230 } // namespace content |
OLD | NEW |