Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: trunk/src/content/renderer/media/webrtc_local_audio_track_unittest.cc

Issue 110303003: Revert 240548 "Enable platform echo cancellation through the Aud..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/rtc_media_constraints.h" 7 #include "content/renderer/media/rtc_media_constraints.h"
8 #include "content/renderer/media/webrtc_audio_capturer.h" 8 #include "content/renderer/media/webrtc_audio_capturer.h"
9 #include "content/renderer/media/webrtc_audio_device_impl.h" 9 #include "content/renderer/media/webrtc_audio_device_impl.h"
10 #include "content/renderer/media/webrtc_local_audio_source_provider.h" 10 #include "content/renderer/media/webrtc_local_audio_source_provider.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 protected: 161 protected:
162 virtual void SetUp() OVERRIDE { 162 virtual void SetUp() OVERRIDE {
163 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 163 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
164 media::CHANNEL_LAYOUT_STEREO, 2, 0, 48000, 16, 480); 164 media::CHANNEL_LAYOUT_STEREO, 2, 0, 48000, 16, 480);
165 capturer_ = WebRtcAudioCapturer::CreateCapturer(); 165 capturer_ = WebRtcAudioCapturer::CreateCapturer();
166 capturer_source_ = new MockCapturerSource(capturer_.get()); 166 capturer_source_ = new MockCapturerSource(capturer_.get());
167 EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), 0)) 167 EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), 0))
168 .WillOnce(Return()); 168 .WillOnce(Return());
169 capturer_->SetCapturerSource(capturer_source_, 169 capturer_->SetCapturerSource(capturer_source_,
170 params_.channel_layout(), 170 params_.channel_layout(),
171 params_.sample_rate(), 171 params_.sample_rate());
172 params_.effects());
173 } 172 }
174 173
175 media::AudioParameters params_; 174 media::AudioParameters params_;
176 scoped_refptr<MockCapturerSource> capturer_source_; 175 scoped_refptr<MockCapturerSource> capturer_source_;
177 scoped_refptr<WebRtcAudioCapturer> capturer_; 176 scoped_refptr<WebRtcAudioCapturer> capturer_;
178 }; 177 };
179 178
180 // Creates a capturer and audio track, fakes its audio thread, and 179 // Creates a capturer and audio track, fakes its audio thread, and
181 // connect/disconnect the sink to the audio track on the fly, the sink should 180 // connect/disconnect the sink to the audio track on the fly, the sink should
182 // get data callback when the track is connected to the capturer but not when 181 // get data callback when the track is connected to the capturer but not when
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // Setting new source to the capturer and the track should still get packets. 453 // Setting new source to the capturer and the track should still get packets.
455 scoped_refptr<MockCapturerSource> new_source( 454 scoped_refptr<MockCapturerSource> new_source(
456 new MockCapturerSource(capturer_.get())); 455 new MockCapturerSource(capturer_.get()));
457 EXPECT_CALL(*capturer_source_.get(), OnStop()); 456 EXPECT_CALL(*capturer_source_.get(), OnStop());
458 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true)); 457 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true));
459 EXPECT_CALL(*new_source.get(), OnInitialize(_, capturer_.get(), 0)) 458 EXPECT_CALL(*new_source.get(), OnInitialize(_, capturer_.get(), 0))
460 .WillOnce(Return()); 459 .WillOnce(Return());
461 EXPECT_CALL(*new_source.get(), OnStart()); 460 EXPECT_CALL(*new_source.get(), OnStart());
462 capturer_->SetCapturerSource(new_source, 461 capturer_->SetCapturerSource(new_source,
463 params_.channel_layout(), 462 params_.channel_layout(),
464 params_.sample_rate(), 463 params_.sample_rate());
465 params_.effects());
466 464
467 // Stop the track. 465 // Stop the track.
468 EXPECT_CALL(*new_source.get(), OnStop()); 466 EXPECT_CALL(*new_source.get(), OnStop());
469 capturer_->Stop(); 467 capturer_->Stop();
470 } 468 }
471 469
472 // Create a new capturer with new source, connect it to a new audio track. 470 // Create a new capturer with new source, connect it to a new audio track.
473 TEST_F(WebRtcLocalAudioTrackTest, ConnectTracksToDifferentCapturers) { 471 TEST_F(WebRtcLocalAudioTrackTest, ConnectTracksToDifferentCapturers) {
474 // Setup the first audio track and start it. 472 // Setup the first audio track and start it.
475 EXPECT_CALL(*capturer_source_.get(), SetAutomaticGainControl(true)); 473 EXPECT_CALL(*capturer_source_.get(), SetAutomaticGainControl(true));
(...skipping 23 matching lines...) Expand all
499 track_1->AddSink(sink_1.get()); 497 track_1->AddSink(sink_1.get());
500 498
501 // Create a new capturer with new source with different audio format. 499 // Create a new capturer with new source with different audio format.
502 scoped_refptr<WebRtcAudioCapturer> new_capturer( 500 scoped_refptr<WebRtcAudioCapturer> new_capturer(
503 WebRtcAudioCapturer::CreateCapturer()); 501 WebRtcAudioCapturer::CreateCapturer());
504 scoped_refptr<MockCapturerSource> new_source( 502 scoped_refptr<MockCapturerSource> new_source(
505 new MockCapturerSource(new_capturer.get())); 503 new MockCapturerSource(new_capturer.get()));
506 EXPECT_CALL(*new_source.get(), OnInitialize(_, new_capturer.get(), 0)); 504 EXPECT_CALL(*new_source.get(), OnInitialize(_, new_capturer.get(), 0));
507 new_capturer->SetCapturerSource(new_source, 505 new_capturer->SetCapturerSource(new_source,
508 media::CHANNEL_LAYOUT_MONO, 506 media::CHANNEL_LAYOUT_MONO,
509 44100, 507 44100);
510 media::AudioParameters::NO_EFFECTS);
511 508
512 // Setup the second audio track, connect it to the new capturer and start it. 509 // Setup the second audio track, connect it to the new capturer and start it.
513 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true)); 510 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true));
514 EXPECT_CALL(*new_source.get(), OnStart()); 511 EXPECT_CALL(*new_source.get(), OnStart());
515 scoped_refptr<WebRtcLocalAudioTrack> track_2 = 512 scoped_refptr<WebRtcLocalAudioTrack> track_2 =
516 WebRtcLocalAudioTrack::Create(std::string(), new_capturer, NULL, NULL, 513 WebRtcLocalAudioTrack::Create(std::string(), new_capturer, NULL, NULL,
517 &constraints); 514 &constraints);
518 static_cast<WebRtcLocalAudioSourceProvider*>( 515 static_cast<WebRtcLocalAudioSourceProvider*>(
519 track_2->audio_source_provider())->SetSinkParamsForTesting(params_); 516 track_2->audio_source_provider())->SetSinkParamsForTesting(params_);
520 track_2->Start(); 517 track_2->Start();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 // Setup a capturer which works with a buffer size smaller than 10ms. 553 // Setup a capturer which works with a buffer size smaller than 10ms.
557 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 554 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
558 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 128); 555 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 128);
559 556
560 // Create a capturer with new source which works with the format above. 557 // Create a capturer with new source which works with the format above.
561 scoped_refptr<WebRtcAudioCapturer> capturer( 558 scoped_refptr<WebRtcAudioCapturer> capturer(
562 WebRtcAudioCapturer::CreateCapturer()); 559 WebRtcAudioCapturer::CreateCapturer());
563 scoped_refptr<MockCapturerSource> source( 560 scoped_refptr<MockCapturerSource> source(
564 new MockCapturerSource(capturer.get())); 561 new MockCapturerSource(capturer.get()));
565 capturer->Initialize(-1, params.channel_layout(), params.sample_rate(), 562 capturer->Initialize(-1, params.channel_layout(), params.sample_rate(),
566 params.frames_per_buffer(), 0, std::string(), 0, 0, 563 params.frames_per_buffer(), 0, std::string(), 0, 0);
567 params.effects());
568 564
569 EXPECT_CALL(*source.get(), OnInitialize(_, capturer.get(), 0)); 565 EXPECT_CALL(*source.get(), OnInitialize(_, capturer.get(), 0));
570 capturer->SetCapturerSource(source, params.channel_layout(), 566 capturer->SetCapturerSource(source, params.channel_layout(),
571 params.sample_rate(), params.effects()); 567 params.sample_rate());
572 568
573 // Setup a audio track, connect it to the capturer and start it. 569 // Setup a audio track, connect it to the capturer and start it.
574 EXPECT_CALL(*source.get(), SetAutomaticGainControl(true)); 570 EXPECT_CALL(*source.get(), SetAutomaticGainControl(true));
575 EXPECT_CALL(*source.get(), OnStart()); 571 EXPECT_CALL(*source.get(), OnStart());
576 RTCMediaConstraints constraints; 572 RTCMediaConstraints constraints;
577 scoped_refptr<WebRtcLocalAudioTrack> track = 573 scoped_refptr<WebRtcLocalAudioTrack> track =
578 WebRtcLocalAudioTrack::Create(std::string(), capturer, NULL, NULL, 574 WebRtcLocalAudioTrack::Create(std::string(), capturer, NULL, NULL,
579 &constraints); 575 &constraints);
580 static_cast<WebRtcLocalAudioSourceProvider*>( 576 static_cast<WebRtcLocalAudioSourceProvider*>(
581 track->audio_source_provider())->SetSinkParamsForTesting(params); 577 track->audio_source_provider())->SetSinkParamsForTesting(params);
(...skipping 15 matching lines...) Expand all
597 .Times(AtLeast(1)).WillRepeatedly(SignalEvent(&event)); 593 .Times(AtLeast(1)).WillRepeatedly(SignalEvent(&event));
598 track->AddSink(sink.get()); 594 track->AddSink(sink.get());
599 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); 595 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout()));
600 596
601 // Stopping the new source will stop the second track. 597 // Stopping the new source will stop the second track.
602 EXPECT_CALL(*source, OnStop()).Times(1); 598 EXPECT_CALL(*source, OnStop()).Times(1);
603 capturer->Stop(); 599 capturer->Stop();
604 } 600 }
605 601
606 } // namespace content 602 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698