| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 media::AudioParameters params_; | 163 media::AudioParameters params_; |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 } // namespace | 166 } // namespace |
| 167 | 167 |
| 168 class WebRtcLocalAudioTrackTest : public ::testing::Test { | 168 class WebRtcLocalAudioTrackTest : public ::testing::Test { |
| 169 protected: | 169 protected: |
| 170 virtual void SetUp() OVERRIDE { | 170 virtual void SetUp() OVERRIDE { |
| 171 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 171 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 172 media::CHANNEL_LAYOUT_STEREO, 2, 0, 48000, 16, 480); | 172 media::CHANNEL_LAYOUT_STEREO, 2, 0, 48000, 16, 480); |
| 173 blink::WebMediaConstraints constraints; | 173 MockMediaConstraintFactory constraint_factory; |
| 174 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, | 174 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, |
| 175 std::string(), std::string()); | 175 std::string(), std::string()); |
| 176 capturer_ = WebRtcAudioCapturer::CreateCapturer(-1, device, | 176 capturer_ = WebRtcAudioCapturer::CreateCapturer( |
| 177 constraints, NULL); | 177 -1, device, constraint_factory.CreateWebMediaConstraints(), NULL); |
| 178 capturer_source_ = new MockCapturerSource(capturer_.get()); | 178 capturer_source_ = new MockCapturerSource(capturer_.get()); |
| 179 EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), -1)) | 179 EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), -1)) |
| 180 .WillOnce(Return()); | 180 .WillOnce(Return()); |
| 181 capturer_->SetCapturerSourceForTesting(capturer_source_, params_); | 181 capturer_->SetCapturerSourceForTesting(capturer_source_, params_); |
| 182 } | 182 } |
| 183 | 183 |
| 184 media::AudioParameters params_; | 184 media::AudioParameters params_; |
| 185 scoped_refptr<MockCapturerSource> capturer_source_; | 185 scoped_refptr<MockCapturerSource> capturer_source_; |
| 186 scoped_refptr<WebRtcAudioCapturer> capturer_; | 186 scoped_refptr<WebRtcAudioCapturer> capturer_; |
| 187 }; | 187 }; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 // Verify the data flow by connecting the |sink_1| to |track_1|. | 437 // Verify the data flow by connecting the |sink_1| to |track_1|. |
| 438 scoped_ptr<MockMediaStreamAudioSink> sink_1(new MockMediaStreamAudioSink()); | 438 scoped_ptr<MockMediaStreamAudioSink> sink_1(new MockMediaStreamAudioSink()); |
| 439 EXPECT_CALL(*sink_1.get(), | 439 EXPECT_CALL(*sink_1.get(), |
| 440 CaptureData(kNumberOfNetworkChannelsForTrack1, | 440 CaptureData(kNumberOfNetworkChannelsForTrack1, |
| 441 0, 0, _, false)) | 441 0, 0, _, false)) |
| 442 .Times(AnyNumber()).WillRepeatedly(Return()); | 442 .Times(AnyNumber()).WillRepeatedly(Return()); |
| 443 EXPECT_CALL(*sink_1.get(), FormatIsSet()).Times(AnyNumber()); | 443 EXPECT_CALL(*sink_1.get(), FormatIsSet()).Times(AnyNumber()); |
| 444 track_1->AddSink(sink_1.get()); | 444 track_1->AddSink(sink_1.get()); |
| 445 | 445 |
| 446 // Create a new capturer with new source with different audio format. | 446 // Create a new capturer with new source with different audio format. |
| 447 blink::WebMediaConstraints constraints; | 447 MockMediaConstraintFactory constraint_factory; |
| 448 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, | 448 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, |
| 449 std::string(), std::string()); | 449 std::string(), std::string()); |
| 450 scoped_refptr<WebRtcAudioCapturer> new_capturer( | 450 scoped_refptr<WebRtcAudioCapturer> new_capturer( |
| 451 WebRtcAudioCapturer::CreateCapturer(-1, device, constraints, NULL)); | 451 WebRtcAudioCapturer::CreateCapturer( |
| 452 -1, device, constraint_factory.CreateWebMediaConstraints(), NULL)); |
| 452 scoped_refptr<MockCapturerSource> new_source( | 453 scoped_refptr<MockCapturerSource> new_source( |
| 453 new MockCapturerSource(new_capturer.get())); | 454 new MockCapturerSource(new_capturer.get())); |
| 454 EXPECT_CALL(*new_source.get(), OnInitialize(_, new_capturer.get(), -1)); | 455 EXPECT_CALL(*new_source.get(), OnInitialize(_, new_capturer.get(), -1)); |
| 455 media::AudioParameters new_param( | 456 media::AudioParameters new_param( |
| 456 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 457 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 457 media::CHANNEL_LAYOUT_MONO, 44100, 16, 441); | 458 media::CHANNEL_LAYOUT_MONO, 44100, 16, 441); |
| 458 new_capturer->SetCapturerSourceForTesting(new_source, new_param); | 459 new_capturer->SetCapturerSourceForTesting(new_source, new_param); |
| 459 | 460 |
| 460 // Setup the second audio track, connect it to the new capturer and start it. | 461 // Setup the second audio track, connect it to the new capturer and start it. |
| 461 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true)); | 462 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 track->AddSink(sink.get()); | 549 track->AddSink(sink.get()); |
| 549 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); | 550 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); |
| 550 EXPECT_EQ(expected_buffer_size, sink->audio_params().frames_per_buffer()); | 551 EXPECT_EQ(expected_buffer_size, sink->audio_params().frames_per_buffer()); |
| 551 | 552 |
| 552 // Stopping the new source will stop the second track. | 553 // Stopping the new source will stop the second track. |
| 553 EXPECT_CALL(*source, OnStop()).Times(1); | 554 EXPECT_CALL(*source, OnStop()).Times(1); |
| 554 capturer->Stop(); | 555 capturer->Stop(); |
| 555 } | 556 } |
| 556 | 557 |
| 557 } // namespace content | 558 } // namespace content |
| OLD | NEW |