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/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_local_audio_track.h" | 9 #include "content/renderer/media/webrtc_local_audio_track.h" |
10 #include "media/audio/audio_parameters.h" | 10 #include "media/audio/audio_parameters.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 bool key_pressed)); | 127 bool key_pressed)); |
128 MOCK_METHOD1(SetCaptureFormat, void(const media::AudioParameters& params)); | 128 MOCK_METHOD1(SetCaptureFormat, void(const media::AudioParameters& params)); |
129 }; | 129 }; |
130 | 130 |
131 } // namespace | 131 } // namespace |
132 | 132 |
133 class WebRtcLocalAudioTrackTest : public ::testing::Test { | 133 class WebRtcLocalAudioTrackTest : public ::testing::Test { |
134 protected: | 134 protected: |
135 virtual void SetUp() OVERRIDE { | 135 virtual void SetUp() OVERRIDE { |
136 capturer_ = WebRtcAudioCapturer::CreateCapturer(); | 136 capturer_ = WebRtcAudioCapturer::CreateCapturer(); |
137 capturer_->EnablePeerConnectionMode(); | |
tommi (sloooow) - chröme
2013/09/06 11:20:30
why do we need this? Should we run all tests twic
no longer working on chromium
2013/09/10 12:43:15
Oh, we don't need this. Removed.
| |
137 capturer_source_ = new MockCapturerSource(); | 138 capturer_source_ = new MockCapturerSource(); |
138 EXPECT_CALL(*capturer_source_.get(), Initialize(_, capturer_.get(), 0)) | 139 EXPECT_CALL(*capturer_source_.get(), Initialize(_, capturer_.get(), 0)) |
139 .WillOnce(Return()); | 140 .WillOnce(Return()); |
140 capturer_->SetCapturerSource(capturer_source_, | 141 capturer_->SetCapturerSource(capturer_source_, |
141 media::CHANNEL_LAYOUT_STEREO, | 142 media::CHANNEL_LAYOUT_STEREO, |
142 48000); | 143 48000); |
143 | 144 |
144 EXPECT_CALL(*capturer_source_.get(), SetAutomaticGainControl(false)) | 145 EXPECT_CALL(*capturer_source_.get(), SetAutomaticGainControl(false)) |
145 .WillOnce(Return()); | 146 .WillOnce(Return()); |
146 | 147 |
(...skipping 13 matching lines...) Expand all Loading... | |
160 }; | 161 }; |
161 | 162 |
162 // Creates a capturer and audio track, fakes its audio thread, and | 163 // Creates a capturer and audio track, fakes its audio thread, and |
163 // connect/disconnect the sink to the audio track on the fly, the sink should | 164 // connect/disconnect the sink to the audio track on the fly, the sink should |
164 // get data callback when the track is connected to the capturer but not when | 165 // get data callback when the track is connected to the capturer but not when |
165 // the track is disconnected from the capturer. | 166 // the track is disconnected from the capturer. |
166 TEST_F(WebRtcLocalAudioTrackTest, ConnectAndDisconnectOneSink) { | 167 TEST_F(WebRtcLocalAudioTrackTest, ConnectAndDisconnectOneSink) { |
167 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); | 168 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); |
168 RTCMediaConstraints constraints; | 169 RTCMediaConstraints constraints; |
169 scoped_refptr<WebRtcLocalAudioTrack> track = | 170 scoped_refptr<WebRtcLocalAudioTrack> track = |
170 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, | 171 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, NULL, |
171 &constraints); | 172 &constraints); |
172 track->Start(); | 173 track->Start(); |
173 EXPECT_TRUE(track->enabled()); | 174 EXPECT_TRUE(track->enabled()); |
174 | 175 |
175 // Connect a number of network channels to the audio track. | 176 // Connect a number of network channels to the audio track. |
176 static const int kNumberOfNetworkChannels = 4; | 177 static const int kNumberOfNetworkChannels = 4; |
177 for (int i = 0; i < kNumberOfNetworkChannels; ++i) { | 178 for (int i = 0; i < kNumberOfNetworkChannels; ++i) { |
178 static_cast<webrtc::AudioTrackInterface*>(track.get())-> | 179 static_cast<webrtc::AudioTrackInterface*>(track.get())-> |
179 GetRenderer()->AddChannel(i); | 180 GetRenderer()->AddChannel(i); |
180 } | 181 } |
(...skipping 25 matching lines...) Expand all Loading... | |
206 // The same setup as ConnectAndDisconnectOneSink, but enable and disable the | 207 // The same setup as ConnectAndDisconnectOneSink, but enable and disable the |
207 // audio track on the fly. When the audio track is disabled, there is no data | 208 // audio track on the fly. When the audio track is disabled, there is no data |
208 // callback to the sink; when the audio track is enabled, there comes data | 209 // callback to the sink; when the audio track is enabled, there comes data |
209 // callback. | 210 // callback. |
210 // TODO(xians): Enable this test after resolving the racing issue that TSAN | 211 // TODO(xians): Enable this test after resolving the racing issue that TSAN |
211 // reports on MediaStreamTrack::enabled(); | 212 // reports on MediaStreamTrack::enabled(); |
212 TEST_F(WebRtcLocalAudioTrackTest, DISABLED_DisableEnableAudioTrack) { | 213 TEST_F(WebRtcLocalAudioTrackTest, DISABLED_DisableEnableAudioTrack) { |
213 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); | 214 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); |
214 RTCMediaConstraints constraints; | 215 RTCMediaConstraints constraints; |
215 scoped_refptr<WebRtcLocalAudioTrack> track = | 216 scoped_refptr<WebRtcLocalAudioTrack> track = |
216 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, | 217 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, NULL, |
217 &constraints); | 218 &constraints); |
218 track->Start(); | 219 track->Start(); |
219 static_cast<webrtc::AudioTrackInterface*>(track.get())-> | 220 static_cast<webrtc::AudioTrackInterface*>(track.get())-> |
220 GetRenderer()->AddChannel(0); | 221 GetRenderer()->AddChannel(0); |
221 EXPECT_TRUE(track->enabled()); | 222 EXPECT_TRUE(track->enabled()); |
222 EXPECT_TRUE(track->set_enabled(false)); | 223 EXPECT_TRUE(track->set_enabled(false)); |
223 scoped_ptr<MockWebRtcAudioCapturerSink> sink( | 224 scoped_ptr<MockWebRtcAudioCapturerSink> sink( |
224 new MockWebRtcAudioCapturerSink()); | 225 new MockWebRtcAudioCapturerSink()); |
225 const media::AudioParameters params = capturer_->audio_parameters(); | 226 const media::AudioParameters params = capturer_->audio_parameters(); |
226 base::WaitableEvent event(false, false); | 227 base::WaitableEvent event(false, false); |
(...skipping 29 matching lines...) Expand all Loading... | |
256 track->Stop(); | 257 track->Stop(); |
257 track = NULL; | 258 track = NULL; |
258 } | 259 } |
259 | 260 |
260 // Create multiple audio tracks and enable/disable them, verify that the audio | 261 // Create multiple audio tracks and enable/disable them, verify that the audio |
261 // callbacks appear/disappear. | 262 // callbacks appear/disappear. |
262 TEST_F(WebRtcLocalAudioTrackTest, MultipleAudioTracks) { | 263 TEST_F(WebRtcLocalAudioTrackTest, MultipleAudioTracks) { |
263 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); | 264 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return()); |
264 RTCMediaConstraints constraints; | 265 RTCMediaConstraints constraints; |
265 scoped_refptr<WebRtcLocalAudioTrack> track_1 = | 266 scoped_refptr<WebRtcLocalAudioTrack> track_1 = |
266 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, | 267 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, NULL, |
267 &constraints); | 268 &constraints); |
268 track_1->Start(); | 269 track_1->Start(); |
269 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> | 270 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> |
270 GetRenderer()->AddChannel(0); | 271 GetRenderer()->AddChannel(0); |
271 EXPECT_TRUE(track_1->enabled()); | 272 EXPECT_TRUE(track_1->enabled()); |
272 scoped_ptr<MockWebRtcAudioCapturerSink> sink_1( | 273 scoped_ptr<MockWebRtcAudioCapturerSink> sink_1( |
273 new MockWebRtcAudioCapturerSink()); | 274 new MockWebRtcAudioCapturerSink()); |
274 const media::AudioParameters params = capturer_->audio_parameters(); | 275 const media::AudioParameters params = capturer_->audio_parameters(); |
275 base::WaitableEvent event_1(false, false); | 276 base::WaitableEvent event_1(false, false); |
276 EXPECT_CALL(*sink_1, SetCaptureFormat(_)).WillOnce(Return()); | 277 EXPECT_CALL(*sink_1, SetCaptureFormat(_)).WillOnce(Return()); |
277 EXPECT_CALL(*sink_1, | 278 EXPECT_CALL(*sink_1, |
278 CaptureData(1, | 279 CaptureData(1, |
279 params.sample_rate(), | 280 params.sample_rate(), |
280 params.channels(), | 281 params.channels(), |
281 params.frames_per_buffer(), | 282 params.frames_per_buffer(), |
282 0, | 283 0, |
283 0, | 284 0, |
284 false, | 285 false, |
285 false)).Times(AtLeast(1)) | 286 false)).Times(AtLeast(1)) |
286 .WillRepeatedly(SignalEvent(&event_1)); | 287 .WillRepeatedly(SignalEvent(&event_1)); |
287 track_1->AddSink(sink_1.get()); | 288 track_1->AddSink(sink_1.get()); |
288 EXPECT_TRUE(event_1.TimedWait(TestTimeouts::tiny_timeout())); | 289 EXPECT_TRUE(event_1.TimedWait(TestTimeouts::tiny_timeout())); |
289 | 290 |
290 scoped_refptr<WebRtcLocalAudioTrack> track_2 = | 291 scoped_refptr<WebRtcLocalAudioTrack> track_2 = |
291 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, | 292 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, NULL, |
292 &constraints); | 293 &constraints); |
293 track_2->Start(); | 294 track_2->Start(); |
294 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> | 295 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> |
295 GetRenderer()->AddChannel(1); | 296 GetRenderer()->AddChannel(1); |
296 EXPECT_TRUE(track_2->enabled()); | 297 EXPECT_TRUE(track_2->enabled()); |
297 | 298 |
298 // Verify both |sink_1| and |sink_2| get data. | 299 // Verify both |sink_1| and |sink_2| get data. |
299 event_1.Reset(); | 300 event_1.Reset(); |
300 base::WaitableEvent event_2(false, false); | 301 base::WaitableEvent event_2(false, false); |
301 | 302 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 track_2 = NULL; | 337 track_2 = NULL; |
337 } | 338 } |
338 | 339 |
339 | 340 |
340 // Start one track and verify the capturer is correctly starting its source. | 341 // Start one track and verify the capturer is correctly starting its source. |
341 // And it should be fine to not to call Stop() explicitly. | 342 // And it should be fine to not to call Stop() explicitly. |
342 TEST_F(WebRtcLocalAudioTrackTest, StartOneAudioTrack) { | 343 TEST_F(WebRtcLocalAudioTrackTest, StartOneAudioTrack) { |
343 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); | 344 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); |
344 RTCMediaConstraints constraints; | 345 RTCMediaConstraints constraints; |
345 scoped_refptr<WebRtcLocalAudioTrack> track = | 346 scoped_refptr<WebRtcLocalAudioTrack> track = |
346 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, | 347 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, NULL, |
347 &constraints); | 348 &constraints); |
348 track->Start(); | 349 track->Start(); |
349 | 350 |
350 // When the track goes away, it will automatically stop the | 351 // When the track goes away, it will automatically stop the |
351 // |capturer_source_|. | 352 // |capturer_source_|. |
352 EXPECT_CALL(*capturer_source_.get(), Stop()); | 353 EXPECT_CALL(*capturer_source_.get(), Stop()); |
353 track->Stop(); | 354 track->Stop(); |
354 track = NULL; | 355 track = NULL; |
355 } | 356 } |
356 | 357 |
357 // Start/Stop tracks and verify the capturer is correctly starting/stopping | 358 // Start/Stop tracks and verify the capturer is correctly starting/stopping |
358 // its source. | 359 // its source. |
359 TEST_F(WebRtcLocalAudioTrackTest, StartAndStopAudioTracks) { | 360 TEST_F(WebRtcLocalAudioTrackTest, StartAndStopAudioTracks) { |
360 // Starting the first audio track will start the |capturer_source_|. | 361 // Starting the first audio track will start the |capturer_source_|. |
361 base::WaitableEvent event(false, false); | 362 base::WaitableEvent event(false, false); |
362 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(SignalEvent(&event)); | 363 EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(SignalEvent(&event)); |
363 RTCMediaConstraints constraints; | 364 RTCMediaConstraints constraints; |
364 scoped_refptr<WebRtcLocalAudioTrack> track_1 = | 365 scoped_refptr<WebRtcLocalAudioTrack> track_1 = |
365 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, | 366 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, NULL, |
366 &constraints); | 367 &constraints); |
367 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> | 368 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> |
368 GetRenderer()->AddChannel(0); | 369 GetRenderer()->AddChannel(0); |
369 track_1->Start(); | 370 track_1->Start(); |
370 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); | 371 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); |
371 | 372 |
372 // Verify the data flow by connecting the sink to |track_1|. | 373 // Verify the data flow by connecting the sink to |track_1|. |
373 scoped_ptr<MockWebRtcAudioCapturerSink> sink( | 374 scoped_ptr<MockWebRtcAudioCapturerSink> sink( |
374 new MockWebRtcAudioCapturerSink()); | 375 new MockWebRtcAudioCapturerSink()); |
375 event.Reset(); | 376 event.Reset(); |
376 EXPECT_CALL(*sink, CaptureData(_, _, _, _, 0, 0, false, false)) | 377 EXPECT_CALL(*sink, CaptureData(_, _, _, _, 0, 0, false, false)) |
377 .Times(AnyNumber()).WillRepeatedly(Return()); | 378 .Times(AnyNumber()).WillRepeatedly(Return()); |
378 EXPECT_CALL(*sink, SetCaptureFormat(_)).Times(1); | 379 EXPECT_CALL(*sink, SetCaptureFormat(_)).Times(1); |
379 track_1->AddSink(sink.get()); | 380 track_1->AddSink(sink.get()); |
380 | 381 |
381 // Start the second audio track will not start the |capturer_source_| | 382 // Start the second audio track will not start the |capturer_source_| |
382 // since it has been started. | 383 // since it has been started. |
383 EXPECT_CALL(*capturer_source_.get(), Start()).Times(0); | 384 EXPECT_CALL(*capturer_source_.get(), Start()).Times(0); |
384 scoped_refptr<WebRtcLocalAudioTrack> track_2 = | 385 scoped_refptr<WebRtcLocalAudioTrack> track_2 = |
385 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, | 386 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, NULL, |
386 &constraints); | 387 &constraints); |
387 track_2->Start(); | 388 track_2->Start(); |
388 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> | 389 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> |
389 GetRenderer()->AddChannel(1); | 390 GetRenderer()->AddChannel(1); |
390 | 391 |
391 // Stop the first audio track will not stop the |capturer_source_|. | 392 // Stop the first audio track will not stop the |capturer_source_|. |
392 EXPECT_CALL(*capturer_source_.get(), Stop()).Times(0); | 393 EXPECT_CALL(*capturer_source_.get(), Stop()).Times(0); |
393 track_1->RemoveSink(sink.get()); | 394 track_1->RemoveSink(sink.get()); |
394 track_1->Stop(); | 395 track_1->Stop(); |
395 track_1 = NULL; | 396 track_1 = NULL; |
(...skipping 12 matching lines...) Expand all Loading... | |
408 track_2 = NULL; | 409 track_2 = NULL; |
409 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); | 410 EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout())); |
410 } | 411 } |
411 | 412 |
412 // Set new source to the existing capturer. | 413 // Set new source to the existing capturer. |
413 TEST_F(WebRtcLocalAudioTrackTest, SetNewSourceForCapturerAfterStartTrack) { | 414 TEST_F(WebRtcLocalAudioTrackTest, SetNewSourceForCapturerAfterStartTrack) { |
414 // Setup the audio track and start the track. | 415 // Setup the audio track and start the track. |
415 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); | 416 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); |
416 RTCMediaConstraints constraints; | 417 RTCMediaConstraints constraints; |
417 scoped_refptr<WebRtcLocalAudioTrack> track = | 418 scoped_refptr<WebRtcLocalAudioTrack> track = |
418 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, | 419 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, NULL, |
419 &constraints); | 420 &constraints); |
420 track->Start(); | 421 track->Start(); |
421 | 422 |
422 // Setting new source to the capturer and the track should still get packets. | 423 // Setting new source to the capturer and the track should still get packets. |
423 scoped_refptr<MockCapturerSource> new_source(new MockCapturerSource()); | 424 scoped_refptr<MockCapturerSource> new_source(new MockCapturerSource()); |
424 EXPECT_CALL(*capturer_source_.get(), Stop()); | 425 EXPECT_CALL(*capturer_source_.get(), Stop()); |
425 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(false)); | 426 EXPECT_CALL(*new_source.get(), SetAutomaticGainControl(false)); |
426 EXPECT_CALL(*new_source.get(), Initialize(_, capturer_.get(), 0)) | 427 EXPECT_CALL(*new_source.get(), Initialize(_, capturer_.get(), 0)) |
427 .WillOnce(Return()); | 428 .WillOnce(Return()); |
428 EXPECT_CALL(*new_source.get(), Start()).WillOnce(Return()); | 429 EXPECT_CALL(*new_source.get(), Start()).WillOnce(Return()); |
429 capturer_->SetCapturerSource(new_source, | 430 capturer_->SetCapturerSource(new_source, |
430 media::CHANNEL_LAYOUT_STEREO, | 431 media::CHANNEL_LAYOUT_STEREO, |
431 48000); | 432 48000); |
432 | 433 |
433 // Stop the track. | 434 // Stop the track. |
434 EXPECT_CALL(*new_source.get(), Stop()); | 435 EXPECT_CALL(*new_source.get(), Stop()); |
435 track->Stop(); | 436 track->Stop(); |
436 track = NULL; | 437 track = NULL; |
437 } | 438 } |
438 | 439 |
439 // Create a new capturer with new source, connect it to a new audio track. | 440 // Create a new capturer with new source, connect it to a new audio track. |
440 TEST_F(WebRtcLocalAudioTrackTest, ConnectTracksToDifferentCapturers) { | 441 TEST_F(WebRtcLocalAudioTrackTest, ConnectTracksToDifferentCapturers) { |
441 // Setup the first audio track and start it. | 442 // Setup the first audio track and start it. |
442 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); | 443 EXPECT_CALL(*capturer_source_.get(), Start()).Times(1); |
443 RTCMediaConstraints constraints; | 444 RTCMediaConstraints constraints; |
444 scoped_refptr<WebRtcLocalAudioTrack> track_1 = | 445 scoped_refptr<WebRtcLocalAudioTrack> track_1 = |
445 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, | 446 WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL, NULL, |
446 &constraints); | 447 &constraints); |
447 track_1->Start(); | 448 track_1->Start(); |
448 | 449 |
449 // Connect a number of network channels to the |track_1|. | 450 // Connect a number of network channels to the |track_1|. |
450 static const int kNumberOfNetworkChannelsForTrack1 = 2; | 451 static const int kNumberOfNetworkChannelsForTrack1 = 2; |
451 for (int i = 0; i < kNumberOfNetworkChannelsForTrack1; ++i) { | 452 for (int i = 0; i < kNumberOfNetworkChannelsForTrack1; ++i) { |
452 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> | 453 static_cast<webrtc::AudioTrackInterface*>(track_1.get())-> |
453 GetRenderer()->AddChannel(i); | 454 GetRenderer()->AddChannel(i); |
454 } | 455 } |
455 // Verify the data flow by connecting the |sink_1| to |track_1|. | 456 // Verify the data flow by connecting the |sink_1| to |track_1|. |
(...skipping 19 matching lines...) Expand all Loading... | |
475 media::CHANNEL_LAYOUT_MONO, | 476 media::CHANNEL_LAYOUT_MONO, |
476 44100); | 477 44100); |
477 | 478 |
478 // Start the audio thread used by the new source. | 479 // Start the audio thread used by the new source. |
479 scoped_ptr<FakeAudioThread> audio_thread(new FakeAudioThread(new_capturer)); | 480 scoped_ptr<FakeAudioThread> audio_thread(new FakeAudioThread(new_capturer)); |
480 audio_thread->Start(); | 481 audio_thread->Start(); |
481 | 482 |
482 // Setup the second audio track, connect it to the new capturer and start it. | 483 // Setup the second audio track, connect it to the new capturer and start it. |
483 EXPECT_CALL(*new_source.get(), Start()).Times(1); | 484 EXPECT_CALL(*new_source.get(), Start()).Times(1); |
484 scoped_refptr<WebRtcLocalAudioTrack> track_2 = | 485 scoped_refptr<WebRtcLocalAudioTrack> track_2 = |
485 WebRtcLocalAudioTrack::Create(std::string(), new_capturer, NULL, | 486 WebRtcLocalAudioTrack::Create(std::string(), new_capturer, NULL, NULL, |
486 &constraints); | 487 &constraints); |
487 track_2->Start(); | 488 track_2->Start(); |
488 | 489 |
489 // Connect a number of network channels to the |track_2|. | 490 // Connect a number of network channels to the |track_2|. |
490 static const int kNumberOfNetworkChannelsForTrack2 = 3; | 491 static const int kNumberOfNetworkChannelsForTrack2 = 3; |
491 for (int i = 0; i < kNumberOfNetworkChannelsForTrack2; ++i) { | 492 for (int i = 0; i < kNumberOfNetworkChannelsForTrack2; ++i) { |
492 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> | 493 static_cast<webrtc::AudioTrackInterface*>(track_2.get())-> |
493 GetRenderer()->AddChannel(i); | 494 GetRenderer()->AddChannel(i); |
494 } | 495 } |
495 // Verify the data flow by connecting the |sink_2| to |track_2|. | 496 // Verify the data flow by connecting the |sink_2| to |track_2|. |
(...skipping 17 matching lines...) Expand all Loading... | |
513 audio_thread->Stop(); | 514 audio_thread->Stop(); |
514 audio_thread.reset(); | 515 audio_thread.reset(); |
515 | 516 |
516 // Stop the first audio track. | 517 // Stop the first audio track. |
517 EXPECT_CALL(*capturer_source_.get(), Stop()); | 518 EXPECT_CALL(*capturer_source_.get(), Stop()); |
518 track_1->Stop(); | 519 track_1->Stop(); |
519 track_1 = NULL; | 520 track_1 = NULL; |
520 } | 521 } |
521 | 522 |
522 } // namespace content | 523 } // namespace content |
OLD | NEW |