OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 static const int kDefaultTimeout = 10000; | 81 static const int kDefaultTimeout = 10000; |
82 static const int kMaxWaitForStatsMs = 3000; | 82 static const int kMaxWaitForStatsMs = 3000; |
83 static const int kMaxWaitForActivationMs = 5000; | 83 static const int kMaxWaitForActivationMs = 5000; |
84 static const int kMaxWaitForFramesMs = 10000; | 84 static const int kMaxWaitForFramesMs = 10000; |
85 // Default number of audio/video frames to wait for before considering a test | 85 // Default number of audio/video frames to wait for before considering a test |
86 // successful. | 86 // successful. |
87 static const int kDefaultExpectedAudioFrameCount = 3; | 87 static const int kDefaultExpectedAudioFrameCount = 3; |
88 static const int kDefaultExpectedVideoFrameCount = 3; | 88 static const int kDefaultExpectedVideoFrameCount = 3; |
89 | 89 |
90 static const char kDefaultStreamLabel[] = "stream_label"; | |
91 static const char kDefaultVideoTrackId[] = "video_track"; | |
92 static const char kDefaultAudioTrackId[] = "audio_track"; | |
93 static const char kDataChannelLabel[] = "data_channel"; | 90 static const char kDataChannelLabel[] = "data_channel"; |
94 | 91 |
95 // SRTP cipher name negotiated by the tests. This must be updated if the | 92 // SRTP cipher name negotiated by the tests. This must be updated if the |
96 // default changes. | 93 // default changes. |
97 static const int kDefaultSrtpCryptoSuite = rtc::SRTP_AES128_CM_SHA1_32; | 94 static const int kDefaultSrtpCryptoSuite = rtc::SRTP_AES128_CM_SHA1_32; |
98 static const int kDefaultSrtpCryptoSuiteGcm = rtc::SRTP_AEAD_AES_256_GCM; | 95 static const int kDefaultSrtpCryptoSuiteGcm = rtc::SRTP_AEAD_AES_256_GCM; |
99 | 96 |
100 // Helper function for constructing offer/answer options to initiate an ICE | 97 // Helper function for constructing offer/answer options to initiate an ICE |
101 // restart. | 98 // restart. |
102 PeerConnectionInterface::RTCOfferAnswerOptions IceRestartOfferAnswerOptions() { | 99 PeerConnectionInterface::RTCOfferAnswerOptions IceRestartOfferAnswerOptions() { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 296 } |
300 | 297 |
301 rtc::scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack() { | 298 rtc::scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack() { |
302 FakeConstraints constraints; | 299 FakeConstraints constraints; |
303 // Disable highpass filter so that we can get all the test audio frames. | 300 // Disable highpass filter so that we can get all the test audio frames. |
304 constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false); | 301 constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false); |
305 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = | 302 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = |
306 peer_connection_factory_->CreateAudioSource(&constraints); | 303 peer_connection_factory_->CreateAudioSource(&constraints); |
307 // TODO(perkj): Test audio source when it is implemented. Currently audio | 304 // TODO(perkj): Test audio source when it is implemented. Currently audio |
308 // always use the default input. | 305 // always use the default input. |
309 return peer_connection_factory_->CreateAudioTrack(kDefaultAudioTrackId, | 306 return peer_connection_factory_->CreateAudioTrack(rtc::CreateRandomUuid(), |
310 source); | 307 source); |
311 } | 308 } |
312 | 309 |
313 rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack() { | 310 rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack() { |
314 return CreateLocalVideoTrackInternal( | 311 return CreateLocalVideoTrackInternal(FakeConstraints(), |
315 kDefaultVideoTrackId, FakeConstraints(), webrtc::kVideoRotation_0); | 312 webrtc::kVideoRotation_0); |
316 } | 313 } |
317 | 314 |
318 rtc::scoped_refptr<webrtc::VideoTrackInterface> | 315 rtc::scoped_refptr<webrtc::VideoTrackInterface> |
319 CreateLocalVideoTrackWithConstraints(const FakeConstraints& constraints) { | 316 CreateLocalVideoTrackWithConstraints(const FakeConstraints& constraints) { |
320 return CreateLocalVideoTrackInternal(kDefaultVideoTrackId, constraints, | 317 return CreateLocalVideoTrackInternal(constraints, webrtc::kVideoRotation_0); |
321 webrtc::kVideoRotation_0); | |
322 } | 318 } |
323 | 319 |
324 rtc::scoped_refptr<webrtc::VideoTrackInterface> | 320 rtc::scoped_refptr<webrtc::VideoTrackInterface> |
325 CreateLocalVideoTrackWithRotation(webrtc::VideoRotation rotation) { | 321 CreateLocalVideoTrackWithRotation(webrtc::VideoRotation rotation) { |
326 return CreateLocalVideoTrackInternal(kDefaultVideoTrackId, | 322 return CreateLocalVideoTrackInternal(FakeConstraints(), rotation); |
327 FakeConstraints(), rotation); | |
328 } | |
329 | |
330 rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrackWithId( | |
331 const std::string& id) { | |
332 return CreateLocalVideoTrackInternal(id, FakeConstraints(), | |
333 webrtc::kVideoRotation_0); | |
334 } | 323 } |
335 | 324 |
336 void AddMediaStreamFromTracks( | 325 void AddMediaStreamFromTracks( |
337 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio, | 326 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio, |
338 rtc::scoped_refptr<webrtc::VideoTrackInterface> video) { | 327 rtc::scoped_refptr<webrtc::VideoTrackInterface> video) { |
339 AddMediaStreamFromTracksWithLabel(audio, video, kDefaultStreamLabel); | |
340 } | |
341 | |
342 void AddMediaStreamFromTracksWithLabel( | |
343 rtc::scoped_refptr<webrtc::AudioTrackInterface> audio, | |
344 rtc::scoped_refptr<webrtc::VideoTrackInterface> video, | |
345 const std::string& stream_label) { | |
346 rtc::scoped_refptr<MediaStreamInterface> stream = | 328 rtc::scoped_refptr<MediaStreamInterface> stream = |
347 peer_connection_factory_->CreateLocalMediaStream(stream_label); | 329 peer_connection_factory_->CreateLocalMediaStream( |
| 330 rtc::CreateRandomUuid()); |
348 if (audio) { | 331 if (audio) { |
349 stream->AddTrack(audio); | 332 stream->AddTrack(audio); |
350 } | 333 } |
351 if (video) { | 334 if (video) { |
352 stream->AddTrack(video); | 335 stream->AddTrack(video); |
353 } | 336 } |
354 EXPECT_TRUE(pc()->AddStream(stream)); | 337 EXPECT_TRUE(pc()->AddStream(stream)); |
355 } | 338 } |
356 | 339 |
357 bool SignalingStateStable() { | 340 bool SignalingStateStable() { |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 | 610 |
628 void set_signaling_delay_ms(int delay_ms) { signaling_delay_ms_ = delay_ms; } | 611 void set_signaling_delay_ms(int delay_ms) { signaling_delay_ms_ = delay_ms; } |
629 | 612 |
630 void EnableVideoDecoderFactory() { | 613 void EnableVideoDecoderFactory() { |
631 video_decoder_factory_enabled_ = true; | 614 video_decoder_factory_enabled_ = true; |
632 fake_video_decoder_factory_->AddSupportedVideoCodecType( | 615 fake_video_decoder_factory_->AddSupportedVideoCodecType( |
633 webrtc::kVideoCodecVP8); | 616 webrtc::kVideoCodecVP8); |
634 } | 617 } |
635 | 618 |
636 rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrackInternal( | 619 rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrackInternal( |
637 const std::string& track_id, | |
638 const FakeConstraints& constraints, | 620 const FakeConstraints& constraints, |
639 webrtc::VideoRotation rotation) { | 621 webrtc::VideoRotation rotation) { |
640 // Set max frame rate to 10fps to reduce the risk of test flakiness. | 622 // Set max frame rate to 10fps to reduce the risk of test flakiness. |
641 // TODO(deadbeef): Do something more robust. | 623 // TODO(deadbeef): Do something more robust. |
642 FakeConstraints source_constraints = constraints; | 624 FakeConstraints source_constraints = constraints; |
643 source_constraints.SetMandatoryMaxFrameRate(10); | 625 source_constraints.SetMandatoryMaxFrameRate(10); |
644 | 626 |
645 cricket::FakeVideoCapturer* fake_capturer = | 627 cricket::FakeVideoCapturer* fake_capturer = |
646 new webrtc::FakePeriodicVideoCapturer(); | 628 new webrtc::FakePeriodicVideoCapturer(); |
647 fake_capturer->SetRotation(rotation); | 629 fake_capturer->SetRotation(rotation); |
648 video_capturers_.push_back(fake_capturer); | 630 video_capturers_.push_back(fake_capturer); |
649 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source = | 631 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source = |
650 peer_connection_factory_->CreateVideoSource(fake_capturer, | 632 peer_connection_factory_->CreateVideoSource(fake_capturer, |
651 &source_constraints); | 633 &source_constraints); |
652 rtc::scoped_refptr<webrtc::VideoTrackInterface> track( | 634 rtc::scoped_refptr<webrtc::VideoTrackInterface> track( |
653 peer_connection_factory_->CreateVideoTrack(track_id, source)); | 635 peer_connection_factory_->CreateVideoTrack(rtc::CreateRandomUuid(), |
| 636 source)); |
654 if (!local_video_renderer_) { | 637 if (!local_video_renderer_) { |
655 local_video_renderer_.reset(new webrtc::FakeVideoTrackRenderer(track)); | 638 local_video_renderer_.reset(new webrtc::FakeVideoTrackRenderer(track)); |
656 } | 639 } |
657 return track; | 640 return track; |
658 } | 641 } |
659 | 642 |
660 void HandleIncomingOffer(const std::string& msg) { | 643 void HandleIncomingOffer(const std::string& msg) { |
661 LOG(LS_INFO) << debug_name_ << ": HandleIncomingOffer"; | 644 LOG(LS_INFO) << debug_name_ << ": HandleIncomingOffer"; |
662 std::unique_ptr<SessionDescriptionInterface> desc( | 645 std::unique_ptr<SessionDescriptionInterface> desc( |
663 webrtc::CreateSessionDescription("offer", msg, nullptr)); | 646 webrtc::CreateSessionDescription("offer", msg, nullptr)); |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 kDefaultExpectedAudioFrameCount, 0, | 1387 kDefaultExpectedAudioFrameCount, 0, |
1405 kMaxWaitForFramesMs); | 1388 kMaxWaitForFramesMs); |
1406 // Sanity check that the callee's description has a rejected video section. | 1389 // Sanity check that the callee's description has a rejected video section. |
1407 ASSERT_NE(nullptr, callee()->pc()->local_description()); | 1390 ASSERT_NE(nullptr, callee()->pc()->local_description()); |
1408 const ContentInfo* callee_video_content = | 1391 const ContentInfo* callee_video_content = |
1409 GetFirstVideoContent(callee()->pc()->local_description()->description()); | 1392 GetFirstVideoContent(callee()->pc()->local_description()->description()); |
1410 ASSERT_NE(nullptr, callee_video_content); | 1393 ASSERT_NE(nullptr, callee_video_content); |
1411 EXPECT_TRUE(callee_video_content->rejected); | 1394 EXPECT_TRUE(callee_video_content->rejected); |
1412 // Now negotiate with video and ensure negotiation succeeds, with video | 1395 // Now negotiate with video and ensure negotiation succeeds, with video |
1413 // frames and additional audio frames being received. | 1396 // frames and additional audio frames being received. |
1414 callee()->AddMediaStreamFromTracksWithLabel( | 1397 callee()->AddVideoOnlyMediaStream(); |
1415 nullptr, callee()->CreateLocalVideoTrack(), "video_only_stream"); | |
1416 options.offer_to_receive_video = 1; | 1398 options.offer_to_receive_video = 1; |
1417 callee()->SetOfferAnswerOptions(options); | 1399 callee()->SetOfferAnswerOptions(options); |
1418 callee()->CreateAndSetAndSignalOffer(); | 1400 callee()->CreateAndSetAndSignalOffer(); |
1419 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); | 1401 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); |
1420 // Expect additional audio frames to be received after the upgrade. | 1402 // Expect additional audio frames to be received after the upgrade. |
1421 ExpectNewFramesReceivedWithWait( | 1403 ExpectNewFramesReceivedWithWait( |
1422 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, | 1404 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, |
1423 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, | 1405 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, |
1424 kMaxWaitForFramesMs); | 1406 kMaxWaitForFramesMs); |
1425 } | 1407 } |
1426 | 1408 |
1427 // Simpler than the above test; just add an audio track to an established | 1409 // Simpler than the above test; just add an audio track to an established |
1428 // video-only connection. | 1410 // video-only connection. |
1429 TEST_F(PeerConnectionIntegrationTest, AddAudioToVideoOnlyCall) { | 1411 TEST_F(PeerConnectionIntegrationTest, AddAudioToVideoOnlyCall) { |
1430 ASSERT_TRUE(CreatePeerConnectionWrappers()); | 1412 ASSERT_TRUE(CreatePeerConnectionWrappers()); |
1431 ConnectFakeSignaling(); | 1413 ConnectFakeSignaling(); |
1432 // Do initial offer/answer with just a video track. | 1414 // Do initial offer/answer with just a video track. |
1433 caller()->AddVideoOnlyMediaStream(); | 1415 caller()->AddVideoOnlyMediaStream(); |
1434 callee()->AddVideoOnlyMediaStream(); | 1416 callee()->AddVideoOnlyMediaStream(); |
1435 caller()->CreateAndSetAndSignalOffer(); | 1417 caller()->CreateAndSetAndSignalOffer(); |
1436 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); | 1418 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); |
1437 // Now add an audio track and do another offer/answer. | 1419 // Now add an audio track and do another offer/answer. |
1438 caller()->AddMediaStreamFromTracksWithLabel(caller()->CreateLocalAudioTrack(), | 1420 caller()->AddAudioOnlyMediaStream(); |
1439 nullptr, "audio_stream"); | 1421 callee()->AddAudioOnlyMediaStream(); |
1440 callee()->AddMediaStreamFromTracksWithLabel(callee()->CreateLocalAudioTrack(), | |
1441 nullptr, "audio_stream"); | |
1442 caller()->CreateAndSetAndSignalOffer(); | 1422 caller()->CreateAndSetAndSignalOffer(); |
1443 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); | 1423 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); |
1444 // Ensure both audio and video frames are received end-to-end. | 1424 // Ensure both audio and video frames are received end-to-end. |
1445 ExpectNewFramesReceivedWithWait( | 1425 ExpectNewFramesReceivedWithWait( |
1446 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, | 1426 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, |
1447 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, | 1427 kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount, |
1448 kMaxWaitForFramesMs); | 1428 kMaxWaitForFramesMs); |
1449 } | 1429 } |
1450 | 1430 |
1451 // This test sets up a call that's transferred to a new caller with a different | 1431 // This test sets up a call that's transferred to a new caller with a different |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 kMaxWaitForFramesMs); | 1760 kMaxWaitForFramesMs); |
1781 } | 1761 } |
1782 | 1762 |
1783 // Test that if two video tracks are sent (from caller to callee, in this test), | 1763 // Test that if two video tracks are sent (from caller to callee, in this test), |
1784 // they're transmitted correctly end-to-end. | 1764 // they're transmitted correctly end-to-end. |
1785 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithTwoVideoTracks) { | 1765 TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithTwoVideoTracks) { |
1786 ASSERT_TRUE(CreatePeerConnectionWrappers()); | 1766 ASSERT_TRUE(CreatePeerConnectionWrappers()); |
1787 ConnectFakeSignaling(); | 1767 ConnectFakeSignaling(); |
1788 // Add one audio/video stream, and one video-only stream. | 1768 // Add one audio/video stream, and one video-only stream. |
1789 caller()->AddAudioVideoMediaStream(); | 1769 caller()->AddAudioVideoMediaStream(); |
1790 caller()->AddMediaStreamFromTracksWithLabel( | 1770 caller()->AddVideoOnlyMediaStream(); |
1791 nullptr, caller()->CreateLocalVideoTrackWithId("extra_track"), | |
1792 "extra_stream"); | |
1793 caller()->CreateAndSetAndSignalOffer(); | 1771 caller()->CreateAndSetAndSignalOffer(); |
1794 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); | 1772 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); |
1795 ASSERT_EQ(2u, callee()->number_of_remote_streams()); | 1773 ASSERT_EQ(2u, callee()->number_of_remote_streams()); |
1796 int expected_callee_received_frames = kDefaultExpectedVideoFrameCount; | 1774 int expected_callee_received_frames = kDefaultExpectedVideoFrameCount; |
1797 ExpectNewFramesReceivedWithWait(0, 0, 0, expected_callee_received_frames, | 1775 ExpectNewFramesReceivedWithWait(0, 0, 0, expected_callee_received_frames, |
1798 kMaxWaitForFramesMs); | 1776 kMaxWaitForFramesMs); |
1799 } | 1777 } |
1800 | 1778 |
1801 static void MakeSpecCompliantMaxBundleOffer(cricket::SessionDescription* desc) { | 1779 static void MakeSpecCompliantMaxBundleOffer(cricket::SessionDescription* desc) { |
1802 bool first = true; | 1780 bool first = true; |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2993 caller()->CreateAndSetAndSignalOffer(); | 2971 caller()->CreateAndSetAndSignalOffer(); |
2994 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); | 2972 ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); |
2995 // Wait for additional audio frames to be received by the callee. | 2973 // Wait for additional audio frames to be received by the callee. |
2996 ExpectNewFramesReceivedWithWait(0, 0, kDefaultExpectedAudioFrameCount, 0, | 2974 ExpectNewFramesReceivedWithWait(0, 0, kDefaultExpectedAudioFrameCount, 0, |
2997 kMaxWaitForFramesMs); | 2975 kMaxWaitForFramesMs); |
2998 } | 2976 } |
2999 | 2977 |
3000 } // namespace | 2978 } // namespace |
3001 | 2979 |
3002 #endif // if !defined(THREAD_SANITIZER) | 2980 #endif // if !defined(THREAD_SANITIZER) |
OLD | NEW |