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

Unified Diff: content/renderer/media/webrtc_local_audio_track_unittest.cc

Issue 133903004: Cleaned up the WebRtcAudioCapturer a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Per's comments. Created 6 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/webrtc_local_audio_track_unittest.cc
diff --git a/content/renderer/media/webrtc_local_audio_track_unittest.cc b/content/renderer/media/webrtc_local_audio_track_unittest.cc
index a43577669d60216760bf48ff3b14fc16d86952b8..3eebdf82eee2775e2567fd4e6d1a70ba3b17ca3e 100644
--- a/content/renderer/media/webrtc_local_audio_track_unittest.cc
+++ b/content/renderer/media/webrtc_local_audio_track_unittest.cc
@@ -162,14 +162,12 @@ class WebRtcLocalAudioTrackTest : public ::testing::Test {
virtual void SetUp() OVERRIDE {
params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
media::CHANNEL_LAYOUT_STEREO, 2, 0, 48000, 16, 480);
- capturer_ = WebRtcAudioCapturer::CreateCapturer();
+ capturer_ = WebRtcAudioCapturer::CreateCapturer(-1, StreamDeviceInfo(),
+ NULL);
capturer_source_ = new MockCapturerSource(capturer_.get());
- EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), 0))
+ EXPECT_CALL(*capturer_source_.get(), OnInitialize(_, capturer_.get(), -1))
.WillOnce(Return());
- capturer_->SetCapturerSource(capturer_source_,
- params_.channel_layout(),
- params_.sample_rate(),
- params_.effects());
+ capturer_->SetCapturerSourceForTesting(capturer_source_, params_);
}
media::AudioParameters params_;
@@ -456,13 +454,10 @@ TEST_F(WebRtcLocalAudioTrackTest, SetNewSourceForCapturerAfterStartTrack) {
new MockCapturerSource(capturer_.get()));
EXPECT_CALL(*capturer_source_.get(), OnStop());
EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true));
- EXPECT_CALL(*new_source.get(), OnInitialize(_, capturer_.get(), 0))
+ EXPECT_CALL(*new_source.get(), OnInitialize(_, capturer_.get(), -1))
.WillOnce(Return());
EXPECT_CALL(*new_source.get(), OnStart());
- capturer_->SetCapturerSource(new_source,
- params_.channel_layout(),
- params_.sample_rate(),
- params_.effects());
+ capturer_->SetCapturerSourceForTesting(new_source, params_);
// Stop the track.
EXPECT_CALL(*new_source.get(), OnStop());
@@ -500,14 +495,14 @@ TEST_F(WebRtcLocalAudioTrackTest, ConnectTracksToDifferentCapturers) {
// Create a new capturer with new source with different audio format.
scoped_refptr<WebRtcAudioCapturer> new_capturer(
- WebRtcAudioCapturer::CreateCapturer());
+ WebRtcAudioCapturer::CreateCapturer(-1, StreamDeviceInfo(), NULL));
scoped_refptr<MockCapturerSource> new_source(
new MockCapturerSource(new_capturer.get()));
- EXPECT_CALL(*new_source.get(), OnInitialize(_, new_capturer.get(), 0));
- new_capturer->SetCapturerSource(new_source,
- media::CHANNEL_LAYOUT_MONO,
- 44100,
- media::AudioParameters::NO_EFFECTS);
+ EXPECT_CALL(*new_source.get(), OnInitialize(_, new_capturer.get(), -1));
+ media::AudioParameters new_param(
+ media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
+ media::CHANNEL_LAYOUT_MONO, 44100, 16, 441);
+ new_capturer->SetCapturerSourceForTesting(new_source, new_param);
// Setup the second audio track, connect it to the new capturer and start it.
EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(true));
@@ -531,7 +526,8 @@ TEST_F(WebRtcLocalAudioTrackTest, ConnectTracksToDifferentCapturers) {
EXPECT_CALL(
*sink_2,
CaptureData(
- kNumberOfNetworkChannelsForTrack2, 44100, 1, _, 0, 0, false, false))
+ kNumberOfNetworkChannelsForTrack2, new_param.sample_rate(),
+ new_param.channels(), _, 0, 0, false, false))
.Times(AnyNumber()).WillRepeatedly(Return());
EXPECT_CALL(*sink_2, OnSetFormat(_)).WillOnce(SignalEvent(&event));
track_2->AddSink(sink_2.get());
@@ -559,16 +555,17 @@ TEST_F(WebRtcLocalAudioTrackTest, TrackWorkWithSmallBufferSize) {
// Create a capturer with new source which works with the format above.
scoped_refptr<WebRtcAudioCapturer> capturer(
- WebRtcAudioCapturer::CreateCapturer());
+ WebRtcAudioCapturer::CreateCapturer(
+ -1,
+ StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE,
+ "", "", params.sample_rate(),
+ params.channel_layout(),
+ params.frames_per_buffer()),
+ NULL));
scoped_refptr<MockCapturerSource> source(
new MockCapturerSource(capturer.get()));
- capturer->Initialize(-1, params.channel_layout(), params.sample_rate(),
- params.frames_per_buffer(), 0, std::string(), 0, 0,
- params.effects());
-
- EXPECT_CALL(*source.get(), OnInitialize(_, capturer.get(), 0));
- capturer->SetCapturerSource(source, params.channel_layout(),
- params.sample_rate(), params.effects());
+ EXPECT_CALL(*source.get(), OnInitialize(_, capturer.get(), -1));
+ capturer->SetCapturerSourceForTesting(source, params);
// Setup a audio track, connect it to the capturer and start it.
EXPECT_CALL(*source.get(), SetAutomaticGainControl(true));

Powered by Google App Engine
This is Rietveld 408576698