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