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/synchronization/waitable_event.h" | 5 #include "base/synchronization/waitable_event.h" |
6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
7 #include "content/renderer/media/mock_media_constraint_factory.h" | 7 #include "content/renderer/media/mock_media_constraint_factory.h" |
8 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 8 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
9 #include "content/renderer/media/webrtc_audio_capturer.h" | 9 #include "content/renderer/media/webrtc_audio_capturer.h" |
10 #include "content/renderer/media/webrtc_audio_device_impl.h" | 10 #include "content/renderer/media/webrtc_audio_device_impl.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 media::AudioParameters params_; | 162 media::AudioParameters params_; |
163 }; | 163 }; |
164 | 164 |
165 } // namespace | 165 } // namespace |
166 | 166 |
167 class WebRtcLocalAudioTrackTest : public ::testing::Test { | 167 class WebRtcLocalAudioTrackTest : public ::testing::Test { |
168 protected: | 168 protected: |
169 virtual void SetUp() OVERRIDE { | 169 virtual void SetUp() OVERRIDE { |
170 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 170 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
171 media::CHANNEL_LAYOUT_STEREO, 2, 0, 48000, 16, 480); | 171 media::CHANNEL_LAYOUT_STEREO, 2, 0, 48000, 16, 480); |
172 blink::WebMediaConstraints constraints; | 172 MockMediaConstraintFactory constraint_factory; |
173 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, | 173 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, |
174 std::string(), std::string()); | 174 std::string(), std::string()); |
175 capturer_ = WebRtcAudioCapturer::CreateCapturer(-1, device, | 175 capturer_ = WebRtcAudioCapturer::CreateCapturer( |
176 constraints, NULL); | 176 -1, device, constraint_factory.CreateWebMediaConstraints(), NULL); |
177 capturer_source_ = new MockCapturerSource(capturer_.get()); | 177 capturer_source_ = new MockCapturerSource(capturer_.get()); |
178 EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), -1)) | 178 EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), -1)) |
179 .WillOnce(Return()); | 179 .WillOnce(Return()); |
180 capturer_->SetCapturerSourceForTesting(capturer_source_, params_); | 180 capturer_->SetCapturerSourceForTesting(capturer_source_, params_); |
181 } | 181 } |
182 | 182 |
183 media::AudioParameters params_; | 183 media::AudioParameters params_; |
184 scoped_refptr<MockCapturerSource> capturer_source_; | 184 scoped_refptr<MockCapturerSource> capturer_source_; |
185 scoped_refptr<WebRtcAudioCapturer> capturer_; | 185 scoped_refptr<WebRtcAudioCapturer> capturer_; |
186 }; | 186 }; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 // Verify the data flow by connecting the |sink_1| to |track_1|. | 420 // Verify the data flow by connecting the |sink_1| to |track_1|. |
421 scoped_ptr<MockMediaStreamAudioSink> sink_1(new MockMediaStreamAudioSink()); | 421 scoped_ptr<MockMediaStreamAudioSink> sink_1(new MockMediaStreamAudioSink()); |
422 EXPECT_CALL(*sink_1.get(), | 422 EXPECT_CALL(*sink_1.get(), |
423 CaptureData(kNumberOfNetworkChannelsForTrack1, | 423 CaptureData(kNumberOfNetworkChannelsForTrack1, |
424 0, 0, _, false)) | 424 0, 0, _, false)) |
425 .Times(AnyNumber()).WillRepeatedly(Return()); | 425 .Times(AnyNumber()).WillRepeatedly(Return()); |
426 EXPECT_CALL(*sink_1.get(), FormatIsSet()).Times(AnyNumber()); | 426 EXPECT_CALL(*sink_1.get(), FormatIsSet()).Times(AnyNumber()); |
427 track_1->AddSink(sink_1.get()); | 427 track_1->AddSink(sink_1.get()); |
428 | 428 |
429 // Create a new capturer with new source with different audio format. | 429 // Create a new capturer with new source with different audio format. |
430 blink::WebMediaConstraints constraints; | 430 MockMediaConstraintFactory constraint_factory; |
431 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, | 431 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, |
432 std::string(), std::string()); | 432 std::string(), std::string()); |
433 scoped_refptr<WebRtcAudioCapturer> new_capturer( | 433 scoped_refptr<WebRtcAudioCapturer> new_capturer( |
434 WebRtcAudioCapturer::CreateCapturer(-1, device, constraints, NULL)); | 434 WebRtcAudioCapturer::CreateCapturer( |
| 435 -1, device, constraint_factory.CreateWebMediaConstraints(), NULL)); |
435 scoped_refptr<MockCapturerSource> new_source( | 436 scoped_refptr<MockCapturerSource> new_source( |
436 new MockCapturerSource(new_capturer.get())); | 437 new MockCapturerSource(new_capturer.get())); |
437 EXPECT_CALL(*new_source.get(), OnInitialize(_, new_capturer.get(), -1)); | 438 EXPECT_CALL(*new_source.get(), OnInitialize(_, new_capturer.get(), -1)); |
438 media::AudioParameters new_param( | 439 media::AudioParameters new_param( |
439 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 440 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
440 media::CHANNEL_LAYOUT_MONO, 44100, 16, 441); | 441 media::CHANNEL_LAYOUT_MONO, 44100, 16, 441); |
441 new_capturer->SetCapturerSourceForTesting(new_source, new_param); | 442 new_capturer->SetCapturerSourceForTesting(new_source, new_param); |
442 | 443 |
443 // Setup the second audio track, connect it to the new capturer and start it. | 444 // Setup the second audio track, connect it to the new capturer and start it. |
444 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true)); | 445 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true)); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 track->AddSink(sink.get()); | 528 track->AddSink(sink.get()); |
528 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); | 529 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); |
529 EXPECT_EQ(expected_buffer_size, sink->audio_params().frames_per_buffer()); | 530 EXPECT_EQ(expected_buffer_size, sink->audio_params().frames_per_buffer()); |
530 | 531 |
531 // Stopping the new source will stop the second track. | 532 // Stopping the new source will stop the second track. |
532 EXPECT_CALL(*source, OnStop()).Times(1); | 533 EXPECT_CALL(*source, OnStop()).Times(1); |
533 capturer->Stop(); | 534 capturer->Stop(); |
534 } | 535 } |
535 | 536 |
536 } // namespace content | 537 } // namespace content |
OLD | NEW |