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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 }; | 147 }; |
148 | 148 |
149 class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, | 149 class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, |
150 public SignalingMessageReceiver, | 150 public SignalingMessageReceiver, |
151 public ObserverInterface { | 151 public ObserverInterface { |
152 public: | 152 public: |
153 static PeerConnectionTestClient* CreateClientWithDtlsIdentityStore( | 153 static PeerConnectionTestClient* CreateClientWithDtlsIdentityStore( |
154 const std::string& id, | 154 const std::string& id, |
155 const MediaConstraintsInterface* constraints, | 155 const MediaConstraintsInterface* constraints, |
156 const PeerConnectionFactory::Options* options, | 156 const PeerConnectionFactory::Options* options, |
| 157 const PeerConnectionInterface::RTCConfiguration& config, |
157 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, | 158 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, |
158 bool prefer_constraint_apis) { | 159 bool prefer_constraint_apis) { |
159 PeerConnectionTestClient* client(new PeerConnectionTestClient(id)); | 160 PeerConnectionTestClient* client(new PeerConnectionTestClient(id)); |
160 if (!client->Init(constraints, options, std::move(dtls_identity_store), | 161 if (!client->Init(constraints, options, config, |
161 prefer_constraint_apis)) { | 162 std::move(dtls_identity_store), prefer_constraint_apis)) { |
162 delete client; | 163 delete client; |
163 return nullptr; | 164 return nullptr; |
164 } | 165 } |
165 return client; | 166 return client; |
166 } | 167 } |
167 | 168 |
168 static PeerConnectionTestClient* CreateClient( | 169 static PeerConnectionTestClient* CreateClient( |
169 const std::string& id, | 170 const std::string& id, |
170 const MediaConstraintsInterface* constraints, | 171 const MediaConstraintsInterface* constraints, |
171 const PeerConnectionFactory::Options* options) { | 172 const PeerConnectionFactory::Options* options, |
| 173 const PeerConnectionInterface::RTCConfiguration& config) { |
172 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( | 174 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
173 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() | 175 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
174 : nullptr); | 176 : nullptr); |
175 | |
176 return CreateClientWithDtlsIdentityStore( | 177 return CreateClientWithDtlsIdentityStore( |
177 id, constraints, options, std::move(dtls_identity_store), true); | 178 id, constraints, options, config, std::move(dtls_identity_store), true); |
178 } | 179 } |
179 | 180 |
180 static PeerConnectionTestClient* CreateClientPreferNoConstraints( | 181 static PeerConnectionTestClient* CreateClientPreferNoConstraints( |
181 const std::string& id, | 182 const std::string& id, |
182 const PeerConnectionFactory::Options* options) { | 183 const PeerConnectionFactory::Options* options, |
| 184 const PeerConnectionInterface::RTCConfiguration& config) { |
183 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( | 185 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
184 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() | 186 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
185 : nullptr); | 187 : nullptr); |
186 | |
187 return CreateClientWithDtlsIdentityStore( | 188 return CreateClientWithDtlsIdentityStore( |
188 id, nullptr, options, std::move(dtls_identity_store), false); | 189 id, nullptr, options, config, std::move(dtls_identity_store), false); |
189 } | 190 } |
190 | 191 |
191 ~PeerConnectionTestClient() { | 192 ~PeerConnectionTestClient() { |
192 } | 193 } |
193 | 194 |
194 void Negotiate() { Negotiate(true, true); } | 195 void Negotiate() { Negotiate(true, true); } |
195 | 196 |
196 void Negotiate(bool audio, bool video) { | 197 void Negotiate(bool audio, bool video) { |
197 rtc::scoped_ptr<SessionDescriptionInterface> offer; | 198 rtc::scoped_ptr<SessionDescriptionInterface> offer; |
198 ASSERT_TRUE(DoCreateOffer(&offer)); | 199 ASSERT_TRUE(DoCreateOffer(&offer)); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 offer_answer_options_.offer_to_receive_video == | 420 offer_answer_options_.offer_to_receive_video == |
420 PeerConnectionInterface::RTCOfferAnswerOptions::kUndefined; | 421 PeerConnectionInterface::RTCOfferAnswerOptions::kUndefined; |
421 } | 422 } |
422 | 423 |
423 void OnDataChannel(DataChannelInterface* data_channel) override { | 424 void OnDataChannel(DataChannelInterface* data_channel) override { |
424 LOG(INFO) << id_ << "OnDataChannel"; | 425 LOG(INFO) << id_ << "OnDataChannel"; |
425 data_channel_ = data_channel; | 426 data_channel_ = data_channel; |
426 data_observer_.reset(new MockDataChannelObserver(data_channel)); | 427 data_observer_.reset(new MockDataChannelObserver(data_channel)); |
427 } | 428 } |
428 | 429 |
429 void CreateDataChannel() { | 430 void CreateDataChannel() { CreateDataChannel(nullptr); } |
430 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, nullptr); | 431 |
| 432 void CreateDataChannel(const webrtc::DataChannelInit* init) { |
| 433 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, init); |
431 ASSERT_TRUE(data_channel_.get() != nullptr); | 434 ASSERT_TRUE(data_channel_.get() != nullptr); |
432 data_observer_.reset(new MockDataChannelObserver(data_channel_)); | 435 data_observer_.reset(new MockDataChannelObserver(data_channel_)); |
433 } | 436 } |
434 | 437 |
435 rtc::scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack( | 438 rtc::scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack( |
436 const std::string& stream_label) { | 439 const std::string& stream_label) { |
437 FakeConstraints constraints; | 440 FakeConstraints constraints; |
438 // Disable highpass filter so that we can get all the test audio frames. | 441 // Disable highpass filter so that we can get all the test audio frames. |
439 constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false); | 442 constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false); |
440 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = | 443 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 private: | 795 private: |
793 bool completed_; | 796 bool completed_; |
794 std::vector<std::string> tones_; | 797 std::vector<std::string> tones_; |
795 }; | 798 }; |
796 | 799 |
797 explicit PeerConnectionTestClient(const std::string& id) : id_(id) {} | 800 explicit PeerConnectionTestClient(const std::string& id) : id_(id) {} |
798 | 801 |
799 bool Init( | 802 bool Init( |
800 const MediaConstraintsInterface* constraints, | 803 const MediaConstraintsInterface* constraints, |
801 const PeerConnectionFactory::Options* options, | 804 const PeerConnectionFactory::Options* options, |
| 805 const PeerConnectionInterface::RTCConfiguration& config, |
802 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, | 806 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, |
803 bool prefer_constraint_apis) { | 807 bool prefer_constraint_apis) { |
804 EXPECT_TRUE(!peer_connection_); | 808 EXPECT_TRUE(!peer_connection_); |
805 EXPECT_TRUE(!peer_connection_factory_); | 809 EXPECT_TRUE(!peer_connection_factory_); |
806 if (!prefer_constraint_apis) { | 810 if (!prefer_constraint_apis) { |
807 EXPECT_TRUE(!constraints); | 811 EXPECT_TRUE(!constraints); |
808 } | 812 } |
809 prefer_constraint_apis_ = prefer_constraint_apis; | 813 prefer_constraint_apis_ = prefer_constraint_apis; |
810 | 814 |
811 rtc::scoped_ptr<cricket::PortAllocator> port_allocator( | 815 rtc::scoped_ptr<cricket::PortAllocator> port_allocator( |
812 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); | 816 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); |
813 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); | 817 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); |
814 | 818 |
815 if (fake_audio_capture_module_ == nullptr) { | 819 if (fake_audio_capture_module_ == nullptr) { |
816 return false; | 820 return false; |
817 } | 821 } |
818 fake_video_decoder_factory_ = new FakeWebRtcVideoDecoderFactory(); | 822 fake_video_decoder_factory_ = new FakeWebRtcVideoDecoderFactory(); |
819 fake_video_encoder_factory_ = new FakeWebRtcVideoEncoderFactory(); | 823 fake_video_encoder_factory_ = new FakeWebRtcVideoEncoderFactory(); |
820 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( | 824 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( |
821 rtc::Thread::Current(), rtc::Thread::Current(), | 825 rtc::Thread::Current(), rtc::Thread::Current(), |
822 fake_audio_capture_module_, fake_video_encoder_factory_, | 826 fake_audio_capture_module_, fake_video_encoder_factory_, |
823 fake_video_decoder_factory_); | 827 fake_video_decoder_factory_); |
824 if (!peer_connection_factory_) { | 828 if (!peer_connection_factory_) { |
825 return false; | 829 return false; |
826 } | 830 } |
827 if (options) { | 831 if (options) { |
828 peer_connection_factory_->SetOptions(*options); | 832 peer_connection_factory_->SetOptions(*options); |
829 } | 833 } |
830 peer_connection_ = CreatePeerConnection( | 834 peer_connection_ = |
831 std::move(port_allocator), constraints, std::move(dtls_identity_store)); | 835 CreatePeerConnection(std::move(port_allocator), constraints, config, |
| 836 std::move(dtls_identity_store)); |
832 return peer_connection_.get() != nullptr; | 837 return peer_connection_.get() != nullptr; |
833 } | 838 } |
834 | 839 |
835 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( | 840 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( |
836 rtc::scoped_ptr<cricket::PortAllocator> port_allocator, | 841 rtc::scoped_ptr<cricket::PortAllocator> port_allocator, |
837 const MediaConstraintsInterface* constraints, | 842 const MediaConstraintsInterface* constraints, |
| 843 const PeerConnectionInterface::RTCConfiguration& config, |
838 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) { | 844 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) { |
839 // CreatePeerConnection with RTCConfiguration. | |
840 webrtc::PeerConnectionInterface::RTCConfiguration config; | |
841 webrtc::PeerConnectionInterface::IceServer ice_server; | |
842 ice_server.uri = "stun:stun.l.google.com:19302"; | |
843 config.servers.push_back(ice_server); | |
844 | |
845 return peer_connection_factory_->CreatePeerConnection( | 845 return peer_connection_factory_->CreatePeerConnection( |
846 config, constraints, std::move(port_allocator), | 846 config, constraints, std::move(port_allocator), |
847 std::move(dtls_identity_store), this); | 847 std::move(dtls_identity_store), this); |
848 } | 848 } |
849 | 849 |
850 void HandleIncomingOffer(const std::string& msg) { | 850 void HandleIncomingOffer(const std::string& msg) { |
851 LOG(INFO) << id_ << "HandleIncomingOffer "; | 851 LOG(INFO) << id_ << "HandleIncomingOffer "; |
852 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { | 852 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { |
853 // If we are not sending any streams ourselves it is time to add some. | 853 // If we are not sending any streams ourselves it is time to add some. |
854 AddMediaStream(true, true); | 854 AddMediaStream(true, true); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 | 1012 |
1013 rtc::scoped_refptr<DataChannelInterface> data_channel_; | 1013 rtc::scoped_refptr<DataChannelInterface> data_channel_; |
1014 rtc::scoped_ptr<MockDataChannelObserver> data_observer_; | 1014 rtc::scoped_ptr<MockDataChannelObserver> data_observer_; |
1015 }; | 1015 }; |
1016 | 1016 |
1017 class P2PTestConductor : public testing::Test { | 1017 class P2PTestConductor : public testing::Test { |
1018 public: | 1018 public: |
1019 P2PTestConductor() | 1019 P2PTestConductor() |
1020 : pss_(new rtc::PhysicalSocketServer), | 1020 : pss_(new rtc::PhysicalSocketServer), |
1021 ss_(new rtc::VirtualSocketServer(pss_.get())), | 1021 ss_(new rtc::VirtualSocketServer(pss_.get())), |
1022 ss_scope_(ss_.get()) {} | 1022 ss_scope_(ss_.get()) { |
| 1023 webrtc::PeerConnectionInterface::IceServer ice_server; |
| 1024 ice_server.uri = "stun:stun.l.google.com:19302"; |
| 1025 config_.servers.push_back(ice_server); |
| 1026 } |
1023 | 1027 |
1024 bool SessionActive() { | 1028 bool SessionActive() { |
1025 return initiating_client_->SessionActive() && | 1029 return initiating_client_->SessionActive() && |
1026 receiving_client_->SessionActive(); | 1030 receiving_client_->SessionActive(); |
1027 } | 1031 } |
1028 | 1032 |
1029 // Return true if the number of frames provided have been received | 1033 // Return true if the number of frames provided have been received |
1030 // on the video and audio tracks provided. | 1034 // on the video and audio tracks provided. |
1031 bool FramesHaveArrived(int audio_frames_to_receive, | 1035 bool FramesHaveArrived(int audio_frames_to_receive, |
1032 int video_frames_to_receive) { | 1036 int video_frames_to_receive) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 bool CreateTestClients() { return CreateTestClients(nullptr, nullptr); } | 1124 bool CreateTestClients() { return CreateTestClients(nullptr, nullptr); } |
1121 | 1125 |
1122 bool CreateTestClients(MediaConstraintsInterface* init_constraints, | 1126 bool CreateTestClients(MediaConstraintsInterface* init_constraints, |
1123 MediaConstraintsInterface* recv_constraints) { | 1127 MediaConstraintsInterface* recv_constraints) { |
1124 return CreateTestClients(init_constraints, nullptr, recv_constraints, | 1128 return CreateTestClients(init_constraints, nullptr, recv_constraints, |
1125 nullptr); | 1129 nullptr); |
1126 } | 1130 } |
1127 | 1131 |
1128 bool CreateTestClientsThatPreferNoConstraints() { | 1132 bool CreateTestClientsThatPreferNoConstraints() { |
1129 initiating_client_.reset( | 1133 initiating_client_.reset( |
1130 PeerConnectionTestClient::CreateClientPreferNoConstraints("Caller: ", | 1134 PeerConnectionTestClient::CreateClientPreferNoConstraints( |
1131 nullptr)); | 1135 "Caller: ", nullptr, config_)); |
1132 receiving_client_.reset( | 1136 receiving_client_.reset( |
1133 PeerConnectionTestClient::CreateClientPreferNoConstraints("Callee: ", | 1137 PeerConnectionTestClient::CreateClientPreferNoConstraints( |
1134 nullptr)); | 1138 "Callee: ", nullptr, config_)); |
1135 if (!initiating_client_ || !receiving_client_) { | 1139 if (!initiating_client_ || !receiving_client_) { |
1136 return false; | 1140 return false; |
1137 } | 1141 } |
1138 // Remember the choice for possible later resets of the clients. | 1142 // Remember the choice for possible later resets of the clients. |
1139 prefer_constraint_apis_ = false; | 1143 prefer_constraint_apis_ = false; |
1140 SetSignalingReceivers(); | 1144 SetSignalingReceivers(); |
1141 return true; | 1145 return true; |
1142 } | 1146 } |
1143 | 1147 |
1144 void SetSignalingReceivers() { | 1148 void SetSignalingReceivers() { |
1145 initiating_client_->set_signaling_message_receiver(receiving_client_.get()); | 1149 initiating_client_->set_signaling_message_receiver(receiving_client_.get()); |
1146 receiving_client_->set_signaling_message_receiver(initiating_client_.get()); | 1150 receiving_client_->set_signaling_message_receiver(initiating_client_.get()); |
1147 } | 1151 } |
1148 | 1152 |
1149 bool CreateTestClients(MediaConstraintsInterface* init_constraints, | 1153 bool CreateTestClients(MediaConstraintsInterface* init_constraints, |
1150 PeerConnectionFactory::Options* init_options, | 1154 PeerConnectionFactory::Options* init_options, |
1151 MediaConstraintsInterface* recv_constraints, | 1155 MediaConstraintsInterface* recv_constraints, |
1152 PeerConnectionFactory::Options* recv_options) { | 1156 PeerConnectionFactory::Options* recv_options) { |
1153 initiating_client_.reset(PeerConnectionTestClient::CreateClient( | 1157 initiating_client_.reset(PeerConnectionTestClient::CreateClient( |
1154 "Caller: ", init_constraints, init_options)); | 1158 "Caller: ", init_constraints, init_options, config_)); |
1155 receiving_client_.reset(PeerConnectionTestClient::CreateClient( | 1159 receiving_client_.reset(PeerConnectionTestClient::CreateClient( |
1156 "Callee: ", recv_constraints, recv_options)); | 1160 "Callee: ", recv_constraints, recv_options, config_)); |
1157 if (!initiating_client_ || !receiving_client_) { | 1161 if (!initiating_client_ || !receiving_client_) { |
1158 return false; | 1162 return false; |
1159 } | 1163 } |
1160 SetSignalingReceivers(); | 1164 SetSignalingReceivers(); |
1161 return true; | 1165 return true; |
1162 } | 1166 } |
1163 | 1167 |
1164 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints, | 1168 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints, |
1165 const webrtc::FakeConstraints& recv_constraints) { | 1169 const webrtc::FakeConstraints& recv_constraints) { |
1166 initiating_client_->SetVideoConstraints(init_constraints); | 1170 initiating_client_->SetVideoConstraints(init_constraints); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, | 1250 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, |
1247 true); | 1251 true); |
1248 | 1252 |
1249 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( | 1253 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
1250 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() | 1254 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
1251 : nullptr); | 1255 : nullptr); |
1252 dtls_identity_store->use_alternate_key(); | 1256 dtls_identity_store->use_alternate_key(); |
1253 | 1257 |
1254 // Make sure the new client is using a different certificate. | 1258 // Make sure the new client is using a different certificate. |
1255 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore( | 1259 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore( |
1256 "New Peer: ", &setup_constraints, nullptr, | 1260 "New Peer: ", &setup_constraints, nullptr, config_, |
1257 std::move(dtls_identity_store), prefer_constraint_apis_); | 1261 std::move(dtls_identity_store), prefer_constraint_apis_); |
1258 } | 1262 } |
1259 | 1263 |
1260 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { | 1264 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { |
1261 // Messages may get lost on the unreliable DataChannel, so we send multiple | 1265 // Messages may get lost on the unreliable DataChannel, so we send multiple |
1262 // times to avoid test flakiness. | 1266 // times to avoid test flakiness. |
1263 static const size_t kSendAttempts = 5; | 1267 static const size_t kSendAttempts = 5; |
1264 | 1268 |
1265 for (size_t i = 0; i < kSendAttempts; ++i) { | 1269 for (size_t i = 0; i < kSendAttempts; ++i) { |
1266 dc->Send(DataBuffer(data)); | 1270 dc->Send(DataBuffer(data)); |
(...skipping 19 matching lines...) Expand all Loading... |
1286 | 1290 |
1287 // Set the |receiving_client_| to the |client| passed in and return the | 1291 // Set the |receiving_client_| to the |client| passed in and return the |
1288 // original |receiving_client_|. | 1292 // original |receiving_client_|. |
1289 PeerConnectionTestClient* set_receiving_client( | 1293 PeerConnectionTestClient* set_receiving_client( |
1290 PeerConnectionTestClient* client) { | 1294 PeerConnectionTestClient* client) { |
1291 PeerConnectionTestClient* old = receiving_client_.release(); | 1295 PeerConnectionTestClient* old = receiving_client_.release(); |
1292 receiving_client_.reset(client); | 1296 receiving_client_.reset(client); |
1293 return old; | 1297 return old; |
1294 } | 1298 } |
1295 | 1299 |
| 1300 webrtc::PeerConnectionInterface::RTCConfiguration* config() { |
| 1301 return &config_; |
| 1302 } |
| 1303 |
1296 private: | 1304 private: |
1297 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; | 1305 rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; |
1298 rtc::scoped_ptr<rtc::VirtualSocketServer> ss_; | 1306 rtc::scoped_ptr<rtc::VirtualSocketServer> ss_; |
1299 rtc::SocketServerScope ss_scope_; | 1307 rtc::SocketServerScope ss_scope_; |
1300 rtc::scoped_ptr<PeerConnectionTestClient> initiating_client_; | 1308 rtc::scoped_ptr<PeerConnectionTestClient> initiating_client_; |
1301 rtc::scoped_ptr<PeerConnectionTestClient> receiving_client_; | 1309 rtc::scoped_ptr<PeerConnectionTestClient> receiving_client_; |
1302 bool prefer_constraint_apis_ = true; | 1310 bool prefer_constraint_apis_ = true; |
| 1311 webrtc::PeerConnectionInterface::RTCConfiguration config_; |
1303 }; | 1312 }; |
1304 | 1313 |
1305 // Disable for TSan v2, see | 1314 // Disable for TSan v2, see |
1306 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. | 1315 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. |
1307 #if !defined(THREAD_SANITIZER) | 1316 #if !defined(THREAD_SANITIZER) |
1308 | 1317 |
1309 // This test sets up a Jsep call between two parties and test Dtmf. | 1318 // This test sets up a Jsep call between two parties and test Dtmf. |
1310 // TODO(holmer): Disabled due to sometimes crashing on buildbots. | 1319 // TODO(holmer): Disabled due to sometimes crashing on buildbots. |
1311 // See issue webrtc/2378. | 1320 // See issue webrtc/2378. |
1312 TEST_F(P2PTestConductor, DISABLED_LocalP2PTestDtmf) { | 1321 TEST_F(P2PTestConductor, DISABLED_LocalP2PTestDtmf) { |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 receiving_client()->data_channel()->Send(DataBuffer(data)); | 1773 receiving_client()->data_channel()->Send(DataBuffer(data)); |
1765 EXPECT_EQ_WAIT(data, initializing_client()->data_observer()->last_message(), | 1774 EXPECT_EQ_WAIT(data, initializing_client()->data_observer()->last_message(), |
1766 kMaxWaitMs); | 1775 kMaxWaitMs); |
1767 | 1776 |
1768 receiving_client()->data_channel()->Close(); | 1777 receiving_client()->data_channel()->Close(); |
1769 EXPECT_TRUE_WAIT(!initializing_client()->data_observer()->IsOpen(), | 1778 EXPECT_TRUE_WAIT(!initializing_client()->data_observer()->IsOpen(), |
1770 kMaxWaitMs); | 1779 kMaxWaitMs); |
1771 EXPECT_TRUE_WAIT(!receiving_client()->data_observer()->IsOpen(), kMaxWaitMs); | 1780 EXPECT_TRUE_WAIT(!receiving_client()->data_observer()->IsOpen(), kMaxWaitMs); |
1772 } | 1781 } |
1773 | 1782 |
| 1783 #ifdef HAVE_QUIC |
| 1784 // This test sets up a call between two parties using QUIC instead of DTLS for |
| 1785 // audio and video, and a QUIC data channel. |
| 1786 TEST_F(P2PTestConductor, LocalP2PTestQuicDataChannel) { |
| 1787 config()->enable_quic = true; |
| 1788 ASSERT_TRUE(CreateTestClients()); |
| 1789 webrtc::DataChannelInit init; |
| 1790 init.ordered = false; |
| 1791 init.reliable = true; |
| 1792 init.id = 1; |
| 1793 initializing_client()->CreateDataChannel(&init); |
| 1794 receiving_client()->CreateDataChannel(&init); |
| 1795 LocalP2PTest(); |
| 1796 ASSERT_NE(nullptr, initializing_client()->data_channel()); |
| 1797 ASSERT_NE(nullptr, receiving_client()->data_channel()); |
| 1798 EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(), |
| 1799 kMaxWaitMs); |
| 1800 EXPECT_TRUE_WAIT(receiving_client()->data_observer()->IsOpen(), kMaxWaitMs); |
| 1801 |
| 1802 std::string data = "hello world"; |
| 1803 |
| 1804 initializing_client()->data_channel()->Send(DataBuffer(data)); |
| 1805 EXPECT_EQ_WAIT(data, receiving_client()->data_observer()->last_message(), |
| 1806 kMaxWaitMs); |
| 1807 |
| 1808 receiving_client()->data_channel()->Send(DataBuffer(data)); |
| 1809 EXPECT_EQ_WAIT(data, initializing_client()->data_observer()->last_message(), |
| 1810 kMaxWaitMs); |
| 1811 } |
| 1812 #endif // HAVE_QUIC |
| 1813 |
1774 // This test sets up a call between two parties and creates a data channel. | 1814 // This test sets up a call between two parties and creates a data channel. |
1775 // The test tests that received data is buffered unless an observer has been | 1815 // The test tests that received data is buffered unless an observer has been |
1776 // registered. | 1816 // registered. |
1777 // Rtp data channels can receive data before the underlying | 1817 // Rtp data channels can receive data before the underlying |
1778 // transport has detected that a channel is writable and thus data can be | 1818 // transport has detected that a channel is writable and thus data can be |
1779 // received before the data channel state changes to open. That is hard to test | 1819 // received before the data channel state changes to open. That is hard to test |
1780 // but the same buffering is used in that case. | 1820 // but the same buffering is used in that case. |
1781 TEST_F(P2PTestConductor, RegisterDataChannelObserver) { | 1821 TEST_F(P2PTestConductor, RegisterDataChannelObserver) { |
1782 FakeConstraints setup_constraints; | 1822 FakeConstraints setup_constraints; |
1783 setup_constraints.SetAllowRtpDataChannels(); | 1823 setup_constraints.SetAllowRtpDataChannels(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1850 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1890 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
1851 FakeConstraints constraints; | 1891 FakeConstraints constraints; |
1852 constraints.SetMandatory( | 1892 constraints.SetMandatory( |
1853 MediaConstraintsInterface::kEnableDtlsSrtp, true); | 1893 MediaConstraintsInterface::kEnableDtlsSrtp, true); |
1854 ASSERT_TRUE(CreateTestClients(&constraints, &constraints)); | 1894 ASSERT_TRUE(CreateTestClients(&constraints, &constraints)); |
1855 initializing_client()->CreateDataChannel(); | 1895 initializing_client()->CreateDataChannel(); |
1856 initializing_client()->Negotiate(false, false); | 1896 initializing_client()->Negotiate(false, false); |
1857 } | 1897 } |
1858 #endif | 1898 #endif |
1859 | 1899 |
| 1900 // Tests negotiation of QUIC data channels is completed without error. |
| 1901 #ifdef HAVE_QUIC |
| 1902 TEST_F(P2PTestConductor, CreateOfferWithQuicDataChannel) { |
| 1903 config()->enable_quic = true; |
| 1904 FakeConstraints constraints; |
| 1905 constraints.SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, true); |
| 1906 ASSERT_TRUE(CreateTestClients(&constraints, &constraints)); |
| 1907 webrtc::DataChannelInit init; |
| 1908 init.ordered = false; |
| 1909 init.reliable = true; |
| 1910 init.id = 1; |
| 1911 initializing_client()->CreateDataChannel(&init); |
| 1912 initializing_client()->Negotiate(false, false); |
| 1913 } |
| 1914 #endif // HAVE_QUIC |
| 1915 |
1860 // This test sets up a call between two parties with audio, and video. | 1916 // This test sets up a call between two parties with audio, and video. |
1861 // During the call, the initializing side restart ice and the test verifies that | 1917 // During the call, the initializing side restart ice and the test verifies that |
1862 // new ice candidates are generated and audio and video still can flow. | 1918 // new ice candidates are generated and audio and video still can flow. |
1863 TEST_F(P2PTestConductor, IceRestart) { | 1919 TEST_F(P2PTestConductor, IceRestart) { |
1864 ASSERT_TRUE(CreateTestClients()); | 1920 ASSERT_TRUE(CreateTestClients()); |
1865 | 1921 |
1866 // Negotiate and wait for ice completion and make sure audio and video plays. | 1922 // Negotiate and wait for ice completion and make sure audio and video plays. |
1867 LocalP2PTest(); | 1923 LocalP2PTest(); |
1868 | 1924 |
1869 // Create a SDP string of the first audio candidate for both clients. | 1925 // Create a SDP string of the first audio candidate for both clients. |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2155 server.urls.push_back("turn:hostname2"); | 2211 server.urls.push_back("turn:hostname2"); |
2156 servers.push_back(server); | 2212 servers.push_back(server); |
2157 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); | 2213 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); |
2158 EXPECT_EQ(2U, turn_servers_.size()); | 2214 EXPECT_EQ(2U, turn_servers_.size()); |
2159 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); | 2215 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); |
2160 } | 2216 } |
2161 | 2217 |
2162 #endif // if !defined(THREAD_SANITIZER) | 2218 #endif // if !defined(THREAD_SANITIZER) |
2163 | 2219 |
2164 } // namespace | 2220 } // namespace |
OLD | NEW |