| 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/public/renderer/media_stream_audio_sink.h" | 7 #include "content/public/renderer/media_stream_audio_sink.h" |
| 8 #include "content/renderer/media/media_stream_audio_source.h" | 8 #include "content/renderer/media/media_stream_audio_source.h" |
| 9 #include "content/renderer/media/mock_media_constraint_factory.h" | 9 #include "content/renderer/media/mock_media_constraint_factory.h" |
| 10 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 10 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 std::string(), std::string()); | 164 std::string(), std::string()); |
| 165 capturer_ = WebRtcAudioCapturer::CreateCapturer( | 165 capturer_ = WebRtcAudioCapturer::CreateCapturer( |
| 166 -1, device, constraint_factory.CreateWebMediaConstraints(), NULL, | 166 -1, device, constraint_factory.CreateWebMediaConstraints(), NULL, |
| 167 audio_source); | 167 audio_source); |
| 168 audio_source->SetAudioCapturer(capturer_.get()); | 168 audio_source->SetAudioCapturer(capturer_.get()); |
| 169 capturer_source_ = new MockCapturerSource(capturer_.get()); | 169 capturer_source_ = new MockCapturerSource(capturer_.get()); |
| 170 EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), -1)) | 170 EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), -1)) |
| 171 .WillOnce(Return()); | 171 .WillOnce(Return()); |
| 172 EXPECT_CALL(*capturer_source_.get(), SetAutomaticGainControl(true)); | 172 EXPECT_CALL(*capturer_source_.get(), SetAutomaticGainControl(true)); |
| 173 EXPECT_CALL(*capturer_source_.get(), OnStart()); | 173 EXPECT_CALL(*capturer_source_.get(), OnStart()); |
| 174 capturer_->SetCapturerSourceForTesting(capturer_source_, params_); | 174 capturer_->SetCapturerSource(capturer_source_, params_); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void TearDown() override { | 177 void TearDown() override { |
| 178 blink_source_.reset(); | 178 blink_source_.reset(); |
| 179 blink::WebHeap::collectAllGarbageForTesting(); | 179 blink::WebHeap::collectAllGarbageForTesting(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 media::AudioParameters params_; | 182 media::AudioParameters params_; |
| 183 blink::WebMediaStreamSource blink_source_; | 183 blink::WebMediaStreamSource blink_source_; |
| 184 scoped_refptr<MockCapturerSource> capturer_source_; | 184 scoped_refptr<MockCapturerSource> capturer_source_; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 NULL)); | 421 NULL)); |
| 422 scoped_refptr<MockCapturerSource> new_source( | 422 scoped_refptr<MockCapturerSource> new_source( |
| 423 new MockCapturerSource(new_capturer.get())); | 423 new MockCapturerSource(new_capturer.get())); |
| 424 EXPECT_CALL(*new_source.get(), OnInitialize(_, new_capturer.get(), -1)); | 424 EXPECT_CALL(*new_source.get(), OnInitialize(_, new_capturer.get(), -1)); |
| 425 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true)); | 425 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true)); |
| 426 EXPECT_CALL(*new_source.get(), OnStart()); | 426 EXPECT_CALL(*new_source.get(), OnStart()); |
| 427 | 427 |
| 428 media::AudioParameters new_param( | 428 media::AudioParameters new_param( |
| 429 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 429 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 430 media::CHANNEL_LAYOUT_MONO, 44100, 16, 441); | 430 media::CHANNEL_LAYOUT_MONO, 44100, 16, 441); |
| 431 new_capturer->SetCapturerSourceForTesting(new_source, new_param); | 431 new_capturer->SetCapturerSource(new_source, new_param); |
| 432 | 432 |
| 433 // Setup the second audio track, connect it to the new capturer and start it. | 433 // Setup the second audio track, connect it to the new capturer and start it. |
| 434 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter_2( | 434 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter_2( |
| 435 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL)); | 435 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL)); |
| 436 scoped_ptr<WebRtcLocalAudioTrack> track_2( | 436 scoped_ptr<WebRtcLocalAudioTrack> track_2( |
| 437 new WebRtcLocalAudioTrack(adapter_2.get(), new_capturer, NULL)); | 437 new WebRtcLocalAudioTrack(adapter_2.get(), new_capturer, NULL)); |
| 438 track_2->Start(); | 438 track_2->Start(); |
| 439 | 439 |
| 440 // Verify the data flow by connecting the |sink_2| to |track_2|. | 440 // Verify the data flow by connecting the |sink_2| to |track_2|. |
| 441 scoped_ptr<MockMediaStreamAudioSink> sink_2(new MockMediaStreamAudioSink()); | 441 scoped_ptr<MockMediaStreamAudioSink> sink_2(new MockMediaStreamAudioSink()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 "", "", params.sample_rate(), | 475 "", "", params.sample_rate(), |
| 476 params.channel_layout(), | 476 params.channel_layout(), |
| 477 params.frames_per_buffer()), | 477 params.frames_per_buffer()), |
| 478 factory.CreateWebMediaConstraints(), | 478 factory.CreateWebMediaConstraints(), |
| 479 NULL, NULL)); | 479 NULL, NULL)); |
| 480 scoped_refptr<MockCapturerSource> source( | 480 scoped_refptr<MockCapturerSource> source( |
| 481 new MockCapturerSource(capturer.get())); | 481 new MockCapturerSource(capturer.get())); |
| 482 EXPECT_CALL(*source.get(), OnInitialize(_, capturer.get(), -1)); | 482 EXPECT_CALL(*source.get(), OnInitialize(_, capturer.get(), -1)); |
| 483 EXPECT_CALL(*source.get(), SetAutomaticGainControl(true)); | 483 EXPECT_CALL(*source.get(), SetAutomaticGainControl(true)); |
| 484 EXPECT_CALL(*source.get(), OnStart()); | 484 EXPECT_CALL(*source.get(), OnStart()); |
| 485 capturer->SetCapturerSourceForTesting(source, params); | 485 capturer->SetCapturerSource(source, params); |
| 486 | 486 |
| 487 // Setup a audio track, connect it to the capturer and start it. | 487 // Setup a audio track, connect it to the capturer and start it. |
| 488 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter( | 488 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter( |
| 489 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL)); | 489 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL)); |
| 490 scoped_ptr<WebRtcLocalAudioTrack> track( | 490 scoped_ptr<WebRtcLocalAudioTrack> track( |
| 491 new WebRtcLocalAudioTrack(adapter.get(), capturer, NULL)); | 491 new WebRtcLocalAudioTrack(adapter.get(), capturer, NULL)); |
| 492 track->Start(); | 492 track->Start(); |
| 493 | 493 |
| 494 // Verify the data flow by connecting the |sink| to |track|. | 494 // Verify the data flow by connecting the |sink| to |track|. |
| 495 scoped_ptr<MockMediaStreamAudioSink> sink(new MockMediaStreamAudioSink()); | 495 scoped_ptr<MockMediaStreamAudioSink> sink(new MockMediaStreamAudioSink()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 510 // Stopping the new source will stop the second track. | 510 // Stopping the new source will stop the second track. |
| 511 EXPECT_CALL(*source.get(), OnStop()).Times(1); | 511 EXPECT_CALL(*source.get(), OnStop()).Times(1); |
| 512 capturer->Stop(); | 512 capturer->Stop(); |
| 513 | 513 |
| 514 // Even though this test don't use |capturer_source_| it will be stopped | 514 // Even though this test don't use |capturer_source_| it will be stopped |
| 515 // during teardown of the test harness. | 515 // during teardown of the test harness. |
| 516 EXPECT_CALL(*capturer_source_.get(), OnStop()); | 516 EXPECT_CALL(*capturer_source_.get(), OnStop()); |
| 517 } | 517 } |
| 518 | 518 |
| 519 } // namespace content | 519 } // namespace content |
| OLD | NEW |