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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 offer_answer_options_.ice_restart = true; | 385 offer_answer_options_.ice_restart = true; |
386 SetExpectIceRestart(true); | 386 SetExpectIceRestart(true); |
387 } | 387 } |
388 | 388 |
389 void SetExpectIceRestart(bool expect_restart) { | 389 void SetExpectIceRestart(bool expect_restart) { |
390 expect_ice_restart_ = expect_restart; | 390 expect_ice_restart_ = expect_restart; |
391 } | 391 } |
392 | 392 |
393 bool ExpectIceRestart() const { return expect_ice_restart_; } | 393 bool ExpectIceRestart() const { return expect_ice_restart_; } |
394 | 394 |
395 void SetExpectIceRenomination() { expect_ice_renomination_ = true; } | |
skvlad
2016/08/26 23:59:10
Should this take a bool just like SetExpectRemoteI
honghaiz3
2016/08/29 18:52:52
Done.
| |
396 void SetExpectRemoteIceRenomination(bool expect_renomination) { | |
397 expect_remote_ice_renomination_ = expect_renomination; | |
398 } | |
399 bool ExpectIceRenomination() { return expect_ice_renomination_; } | |
400 bool ExpectRemoteIceRenomination() { return expect_remote_ice_renomination_; } | |
401 | |
395 void SetReceiveAudioVideo(bool audio, bool video) { | 402 void SetReceiveAudioVideo(bool audio, bool video) { |
396 SetReceiveAudio(audio); | 403 SetReceiveAudio(audio); |
397 SetReceiveVideo(video); | 404 SetReceiveVideo(video); |
398 ASSERT_EQ(audio, can_receive_audio()); | 405 ASSERT_EQ(audio, can_receive_audio()); |
399 ASSERT_EQ(video, can_receive_video()); | 406 ASSERT_EQ(video, can_receive_video()); |
400 } | 407 } |
401 | 408 |
402 void SetReceiveAudio(bool audio) { | 409 void SetReceiveAudio(bool audio) { |
403 if (audio && can_receive_audio()) | 410 if (audio && can_receive_audio()) |
404 return; | 411 return; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
662 EXPECT_NE(ufrag_pwd.first, transport_desc->ice_ufrag); | 669 EXPECT_NE(ufrag_pwd.first, transport_desc->ice_ufrag); |
663 EXPECT_NE(ufrag_pwd.second, transport_desc->ice_pwd); | 670 EXPECT_NE(ufrag_pwd.second, transport_desc->ice_pwd); |
664 } else { | 671 } else { |
665 const IceUfragPwdPair& ufrag_pwd = ufragpair_it->second; | 672 const IceUfragPwdPair& ufrag_pwd = ufragpair_it->second; |
666 EXPECT_EQ(ufrag_pwd.first, transport_desc->ice_ufrag); | 673 EXPECT_EQ(ufrag_pwd.first, transport_desc->ice_ufrag); |
667 EXPECT_EQ(ufrag_pwd.second, transport_desc->ice_pwd); | 674 EXPECT_EQ(ufrag_pwd.second, transport_desc->ice_pwd); |
668 } | 675 } |
669 } | 676 } |
670 } | 677 } |
671 | 678 |
679 void VerifyLocalIceRenomination() { | |
680 ASSERT_TRUE(peer_connection_->local_description() != nullptr); | |
681 const cricket::SessionDescription* desc = | |
682 peer_connection_->local_description()->description(); | |
683 const cricket::ContentInfos& contents = desc->contents(); | |
684 | |
685 for (auto content : contents) { | |
686 if (content.rejected) | |
687 continue; | |
688 const cricket::TransportDescription* transport_desc = | |
689 desc->GetTransportDescriptionByName(content.name); | |
690 const auto& options = transport_desc->transport_options; | |
691 auto iter = std::find(options.begin(), options.end(), | |
692 cricket::ICE_RENOMINATION_STR); | |
693 EXPECT_EQ(ExpectIceRenomination(), iter != options.end()); | |
694 } | |
695 } | |
696 | |
697 void VerifyRemoteIceRenomination() { | |
698 ASSERT_TRUE(peer_connection_->remote_description() != nullptr); | |
699 const cricket::SessionDescription* desc = | |
700 peer_connection_->remote_description()->description(); | |
701 const cricket::ContentInfos& contents = desc->contents(); | |
702 | |
703 for (auto content : contents) { | |
704 if (content.rejected) | |
705 continue; | |
706 const cricket::TransportDescription* transport_desc = | |
707 desc->GetTransportDescriptionByName(content.name); | |
708 const auto& options = transport_desc->transport_options; | |
709 auto iter = std::find(options.begin(), options.end(), | |
710 cricket::ICE_RENOMINATION_STR); | |
711 EXPECT_EQ(ExpectRemoteIceRenomination(), iter != options.end()); | |
712 } | |
713 } | |
714 | |
672 int GetAudioOutputLevelStats(webrtc::MediaStreamTrackInterface* track) { | 715 int GetAudioOutputLevelStats(webrtc::MediaStreamTrackInterface* track) { |
673 rtc::scoped_refptr<MockStatsObserver> | 716 rtc::scoped_refptr<MockStatsObserver> |
674 observer(new rtc::RefCountedObject<MockStatsObserver>()); | 717 observer(new rtc::RefCountedObject<MockStatsObserver>()); |
675 EXPECT_TRUE(peer_connection_->GetStats( | 718 EXPECT_TRUE(peer_connection_->GetStats( |
676 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)); | 719 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)); |
677 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); | 720 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); |
678 EXPECT_NE(0, observer->timestamp()); | 721 EXPECT_NE(0, observer->timestamp()); |
679 return observer->AudioOutputLevel(); | 722 return observer->AudioOutputLevel(); |
680 } | 723 } |
681 | 724 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1022 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; | 1065 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; |
1023 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> | 1066 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> |
1024 peer_connection_factory_; | 1067 peer_connection_factory_; |
1025 | 1068 |
1026 bool prefer_constraint_apis_ = true; | 1069 bool prefer_constraint_apis_ = true; |
1027 bool auto_add_stream_ = true; | 1070 bool auto_add_stream_ = true; |
1028 | 1071 |
1029 typedef std::pair<std::string, std::string> IceUfragPwdPair; | 1072 typedef std::pair<std::string, std::string> IceUfragPwdPair; |
1030 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; | 1073 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; |
1031 bool expect_ice_restart_ = false; | 1074 bool expect_ice_restart_ = false; |
1075 bool expect_ice_renomination_ = false; | |
1076 bool expect_remote_ice_renomination_ = false; | |
1032 | 1077 |
1033 // Needed to keep track of number of frames sent. | 1078 // Needed to keep track of number of frames sent. |
1034 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; | 1079 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; |
1035 // Needed to keep track of number of frames received. | 1080 // Needed to keep track of number of frames received. |
1036 std::map<std::string, std::unique_ptr<webrtc::FakeVideoTrackRenderer>> | 1081 std::map<std::string, std::unique_ptr<webrtc::FakeVideoTrackRenderer>> |
1037 fake_video_renderers_; | 1082 fake_video_renderers_; |
1038 // Needed to ensure frames aren't received for removed tracks. | 1083 // Needed to ensure frames aren't received for removed tracks. |
1039 std::vector<std::unique_ptr<webrtc::FakeVideoTrackRenderer>> | 1084 std::vector<std::unique_ptr<webrtc::FakeVideoTrackRenderer>> |
1040 removed_fake_video_renderers_; | 1085 removed_fake_video_renderers_; |
1041 // Needed to keep track of number of frames received when external decoder | 1086 // Needed to keep track of number of frames received when external decoder |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2058 std::string receiver_candidate_restart; | 2103 std::string receiver_candidate_restart; |
2059 EXPECT_TRUE(audio_candidates_reciever_restart->at(0)->ToString( | 2104 EXPECT_TRUE(audio_candidates_reciever_restart->at(0)->ToString( |
2060 &receiver_candidate_restart)); | 2105 &receiver_candidate_restart)); |
2061 | 2106 |
2062 // Verify that the first candidates in the local session descriptions has | 2107 // Verify that the first candidates in the local session descriptions has |
2063 // changed. | 2108 // changed. |
2064 EXPECT_NE(initiator_candidate, initiator_candidate_restart); | 2109 EXPECT_NE(initiator_candidate, initiator_candidate_restart); |
2065 EXPECT_NE(receiver_candidate, receiver_candidate_restart); | 2110 EXPECT_NE(receiver_candidate, receiver_candidate_restart); |
2066 } | 2111 } |
2067 | 2112 |
2113 TEST_F(P2PTestConductor, IceRenominationDisabled) { | |
2114 config()->ice_renomination = false; | |
2115 ASSERT_TRUE(CreateTestClients()); | |
2116 LocalP2PTest(); | |
2117 | |
2118 initializing_client()->VerifyLocalIceRenomination(); | |
2119 receiving_client()->VerifyLocalIceRenomination(); | |
2120 initializing_client()->VerifyRemoteIceRenomination(); | |
2121 receiving_client()->VerifyRemoteIceRenomination(); | |
2122 } | |
2123 | |
2124 TEST_F(P2PTestConductor, IceRenominationEnabled) { | |
2125 config()->ice_renomination = true; | |
2126 ASSERT_TRUE(CreateTestClients()); | |
2127 initializing_client()->SetExpectIceRenomination(); | |
2128 initializing_client()->SetExpectRemoteIceRenomination(true); | |
2129 receiving_client()->SetExpectIceRenomination(); | |
2130 receiving_client()->SetExpectRemoteIceRenomination(true); | |
2131 LocalP2PTest(); | |
2132 | |
2133 initializing_client()->VerifyLocalIceRenomination(); | |
2134 receiving_client()->VerifyLocalIceRenomination(); | |
2135 initializing_client()->VerifyRemoteIceRenomination(); | |
2136 receiving_client()->VerifyRemoteIceRenomination(); | |
2137 } | |
2138 | |
2068 // This test sets up a call between two parties with audio, and video. | 2139 // This test sets up a call between two parties with audio, and video. |
2069 // It then renegotiates setting the video m-line to "port 0", then later | 2140 // It then renegotiates setting the video m-line to "port 0", then later |
2070 // renegotiates again, enabling video. | 2141 // renegotiates again, enabling video. |
2071 TEST_F(P2PTestConductor, LocalP2PTestVideoDisableEnable) { | 2142 TEST_F(P2PTestConductor, LocalP2PTestVideoDisableEnable) { |
2072 ASSERT_TRUE(CreateTestClients()); | 2143 ASSERT_TRUE(CreateTestClients()); |
2073 | 2144 |
2074 // Do initial negotiation. Will result in video and audio sendonly m-lines. | 2145 // Do initial negotiation. Will result in video and audio sendonly m-lines. |
2075 receiving_client()->set_auto_add_stream(false); | 2146 receiving_client()->set_auto_add_stream(false); |
2076 initializing_client()->AddMediaStream(true, true); | 2147 initializing_client()->AddMediaStream(true, true); |
2077 initializing_client()->Negotiate(); | 2148 initializing_client()->Negotiate(); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2417 server.urls.push_back("turn:hostname2"); | 2488 server.urls.push_back("turn:hostname2"); |
2418 servers.push_back(server); | 2489 servers.push_back(server); |
2419 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); | 2490 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); |
2420 EXPECT_EQ(2U, turn_servers_.size()); | 2491 EXPECT_EQ(2U, turn_servers_.size()); |
2421 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); | 2492 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); |
2422 } | 2493 } |
2423 | 2494 |
2424 #endif // if !defined(THREAD_SANITIZER) | 2495 #endif // if !defined(THREAD_SANITIZER) |
2425 | 2496 |
2426 } // namespace | 2497 } // namespace |
OLD | NEW |