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

Side by Side Diff: webrtc/api/peerconnection_unittest.cc

Issue 2224563004: Add signaling to support ICE renomination. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Merge Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « webrtc/api/peerconnection.cc ('k') | webrtc/api/peerconnectioninterface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 offer_answer_options_.ice_restart = true; 386 offer_answer_options_.ice_restart = true;
387 SetExpectIceRestart(true); 387 SetExpectIceRestart(true);
388 } 388 }
389 389
390 void SetExpectIceRestart(bool expect_restart) { 390 void SetExpectIceRestart(bool expect_restart) {
391 expect_ice_restart_ = expect_restart; 391 expect_ice_restart_ = expect_restart;
392 } 392 }
393 393
394 bool ExpectIceRestart() const { return expect_ice_restart_; } 394 bool ExpectIceRestart() const { return expect_ice_restart_; }
395 395
396 void SetExpectIceRenomination(bool expect_renomination) {
397 expect_ice_renomination_ = expect_renomination;
398 }
399 void SetExpectRemoteIceRenomination(bool expect_renomination) {
400 expect_remote_ice_renomination_ = expect_renomination;
401 }
402 bool ExpectIceRenomination() { return expect_ice_renomination_; }
403 bool ExpectRemoteIceRenomination() { return expect_remote_ice_renomination_; }
404
396 void SetReceiveAudioVideo(bool audio, bool video) { 405 void SetReceiveAudioVideo(bool audio, bool video) {
397 SetReceiveAudio(audio); 406 SetReceiveAudio(audio);
398 SetReceiveVideo(video); 407 SetReceiveVideo(video);
399 ASSERT_EQ(audio, can_receive_audio()); 408 ASSERT_EQ(audio, can_receive_audio());
400 ASSERT_EQ(video, can_receive_video()); 409 ASSERT_EQ(video, can_receive_video());
401 } 410 }
402 411
403 void SetReceiveAudio(bool audio) { 412 void SetReceiveAudio(bool audio) {
404 if (audio && can_receive_audio()) 413 if (audio && can_receive_audio())
405 return; 414 return;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 EXPECT_NE(ufrag_pwd.first, transport_desc->ice_ufrag); 672 EXPECT_NE(ufrag_pwd.first, transport_desc->ice_ufrag);
664 EXPECT_NE(ufrag_pwd.second, transport_desc->ice_pwd); 673 EXPECT_NE(ufrag_pwd.second, transport_desc->ice_pwd);
665 } else { 674 } else {
666 const IceUfragPwdPair& ufrag_pwd = ufragpair_it->second; 675 const IceUfragPwdPair& ufrag_pwd = ufragpair_it->second;
667 EXPECT_EQ(ufrag_pwd.first, transport_desc->ice_ufrag); 676 EXPECT_EQ(ufrag_pwd.first, transport_desc->ice_ufrag);
668 EXPECT_EQ(ufrag_pwd.second, transport_desc->ice_pwd); 677 EXPECT_EQ(ufrag_pwd.second, transport_desc->ice_pwd);
669 } 678 }
670 } 679 }
671 } 680 }
672 681
682 void VerifyLocalIceRenomination() {
683 ASSERT_TRUE(peer_connection_->local_description() != nullptr);
684 const cricket::SessionDescription* desc =
685 peer_connection_->local_description()->description();
686 const cricket::ContentInfos& contents = desc->contents();
687
688 for (auto content : contents) {
689 if (content.rejected)
690 continue;
691 const cricket::TransportDescription* transport_desc =
692 desc->GetTransportDescriptionByName(content.name);
693 const auto& options = transport_desc->transport_options;
694 auto iter = std::find(options.begin(), options.end(),
695 cricket::ICE_RENOMINATION_STR);
696 EXPECT_EQ(ExpectIceRenomination(), iter != options.end());
697 }
698 }
699
700 void VerifyRemoteIceRenomination() {
701 ASSERT_TRUE(peer_connection_->remote_description() != nullptr);
702 const cricket::SessionDescription* desc =
703 peer_connection_->remote_description()->description();
704 const cricket::ContentInfos& contents = desc->contents();
705
706 for (auto content : contents) {
707 if (content.rejected)
708 continue;
709 const cricket::TransportDescription* transport_desc =
710 desc->GetTransportDescriptionByName(content.name);
711 const auto& options = transport_desc->transport_options;
712 auto iter = std::find(options.begin(), options.end(),
713 cricket::ICE_RENOMINATION_STR);
714 EXPECT_EQ(ExpectRemoteIceRenomination(), iter != options.end());
715 }
716 }
717
673 int GetAudioOutputLevelStats(webrtc::MediaStreamTrackInterface* track) { 718 int GetAudioOutputLevelStats(webrtc::MediaStreamTrackInterface* track) {
674 rtc::scoped_refptr<MockStatsObserver> 719 rtc::scoped_refptr<MockStatsObserver>
675 observer(new rtc::RefCountedObject<MockStatsObserver>()); 720 observer(new rtc::RefCountedObject<MockStatsObserver>());
676 EXPECT_TRUE(peer_connection_->GetStats( 721 EXPECT_TRUE(peer_connection_->GetStats(
677 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)); 722 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard));
678 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); 723 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs);
679 EXPECT_NE(0, observer->timestamp()); 724 EXPECT_NE(0, observer->timestamp());
680 return observer->AudioOutputLevel(); 725 return observer->AudioOutputLevel();
681 } 726 }
682 727
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; 1068 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
1024 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> 1069 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
1025 peer_connection_factory_; 1070 peer_connection_factory_;
1026 1071
1027 bool prefer_constraint_apis_ = true; 1072 bool prefer_constraint_apis_ = true;
1028 bool auto_add_stream_ = true; 1073 bool auto_add_stream_ = true;
1029 1074
1030 typedef std::pair<std::string, std::string> IceUfragPwdPair; 1075 typedef std::pair<std::string, std::string> IceUfragPwdPair;
1031 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; 1076 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_;
1032 bool expect_ice_restart_ = false; 1077 bool expect_ice_restart_ = false;
1078 bool expect_ice_renomination_ = false;
1079 bool expect_remote_ice_renomination_ = false;
1033 1080
1034 // Needed to keep track of number of frames sent. 1081 // Needed to keep track of number of frames sent.
1035 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; 1082 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_;
1036 // Needed to keep track of number of frames received. 1083 // Needed to keep track of number of frames received.
1037 std::map<std::string, std::unique_ptr<webrtc::FakeVideoTrackRenderer>> 1084 std::map<std::string, std::unique_ptr<webrtc::FakeVideoTrackRenderer>>
1038 fake_video_renderers_; 1085 fake_video_renderers_;
1039 // Needed to ensure frames aren't received for removed tracks. 1086 // Needed to ensure frames aren't received for removed tracks.
1040 std::vector<std::unique_ptr<webrtc::FakeVideoTrackRenderer>> 1087 std::vector<std::unique_ptr<webrtc::FakeVideoTrackRenderer>>
1041 removed_fake_video_renderers_; 1088 removed_fake_video_renderers_;
1042 // Needed to keep track of number of frames received when external decoder 1089 // Needed to keep track of number of frames received when external decoder
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 std::string receiver_candidate_restart; 2168 std::string receiver_candidate_restart;
2122 EXPECT_TRUE(audio_candidates_reciever_restart->at(0)->ToString( 2169 EXPECT_TRUE(audio_candidates_reciever_restart->at(0)->ToString(
2123 &receiver_candidate_restart)); 2170 &receiver_candidate_restart));
2124 2171
2125 // Verify that the first candidates in the local session descriptions has 2172 // Verify that the first candidates in the local session descriptions has
2126 // changed. 2173 // changed.
2127 EXPECT_NE(initiator_candidate, initiator_candidate_restart); 2174 EXPECT_NE(initiator_candidate, initiator_candidate_restart);
2128 EXPECT_NE(receiver_candidate, receiver_candidate_restart); 2175 EXPECT_NE(receiver_candidate, receiver_candidate_restart);
2129 } 2176 }
2130 2177
2178 TEST_F(P2PTestConductor, IceRenominationDisabled) {
2179 config()->enable_ice_renomination = false;
2180 ASSERT_TRUE(CreateTestClients());
2181 LocalP2PTest();
2182
2183 initializing_client()->VerifyLocalIceRenomination();
2184 receiving_client()->VerifyLocalIceRenomination();
2185 initializing_client()->VerifyRemoteIceRenomination();
2186 receiving_client()->VerifyRemoteIceRenomination();
2187 }
2188
2189 TEST_F(P2PTestConductor, IceRenominationEnabled) {
2190 config()->enable_ice_renomination = true;
2191 ASSERT_TRUE(CreateTestClients());
2192 initializing_client()->SetExpectIceRenomination(true);
2193 initializing_client()->SetExpectRemoteIceRenomination(true);
2194 receiving_client()->SetExpectIceRenomination(true);
2195 receiving_client()->SetExpectRemoteIceRenomination(true);
2196 LocalP2PTest();
2197
2198 initializing_client()->VerifyLocalIceRenomination();
2199 receiving_client()->VerifyLocalIceRenomination();
2200 initializing_client()->VerifyRemoteIceRenomination();
2201 receiving_client()->VerifyRemoteIceRenomination();
2202 }
2203
2131 // This test sets up a call between two parties with audio, and video. 2204 // This test sets up a call between two parties with audio, and video.
2132 // It then renegotiates setting the video m-line to "port 0", then later 2205 // It then renegotiates setting the video m-line to "port 0", then later
2133 // renegotiates again, enabling video. 2206 // renegotiates again, enabling video.
2134 TEST_F(P2PTestConductor, LocalP2PTestVideoDisableEnable) { 2207 TEST_F(P2PTestConductor, LocalP2PTestVideoDisableEnable) {
2135 ASSERT_TRUE(CreateTestClients()); 2208 ASSERT_TRUE(CreateTestClients());
2136 2209
2137 // Do initial negotiation. Will result in video and audio sendonly m-lines. 2210 // Do initial negotiation. Will result in video and audio sendonly m-lines.
2138 receiving_client()->set_auto_add_stream(false); 2211 receiving_client()->set_auto_add_stream(false);
2139 initializing_client()->AddMediaStream(true, true); 2212 initializing_client()->AddMediaStream(true, true);
2140 initializing_client()->Negotiate(); 2213 initializing_client()->Negotiate();
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
2480 server.urls.push_back("turn:hostname2"); 2553 server.urls.push_back("turn:hostname2");
2481 servers.push_back(server); 2554 servers.push_back(server);
2482 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); 2555 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_));
2483 EXPECT_EQ(2U, turn_servers_.size()); 2556 EXPECT_EQ(2U, turn_servers_.size());
2484 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); 2557 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority);
2485 } 2558 }
2486 2559
2487 #endif // if !defined(THREAD_SANITIZER) 2560 #endif // if !defined(THREAD_SANITIZER)
2488 2561
2489 } // namespace 2562 } // namespace
OLDNEW
« no previous file with comments | « webrtc/api/peerconnection.cc ('k') | webrtc/api/peerconnectioninterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698