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 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, | 158 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, |
158 bool prefer_constraint_apis, | 159 bool prefer_constraint_apis, |
159 rtc::Thread* worker_thread) { | 160 rtc::Thread* worker_thread) { |
160 PeerConnectionTestClient* client(new PeerConnectionTestClient(id)); | 161 PeerConnectionTestClient* client(new PeerConnectionTestClient(id)); |
161 if (!client->Init(constraints, options, std::move(dtls_identity_store), | 162 if (!client->Init(constraints, options, config, |
162 prefer_constraint_apis, worker_thread)) { | 163 std::move(dtls_identity_store), prefer_constraint_apis, |
| 164 worker_thread)) { |
163 delete client; | 165 delete client; |
164 return nullptr; | 166 return nullptr; |
165 } | 167 } |
166 return client; | 168 return client; |
167 } | 169 } |
168 | 170 |
169 static PeerConnectionTestClient* CreateClient( | 171 static PeerConnectionTestClient* CreateClient( |
170 const std::string& id, | 172 const std::string& id, |
171 const MediaConstraintsInterface* constraints, | 173 const MediaConstraintsInterface* constraints, |
172 const PeerConnectionFactory::Options* options, | 174 const PeerConnectionFactory::Options* options, |
| 175 const PeerConnectionInterface::RTCConfiguration& config, |
173 rtc::Thread* worker_thread) { | 176 rtc::Thread* worker_thread) { |
174 std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store( | 177 std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
175 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() | 178 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
176 : nullptr); | 179 : nullptr); |
177 | 180 |
178 return CreateClientWithDtlsIdentityStore(id, constraints, options, | 181 return CreateClientWithDtlsIdentityStore(id, constraints, options, config, |
179 std::move(dtls_identity_store), | 182 std::move(dtls_identity_store), |
180 true, worker_thread); | 183 true, worker_thread); |
181 } | 184 } |
182 | 185 |
183 static PeerConnectionTestClient* CreateClientPreferNoConstraints( | 186 static PeerConnectionTestClient* CreateClientPreferNoConstraints( |
184 const std::string& id, | 187 const std::string& id, |
185 const PeerConnectionFactory::Options* options, | 188 const PeerConnectionFactory::Options* options, |
| 189 const PeerConnectionInterface::RTCConfiguration& config, |
186 rtc::Thread* worker_thread) { | 190 rtc::Thread* worker_thread) { |
187 std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store( | 191 std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
188 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() | 192 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
189 : nullptr); | 193 : nullptr); |
190 | 194 |
191 return CreateClientWithDtlsIdentityStore(id, nullptr, options, | 195 return CreateClientWithDtlsIdentityStore(id, nullptr, options, config, |
192 std::move(dtls_identity_store), | 196 std::move(dtls_identity_store), |
193 false, worker_thread); | 197 false, worker_thread); |
194 } | 198 } |
195 | 199 |
196 ~PeerConnectionTestClient() { | 200 ~PeerConnectionTestClient() { |
197 } | 201 } |
198 | 202 |
199 void Negotiate() { Negotiate(true, true); } | 203 void Negotiate() { Negotiate(true, true); } |
200 | 204 |
201 void Negotiate(bool audio, bool video) { | 205 void Negotiate(bool audio, bool video) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 offer_answer_options_.offer_to_receive_video == | 428 offer_answer_options_.offer_to_receive_video == |
425 PeerConnectionInterface::RTCOfferAnswerOptions::kUndefined; | 429 PeerConnectionInterface::RTCOfferAnswerOptions::kUndefined; |
426 } | 430 } |
427 | 431 |
428 void OnDataChannel(DataChannelInterface* data_channel) override { | 432 void OnDataChannel(DataChannelInterface* data_channel) override { |
429 LOG(INFO) << id_ << "OnDataChannel"; | 433 LOG(INFO) << id_ << "OnDataChannel"; |
430 data_channel_ = data_channel; | 434 data_channel_ = data_channel; |
431 data_observer_.reset(new MockDataChannelObserver(data_channel)); | 435 data_observer_.reset(new MockDataChannelObserver(data_channel)); |
432 } | 436 } |
433 | 437 |
434 void CreateDataChannel() { | 438 void CreateDataChannel() { CreateDataChannel(nullptr); } |
435 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, nullptr); | 439 |
| 440 void CreateDataChannel(const webrtc::DataChannelInit* init) { |
| 441 data_channel_ = pc()->CreateDataChannel(kDataChannelLabel, init); |
436 ASSERT_TRUE(data_channel_.get() != nullptr); | 442 ASSERT_TRUE(data_channel_.get() != nullptr); |
437 data_observer_.reset(new MockDataChannelObserver(data_channel_)); | 443 data_observer_.reset(new MockDataChannelObserver(data_channel_)); |
438 } | 444 } |
439 | 445 |
440 rtc::scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack( | 446 rtc::scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack( |
441 const std::string& stream_label) { | 447 const std::string& stream_label) { |
442 FakeConstraints constraints; | 448 FakeConstraints constraints; |
443 // Disable highpass filter so that we can get all the test audio frames. | 449 // Disable highpass filter so that we can get all the test audio frames. |
444 constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false); | 450 constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false); |
445 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = | 451 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 private: | 803 private: |
798 bool completed_; | 804 bool completed_; |
799 std::vector<std::string> tones_; | 805 std::vector<std::string> tones_; |
800 }; | 806 }; |
801 | 807 |
802 explicit PeerConnectionTestClient(const std::string& id) : id_(id) {} | 808 explicit PeerConnectionTestClient(const std::string& id) : id_(id) {} |
803 | 809 |
804 bool Init( | 810 bool Init( |
805 const MediaConstraintsInterface* constraints, | 811 const MediaConstraintsInterface* constraints, |
806 const PeerConnectionFactory::Options* options, | 812 const PeerConnectionFactory::Options* options, |
| 813 const PeerConnectionInterface::RTCConfiguration& config, |
807 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, | 814 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, |
808 bool prefer_constraint_apis, | 815 bool prefer_constraint_apis, |
809 rtc::Thread* worker_thread) { | 816 rtc::Thread* worker_thread) { |
810 EXPECT_TRUE(!peer_connection_); | 817 EXPECT_TRUE(!peer_connection_); |
811 EXPECT_TRUE(!peer_connection_factory_); | 818 EXPECT_TRUE(!peer_connection_factory_); |
812 if (!prefer_constraint_apis) { | 819 if (!prefer_constraint_apis) { |
813 EXPECT_TRUE(!constraints); | 820 EXPECT_TRUE(!constraints); |
814 } | 821 } |
815 prefer_constraint_apis_ = prefer_constraint_apis; | 822 prefer_constraint_apis_ = prefer_constraint_apis; |
816 | 823 |
817 std::unique_ptr<cricket::PortAllocator> port_allocator( | 824 std::unique_ptr<cricket::PortAllocator> port_allocator( |
818 new cricket::FakePortAllocator(worker_thread, nullptr)); | 825 new cricket::FakePortAllocator(worker_thread, nullptr)); |
819 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); | 826 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); |
820 | 827 |
821 if (fake_audio_capture_module_ == nullptr) { | 828 if (fake_audio_capture_module_ == nullptr) { |
822 return false; | 829 return false; |
823 } | 830 } |
824 fake_video_decoder_factory_ = new FakeWebRtcVideoDecoderFactory(); | 831 fake_video_decoder_factory_ = new FakeWebRtcVideoDecoderFactory(); |
825 fake_video_encoder_factory_ = new FakeWebRtcVideoEncoderFactory(); | 832 fake_video_encoder_factory_ = new FakeWebRtcVideoEncoderFactory(); |
826 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( | 833 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( |
827 worker_thread, rtc::Thread::Current(), fake_audio_capture_module_, | 834 worker_thread, rtc::Thread::Current(), fake_audio_capture_module_, |
828 fake_video_encoder_factory_, fake_video_decoder_factory_); | 835 fake_video_encoder_factory_, fake_video_decoder_factory_); |
829 if (!peer_connection_factory_) { | 836 if (!peer_connection_factory_) { |
830 return false; | 837 return false; |
831 } | 838 } |
832 if (options) { | 839 if (options) { |
833 peer_connection_factory_->SetOptions(*options); | 840 peer_connection_factory_->SetOptions(*options); |
834 } | 841 } |
835 peer_connection_ = CreatePeerConnection( | 842 peer_connection_ = |
836 std::move(port_allocator), constraints, std::move(dtls_identity_store)); | 843 CreatePeerConnection(std::move(port_allocator), constraints, config, |
| 844 std::move(dtls_identity_store)); |
837 return peer_connection_.get() != nullptr; | 845 return peer_connection_.get() != nullptr; |
838 } | 846 } |
839 | 847 |
840 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( | 848 rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( |
841 std::unique_ptr<cricket::PortAllocator> port_allocator, | 849 std::unique_ptr<cricket::PortAllocator> port_allocator, |
842 const MediaConstraintsInterface* constraints, | 850 const MediaConstraintsInterface* constraints, |
| 851 const PeerConnectionInterface::RTCConfiguration& config, |
843 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) { | 852 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) { |
844 // CreatePeerConnection with RTCConfiguration. | |
845 webrtc::PeerConnectionInterface::RTCConfiguration config; | |
846 webrtc::PeerConnectionInterface::IceServer ice_server; | |
847 ice_server.uri = "stun:stun.l.google.com:19302"; | |
848 config.servers.push_back(ice_server); | |
849 | |
850 return peer_connection_factory_->CreatePeerConnection( | 853 return peer_connection_factory_->CreatePeerConnection( |
851 config, constraints, std::move(port_allocator), | 854 config, constraints, std::move(port_allocator), |
852 std::move(dtls_identity_store), this); | 855 std::move(dtls_identity_store), this); |
853 } | 856 } |
854 | 857 |
855 void HandleIncomingOffer(const std::string& msg) { | 858 void HandleIncomingOffer(const std::string& msg) { |
856 LOG(INFO) << id_ << "HandleIncomingOffer "; | 859 LOG(INFO) << id_ << "HandleIncomingOffer "; |
857 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { | 860 if (NumberOfLocalMediaStreams() == 0 && auto_add_stream_) { |
858 // If we are not sending any streams ourselves it is time to add some. | 861 // If we are not sending any streams ourselves it is time to add some. |
859 AddMediaStream(true, true); | 862 AddMediaStream(true, true); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 std::unique_ptr<MockDataChannelObserver> data_observer_; | 1022 std::unique_ptr<MockDataChannelObserver> data_observer_; |
1020 }; | 1023 }; |
1021 | 1024 |
1022 class P2PTestConductor : public testing::Test { | 1025 class P2PTestConductor : public testing::Test { |
1023 public: | 1026 public: |
1024 P2PTestConductor() | 1027 P2PTestConductor() |
1025 : pss_(new rtc::PhysicalSocketServer), | 1028 : pss_(new rtc::PhysicalSocketServer), |
1026 ss_(new rtc::VirtualSocketServer(pss_.get())), | 1029 ss_(new rtc::VirtualSocketServer(pss_.get())), |
1027 ss_scope_(ss_.get()) { | 1030 ss_scope_(ss_.get()) { |
1028 RTC_CHECK(worker_thread_.Start()); | 1031 RTC_CHECK(worker_thread_.Start()); |
| 1032 webrtc::PeerConnectionInterface::IceServer ice_server; |
| 1033 ice_server.uri = "stun:stun.l.google.com:19302"; |
| 1034 config_.servers.push_back(ice_server); |
1029 } | 1035 } |
1030 | 1036 |
1031 bool SessionActive() { | 1037 bool SessionActive() { |
1032 return initiating_client_->SessionActive() && | 1038 return initiating_client_->SessionActive() && |
1033 receiving_client_->SessionActive(); | 1039 receiving_client_->SessionActive(); |
1034 } | 1040 } |
1035 | 1041 |
1036 // Return true if the number of frames provided have been received | 1042 // Return true if the number of frames provided have been received |
1037 // on the video and audio tracks provided. | 1043 // on the video and audio tracks provided. |
1038 bool FramesHaveArrived(int audio_frames_to_receive, | 1044 bool FramesHaveArrived(int audio_frames_to_receive, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 | 1134 |
1129 bool CreateTestClients(MediaConstraintsInterface* init_constraints, | 1135 bool CreateTestClients(MediaConstraintsInterface* init_constraints, |
1130 MediaConstraintsInterface* recv_constraints) { | 1136 MediaConstraintsInterface* recv_constraints) { |
1131 return CreateTestClients(init_constraints, nullptr, recv_constraints, | 1137 return CreateTestClients(init_constraints, nullptr, recv_constraints, |
1132 nullptr); | 1138 nullptr); |
1133 } | 1139 } |
1134 | 1140 |
1135 bool CreateTestClientsThatPreferNoConstraints() { | 1141 bool CreateTestClientsThatPreferNoConstraints() { |
1136 initiating_client_.reset( | 1142 initiating_client_.reset( |
1137 PeerConnectionTestClient::CreateClientPreferNoConstraints( | 1143 PeerConnectionTestClient::CreateClientPreferNoConstraints( |
1138 "Caller: ", nullptr, &worker_thread_)); | 1144 "Caller: ", nullptr, config_, &worker_thread_)); |
1139 receiving_client_.reset( | 1145 receiving_client_.reset( |
1140 PeerConnectionTestClient::CreateClientPreferNoConstraints( | 1146 PeerConnectionTestClient::CreateClientPreferNoConstraints( |
1141 "Callee: ", nullptr, &worker_thread_)); | 1147 "Callee: ", nullptr, config_, &worker_thread_)); |
1142 if (!initiating_client_ || !receiving_client_) { | 1148 if (!initiating_client_ || !receiving_client_) { |
1143 return false; | 1149 return false; |
1144 } | 1150 } |
1145 // Remember the choice for possible later resets of the clients. | 1151 // Remember the choice for possible later resets of the clients. |
1146 prefer_constraint_apis_ = false; | 1152 prefer_constraint_apis_ = false; |
1147 SetSignalingReceivers(); | 1153 SetSignalingReceivers(); |
1148 return true; | 1154 return true; |
1149 } | 1155 } |
1150 | 1156 |
1151 void SetSignalingReceivers() { | 1157 void SetSignalingReceivers() { |
1152 initiating_client_->set_signaling_message_receiver(receiving_client_.get()); | 1158 initiating_client_->set_signaling_message_receiver(receiving_client_.get()); |
1153 receiving_client_->set_signaling_message_receiver(initiating_client_.get()); | 1159 receiving_client_->set_signaling_message_receiver(initiating_client_.get()); |
1154 } | 1160 } |
1155 | 1161 |
1156 bool CreateTestClients(MediaConstraintsInterface* init_constraints, | 1162 bool CreateTestClients(MediaConstraintsInterface* init_constraints, |
1157 PeerConnectionFactory::Options* init_options, | 1163 PeerConnectionFactory::Options* init_options, |
1158 MediaConstraintsInterface* recv_constraints, | 1164 MediaConstraintsInterface* recv_constraints, |
1159 PeerConnectionFactory::Options* recv_options) { | 1165 PeerConnectionFactory::Options* recv_options) { |
1160 initiating_client_.reset(PeerConnectionTestClient::CreateClient( | 1166 initiating_client_.reset(PeerConnectionTestClient::CreateClient( |
1161 "Caller: ", init_constraints, init_options, &worker_thread_)); | 1167 "Caller: ", init_constraints, init_options, config_, &worker_thread_)); |
1162 receiving_client_.reset(PeerConnectionTestClient::CreateClient( | 1168 receiving_client_.reset(PeerConnectionTestClient::CreateClient( |
1163 "Callee: ", recv_constraints, recv_options, &worker_thread_)); | 1169 "Callee: ", recv_constraints, recv_options, config_, &worker_thread_)); |
1164 if (!initiating_client_ || !receiving_client_) { | 1170 if (!initiating_client_ || !receiving_client_) { |
1165 return false; | 1171 return false; |
1166 } | 1172 } |
1167 SetSignalingReceivers(); | 1173 SetSignalingReceivers(); |
1168 return true; | 1174 return true; |
1169 } | 1175 } |
1170 | 1176 |
1171 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints, | 1177 void SetVideoConstraints(const webrtc::FakeConstraints& init_constraints, |
1172 const webrtc::FakeConstraints& recv_constraints) { | 1178 const webrtc::FakeConstraints& recv_constraints) { |
1173 initiating_client_->SetVideoConstraints(init_constraints); | 1179 initiating_client_->SetVideoConstraints(init_constraints); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, | 1259 setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, |
1254 true); | 1260 true); |
1255 | 1261 |
1256 std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store( | 1262 std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
1257 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() | 1263 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
1258 : nullptr); | 1264 : nullptr); |
1259 dtls_identity_store->use_alternate_key(); | 1265 dtls_identity_store->use_alternate_key(); |
1260 | 1266 |
1261 // Make sure the new client is using a different certificate. | 1267 // Make sure the new client is using a different certificate. |
1262 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore( | 1268 return PeerConnectionTestClient::CreateClientWithDtlsIdentityStore( |
1263 "New Peer: ", &setup_constraints, nullptr, | 1269 "New Peer: ", &setup_constraints, nullptr, config_, |
1264 std::move(dtls_identity_store), prefer_constraint_apis_, | 1270 std::move(dtls_identity_store), prefer_constraint_apis_, |
1265 &worker_thread_); | 1271 &worker_thread_); |
1266 } | 1272 } |
1267 | 1273 |
1268 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { | 1274 void SendRtpData(webrtc::DataChannelInterface* dc, const std::string& data) { |
1269 // Messages may get lost on the unreliable DataChannel, so we send multiple | 1275 // Messages may get lost on the unreliable DataChannel, so we send multiple |
1270 // times to avoid test flakiness. | 1276 // times to avoid test flakiness. |
1271 static const size_t kSendAttempts = 5; | 1277 static const size_t kSendAttempts = 5; |
1272 | 1278 |
1273 for (size_t i = 0; i < kSendAttempts; ++i) { | 1279 for (size_t i = 0; i < kSendAttempts; ++i) { |
(...skipping 19 matching lines...) Expand all Loading... |
1293 } | 1299 } |
1294 | 1300 |
1295 // Set the |receiving_client_| to the |client| passed in and return the | 1301 // Set the |receiving_client_| to the |client| passed in and return the |
1296 // original |receiving_client_|. | 1302 // original |receiving_client_|. |
1297 PeerConnectionTestClient* set_receiving_client( | 1303 PeerConnectionTestClient* set_receiving_client( |
1298 PeerConnectionTestClient* client) { | 1304 PeerConnectionTestClient* client) { |
1299 PeerConnectionTestClient* old = receiving_client_.release(); | 1305 PeerConnectionTestClient* old = receiving_client_.release(); |
1300 receiving_client_.reset(client); | 1306 receiving_client_.reset(client); |
1301 return old; | 1307 return old; |
1302 } | 1308 } |
| 1309 webrtc::PeerConnectionInterface::RTCConfiguration* config() { |
| 1310 return &config_; |
| 1311 } |
1303 | 1312 |
1304 private: | 1313 private: |
1305 // |worker_thread_| is used by both |initiating_client_| and | 1314 // |worker_thread_| is used by both |initiating_client_| and |
1306 // |receiving_client_|. Must be destroyed last. | 1315 // |receiving_client_|. Must be destroyed last. |
1307 rtc::Thread worker_thread_; | 1316 rtc::Thread worker_thread_; |
1308 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | 1317 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
1309 std::unique_ptr<rtc::VirtualSocketServer> ss_; | 1318 std::unique_ptr<rtc::VirtualSocketServer> ss_; |
1310 rtc::SocketServerScope ss_scope_; | 1319 rtc::SocketServerScope ss_scope_; |
1311 std::unique_ptr<PeerConnectionTestClient> initiating_client_; | 1320 std::unique_ptr<PeerConnectionTestClient> initiating_client_; |
1312 std::unique_ptr<PeerConnectionTestClient> receiving_client_; | 1321 std::unique_ptr<PeerConnectionTestClient> receiving_client_; |
1313 bool prefer_constraint_apis_ = true; | 1322 bool prefer_constraint_apis_ = true; |
| 1323 webrtc::PeerConnectionInterface::RTCConfiguration config_; |
1314 }; | 1324 }; |
1315 | 1325 |
1316 // Disable for TSan v2, see | 1326 // Disable for TSan v2, see |
1317 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. | 1327 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. |
1318 #if !defined(THREAD_SANITIZER) | 1328 #if !defined(THREAD_SANITIZER) |
1319 | 1329 |
1320 // This test sets up a Jsep call between two parties and test Dtmf. | 1330 // This test sets up a Jsep call between two parties and test Dtmf. |
1321 // TODO(holmer): Disabled due to sometimes crashing on buildbots. | 1331 // TODO(holmer): Disabled due to sometimes crashing on buildbots. |
1322 // See issue webrtc/2378. | 1332 // See issue webrtc/2378. |
1323 TEST_F(P2PTestConductor, DISABLED_LocalP2PTestDtmf) { | 1333 TEST_F(P2PTestConductor, DISABLED_LocalP2PTestDtmf) { |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 kMaxWaitForFramesMs); | 1984 kMaxWaitForFramesMs); |
1975 // Now set the tracks, and expect frames to immediately start flowing. | 1985 // Now set the tracks, and expect frames to immediately start flowing. |
1976 EXPECT_TRUE( | 1986 EXPECT_TRUE( |
1977 audio_sender->SetTrack(initializing_client()->CreateLocalAudioTrack(""))); | 1987 audio_sender->SetTrack(initializing_client()->CreateLocalAudioTrack(""))); |
1978 EXPECT_TRUE( | 1988 EXPECT_TRUE( |
1979 video_sender->SetTrack(initializing_client()->CreateLocalVideoTrack(""))); | 1989 video_sender->SetTrack(initializing_client()->CreateLocalVideoTrack(""))); |
1980 EXPECT_TRUE_WAIT(FramesHaveArrived(kEndAudioFrameCount, kEndVideoFrameCount), | 1990 EXPECT_TRUE_WAIT(FramesHaveArrived(kEndAudioFrameCount, kEndVideoFrameCount), |
1981 kMaxWaitForFramesMs); | 1991 kMaxWaitForFramesMs); |
1982 } | 1992 } |
1983 | 1993 |
| 1994 #ifdef HAVE_QUIC |
| 1995 // This test sets up a call between two parties using QUIC instead of DTLS |
| 1996 // for |
| 1997 // audio and video, and a QUIC data channel. |
| 1998 TEST_F(P2PTestConductor, LocalP2PTestQuicDataChannel) { |
| 1999 config()->enable_quic = true; |
| 2000 ASSERT_TRUE(CreateTestClients()); |
| 2001 webrtc::DataChannelInit init; |
| 2002 init.ordered = false; |
| 2003 init.reliable = true; |
| 2004 init.id = 1; |
| 2005 initializing_client()->CreateDataChannel(&init); |
| 2006 receiving_client()->CreateDataChannel(&init); |
| 2007 LocalP2PTest(); |
| 2008 ASSERT_NE(nullptr, initializing_client()->data_channel()); |
| 2009 ASSERT_NE(nullptr, receiving_client()->data_channel()); |
| 2010 EXPECT_TRUE_WAIT(initializing_client()->data_observer()->IsOpen(), |
| 2011 kMaxWaitMs); |
| 2012 EXPECT_TRUE_WAIT(receiving_client()->data_observer()->IsOpen(), kMaxWaitMs); |
| 2013 |
| 2014 std::string data = "hello world"; |
| 2015 |
| 2016 initializing_client()->data_channel()->Send(DataBuffer(data)); |
| 2017 EXPECT_EQ_WAIT(data, receiving_client()->data_observer()->last_message(), |
| 2018 kMaxWaitMs); |
| 2019 |
| 2020 receiving_client()->data_channel()->Send(DataBuffer(data)); |
| 2021 EXPECT_EQ_WAIT(data, initializing_client()->data_observer()->last_message(), |
| 2022 kMaxWaitMs); |
| 2023 } |
| 2024 |
| 2025 // Tests that negotiation of QUIC data channels is completed without error. |
| 2026 TEST_F(P2PTestConductor, CreateOfferWithQuicDataChannel) { |
| 2027 config()->enable_quic = true; |
| 2028 FakeConstraints constraints; |
| 2029 constraints.SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, true); |
| 2030 ASSERT_TRUE(CreateTestClients(&constraints, &constraints)); |
| 2031 webrtc::DataChannelInit init; |
| 2032 init.ordered = false; |
| 2033 init.reliable = true; |
| 2034 init.id = 1; |
| 2035 initializing_client()->CreateDataChannel(&init); |
| 2036 initializing_client()->Negotiate(false, false); |
| 2037 } |
| 2038 |
| 2039 // This test sets up a Jsep call using QUIC. The callee only receives video. |
| 2040 TEST_F(P2PTestConductor, LocalP2PTestAnswerVideoQuic) { |
| 2041 config()->enable_quic = true; |
| 2042 ASSERT_TRUE(CreateTestClients()); |
| 2043 receiving_client()->SetReceiveAudioVideo(false, true); |
| 2044 LocalP2PTest(); |
| 2045 } |
| 2046 |
| 2047 // This test sets up a Jsep call using QUIC. The callee only receives audio. |
| 2048 TEST_F(P2PTestConductor, LocalP2PTestAnswerAudioQuic) { |
| 2049 config()->enable_quic = true; |
| 2050 ASSERT_TRUE(CreateTestClients()); |
| 2051 receiving_client()->SetReceiveAudioVideo(true, false); |
| 2052 LocalP2PTest(); |
| 2053 } |
| 2054 |
| 2055 // This test sets up a Jsep call between two parties using QUIC. The callee |
| 2056 // rejects both audio and video. |
| 2057 TEST_F(P2PTestConductor, LocalP2PTestAnswerNoneQuic) { |
| 2058 config()->enable_quic = true; |
| 2059 ASSERT_TRUE(CreateTestClients()); |
| 2060 receiving_client()->SetReceiveAudioVideo(false, false); |
| 2061 LocalP2PTest(); |
| 2062 } |
| 2063 |
| 2064 #endif // HAVE_QUIC |
| 2065 |
1984 TEST_F(P2PTestConductor, ForwardVideoOnlyStream) { | 2066 TEST_F(P2PTestConductor, ForwardVideoOnlyStream) { |
1985 ASSERT_TRUE(CreateTestClients()); | 2067 ASSERT_TRUE(CreateTestClients()); |
1986 // One-way stream | 2068 // One-way stream |
1987 receiving_client()->set_auto_add_stream(false); | 2069 receiving_client()->set_auto_add_stream(false); |
1988 // Video only, audio forwarding not expected to work. | 2070 // Video only, audio forwarding not expected to work. |
1989 initializing_client()->AddMediaStream(false, true); | 2071 initializing_client()->AddMediaStream(false, true); |
1990 initializing_client()->Negotiate(); | 2072 initializing_client()->Negotiate(); |
1991 | 2073 |
1992 ASSERT_TRUE_WAIT(SessionActive(), kMaxWaitForActivationMs); | 2074 ASSERT_TRUE_WAIT(SessionActive(), kMaxWaitForActivationMs); |
1993 VerifySessionDescriptions(); | 2075 VerifySessionDescriptions(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 server.urls.push_back("turn:hostname2"); | 2281 server.urls.push_back("turn:hostname2"); |
2200 servers.push_back(server); | 2282 servers.push_back(server); |
2201 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); | 2283 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); |
2202 EXPECT_EQ(2U, turn_servers_.size()); | 2284 EXPECT_EQ(2U, turn_servers_.size()); |
2203 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); | 2285 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); |
2204 } | 2286 } |
2205 | 2287 |
2206 #endif // if !defined(THREAD_SANITIZER) | 2288 #endif // if !defined(THREAD_SANITIZER) |
2207 | 2289 |
2208 } // namespace | 2290 } // namespace |
OLD | NEW |