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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 }; | 167 }; |
168 | 168 |
169 class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, | 169 class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, |
170 public SignalingMessageReceiver, | 170 public SignalingMessageReceiver, |
171 public ObserverInterface { | 171 public ObserverInterface { |
172 public: | 172 public: |
173 static PeerConnectionTestClient* CreateClientWithDtlsIdentityStore( | 173 static PeerConnectionTestClient* CreateClientWithDtlsIdentityStore( |
174 const std::string& id, | 174 const std::string& id, |
175 const MediaConstraintsInterface* constraints, | 175 const MediaConstraintsInterface* constraints, |
176 const PeerConnectionFactory::Options* options, | 176 const PeerConnectionFactory::Options* options, |
| 177 const PeerConnectionInterface::RTCConfiguration& config, |
177 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, | 178 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
178 bool prefer_constraint_apis, | 179 bool prefer_constraint_apis, |
179 rtc::Thread* network_thread, | 180 rtc::Thread* network_thread, |
180 rtc::Thread* worker_thread) { | 181 rtc::Thread* worker_thread) { |
181 PeerConnectionTestClient* client(new PeerConnectionTestClient(id)); | 182 PeerConnectionTestClient* client(new PeerConnectionTestClient(id)); |
182 if (!client->Init(constraints, options, std::move(cert_generator), | 183 if (!client->Init(constraints, options, config, std::move(cert_generator), |
183 prefer_constraint_apis, network_thread, worker_thread)) { | 184 prefer_constraint_apis, network_thread, worker_thread)) { |
184 delete client; | 185 delete client; |
185 return nullptr; | 186 return nullptr; |
186 } | 187 } |
187 return client; | 188 return client; |
188 } | 189 } |
189 | 190 |
190 static PeerConnectionTestClient* CreateClient( | 191 static PeerConnectionTestClient* CreateClient( |
191 const std::string& id, | 192 const std::string& id, |
192 const MediaConstraintsInterface* constraints, | 193 const MediaConstraintsInterface* constraints, |
193 const PeerConnectionFactory::Options* options, | 194 const PeerConnectionFactory::Options* options, |
| 195 const PeerConnectionInterface::RTCConfiguration& config, |
194 rtc::Thread* network_thread, | 196 rtc::Thread* network_thread, |
195 rtc::Thread* worker_thread) { | 197 rtc::Thread* worker_thread) { |
196 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( | 198 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( |
197 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? | 199 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? |
198 new FakeRTCCertificateGenerator() : nullptr); | 200 new FakeRTCCertificateGenerator() : nullptr); |
199 | 201 |
200 return CreateClientWithDtlsIdentityStore( | 202 return CreateClientWithDtlsIdentityStore(id, constraints, options, config, |
201 id, constraints, options, std::move(cert_generator), true, | 203 std::move(cert_generator), true, |
202 network_thread, worker_thread); | 204 network_thread, worker_thread); |
203 } | 205 } |
204 | 206 |
205 static PeerConnectionTestClient* CreateClientPreferNoConstraints( | 207 static PeerConnectionTestClient* CreateClientPreferNoConstraints( |
206 const std::string& id, | 208 const std::string& id, |
207 const PeerConnectionFactory::Options* options, | 209 const PeerConnectionFactory::Options* options, |
| 210 const PeerConnectionInterface::RTCConfiguration& config, |
208 rtc::Thread* network_thread, | 211 rtc::Thread* network_thread, |
209 rtc::Thread* worker_thread) { | 212 rtc::Thread* worker_thread) { |
210 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( | 213 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( |
211 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? | 214 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? |
212 new FakeRTCCertificateGenerator() : nullptr); | 215 new FakeRTCCertificateGenerator() : nullptr); |
213 | 216 |
214 return CreateClientWithDtlsIdentityStore( | 217 return CreateClientWithDtlsIdentityStore(id, nullptr, options, config, |
215 id, nullptr, options, std::move(cert_generator), false, | 218 std::move(cert_generator), false, |
216 network_thread, worker_thread); | 219 network_thread, worker_thread); |
217 } | 220 } |
218 | 221 |
219 ~PeerConnectionTestClient() { | 222 ~PeerConnectionTestClient() { |
220 } | 223 } |
221 | 224 |
222 void Negotiate() { Negotiate(true, true); } | 225 void Negotiate() { Negotiate(true, true); } |
223 | 226 |
224 void Negotiate(bool audio, bool video) { | 227 void Negotiate(bool audio, bool video) { |
225 std::unique_ptr<SessionDescriptionInterface> offer; | 228 std::unique_ptr<SessionDescriptionInterface> offer; |
226 ASSERT_TRUE(DoCreateOffer(&offer)); | 229 ASSERT_TRUE(DoCreateOffer(&offer)); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 PeerConnectionInterface::RTCOfferAnswerOptions::kUndefined; | 453 PeerConnectionInterface::RTCOfferAnswerOptions::kUndefined; |
451 } | 454 } |
452 | 455 |
453 void OnDataChannel( | 456 void OnDataChannel( |
454 rtc::scoped_refptr<DataChannelInterface> data_channel) override { | 457 rtc::scoped_refptr<DataChannelInterface> data_channel) override { |
455 LOG(INFO) << id_ << "OnDataChannel"; | 458 LOG(INFO) << id_ << "OnDataChannel"; |
456 data_channel_ = data_channel; | 459 data_channel_ = data_channel; |
457 data_observer_.reset(new MockDataChannelObserver(data_channel)); | 460 data_observer_.reset(new MockDataChannelObserver(data_channel)); |
458 } | 461 } |
459 | 462 |
460 void CreateDataChannel() { | 463 void CreateDataChannel() { CreateDataChannel(nullptr); } |
461 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, nullptr); | 464 |
| 465 void CreateDataChannel(const webrtc::DataChannelInit* init) { |
| 466 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, init); |
462 ASSERT_TRUE(data_channel_.get() != nullptr); | 467 ASSERT_TRUE(data_channel_.get() != nullptr); |
463 data_observer_.reset(new MockDataChannelObserver(data_channel_)); | 468 data_observer_.reset(new MockDataChannelObserver(data_channel_)); |
464 } | 469 } |
465 | 470 |
466 rtc::scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack( | 471 rtc::scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack( |
467 const std::string& stream_label) { | 472 const std::string& stream_label) { |
468 FakeConstraints constraints; | 473 FakeConstraints constraints; |
469 // Disable highpass filter so that we can get all the test audio frames. | 474 // Disable highpass filter so that we can get all the test audio frames. |
470 constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false); | 475 constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false); |
471 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = | 476 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 private: | 843 private: |
839 bool completed_; | 844 bool completed_; |
840 std::vector<std::string> tones_; | 845 std::vector<std::string> tones_; |
841 }; | 846 }; |
842 | 847 |
843 explicit PeerConnectionTestClient(const std::string& id) : id_(id) {} | 848 explicit PeerConnectionTestClient(const std::string& id) : id_(id) {} |
844 | 849 |
845 bool Init( | 850 bool Init( |
846 const MediaConstraintsInterface* constraints, | 851 const MediaConstraintsInterface* constraints, |
847 const PeerConnectionFactory::Options* options, | 852 const PeerConnectionFactory::Options* options, |
| 853 const PeerConnectionInterface::RTCConfiguration& config, |
848 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, | 854 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
849 bool prefer_constraint_apis, | 855 bool prefer_constraint_apis, |
850 rtc::Thread* network_thread, | 856 rtc::Thread* network_thread, |
851 rtc::Thread* worker_thread) { | 857 rtc::Thread* worker_thread) { |
852 EXPECT_TRUE(!peer_connection_); | 858 EXPECT_TRUE(!peer_connection_); |
853 EXPECT_TRUE(!peer_connection_factory_); | 859 EXPECT_TRUE(!peer_connection_factory_); |
854 if (!prefer_constraint_apis) { | 860 if (!prefer_constraint_apis) { |
855 EXPECT_TRUE(!constraints); | 861 EXPECT_TRUE(!constraints); |
856 } | 862 } |
857 prefer_constraint_apis_ = prefer_constraint_apis; | 863 prefer_constraint_apis_ = prefer_constraint_apis; |
(...skipping 11 matching lines...) Expand all Loading... |
869 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( | 875 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( |
870 network_thread, worker_thread, signaling_thread, | 876 network_thread, worker_thread, signaling_thread, |
871 fake_audio_capture_module_, fake_video_encoder_factory_, | 877 fake_audio_capture_module_, fake_video_encoder_factory_, |
872 fake_video_decoder_factory_); | 878 fake_video_decoder_factory_); |
873 if (!peer_connection_factory_) { | 879 if (!peer_connection_factory_) { |
874 return false; | 880 return false; |
875 } | 881 } |
876 if (options) { | 882 if (options) { |
877 peer_connection_factory_->SetOptions(*options); | 883 peer_connection_factory_->SetOptions(*options); |
878 } | 884 } |
879 peer_connection_ = CreatePeerConnection( | 885 peer_connection_ = |
880 std::move(port_allocator), constraints, std::move(cert_generator)); | 886 CreatePeerConnection(std::move(port_allocator), constraints, config, |
| 887 std::move(cert_generator)); |
| 888 |
881 return peer_connection_.get() != nullptr; | 889 return peer_connection_.get() != nullptr; |
882 } | 890 } |
883 | 891 |
884 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( | 892 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( |
885 std::unique_ptr<cricket::PortAllocator> port_allocator, | 893 std::unique_ptr<cricket::PortAllocator> port_allocator, |
886 const MediaConstraintsInterface* constraints, | 894 const MediaConstraintsInterface* constraints, |
| 895 const PeerConnectionInterface::RTCConfiguration& config, |
887 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator) { | 896 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator) { |
888 // CreatePeerConnection with RTCConfiguration. | |
889 webrtc::PeerConnectionInterface::RTCConfiguration config; | |
890 webrtc::PeerConnectionInterface::IceServer ice_server; | |
891 ice_server.uri = "stun:stun.l.google.com:19302"; | |
892 config.servers.push_back(ice_server); | |
893 | |
894 return peer_connection_factory_->CreatePeerConnection( | 897 return peer_connection_factory_->CreatePeerConnection( |
895 config, constraints, std::move(port_allocator), | 898 config, constraints, std::move(port_allocator), |
896 std::move(cert_generator), this); | 899 std::move(cert_generator), this); |
897 } | 900 } |
898 | 901 |
899 void HandleIncomingOffer(const std::string& msg) { | 902 void HandleIncomingOffer(const std::string& msg) { |
900 LOG(INFO) << id_ << "HandleIncomingOffer "; | 903 LOG(INFO) << id_ << "HandleIncomingOffer "; |
901 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { | 904 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { |
902 // If we are not sending any streams ourselves it is time to add some. | 905 // If we are not sending any streams ourselves it is time to add some. |
903 AddMediaStream(true, true); | 906 AddMediaStream(true, true); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 | 1074 |
1072 class P2PTestConductor : public testing::Test { | 1075 class P2PTestConductor : public testing::Test { |
1073 public: | 1076 public: |
1074 P2PTestConductor() | 1077 P2PTestConductor() |
1075 : pss_(new rtc::PhysicalSocketServer), | 1078 : pss_(new rtc::PhysicalSocketServer), |
1076 ss_(new rtc::VirtualSocketServer(pss_.get())), | 1079 ss_(new rtc::VirtualSocketServer(pss_.get())), |
1077 network_thread_(new rtc::Thread(ss_.get())), | 1080 network_thread_(new rtc::Thread(ss_.get())), |
1078 worker_thread_(rtc::Thread::Create()) { | 1081 worker_thread_(rtc::Thread::Create()) { |
1079 RTC_CHECK(network_thread_->Start()); | 1082 RTC_CHECK(network_thread_->Start()); |
1080 RTC_CHECK(worker_thread_->Start()); | 1083 RTC_CHECK(worker_thread_->Start()); |
| 1084 webrtc::PeerConnectionInterface::IceServer ice_server; |
| 1085 ice_server.uri = "stun:stun.l.google.com:19302"; |
| 1086 config_.servers.push_back(ice_server); |
1081 } | 1087 } |
1082 | 1088 |
1083 bool SessionActive() { | 1089 bool SessionActive() { |
1084 return initiating_client_->SessionActive() && | 1090 return initiating_client_->SessionActive() && |
1085 receiving_client_->SessionActive(); | 1091 receiving_client_->SessionActive(); |
1086 } | 1092 } |
1087 | 1093 |
1088 // Return true if the number of frames provided have been received | 1094 // Return true if the number of frames provided have been received |
1089 // on the video and audio tracks provided. | 1095 // on the video and audio tracks provided. |
1090 bool FramesHaveArrived(int audio_frames_to_receive, | 1096 bool FramesHaveArrived(int audio_frames_to_receive, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 | 1186 |
1181 bool CreateTestClients(MediaConstraintsInterface* init_constraints, | 1187 bool CreateTestClients(MediaConstraintsInterface* init_constraints, |
1182 MediaConstraintsInterface* recv_constraints) { | 1188 MediaConstraintsInterface* recv_constraints) { |
1183 return CreateTestClients(init_constraints, nullptr, recv_constraints, | 1189 return CreateTestClients(init_constraints, nullptr, recv_constraints, |
1184 nullptr); | 1190 nullptr); |
1185 } | 1191 } |
1186 | 1192 |
1187 bool CreateTestClientsThatPreferNoConstraints() { | 1193 bool CreateTestClientsThatPreferNoConstraints() { |
1188 initiating_client_.reset( | 1194 initiating_client_.reset( |
1189 PeerConnectionTestClient::CreateClientPreferNoConstraints( | 1195 PeerConnectionTestClient::CreateClientPreferNoConstraints( |
1190 "Caller: ", nullptr, network_thread_.get(), worker_thread_.get())); | 1196 "Caller: ", nullptr, config_, network_thread_.get(), |
| 1197 worker_thread_.get())); |
1191 receiving_client_.reset( | 1198 receiving_client_.reset( |
1192 PeerConnectionTestClient::CreateClientPreferNoConstraints( | 1199 PeerConnectionTestClient::CreateClientPreferNoConstraints( |
1193 "Callee: ", nullptr, network_thread_.get(), worker_thread_.get())); | 1200 "Callee: ", nullptr, config_, network_thread_.get(), |
| 1201 worker_thread_.get())); |
1194 if (!initiating_client_ || !receiving_client_) { | 1202 if (!initiating_client_ || !receiving_client_) { |
1195 return false; | 1203 return false; |
1196 } | 1204 } |
1197 // Remember the choice for possible later resets of the clients. | 1205 // Remember the choice for possible later resets of the clients. |
1198 prefer_constraint_apis_ = false; | 1206 prefer_constraint_apis_ = false; |
1199 SetSignalingReceivers(); | 1207 SetSignalingReceivers(); |
1200 return true; | 1208 return true; |
1201 } | 1209 } |
1202 | 1210 |
1203 void SetSignalingReceivers() { | 1211 void SetSignalingReceivers() { |
1204 initiating_client_->set_signaling_message_receiver(receiving_client_.get()); | 1212 initiating_client_->set_signaling_message_receiver(receiving_client_.get()); |
1205 receiving_client_->set_signaling_message_receiver(initiating_client_.get()); | 1213 receiving_client_->set_signaling_message_receiver(initiating_client_.get()); |
1206 } | 1214 } |
1207 | 1215 |
1208 bool CreateTestClients(MediaConstraintsInterface* init_constraints, | 1216 bool CreateTestClients(MediaConstraintsInterface* init_constraints, |
1209 PeerConnectionFactory::Options* init_options, | 1217 PeerConnectionFactory::Options* init_options, |
1210 MediaConstraintsInterface* recv_constraints, | 1218 MediaConstraintsInterface* recv_constraints, |
1211 PeerConnectionFactory::Options* recv_options) { | 1219 PeerConnectionFactory::Options* recv_options) { |
1212 initiating_client_.reset(PeerConnectionTestClient::CreateClient( | 1220 initiating_client_.reset(PeerConnectionTestClient::CreateClient( |
1213 "Caller: ", init_constraints, init_options, network_thread_.get(), | 1221 "Caller: ", init_constraints, init_options, config_, |
1214 worker_thread_.get())); | 1222 network_thread_.get(), worker_thread_.get())); |
1215 receiving_client_.reset(PeerConnectionTestClient::CreateClient( | 1223 receiving_client_.reset(PeerConnectionTestClient::CreateClient( |
1216 "Callee: ", recv_constraints, recv_options, network_thread_.get(), | 1224 "Callee: ", recv_constraints, recv_options, config_, |
1217 worker_thread_.get())); | 1225 network_thread_.get(), worker_thread_.get())); |
1218 if (!initiating_client_ || !receiving_client_) { | 1226 if (!initiating_client_ || !receiving_client_) { |
1219 return false; | 1227 return false; |
1220 } | 1228 } |
1221 SetSignalingReceivers(); | 1229 SetSignalingReceivers(); |
1222 return true; | 1230 return true; |
1223 } | 1231 } |
1224 | 1232 |
1225 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints, | 1233 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints, |
1226 const webrtc::FakeConstraints& recv_constraints) { | 1234 const webrtc::FakeConstraints& recv_constraints) { |
1227 initiating_client_->SetVideoConstraints(init_constraints); | 1235 initiating_client_->SetVideoConstraints(init_constraints); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, | 1315 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, |
1308 true); | 1316 true); |
1309 | 1317 |
1310 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( | 1318 std::unique_ptr<FakeRTCCertificateGenerator> cert_generator( |
1311 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? | 1319 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? |
1312 new FakeRTCCertificateGenerator() : nullptr); | 1320 new FakeRTCCertificateGenerator() : nullptr); |
1313 cert_generator->use_alternate_key(); | 1321 cert_generator->use_alternate_key(); |
1314 | 1322 |
1315 // Make sure the new client is using a different certificate. | 1323 // Make sure the new client is using a different certificate. |
1316 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore( | 1324 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore( |
1317 "New Peer: ", &setup_constraints, nullptr, | 1325 "New Peer: ", &setup_constraints, nullptr, config_, |
1318 std::move(cert_generator), prefer_constraint_apis_, | 1326 std::move(cert_generator), prefer_constraint_apis_, |
1319 network_thread_.get(), worker_thread_.get()); | 1327 network_thread_.get(), worker_thread_.get()); |
1320 } | 1328 } |
1321 | 1329 |
1322 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { | 1330 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { |
1323 // Messages may get lost on the unreliable DataChannel, so we send multiple | 1331 // Messages may get lost on the unreliable DataChannel, so we send multiple |
1324 // times to avoid test flakiness. | 1332 // times to avoid test flakiness. |
1325 static const size_t kSendAttempts = 5; | 1333 static const size_t kSendAttempts = 5; |
1326 | 1334 |
1327 for (size_t i = 0; i < kSendAttempts; ++i) { | 1335 for (size_t i = 0; i < kSendAttempts; ++i) { |
(...skipping 19 matching lines...) Expand all Loading... |
1347 } | 1355 } |
1348 | 1356 |
1349 // Set the |receiving_client_| to the |client| passed in and return the | 1357 // Set the |receiving_client_| to the |client| passed in and return the |
1350 // original |receiving_client_|. | 1358 // original |receiving_client_|. |
1351 PeerConnectionTestClient* set_receiving_client( | 1359 PeerConnectionTestClient* set_receiving_client( |
1352 PeerConnectionTestClient* client) { | 1360 PeerConnectionTestClient* client) { |
1353 PeerConnectionTestClient* old = receiving_client_.release(); | 1361 PeerConnectionTestClient* old = receiving_client_.release(); |
1354 receiving_client_.reset(client); | 1362 receiving_client_.reset(client); |
1355 return old; | 1363 return old; |
1356 } | 1364 } |
| 1365 webrtc::PeerConnectionInterface::RTCConfiguration* config() { |
| 1366 return &config_; |
| 1367 } |
1357 | 1368 |
1358 bool AllObserversReceived( | 1369 bool AllObserversReceived( |
1359 const std::vector<std::unique_ptr<MockRtpReceiverObserver>>& observers) { | 1370 const std::vector<std::unique_ptr<MockRtpReceiverObserver>>& observers) { |
1360 for (auto& observer : observers) { | 1371 for (auto& observer : observers) { |
1361 if (!observer->first_packet_received()) { | 1372 if (!observer->first_packet_received()) { |
1362 return false; | 1373 return false; |
1363 } | 1374 } |
1364 } | 1375 } |
1365 return true; | 1376 return true; |
1366 } | 1377 } |
(...skipping 25 matching lines...) Expand all Loading... |
1392 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | 1403 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
1393 std::unique_ptr<rtc::VirtualSocketServer> ss_; | 1404 std::unique_ptr<rtc::VirtualSocketServer> ss_; |
1394 // |network_thread_| and |worker_thread_| are used by both | 1405 // |network_thread_| and |worker_thread_| are used by both |
1395 // |initiating_client_| and |receiving_client_| so they must be destroyed | 1406 // |initiating_client_| and |receiving_client_| so they must be destroyed |
1396 // later. | 1407 // later. |
1397 std::unique_ptr<rtc::Thread> network_thread_; | 1408 std::unique_ptr<rtc::Thread> network_thread_; |
1398 std::unique_ptr<rtc::Thread> worker_thread_; | 1409 std::unique_ptr<rtc::Thread> worker_thread_; |
1399 std::unique_ptr<PeerConnectionTestClient> initiating_client_; | 1410 std::unique_ptr<PeerConnectionTestClient> initiating_client_; |
1400 std::unique_ptr<PeerConnectionTestClient> receiving_client_; | 1411 std::unique_ptr<PeerConnectionTestClient> receiving_client_; |
1401 bool prefer_constraint_apis_ = true; | 1412 bool prefer_constraint_apis_ = true; |
| 1413 webrtc::PeerConnectionInterface::RTCConfiguration config_; |
1402 }; | 1414 }; |
1403 | 1415 |
1404 // Disable for TSan v2, see | 1416 // Disable for TSan v2, see |
1405 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. | 1417 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. |
1406 #if !defined(THREAD_SANITIZER) | 1418 #if !defined(THREAD_SANITIZER) |
1407 | 1419 |
1408 TEST_F(P2PTestConductor, TestRtpReceiverObserverCallbackFunction) { | 1420 TEST_F(P2PTestConductor, TestRtpReceiverObserverCallbackFunction) { |
1409 ASSERT_TRUE(CreateTestClients()); | 1421 ASSERT_TRUE(CreateTestClients()); |
1410 LocalP2PTest(); | 1422 LocalP2PTest(); |
1411 EXPECT_TRUE_WAIT( | 1423 EXPECT_TRUE_WAIT( |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2109 kMaxWaitForFramesMs); | 2121 kMaxWaitForFramesMs); |
2110 // Now set the tracks, and expect frames to immediately start flowing. | 2122 // Now set the tracks, and expect frames to immediately start flowing. |
2111 EXPECT_TRUE( | 2123 EXPECT_TRUE( |
2112 audio_sender->SetTrack(initializing_client()->CreateLocalAudioTrack(""))); | 2124 audio_sender->SetTrack(initializing_client()->CreateLocalAudioTrack(""))); |
2113 EXPECT_TRUE( | 2125 EXPECT_TRUE( |
2114 video_sender->SetTrack(initializing_client()->CreateLocalVideoTrack(""))); | 2126 video_sender->SetTrack(initializing_client()->CreateLocalVideoTrack(""))); |
2115 EXPECT_TRUE_WAIT(FramesHaveArrived(kEndAudioFrameCount, kEndVideoFrameCount), | 2127 EXPECT_TRUE_WAIT(FramesHaveArrived(kEndAudioFrameCount, kEndVideoFrameCount), |
2116 kMaxWaitForFramesMs); | 2128 kMaxWaitForFramesMs); |
2117 } | 2129 } |
2118 | 2130 |
| 2131 #ifdef HAVE_QUIC |
| 2132 // This test sets up a call between two parties using QUIC instead of DTLS for |
| 2133 // audio and video, and a QUIC data channel. |
| 2134 TEST_F(P2PTestConductor, LocalP2PTestQuicDataChannel) { |
| 2135 config()->enable_quic = true; |
| 2136 ASSERT_TRUE(CreateTestClients()); |
| 2137 webrtc::DataChannelInit init; |
| 2138 init.ordered = false; |
| 2139 init.reliable = true; |
| 2140 init.id = 1; |
| 2141 initializing_client()->CreateDataChannel(&init); |
| 2142 receiving_client()->CreateDataChannel(&init); |
| 2143 LocalP2PTest(); |
| 2144 ASSERT_NE(nullptr, initializing_client()->data_channel()); |
| 2145 ASSERT_NE(nullptr, receiving_client()->data_channel()); |
| 2146 EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(), |
| 2147 kMaxWaitMs); |
| 2148 EXPECT_TRUE_WAIT(receiving_client()->data_observer()->IsOpen(), kMaxWaitMs); |
| 2149 |
| 2150 std::string data = "hello world"; |
| 2151 |
| 2152 initializing_client()->data_channel()->Send(DataBuffer(data)); |
| 2153 EXPECT_EQ_WAIT(data, receiving_client()->data_observer()->last_message(), |
| 2154 kMaxWaitMs); |
| 2155 |
| 2156 receiving_client()->data_channel()->Send(DataBuffer(data)); |
| 2157 EXPECT_EQ_WAIT(data, initializing_client()->data_observer()->last_message(), |
| 2158 kMaxWaitMs); |
| 2159 } |
| 2160 |
| 2161 // Tests that negotiation of QUIC data channels is completed without error. |
| 2162 TEST_F(P2PTestConductor, NegotiateQuicDataChannel) { |
| 2163 config()->enable_quic = true; |
| 2164 FakeConstraints constraints; |
| 2165 constraints.SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, true); |
| 2166 ASSERT_TRUE(CreateTestClients(&constraints, &constraints)); |
| 2167 webrtc::DataChannelInit init; |
| 2168 init.ordered = false; |
| 2169 init.reliable = true; |
| 2170 init.id = 1; |
| 2171 initializing_client()->CreateDataChannel(&init); |
| 2172 initializing_client()->Negotiate(false, false); |
| 2173 } |
| 2174 |
| 2175 // This test sets up a JSEP call using QUIC. The callee only receives video. |
| 2176 TEST_F(P2PTestConductor, LocalP2PTestVideoOnlyWithQuic) { |
| 2177 config()->enable_quic = true; |
| 2178 ASSERT_TRUE(CreateTestClients()); |
| 2179 receiving_client()->SetReceiveAudioVideo(false, true); |
| 2180 LocalP2PTest(); |
| 2181 } |
| 2182 |
| 2183 // This test sets up a JSEP call using QUIC. The callee only receives audio. |
| 2184 TEST_F(P2PTestConductor, LocalP2PTestAudioOnlyWithQuic) { |
| 2185 config()->enable_quic = true; |
| 2186 ASSERT_TRUE(CreateTestClients()); |
| 2187 receiving_client()->SetReceiveAudioVideo(true, false); |
| 2188 LocalP2PTest(); |
| 2189 } |
| 2190 |
| 2191 // This test sets up a JSEP call using QUIC. The callee rejects both audio and |
| 2192 // video. |
| 2193 TEST_F(P2PTestConductor, LocalP2PTestNoVideoAudioWithQuic) { |
| 2194 config()->enable_quic = true; |
| 2195 ASSERT_TRUE(CreateTestClients()); |
| 2196 receiving_client()->SetReceiveAudioVideo(false, false); |
| 2197 LocalP2PTest(); |
| 2198 } |
| 2199 |
| 2200 #endif // HAVE_QUIC |
| 2201 |
2119 TEST_F(P2PTestConductor, ForwardVideoOnlyStream) { | 2202 TEST_F(P2PTestConductor, ForwardVideoOnlyStream) { |
2120 ASSERT_TRUE(CreateTestClients()); | 2203 ASSERT_TRUE(CreateTestClients()); |
2121 // One-way stream | 2204 // One-way stream |
2122 receiving_client()->set_auto_add_stream(false); | 2205 receiving_client()->set_auto_add_stream(false); |
2123 // Video only, audio forwarding not expected to work. | 2206 // Video only, audio forwarding not expected to work. |
2124 initializing_client()->AddMediaStream(false, true); | 2207 initializing_client()->AddMediaStream(false, true); |
2125 initializing_client()->Negotiate(); | 2208 initializing_client()->Negotiate(); |
2126 | 2209 |
2127 ASSERT_TRUE_WAIT(SessionActive(), kMaxWaitForActivationMs); | 2210 ASSERT_TRUE_WAIT(SessionActive(), kMaxWaitForActivationMs); |
2128 VerifySessionDescriptions(); | 2211 VerifySessionDescriptions(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2334 server.urls.push_back("turn:hostname2"); | 2417 server.urls.push_back("turn:hostname2"); |
2335 servers.push_back(server); | 2418 servers.push_back(server); |
2336 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); | 2419 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); |
2337 EXPECT_EQ(2U, turn_servers_.size()); | 2420 EXPECT_EQ(2U, turn_servers_.size()); |
2338 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); | 2421 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); |
2339 } | 2422 } |
2340 | 2423 |
2341 #endif // if !defined(THREAD_SANITIZER) | 2424 #endif // if !defined(THREAD_SANITIZER) |
2342 | 2425 |
2343 } // namespace | 2426 } // namespace |
OLD | NEW |