| 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/rtc_media_constraints.h" |
| 7 #include "content/renderer/media/webrtc_audio_capturer.h" | 8 #include "content/renderer/media/webrtc_audio_capturer.h" |
| 8 #include "content/renderer/media/webrtc_local_audio_track.h" | 9 #include "content/renderer/media/webrtc_local_audio_track.h" |
| 9 #include "media/audio/audio_parameters.h" | 10 #include "media/audio/audio_parameters.h" |
| 10 #include "media/base/audio_bus.h" | 11 #include "media/base/audio_bus.h" |
| 11 #include "media/base/audio_capturer_source.h" | 12 #include "media/base/audio_capturer_source.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 15 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
| 15 | 16 |
| 16 using ::testing::_; | 17 using ::testing::_; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 scoped_refptr<WebRtcAudioCapturer> capturer_; | 158 scoped_refptr<WebRtcAudioCapturer> capturer_; |
| 158 scoped_ptr<FakeAudioThread> audio_thread_; | 159 scoped_ptr<FakeAudioThread> audio_thread_; |
| 159 }; | 160 }; |
| 160 | 161 |
| 161 // Creates a capturer and audio track, fakes its audio thread, and | 162 // Creates a capturer and audio track, fakes its audio thread, and |
| 162 // connect/disconnect the sink to the audio track on the fly, the sink should | 163 // connect/disconnect the sink to the audio track on the fly, the sink should |
| 163 // get data callback when the track is connected to the capturer but not when | 164 // get data callback when the track is connected to the capturer but not when |
| 164 // the track is disconnected from the capturer. | 165 // the track is disconnected from the capturer. |
| 165 TEST_F(WebRtcLocalAudioTrackTest, ConnectAndDisconnectOneSink) { | 166 TEST_F(WebRtcLocalAudioTrackTest, ConnectAndDisconnectOneSink) { |
| 166 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); | 167 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); |
| 168 RTCMediaConstraints constraints; |
| 167 scoped_refptr<WebRtcLocalAudioTrack> track = | 169 scoped_refptr<WebRtcLocalAudioTrack> track = |
| 168 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL); | 170 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, |
| 171 &constraints); |
| 169 track->Start(); | 172 track->Start(); |
| 170 EXPECT_TRUE(track->enabled()); | 173 EXPECT_TRUE(track->enabled()); |
| 171 | 174 |
| 172 // Connect a number of network channels to the audio track. | 175 // Connect a number of network channels to the audio track. |
| 173 static const int kNumberOfNetworkChannels = 4; | 176 static const int kNumberOfNetworkChannels = 4; |
| 174 for (int i = 0; i < kNumberOfNetworkChannels; ++i) { | 177 for (int i = 0; i < kNumberOfNetworkChannels; ++i) { |
| 175 static_cast<webrtc::AudioTrackInterface*>(track.get())-> | 178 static_cast<webrtc::AudioTrackInterface*>(track.get())-> |
| 176 GetRenderer()->AddChannel(i); | 179 GetRenderer()->AddChannel(i); |
| 177 } | 180 } |
| 178 scoped_ptr<MockWebRtcAudioCapturerSink> sink( | 181 scoped_ptr<MockWebRtcAudioCapturerSink> sink( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 201 } | 204 } |
| 202 | 205 |
| 203 // The same setup as ConnectAndDisconnectOneSink, but enable and disable the | 206 // The same setup as ConnectAndDisconnectOneSink, but enable and disable the |
| 204 // audio track on the fly. When the audio track is disabled, there is no data | 207 // audio track on the fly. When the audio track is disabled, there is no data |
| 205 // callback to the sink; when the audio track is enabled, there comes data | 208 // callback to the sink; when the audio track is enabled, there comes data |
| 206 // callback. | 209 // callback. |
| 207 // TODO(xians): Enable this test after resolving the racing issue that TSAN | 210 // TODO(xians): Enable this test after resolving the racing issue that TSAN |
| 208 // reports on MediaStreamTrack::enabled(); | 211 // reports on MediaStreamTrack::enabled(); |
| 209 TEST_F(WebRtcLocalAudioTrackTest, DISABLED_DisableEnableAudioTrack) { | 212 TEST_F(WebRtcLocalAudioTrackTest, DISABLED_DisableEnableAudioTrack) { |
| 210 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); | 213 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); |
| 214 RTCMediaConstraints constraints; |
| 211 scoped_refptr<WebRtcLocalAudioTrack> track = | 215 scoped_refptr<WebRtcLocalAudioTrack> track = |
| 212 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL); | 216 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, |
| 217 &constraints); |
| 213 track->Start(); | 218 track->Start(); |
| 214 static_cast<webrtc::AudioTrackInterface*>(track.get())-> | 219 static_cast<webrtc::AudioTrackInterface*>(track.get())-> |
| 215 GetRenderer()->AddChannel(0); | 220 GetRenderer()->AddChannel(0); |
| 216 EXPECT_TRUE(track->enabled()); | 221 EXPECT_TRUE(track->enabled()); |
| 217 EXPECT_TRUE(track->set_enabled(false)); | 222 EXPECT_TRUE(track->set_enabled(false)); |
| 218 scoped_ptr<MockWebRtcAudioCapturerSink> sink( | 223 scoped_ptr<MockWebRtcAudioCapturerSink> sink( |
| 219 new MockWebRtcAudioCapturerSink()); | 224 new MockWebRtcAudioCapturerSink()); |
| 220 const media::AudioParameters params = capturer_->audio_parameters(); | 225 const media::AudioParameters params = capturer_->audio_parameters(); |
| 221 base::WaitableEvent event(false, false); | 226 base::WaitableEvent event(false, false); |
| 222 EXPECT_CALL(*sink, SetCaptureFormat(_)).WillOnce(Return()); | 227 EXPECT_CALL(*sink, SetCaptureFormat(_)).WillOnce(Return()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 249 | 254 |
| 250 EXPECT_CALL(*capturer_source_.get(), Stop()).WillOnce(Return()); | 255 EXPECT_CALL(*capturer_source_.get(), Stop()).WillOnce(Return()); |
| 251 track->Stop(); | 256 track->Stop(); |
| 252 track = NULL; | 257 track = NULL; |
| 253 } | 258 } |
| 254 | 259 |
| 255 // Create multiple audio tracks and enable/disable them, verify that the audio | 260 // Create multiple audio tracks and enable/disable them, verify that the audio |
| 256 // callbacks appear/disappear. | 261 // callbacks appear/disappear. |
| 257 TEST_F(WebRtcLocalAudioTrackTest, MultipleAudioTracks) { | 262 TEST_F(WebRtcLocalAudioTrackTest, MultipleAudioTracks) { |
| 258 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); | 263 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); |
| 264 RTCMediaConstraints constraints; |
| 259 scoped_refptr<WebRtcLocalAudioTrack> track_1 = | 265 scoped_refptr<WebRtcLocalAudioTrack> track_1 = |
| 260 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL); | 266 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, |
| 267 &constraints); |
| 261 track_1->Start(); | 268 track_1->Start(); |
| 262 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> | 269 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> |
| 263 GetRenderer()->AddChannel(0); | 270 GetRenderer()->AddChannel(0); |
| 264 EXPECT_TRUE(track_1->enabled()); | 271 EXPECT_TRUE(track_1->enabled()); |
| 265 scoped_ptr<MockWebRtcAudioCapturerSink> sink_1( | 272 scoped_ptr<MockWebRtcAudioCapturerSink> sink_1( |
| 266 new MockWebRtcAudioCapturerSink()); | 273 new MockWebRtcAudioCapturerSink()); |
| 267 const media::AudioParameters params = capturer_->audio_parameters(); | 274 const media::AudioParameters params = capturer_->audio_parameters(); |
| 268 base::WaitableEvent event_1(false, false); | 275 base::WaitableEvent event_1(false, false); |
| 269 EXPECT_CALL(*sink_1, SetCaptureFormat(_)).WillOnce(Return()); | 276 EXPECT_CALL(*sink_1, SetCaptureFormat(_)).WillOnce(Return()); |
| 270 EXPECT_CALL(*sink_1, | 277 EXPECT_CALL(*sink_1, |
| 271 CaptureData(1, | 278 CaptureData(1, |
| 272 params.sample_rate(), | 279 params.sample_rate(), |
| 273 params.channels(), | 280 params.channels(), |
| 274 params.frames_per_buffer(), | 281 params.frames_per_buffer(), |
| 275 0, | 282 0, |
| 276 0, | 283 0, |
| 277 false, | 284 false, |
| 278 false)).Times(AtLeast(1)) | 285 false)).Times(AtLeast(1)) |
| 279 .WillRepeatedly(SignalEvent(&event_1)); | 286 .WillRepeatedly(SignalEvent(&event_1)); |
| 280 track_1->AddSink(sink_1.get()); | 287 track_1->AddSink(sink_1.get()); |
| 281 EXPECT_TRUE(event_1.TimedWait(TestTimeouts::tiny_timeout())); | 288 EXPECT_TRUE(event_1.TimedWait(TestTimeouts::tiny_timeout())); |
| 282 | 289 |
| 283 scoped_refptr<WebRtcLocalAudioTrack> track_2 = | 290 scoped_refptr<WebRtcLocalAudioTrack> track_2 = |
| 284 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL); | 291 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, |
| 292 &constraints); |
| 285 track_2->Start(); | 293 track_2->Start(); |
| 286 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> | 294 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> |
| 287 GetRenderer()->AddChannel(1); | 295 GetRenderer()->AddChannel(1); |
| 288 EXPECT_TRUE(track_2->enabled()); | 296 EXPECT_TRUE(track_2->enabled()); |
| 289 | 297 |
| 290 // Verify both |sink_1| and |sink_2| get data. | 298 // Verify both |sink_1| and |sink_2| get data. |
| 291 event_1.Reset(); | 299 event_1.Reset(); |
| 292 base::WaitableEvent event_2(false, false); | 300 base::WaitableEvent event_2(false, false); |
| 293 | 301 |
| 294 scoped_ptr<MockWebRtcAudioCapturerSink> sink_2( | 302 scoped_ptr<MockWebRtcAudioCapturerSink> sink_2( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 track_2->RemoveSink(sink_2.get()); | 334 track_2->RemoveSink(sink_2.get()); |
| 327 track_2->Stop(); | 335 track_2->Stop(); |
| 328 track_2 = NULL; | 336 track_2 = NULL; |
| 329 } | 337 } |
| 330 | 338 |
| 331 | 339 |
| 332 // Start one track and verify the capturer is correctly starting its source. | 340 // Start one track and verify the capturer is correctly starting its source. |
| 333 // And it should be fine to not to call Stop() explicitly. | 341 // And it should be fine to not to call Stop() explicitly. |
| 334 TEST_F(WebRtcLocalAudioTrackTest, StartOneAudioTrack) { | 342 TEST_F(WebRtcLocalAudioTrackTest, StartOneAudioTrack) { |
| 335 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); | 343 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); |
| 344 RTCMediaConstraints constraints; |
| 336 scoped_refptr<WebRtcLocalAudioTrack> track = | 345 scoped_refptr<WebRtcLocalAudioTrack> track = |
| 337 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL); | 346 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, |
| 347 &constraints); |
| 338 track->Start(); | 348 track->Start(); |
| 339 | 349 |
| 340 // When the track goes away, it will automatically stop the | 350 // When the track goes away, it will automatically stop the |
| 341 // |capturer_source_|. | 351 // |capturer_source_|. |
| 342 EXPECT_CALL(*capturer_source_.get(), Stop()); | 352 EXPECT_CALL(*capturer_source_.get(), Stop()); |
| 343 track->Stop(); | 353 track->Stop(); |
| 344 track = NULL; | 354 track = NULL; |
| 345 } | 355 } |
| 346 | 356 |
| 347 // Start/Stop tracks and verify the capturer is correctly starting/stopping | 357 // Start/Stop tracks and verify the capturer is correctly starting/stopping |
| 348 // its source. | 358 // its source. |
| 349 TEST_F(WebRtcLocalAudioTrackTest, StartAndStopAudioTracks) { | 359 TEST_F(WebRtcLocalAudioTrackTest, StartAndStopAudioTracks) { |
| 350 // Starting the first audio track will start the |capturer_source_|. | 360 // Starting the first audio track will start the |capturer_source_|. |
| 351 base::WaitableEvent event(false, false); | 361 base::WaitableEvent event(false, false); |
| 352 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(SignalEvent(&event)); | 362 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(SignalEvent(&event)); |
| 363 RTCMediaConstraints constraints; |
| 353 scoped_refptr<WebRtcLocalAudioTrack> track_1 = | 364 scoped_refptr<WebRtcLocalAudioTrack> track_1 = |
| 354 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL); | 365 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, |
| 366 &constraints); |
| 355 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> | 367 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> |
| 356 GetRenderer()->AddChannel(0); | 368 GetRenderer()->AddChannel(0); |
| 357 track_1->Start(); | 369 track_1->Start(); |
| 358 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); | 370 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); |
| 359 | 371 |
| 360 // Verify the data flow by connecting the sink to |track_1|. | 372 // Verify the data flow by connecting the sink to |track_1|. |
| 361 scoped_ptr<MockWebRtcAudioCapturerSink> sink( | 373 scoped_ptr<MockWebRtcAudioCapturerSink> sink( |
| 362 new MockWebRtcAudioCapturerSink()); | 374 new MockWebRtcAudioCapturerSink()); |
| 363 event.Reset(); | 375 event.Reset(); |
| 364 EXPECT_CALL(*sink, CaptureData(_, _, _, _, 0, 0, false, false)) | 376 EXPECT_CALL(*sink, CaptureData(_, _, _, _, 0, 0, false, false)) |
| 365 .Times(AnyNumber()).WillRepeatedly(Return()); | 377 .Times(AnyNumber()).WillRepeatedly(Return()); |
| 366 EXPECT_CALL(*sink, SetCaptureFormat(_)).Times(1); | 378 EXPECT_CALL(*sink, SetCaptureFormat(_)).Times(1); |
| 367 track_1->AddSink(sink.get()); | 379 track_1->AddSink(sink.get()); |
| 368 | 380 |
| 369 // Start the second audio track will not start the |capturer_source_| | 381 // Start the second audio track will not start the |capturer_source_| |
| 370 // since it has been started. | 382 // since it has been started. |
| 371 EXPECT_CALL(*capturer_source_.get(), Start()).Times(0); | 383 EXPECT_CALL(*capturer_source_.get(), Start()).Times(0); |
| 372 scoped_refptr<WebRtcLocalAudioTrack> track_2 = | 384 scoped_refptr<WebRtcLocalAudioTrack> track_2 = |
| 373 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL); | 385 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, |
| 386 &constraints); |
| 374 track_2->Start(); | 387 track_2->Start(); |
| 375 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> | 388 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> |
| 376 GetRenderer()->AddChannel(1); | 389 GetRenderer()->AddChannel(1); |
| 377 | 390 |
| 378 // Stop the first audio track will not stop the |capturer_source_|. | 391 // Stop the first audio track will not stop the |capturer_source_|. |
| 379 EXPECT_CALL(*capturer_source_.get(), Stop()).Times(0); | 392 EXPECT_CALL(*capturer_source_.get(), Stop()).Times(0); |
| 380 track_1->RemoveSink(sink.get()); | 393 track_1->RemoveSink(sink.get()); |
| 381 track_1->Stop(); | 394 track_1->Stop(); |
| 382 track_1 = NULL; | 395 track_1 = NULL; |
| 383 | 396 |
| 384 EXPECT_CALL(*sink, CaptureData(_, _, _, _, 0, 0, false, false)) | 397 EXPECT_CALL(*sink, CaptureData(_, _, _, _, 0, 0, false, false)) |
| 385 .Times(AnyNumber()).WillRepeatedly(Return()); | 398 .Times(AnyNumber()).WillRepeatedly(Return()); |
| 386 EXPECT_CALL(*sink, SetCaptureFormat(_)).Times(1); | 399 EXPECT_CALL(*sink, SetCaptureFormat(_)).Times(1); |
| 387 track_2->AddSink(sink.get()); | 400 track_2->AddSink(sink.get()); |
| 388 | 401 |
| 389 // Stop the last audio track will stop the |capturer_source_|. | 402 // Stop the last audio track will stop the |capturer_source_|. |
| 390 event.Reset(); | 403 event.Reset(); |
| 391 EXPECT_CALL(*capturer_source_.get(), Stop()) | 404 EXPECT_CALL(*capturer_source_.get(), Stop()) |
| 392 .Times(1).WillOnce(SignalEvent(&event)); | 405 .Times(1).WillOnce(SignalEvent(&event)); |
| 393 track_2->Stop(); | 406 track_2->Stop(); |
| 394 track_2->RemoveSink(sink.get()); | 407 track_2->RemoveSink(sink.get()); |
| 395 track_2 = NULL; | 408 track_2 = NULL; |
| 396 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); | 409 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); |
| 397 } | 410 } |
| 398 | 411 |
| 399 // Set new source to the existing capturer. | 412 // Set new source to the existing capturer. |
| 400 TEST_F(WebRtcLocalAudioTrackTest, SetNewSourceForCapturerAfterStartTrack) { | 413 TEST_F(WebRtcLocalAudioTrackTest, SetNewSourceForCapturerAfterStartTrack) { |
| 401 // Setup the audio track and start the track. | 414 // Setup the audio track and start the track. |
| 402 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); | 415 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); |
| 416 RTCMediaConstraints constraints; |
| 403 scoped_refptr<WebRtcLocalAudioTrack> track = | 417 scoped_refptr<WebRtcLocalAudioTrack> track = |
| 404 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL); | 418 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, |
| 419 &constraints); |
| 405 track->Start(); | 420 track->Start(); |
| 406 | 421 |
| 407 // Setting new source to the capturer and the track should still get packets. | 422 // Setting new source to the capturer and the track should still get packets. |
| 408 scoped_refptr<MockCapturerSource> new_source(new MockCapturerSource()); | 423 scoped_refptr<MockCapturerSource> new_source(new MockCapturerSource()); |
| 409 EXPECT_CALL(*capturer_source_.get(), Stop()); | 424 EXPECT_CALL(*capturer_source_.get(), Stop()); |
| 410 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(false)); | 425 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(false)); |
| 411 EXPECT_CALL(*new_source.get(), Initialize(_, capturer_.get(), 0)) | 426 EXPECT_CALL(*new_source.get(), Initialize(_, capturer_.get(), 0)) |
| 412 .WillOnce(Return()); | 427 .WillOnce(Return()); |
| 413 EXPECT_CALL(*new_source.get(), Start()).WillOnce(Return()); | 428 EXPECT_CALL(*new_source.get(), Start()).WillOnce(Return()); |
| 414 capturer_->SetCapturerSource(new_source, | 429 capturer_->SetCapturerSource(new_source, |
| 415 media::CHANNEL_LAYOUT_STEREO, | 430 media::CHANNEL_LAYOUT_STEREO, |
| 416 48000); | 431 48000); |
| 417 | 432 |
| 418 // Stop the track. | 433 // Stop the track. |
| 419 EXPECT_CALL(*new_source.get(), Stop()); | 434 EXPECT_CALL(*new_source.get(), Stop()); |
| 420 track->Stop(); | 435 track->Stop(); |
| 421 track = NULL; | 436 track = NULL; |
| 422 } | 437 } |
| 423 | 438 |
| 424 // Create a new capturer with new source, connect it to a new audio track. | 439 // Create a new capturer with new source, connect it to a new audio track. |
| 425 TEST_F(WebRtcLocalAudioTrackTest, ConnectTracksToDifferentCapturers) { | 440 TEST_F(WebRtcLocalAudioTrackTest, ConnectTracksToDifferentCapturers) { |
| 426 // Setup the first audio track and start it. | 441 // Setup the first audio track and start it. |
| 427 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); | 442 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); |
| 443 RTCMediaConstraints constraints; |
| 428 scoped_refptr<WebRtcLocalAudioTrack> track_1 = | 444 scoped_refptr<WebRtcLocalAudioTrack> track_1 = |
| 429 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL); | 445 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, |
| 446 &constraints); |
| 430 track_1->Start(); | 447 track_1->Start(); |
| 431 | 448 |
| 432 // Connect a number of network channels to the |track_1|. | 449 // Connect a number of network channels to the |track_1|. |
| 433 static const int kNumberOfNetworkChannelsForTrack1 = 2; | 450 static const int kNumberOfNetworkChannelsForTrack1 = 2; |
| 434 for (int i = 0; i < kNumberOfNetworkChannelsForTrack1; ++i) { | 451 for (int i = 0; i < kNumberOfNetworkChannelsForTrack1; ++i) { |
| 435 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> | 452 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> |
| 436 GetRenderer()->AddChannel(i); | 453 GetRenderer()->AddChannel(i); |
| 437 } | 454 } |
| 438 // Verify the data flow by connecting the |sink_1| to |track_1|. | 455 // Verify the data flow by connecting the |sink_1| to |track_1|. |
| 439 scoped_ptr<MockWebRtcAudioCapturerSink> sink_1( | 456 scoped_ptr<MockWebRtcAudioCapturerSink> sink_1( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 458 media::CHANNEL_LAYOUT_MONO, | 475 media::CHANNEL_LAYOUT_MONO, |
| 459 44100); | 476 44100); |
| 460 | 477 |
| 461 // Start the audio thread used by the new source. | 478 // Start the audio thread used by the new source. |
| 462 scoped_ptr<FakeAudioThread> audio_thread(new FakeAudioThread(new_capturer)); | 479 scoped_ptr<FakeAudioThread> audio_thread(new FakeAudioThread(new_capturer)); |
| 463 audio_thread->Start(); | 480 audio_thread->Start(); |
| 464 | 481 |
| 465 // Setup the second audio track, connect it to the new capturer and start it. | 482 // Setup the second audio track, connect it to the new capturer and start it. |
| 466 EXPECT_CALL(*new_source.get(), Start()).Times(1); | 483 EXPECT_CALL(*new_source.get(), Start()).Times(1); |
| 467 scoped_refptr<WebRtcLocalAudioTrack> track_2 = | 484 scoped_refptr<WebRtcLocalAudioTrack> track_2 = |
| 468 WebRtcLocalAudioTrack::Create(std::string(), new_capturer, NULL); | 485 WebRtcLocalAudioTrack::Create(std::string(), new_capturer, NULL, |
| 486 &constraints); |
| 469 track_2->Start(); | 487 track_2->Start(); |
| 470 | 488 |
| 471 // Connect a number of network channels to the |track_2|. | 489 // Connect a number of network channels to the |track_2|. |
| 472 static const int kNumberOfNetworkChannelsForTrack2 = 3; | 490 static const int kNumberOfNetworkChannelsForTrack2 = 3; |
| 473 for (int i = 0; i < kNumberOfNetworkChannelsForTrack2; ++i) { | 491 for (int i = 0; i < kNumberOfNetworkChannelsForTrack2; ++i) { |
| 474 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> | 492 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> |
| 475 GetRenderer()->AddChannel(i); | 493 GetRenderer()->AddChannel(i); |
| 476 } | 494 } |
| 477 // Verify the data flow by connecting the |sink_2| to |track_2|. | 495 // Verify the data flow by connecting the |sink_2| to |track_2|. |
| 478 scoped_ptr<MockWebRtcAudioCapturerSink> sink_2( | 496 scoped_ptr<MockWebRtcAudioCapturerSink> sink_2( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 495 audio_thread->Stop(); | 513 audio_thread->Stop(); |
| 496 audio_thread.reset(); | 514 audio_thread.reset(); |
| 497 | 515 |
| 498 // Stop the first audio track. | 516 // Stop the first audio track. |
| 499 EXPECT_CALL(*capturer_source_.get(), Stop()); | 517 EXPECT_CALL(*capturer_source_.get(), Stop()); |
| 500 track_1->Stop(); | 518 track_1->Stop(); |
| 501 track_1 = NULL; | 519 track_1 = NULL; |
| 502 } | 520 } |
| 503 | 521 |
| 504 } // namespace content | 522 } // namespace content |
| OLD | NEW |