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 IceRenomination() { |
| 396 offer_answer_constraints_.SetOptionalIceRenomination(true); |
| 397 offer_answer_options_.ice_renomination = true; |
| 398 expect_ice_renomination_ = true; |
| 399 } |
| 400 void SetExpectRemoteIceRenomination(bool expect_renomination) { |
| 401 expect_remote_ice_renomination_ = expect_renomination; |
| 402 } |
| 403 bool ExpectIceRenomination() { return expect_ice_renomination_; } |
| 404 bool ExpectRemoteIceRenomination() { return expect_remote_ice_renomination_; } |
| 405 |
395 void SetReceiveAudioVideo(bool audio, bool video) { | 406 void SetReceiveAudioVideo(bool audio, bool video) { |
396 SetReceiveAudio(audio); | 407 SetReceiveAudio(audio); |
397 SetReceiveVideo(video); | 408 SetReceiveVideo(video); |
398 ASSERT_EQ(audio, can_receive_audio()); | 409 ASSERT_EQ(audio, can_receive_audio()); |
399 ASSERT_EQ(video, can_receive_video()); | 410 ASSERT_EQ(video, can_receive_video()); |
400 } | 411 } |
401 | 412 |
402 void SetReceiveAudio(bool audio) { | 413 void SetReceiveAudio(bool audio) { |
403 if (audio && can_receive_audio()) | 414 if (audio && can_receive_audio()) |
404 return; | 415 return; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 EXPECT_NE(ufrag_pwd.first, transport_desc->ice_ufrag); | 673 EXPECT_NE(ufrag_pwd.first, transport_desc->ice_ufrag); |
663 EXPECT_NE(ufrag_pwd.second, transport_desc->ice_pwd); | 674 EXPECT_NE(ufrag_pwd.second, transport_desc->ice_pwd); |
664 } else { | 675 } else { |
665 const IceUfragPwdPair& ufrag_pwd = ufragpair_it->second; | 676 const IceUfragPwdPair& ufrag_pwd = ufragpair_it->second; |
666 EXPECT_EQ(ufrag_pwd.first, transport_desc->ice_ufrag); | 677 EXPECT_EQ(ufrag_pwd.first, transport_desc->ice_ufrag); |
667 EXPECT_EQ(ufrag_pwd.second, transport_desc->ice_pwd); | 678 EXPECT_EQ(ufrag_pwd.second, transport_desc->ice_pwd); |
668 } | 679 } |
669 } | 680 } |
670 } | 681 } |
671 | 682 |
| 683 void VerifyLocalIceRenomination() { |
| 684 ASSERT_TRUE(peer_connection_->local_description() != nullptr); |
| 685 const cricket::SessionDescription* desc = |
| 686 peer_connection_->local_description()->description(); |
| 687 const cricket::ContentInfos& contents = desc->contents(); |
| 688 |
| 689 for (auto content : contents) { |
| 690 if (content.rejected) |
| 691 continue; |
| 692 const cricket::TransportDescription* transport_desc = |
| 693 desc->GetTransportDescriptionByName(content.name); |
| 694 const auto& options = transport_desc->transport_options; |
| 695 auto iter = std::find(options.begin(), options.end(), |
| 696 cricket::ICE_RENOMINATION_STR); |
| 697 EXPECT_EQ(ExpectIceRenomination(), iter != options.end()); |
| 698 } |
| 699 } |
| 700 |
| 701 void VerifyRemoteIceReomination() { |
| 702 ASSERT_TRUE(peer_connection_->remote_description() != nullptr); |
| 703 const cricket::SessionDescription* desc = |
| 704 peer_connection_->remote_description()->description(); |
| 705 const cricket::ContentInfos& contents = desc->contents(); |
| 706 |
| 707 for (auto content : contents) { |
| 708 if (content.rejected) |
| 709 continue; |
| 710 const cricket::TransportDescription* transport_desc = |
| 711 desc->GetTransportDescriptionByName(content.name); |
| 712 const auto& options = transport_desc->transport_options; |
| 713 auto iter = std::find(options.begin(), options.end(), |
| 714 cricket::ICE_RENOMINATION_STR); |
| 715 EXPECT_EQ(ExpectRemoteIceRenomination(), iter != options.end()); |
| 716 } |
| 717 } |
| 718 |
672 int GetAudioOutputLevelStats(webrtc::MediaStreamTrackInterface* track) { | 719 int GetAudioOutputLevelStats(webrtc::MediaStreamTrackInterface* track) { |
673 rtc::scoped_refptr<MockStatsObserver> | 720 rtc::scoped_refptr<MockStatsObserver> |
674 observer(new rtc::RefCountedObject<MockStatsObserver>()); | 721 observer(new rtc::RefCountedObject<MockStatsObserver>()); |
675 EXPECT_TRUE(peer_connection_->GetStats( | 722 EXPECT_TRUE(peer_connection_->GetStats( |
676 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)); | 723 observer, track, PeerConnectionInterface::kStatsOutputLevelStandard)); |
677 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); | 724 EXPECT_TRUE_WAIT(observer->called(), kMaxWaitMs); |
678 EXPECT_NE(0, observer->timestamp()); | 725 EXPECT_NE(0, observer->timestamp()); |
679 return observer->AudioOutputLevel(); | 726 return observer->AudioOutputLevel(); |
680 } | 727 } |
681 | 728 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; | 1069 rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; |
1023 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> | 1070 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> |
1024 peer_connection_factory_; | 1071 peer_connection_factory_; |
1025 | 1072 |
1026 bool prefer_constraint_apis_ = true; | 1073 bool prefer_constraint_apis_ = true; |
1027 bool auto_add_stream_ = true; | 1074 bool auto_add_stream_ = true; |
1028 | 1075 |
1029 typedef std::pair<std::string, std::string> IceUfragPwdPair; | 1076 typedef std::pair<std::string, std::string> IceUfragPwdPair; |
1030 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; | 1077 std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; |
1031 bool expect_ice_restart_ = false; | 1078 bool expect_ice_restart_ = false; |
| 1079 bool expect_ice_renomination_ = false; |
| 1080 bool expect_remote_ice_renomination_ = false; |
1032 | 1081 |
1033 // Needed to keep track of number of frames sent. | 1082 // Needed to keep track of number of frames sent. |
1034 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; | 1083 rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; |
1035 // Needed to keep track of number of frames received. | 1084 // Needed to keep track of number of frames received. |
1036 std::map<std::string, std::unique_ptr<webrtc::FakeVideoTrackRenderer>> | 1085 std::map<std::string, std::unique_ptr<webrtc::FakeVideoTrackRenderer>> |
1037 fake_video_renderers_; | 1086 fake_video_renderers_; |
1038 // Needed to ensure frames aren't received for removed tracks. | 1087 // Needed to ensure frames aren't received for removed tracks. |
1039 std::vector<std::unique_ptr<webrtc::FakeVideoTrackRenderer>> | 1088 std::vector<std::unique_ptr<webrtc::FakeVideoTrackRenderer>> |
1040 removed_fake_video_renderers_; | 1089 removed_fake_video_renderers_; |
1041 // Needed to keep track of number of frames received when external decoder | 1090 // Needed to keep track of number of frames received when external decoder |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 // Verify size of the local preview. | 1213 // Verify size of the local preview. |
1165 EXPECT_EQ(width, initializing_client()->local_rendered_width()); | 1214 EXPECT_EQ(width, initializing_client()->local_rendered_width()); |
1166 EXPECT_EQ(height, initializing_client()->local_rendered_height()); | 1215 EXPECT_EQ(height, initializing_client()->local_rendered_height()); |
1167 } | 1216 } |
1168 | 1217 |
1169 void VerifySessionDescriptions() { | 1218 void VerifySessionDescriptions() { |
1170 initiating_client_->VerifyRejectedMediaInSessionDescription(); | 1219 initiating_client_->VerifyRejectedMediaInSessionDescription(); |
1171 receiving_client_->VerifyRejectedMediaInSessionDescription(); | 1220 receiving_client_->VerifyRejectedMediaInSessionDescription(); |
1172 initiating_client_->VerifyLocalIceUfragAndPassword(); | 1221 initiating_client_->VerifyLocalIceUfragAndPassword(); |
1173 receiving_client_->VerifyLocalIceUfragAndPassword(); | 1222 receiving_client_->VerifyLocalIceUfragAndPassword(); |
| 1223 |
| 1224 initiating_client_->VerifyLocalIceRenomination(); |
| 1225 receiving_client_->VerifyLocalIceRenomination(); |
| 1226 initiating_client_->VerifyRemoteIceReomination(); |
| 1227 receiving_client_->VerifyRemoteIceReomination(); |
1174 } | 1228 } |
1175 | 1229 |
1176 ~P2PTestConductor() { | 1230 ~P2PTestConductor() { |
1177 if (initiating_client_) { | 1231 if (initiating_client_) { |
1178 initiating_client_->set_signaling_message_receiver(nullptr); | 1232 initiating_client_->set_signaling_message_receiver(nullptr); |
1179 } | 1233 } |
1180 if (receiving_client_) { | 1234 if (receiving_client_) { |
1181 receiving_client_->set_signaling_message_receiver(nullptr); | 1235 receiving_client_->set_signaling_message_receiver(nullptr); |
1182 } | 1236 } |
1183 } | 1237 } |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 std::string receiver_candidate_restart; | 2112 std::string receiver_candidate_restart; |
2059 EXPECT_TRUE(audio_candidates_reciever_restart->at(0)->ToString( | 2113 EXPECT_TRUE(audio_candidates_reciever_restart->at(0)->ToString( |
2060 &receiver_candidate_restart)); | 2114 &receiver_candidate_restart)); |
2061 | 2115 |
2062 // Verify that the first candidates in the local session descriptions has | 2116 // Verify that the first candidates in the local session descriptions has |
2063 // changed. | 2117 // changed. |
2064 EXPECT_NE(initiator_candidate, initiator_candidate_restart); | 2118 EXPECT_NE(initiator_candidate, initiator_candidate_restart); |
2065 EXPECT_NE(receiver_candidate, receiver_candidate_restart); | 2119 EXPECT_NE(receiver_candidate, receiver_candidate_restart); |
2066 } | 2120 } |
2067 | 2121 |
| 2122 TEST_F(P2PTestConductor, IceRenomination) { |
| 2123 ASSERT_TRUE(CreateTestClients()); |
| 2124 // Only one side supports ICE renomination. |
| 2125 initializing_client()->SetExpectRemoteIceRenomination(true); |
| 2126 receiving_client()->IceRenomination(); |
| 2127 LocalP2PTest(); |
| 2128 |
| 2129 // Both sides support ICE renomination. |
| 2130 initializing_client()->SetExpectRemoteIceRenomination(true); |
| 2131 receiving_client()->SetExpectRemoteIceRenomination(true); |
| 2132 initializing_client()->IceRenomination(); |
| 2133 receiving_client()->IceRenomination(); |
| 2134 // Restart ice on the initializing client. |
| 2135 receiving_client()->SetExpectIceRestart(true); |
| 2136 initializing_client()->IceRestart(); |
| 2137 // Negotiate and wait for ice completion again and verify ICE renominations. |
| 2138 LocalP2PTest(); |
| 2139 } |
| 2140 |
2068 // This test sets up a call between two parties with audio, and video. | 2141 // 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 | 2142 // It then renegotiates setting the video m-line to "port 0", then later |
2070 // renegotiates again, enabling video. | 2143 // renegotiates again, enabling video. |
2071 TEST_F(P2PTestConductor, LocalP2PTestVideoDisableEnable) { | 2144 TEST_F(P2PTestConductor, LocalP2PTestVideoDisableEnable) { |
2072 ASSERT_TRUE(CreateTestClients()); | 2145 ASSERT_TRUE(CreateTestClients()); |
2073 | 2146 |
2074 // Do initial negotiation. Will result in video and audio sendonly m-lines. | 2147 // Do initial negotiation. Will result in video and audio sendonly m-lines. |
2075 receiving_client()->set_auto_add_stream(false); | 2148 receiving_client()->set_auto_add_stream(false); |
2076 initializing_client()->AddMediaStream(true, true); | 2149 initializing_client()->AddMediaStream(true, true); |
2077 initializing_client()->Negotiate(); | 2150 initializing_client()->Negotiate(); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 server.urls.push_back("turn:hostname2"); | 2490 server.urls.push_back("turn:hostname2"); |
2418 servers.push_back(server); | 2491 servers.push_back(server); |
2419 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); | 2492 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); |
2420 EXPECT_EQ(2U, turn_servers_.size()); | 2493 EXPECT_EQ(2U, turn_servers_.size()); |
2421 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); | 2494 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); |
2422 } | 2495 } |
2423 | 2496 |
2424 #endif // if !defined(THREAD_SANITIZER) | 2497 #endif // if !defined(THREAD_SANITIZER) |
2425 | 2498 |
2426 } // namespace | 2499 } // namespace |
OLD | NEW |