Chromium Code Reviews| 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 params_, constraints, 0, webrtc_audio_device.get())); | 160 params_, 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 | 163 | 
| 162 ProcessDataAndVerifyFormat(audio_processor, | 164 ProcessDataAndVerifyFormat(audio_processor, | 
| 163 params_.sample_rate(), | 165 params_.sample_rate(), | 
| 164 params_.channels(), | 166 params_.channels(), | 
| 165 params_.sample_rate() / 100); | 167 params_.sample_rate() / 100); | 
| 166 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives | 168 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives | 
| 167 // |audio_processor|. | 169 // |audio_processor|. | 
| 168 audio_processor = NULL; | 170 audio_processor = NULL; | 
| 169 } | 171 } | 
| 170 | 172 | 
| 171 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { | 173 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { | 
| 172 // Setup the audio processor with enabling the flag. | 174 // Setup the audio processor with enabling the flag. | 
| 173 CommandLine::ForCurrentProcess()->AppendSwitch( | 175 CommandLine::ForCurrentProcess()->AppendSwitch( | 
| 174 switches::kEnableAudioTrackProcessing); | 176 switches::kEnableAudioTrackProcessing); | 
| 175 blink::WebMediaConstraints constraints; | 177 blink::WebMediaConstraints constraints; | 
| 176 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 178 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 
| 177 new WebRtcAudioDeviceImpl()); | 179 new WebRtcAudioDeviceImpl()); | 
| 178 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 180 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 
| 179 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 181 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 
| 180 params_, constraints, 0, webrtc_audio_device.get())); | 182 params_, constraints, 0, MEDIA_DEVICE_AUDIO_CAPTURE, | 
| 183 webrtc_audio_device.get())); | |
| 181 EXPECT_TRUE(audio_processor->has_audio_processing()); | 184 EXPECT_TRUE(audio_processor->has_audio_processing()); | 
| 182 VerifyDefaultComponents(audio_processor); | 185 VerifyDefaultComponents(audio_processor); | 
| 183 | 186 | 
| 184 ProcessDataAndVerifyFormat(audio_processor, | 187 ProcessDataAndVerifyFormat(audio_processor, | 
| 185 kAudioProcessingSampleRate, | 188 kAudioProcessingSampleRate, | 
| 186 kAudioProcessingNumberOfChannel, | 189 kAudioProcessingNumberOfChannel, | 
| 187 kAudioProcessingSampleRate / 100); | 190 kAudioProcessingSampleRate / 100); | 
| 188 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives | 191 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives | 
| 189 // |audio_processor|. | 192 // |audio_processor|. | 
| 190 audio_processor = NULL; | 193 audio_processor = NULL; | 
| 191 } | 194 } | 
| 192 | 195 | 
| 196 TEST_F(MediaStreamAudioProcessorTest, VerifyCastWithoutAudioProcessing) { | |
| 
 
Alpha Left Google
2014/03/07 21:27:29
Should be VerifyTabCapture...
 
no longer working on chromium
2014/03/07 21:56:52
But we only verified MEDIA_LOOPBACK_AUDIO_CAPTURE
 
Alpha Left Google
2014/03/07 22:09:42
Cast is really using tab capture. This enum is for
 
no longer working on chromium
2014/03/09 15:12:57
Done.
 
 | |
| 197 // Setup the audio processor with enabling the flag. | |
| 198 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 199 switches::kEnableAudioTrackProcessing); | |
| 200 blink::WebMediaConstraints constraints; | |
| 201 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | |
| 202 new WebRtcAudioDeviceImpl()); | |
| 203 // Create MediaStreamAudioProcessor instance for MEDIA_TAB_AUDIO_CAPTURE type. | |
| 204 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | |
| 205 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | |
| 206 params_, constraints, 0, MEDIA_TAB_AUDIO_CAPTURE, | |
| 207 webrtc_audio_device.get())); | |
| 208 EXPECT_FALSE(audio_processor->has_audio_processing()); | |
| 209 | |
| 210 ProcessDataAndVerifyFormat(audio_processor, | |
| 211 params_.sample_rate(), | |
| 212 params_.channels(), | |
| 213 params_.sample_rate() / 100); | |
| 214 | |
| 215 // Create MediaStreamAudioProcessor instance for MEDIA_LOOPBACK_AUDIO_CAPTURE. | |
| 216 audio_processor = | |
| 217 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | |
| 218 params_, constraints, 0, MEDIA_LOOPBACK_AUDIO_CAPTURE, | |
| 219 webrtc_audio_device.get()); | |
| 220 EXPECT_FALSE(audio_processor->has_audio_processing()); | |
| 221 | |
| 222 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives | |
| 223 // |audio_processor|. | |
| 224 audio_processor = NULL; | |
| 225 } | |
| 226 | |
| 193 } // namespace content | 227 } // namespace content | 
| OLD | NEW |