OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 } | 651 } |
652 | 652 |
653 webrtc::PeerConnectionInterface::IceConnectionState ice_connection_state() { | 653 webrtc::PeerConnectionInterface::IceConnectionState ice_connection_state() { |
654 return pc()->ice_connection_state(); | 654 return pc()->ice_connection_state(); |
655 } | 655 } |
656 | 656 |
657 webrtc::PeerConnectionInterface::IceGatheringState ice_gathering_state() { | 657 webrtc::PeerConnectionInterface::IceGatheringState ice_gathering_state() { |
658 return pc()->ice_gathering_state(); | 658 return pc()->ice_gathering_state(); |
659 } | 659 } |
660 | 660 |
661 static void set_use_alternate_key(bool use_alternate_key) { | |
662 use_alternate_key_ = use_alternate_key; | |
pthatcher1
2015/11/18 20:42:43
Why is this (and use_alternate_key_) static?
guoweis_webrtc
2015/11/25 21:03:13
Done.
| |
663 } | |
664 | |
661 private: | 665 private: |
662 class DummyDtmfObserver : public DtmfSenderObserverInterface { | 666 class DummyDtmfObserver : public DtmfSenderObserverInterface { |
663 public: | 667 public: |
664 DummyDtmfObserver() : completed_(false) {} | 668 DummyDtmfObserver() : completed_(false) {} |
665 | 669 |
666 // Implements DtmfSenderObserverInterface. | 670 // Implements DtmfSenderObserverInterface. |
667 void OnToneChange(const std::string& tone) override { | 671 void OnToneChange(const std::string& tone) override { |
668 tones_.push_back(tone); | 672 tones_.push_back(tone); |
669 if (tone.empty()) { | 673 if (tone.empty()) { |
670 completed_ = true; | 674 completed_ = true; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 | 737 |
734 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( | 738 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( |
735 webrtc::PortAllocatorFactoryInterface* factory, | 739 webrtc::PortAllocatorFactoryInterface* factory, |
736 const MediaConstraintsInterface* constraints) { | 740 const MediaConstraintsInterface* constraints) { |
737 // CreatePeerConnection with IceServers. | 741 // CreatePeerConnection with IceServers. |
738 webrtc::PeerConnectionInterface::IceServers ice_servers; | 742 webrtc::PeerConnectionInterface::IceServers ice_servers; |
739 webrtc::PeerConnectionInterface::IceServer ice_server; | 743 webrtc::PeerConnectionInterface::IceServer ice_server; |
740 ice_server.uri = "stun:stun.l.google.com:19302"; | 744 ice_server.uri = "stun:stun.l.google.com:19302"; |
741 ice_servers.push_back(ice_server); | 745 ice_servers.push_back(ice_server); |
742 | 746 |
743 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( | 747 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
744 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() | 748 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
745 : nullptr); | 749 : nullptr); |
750 | |
751 if (use_alternate_key_) { | |
752 dtls_identity_store->use_alternate_key(); | |
753 } else { | |
754 dtls_identity_store->use_original_key(); | |
755 } | |
746 return peer_connection_factory_->CreatePeerConnection( | 756 return peer_connection_factory_->CreatePeerConnection( |
747 ice_servers, constraints, factory, dtls_identity_store.Pass(), this); | 757 ice_servers, constraints, factory, dtls_identity_store.Pass(), this); |
748 } | 758 } |
749 | 759 |
750 void HandleIncomingOffer(const std::string& msg) { | 760 void HandleIncomingOffer(const std::string& msg) { |
751 LOG(INFO) << id_ << "HandleIncomingOffer "; | 761 LOG(INFO) << id_ << "HandleIncomingOffer "; |
752 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { | 762 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { |
753 // If we are not sending any streams ourselves it is time to add some. | 763 // If we are not sending any streams ourselves it is time to add some. |
754 AddMediaStream(true, true); | 764 AddMediaStream(true, true); |
755 } | 765 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
883 | 893 |
884 webrtc::FakeConstraints session_description_constraints_; | 894 webrtc::FakeConstraints session_description_constraints_; |
885 bool remove_msid_ = false; // True if MSID should be removed in received SDP. | 895 bool remove_msid_ = false; // True if MSID should be removed in received SDP. |
886 bool remove_bundle_ = | 896 bool remove_bundle_ = |
887 false; // True if bundle should be removed in received SDP. | 897 false; // True if bundle should be removed in received SDP. |
888 bool remove_sdes_ = | 898 bool remove_sdes_ = |
889 false; // True if a=crypto should be removed in received SDP. | 899 false; // True if a=crypto should be removed in received SDP. |
890 | 900 |
891 rtc::scoped_refptr<DataChannelInterface> data_channel_; | 901 rtc::scoped_refptr<DataChannelInterface> data_channel_; |
892 rtc::scoped_ptr<MockDataChannelObserver> data_observer_; | 902 rtc::scoped_ptr<MockDataChannelObserver> data_observer_; |
903 | |
904 static bool use_alternate_key_; | |
893 }; | 905 }; |
894 | 906 |
907 // FakeDtlsIdentityStore supports 2 keys. We'll use the original key to start | |
908 // with. | |
909 bool PeerConnectionTestClient::use_alternate_key_ = false; | |
910 | |
895 // TODO(deadbeef): Rename this to P2PTestConductor once the Linux memcheck and | 911 // TODO(deadbeef): Rename this to P2PTestConductor once the Linux memcheck and |
896 // Windows DrMemory Full bots' blacklists are updated. | 912 // Windows DrMemory Full bots' blacklists are updated. |
897 class JsepPeerConnectionP2PTestClient : public testing::Test { | 913 class JsepPeerConnectionP2PTestClient : public testing::Test { |
898 public: | 914 public: |
899 JsepPeerConnectionP2PTestClient() | 915 JsepPeerConnectionP2PTestClient() |
900 : pss_(new rtc::PhysicalSocketServer), | 916 : pss_(new rtc::PhysicalSocketServer), |
901 ss_(new rtc::VirtualSocketServer(pss_.get())), | 917 ss_(new rtc::VirtualSocketServer(pss_.get())), |
902 ss_scope_(ss_.get()) {} | 918 ss_scope_(ss_.get()) {} |
903 | 919 |
904 bool SessionActive() { | 920 bool SessionActive() { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 } | 977 } |
962 | 978 |
963 bool CreateTestClients() { return CreateTestClients(nullptr, nullptr); } | 979 bool CreateTestClients() { return CreateTestClients(nullptr, nullptr); } |
964 | 980 |
965 bool CreateTestClients(MediaConstraintsInterface* init_constraints, | 981 bool CreateTestClients(MediaConstraintsInterface* init_constraints, |
966 MediaConstraintsInterface* recv_constraints) { | 982 MediaConstraintsInterface* recv_constraints) { |
967 return CreateTestClients(init_constraints, nullptr, recv_constraints, | 983 return CreateTestClients(init_constraints, nullptr, recv_constraints, |
968 nullptr); | 984 nullptr); |
969 } | 985 } |
970 | 986 |
987 void MutuallySetSignalingReceiver() { | |
pthatcher1
2015/11/18 20:42:43
How about "SetSignalingReceivers" (an "s" on the e
guoweis_webrtc
2015/11/25 21:03:13
Done.
| |
988 initiating_client_->set_signaling_message_receiver(receiving_client_.get()); | |
989 receiving_client_->set_signaling_message_receiver(initiating_client_.get()); | |
990 } | |
991 | |
971 bool CreateTestClients(MediaConstraintsInterface* init_constraints, | 992 bool CreateTestClients(MediaConstraintsInterface* init_constraints, |
972 PeerConnectionFactory::Options* init_options, | 993 PeerConnectionFactory::Options* init_options, |
973 MediaConstraintsInterface* recv_constraints, | 994 MediaConstraintsInterface* recv_constraints, |
974 PeerConnectionFactory::Options* recv_options) { | 995 PeerConnectionFactory::Options* recv_options) { |
975 initiating_client_.reset(PeerConnectionTestClient::CreateClient( | 996 initiating_client_.reset(PeerConnectionTestClient::CreateClient( |
976 "Caller: ", init_constraints, init_options)); | 997 "Caller: ", init_constraints, init_options)); |
977 receiving_client_.reset(PeerConnectionTestClient::CreateClient( | 998 receiving_client_.reset(PeerConnectionTestClient::CreateClient( |
978 "Callee: ", recv_constraints, recv_options)); | 999 "Callee: ", recv_constraints, recv_options)); |
979 if (!initiating_client_ || !receiving_client_) { | 1000 if (!initiating_client_ || !receiving_client_) { |
980 return false; | 1001 return false; |
981 } | 1002 } |
982 initiating_client_->set_signaling_message_receiver(receiving_client_.get()); | 1003 MutuallySetSignalingReceiver(); |
983 receiving_client_->set_signaling_message_receiver(initiating_client_.get()); | |
984 return true; | 1004 return true; |
985 } | 1005 } |
986 | 1006 |
987 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints, | 1007 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints, |
988 const webrtc::FakeConstraints& recv_constraints) { | 1008 const webrtc::FakeConstraints& recv_constraints) { |
989 initiating_client_->SetVideoConstraints(init_constraints); | 1009 initiating_client_->SetVideoConstraints(init_constraints); |
990 receiving_client_->SetVideoConstraints(recv_constraints); | 1010 receiving_client_->SetVideoConstraints(recv_constraints); |
991 } | 1011 } |
992 | 1012 |
993 void EnableVideoDecoderFactory() { | 1013 void EnableVideoDecoderFactory() { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1051 receiving_client_->can_receive_video()) { | 1071 receiving_client_->can_receive_video()) { |
1052 EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceGatheringComplete, | 1072 EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceGatheringComplete, |
1053 receiving_client_->ice_gathering_state(), | 1073 receiving_client_->ice_gathering_state(), |
1054 kMaxWaitForFramesMs); | 1074 kMaxWaitForFramesMs); |
1055 } | 1075 } |
1056 | 1076 |
1057 EXPECT_TRUE_WAIT(FramesNotPending(audio_frame_count, video_frame_count), | 1077 EXPECT_TRUE_WAIT(FramesNotPending(audio_frame_count, video_frame_count), |
1058 kMaxWaitForFramesMs); | 1078 kMaxWaitForFramesMs); |
1059 } | 1079 } |
1060 | 1080 |
1081 // This test sets up a successful call then do the call transfer to another | |
pthatcher1
2015/11/18 20:42:42
do => does
the call transfer => a call transfer
guoweis_webrtc
2015/11/25 21:03:13
Done.
| |
1082 // caller or callee. It uses the alternate identity in FakeDtlsIdentityStore | |
1083 // to make sure a different certificate/fingerprint is used. | |
1084 void TransferCall(bool test_callee) { | |
1085 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
1086 FakeConstraints setup_constraints; | |
1087 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, | |
1088 true); | |
pthatcher1
2015/11/18 20:42:42
Isn't this the default by now?
guoweis_webrtc
2015/11/25 21:03:13
It's not very clear. might be the case from https:
| |
1089 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | |
1090 LocalP2PTest(); | |
1091 VerifyRenderedSize(640, 480); | |
1092 | |
1093 LOG(LS_INFO) << "Starting call transfer"; | |
1094 | |
1095 // Make sure the new client is using a different certificate. | |
1096 PeerConnectionTestClient::set_use_alternate_key(true); | |
1097 rtc::scoped_ptr<PeerConnectionTestClient> new_client( | |
1098 PeerConnectionTestClient::CreateClient("New Peer: ", &setup_constraints, | |
1099 nullptr)); | |
1100 | |
1101 // Keeping the original peer around which will still send packets to the | |
1102 // receiving client. These SRTP packets will be dropped. | |
1103 rtc::scoped_ptr<PeerConnectionTestClient> original_peer; | |
1104 if (test_callee) { | |
1105 original_peer.reset(swap_initializing_client(new_client.release())); | |
pthatcher1
2015/11/18 20:42:43
Wouldn't this work?
if (test_callee) {
original
guoweis_webrtc
2015/11/25 21:03:13
Done.
| |
1106 } else { | |
1107 original_peer.reset(swap_receiving_client(new_client.release())); | |
1108 } | |
1109 | |
1110 // Restore the original certificate to the transfee. | |
1111 PeerConnectionTestClient::set_use_alternate_key(false); | |
1112 MutuallySetSignalingReceiver(); | |
1113 if (test_callee) { | |
1114 receiving_client()->SetExpectIceRestart(true); | |
1115 } else { | |
1116 initializing_client()->IceRestart(); | |
1117 } | |
1118 LocalP2PTest(); | |
1119 VerifyRenderedSize(640, 480); | |
1120 } | |
1121 | |
1061 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { | 1122 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { |
1062 // Messages may get lost on the unreliable DataChannel, so we send multiple | 1123 // Messages may get lost on the unreliable DataChannel, so we send multiple |
1063 // times to avoid test flakiness. | 1124 // times to avoid test flakiness. |
1064 static const size_t kSendAttempts = 5; | 1125 static const size_t kSendAttempts = 5; |
1065 | 1126 |
1066 for (size_t i = 0; i < kSendAttempts; ++i) { | 1127 for (size_t i = 0; i < kSendAttempts; ++i) { |
1067 dc->Send(DataBuffer(data)); | 1128 dc->Send(DataBuffer(data)); |
1068 } | 1129 } |
1069 } | 1130 } |
1070 | 1131 |
1071 PeerConnectionTestClient* initializing_client() { | 1132 PeerConnectionTestClient* initializing_client() { |
1072 return initiating_client_.get(); | 1133 return initiating_client_.get(); |
1073 } | 1134 } |
1135 | |
1136 // Reset the |initiating_client_| to the |client| passed in and return the | |
1137 // original |initiating_client_|. | |
1138 PeerConnectionTestClient* swap_initializing_client( | |
1139 PeerConnectionTestClient* client) { | |
1140 PeerConnectionTestClient* old = initiating_client_.release(); | |
1141 initiating_client_.reset(client); | |
1142 return old; | |
1143 } | |
1144 | |
1074 PeerConnectionTestClient* receiving_client() { | 1145 PeerConnectionTestClient* receiving_client() { |
1075 return receiving_client_.get(); | 1146 return receiving_client_.get(); |
1076 } | 1147 } |
1077 | 1148 |
1149 // Reset the |receiving_client_| to the |client| passed in and return the | |
1150 // original |receiving_client_|. | |
1151 PeerConnectionTestClient* swap_receiving_client( | |
1152 PeerConnectionTestClient* client) { | |
1153 PeerConnectionTestClient* old = receiving_client_.release(); | |
1154 receiving_client_.reset(client); | |
1155 return old; | |
1156 } | |
1157 | |
1078 private: | 1158 private: |
1079 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; | 1159 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; |
1080 rtc::scoped_ptr<rtc::VirtualSocketServer> ss_; | 1160 rtc::scoped_ptr<rtc::VirtualSocketServer> ss_; |
1081 rtc::SocketServerScope ss_scope_; | 1161 rtc::SocketServerScope ss_scope_; |
1082 rtc::scoped_ptr<PeerConnectionTestClient> initiating_client_; | 1162 rtc::scoped_ptr<PeerConnectionTestClient> initiating_client_; |
1083 rtc::scoped_ptr<PeerConnectionTestClient> receiving_client_; | 1163 rtc::scoped_ptr<PeerConnectionTestClient> receiving_client_; |
1084 }; | 1164 }; |
1085 | 1165 |
1086 // Disable for TSan v2, see | 1166 // Disable for TSan v2, see |
1087 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. | 1167 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1152 FakeConstraints setup_constraints; | 1232 FakeConstraints setup_constraints; |
1153 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, | 1233 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, |
1154 true); | 1234 true); |
1155 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1235 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1156 receiving_client()->SetReceiveAudioVideo(true, false); | 1236 receiving_client()->SetReceiveAudioVideo(true, false); |
1157 LocalP2PTest(); | 1237 LocalP2PTest(); |
1158 receiving_client()->SetReceiveAudioVideo(true, true); | 1238 receiving_client()->SetReceiveAudioVideo(true, true); |
1159 receiving_client()->Negotiate(); | 1239 receiving_client()->Negotiate(); |
1160 } | 1240 } |
1161 | 1241 |
1242 // This test sets up a call transfer to a new caller with a different DTLS | |
1243 // fingerprint. | |
1244 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDtlsTransferCallee) { | |
1245 TransferCall(true); | |
pthatcher1
2015/11/18 20:42:43
I think there are enough "if(test_callee)" checks
guoweis_webrtc
2015/11/25 21:03:13
Done.
| |
1246 } | |
1247 | |
1248 // This test sets up a call transfer to a new callee with a different DTLS | |
1249 // fingerprint. | |
1250 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDtlsTransferCaller) { | |
1251 TransferCall(false); | |
1252 } | |
1253 | |
1162 // This test sets up a call between two endpoints that are configured to use | 1254 // This test sets up a call between two endpoints that are configured to use |
1163 // DTLS key agreement. The offerer don't support SDES. As a result, DTLS is | 1255 // DTLS key agreement. The offerer don't support SDES. As a result, DTLS is |
1164 // negotiated and used for transport. | 1256 // negotiated and used for transport. |
1165 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestOfferDtlsButNotSdes) { | 1257 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestOfferDtlsButNotSdes) { |
1166 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1258 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
1167 FakeConstraints setup_constraints; | 1259 FakeConstraints setup_constraints; |
1168 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, | 1260 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, |
1169 true); | 1261 true); |
1170 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1262 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1171 receiving_client()->RemoveSdesCryptoFromReceivedSdp(true); | 1263 receiving_client()->RemoveSdesCryptoFromReceivedSdp(true); |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1811 server.urls.push_back("stun:hostname"); | 1903 server.urls.push_back("stun:hostname"); |
1812 server.urls.push_back("turn:hostname"); | 1904 server.urls.push_back("turn:hostname"); |
1813 servers.push_back(server); | 1905 servers.push_back(server); |
1814 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, | 1906 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, |
1815 &turn_configurations_)); | 1907 &turn_configurations_)); |
1816 EXPECT_EQ(1U, stun_configurations_.size()); | 1908 EXPECT_EQ(1U, stun_configurations_.size()); |
1817 EXPECT_EQ(1U, turn_configurations_.size()); | 1909 EXPECT_EQ(1U, turn_configurations_.size()); |
1818 } | 1910 } |
1819 | 1911 |
1820 #endif // if !defined(THREAD_SANITIZER) | 1912 #endif // if !defined(THREAD_SANITIZER) |
OLD | NEW |