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 22 matching lines...) Expand all Loading... |
33 #include "webrtc/base/sslidentity.h" | 33 #include "webrtc/base/sslidentity.h" |
34 #include "webrtc/base/sslstreamadapter.h" | 34 #include "webrtc/base/sslstreamadapter.h" |
35 #include "webrtc/base/stringutils.h" | 35 #include "webrtc/base/stringutils.h" |
36 #include "webrtc/base/thread.h" | 36 #include "webrtc/base/thread.h" |
37 #include "webrtc/base/virtualsocketserver.h" | 37 #include "webrtc/base/virtualsocketserver.h" |
38 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 38 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
39 #include "webrtc/media/base/fakemediaengine.h" | 39 #include "webrtc/media/base/fakemediaengine.h" |
40 #include "webrtc/media/base/fakevideorenderer.h" | 40 #include "webrtc/media/base/fakevideorenderer.h" |
41 #include "webrtc/media/base/mediachannel.h" | 41 #include "webrtc/media/base/mediachannel.h" |
42 #include "webrtc/media/engine/fakewebrtccall.h" | 42 #include "webrtc/media/engine/fakewebrtccall.h" |
| 43 #include "webrtc/media/sctp/sctptransportinternal.h" |
43 #include "webrtc/p2p/base/packettransportinterface.h" | 44 #include "webrtc/p2p/base/packettransportinterface.h" |
44 #include "webrtc/p2p/base/stunserver.h" | 45 #include "webrtc/p2p/base/stunserver.h" |
45 #include "webrtc/p2p/base/teststunserver.h" | 46 #include "webrtc/p2p/base/teststunserver.h" |
46 #include "webrtc/p2p/base/testturnserver.h" | 47 #include "webrtc/p2p/base/testturnserver.h" |
47 #include "webrtc/p2p/base/transportchannel.h" | 48 #include "webrtc/p2p/base/transportchannel.h" |
48 #include "webrtc/p2p/client/basicportallocator.h" | 49 #include "webrtc/p2p/client/basicportallocator.h" |
49 #include "webrtc/pc/channelmanager.h" | 50 #include "webrtc/pc/channelmanager.h" |
50 #include "webrtc/pc/mediasession.h" | 51 #include "webrtc/pc/mediasession.h" |
51 | 52 |
52 #define MAYBE_SKIP_TEST(feature) \ | 53 #define MAYBE_SKIP_TEST(feature) \ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 static const char kSessionVersion[] = "1"; | 103 static const char kSessionVersion[] = "1"; |
103 | 104 |
104 // Media index of candidates belonging to the first media content. | 105 // Media index of candidates belonging to the first media content. |
105 static const int kMediaContentIndex0 = 0; | 106 static const int kMediaContentIndex0 = 0; |
106 static const char kMediaContentName0[] = "audio"; | 107 static const char kMediaContentName0[] = "audio"; |
107 | 108 |
108 // Media index of candidates belonging to the second media content. | 109 // Media index of candidates belonging to the second media content. |
109 static const int kMediaContentIndex1 = 1; | 110 static const int kMediaContentIndex1 = 1; |
110 static const char kMediaContentName1[] = "video"; | 111 static const char kMediaContentName1[] = "video"; |
111 | 112 |
| 113 static const int kDefaultTimeout = 10000; // 10 seconds. |
112 static const int kIceCandidatesTimeout = 10000; | 114 static const int kIceCandidatesTimeout = 10000; |
113 // STUN timeout with all retransmissions is a total of 9500ms. | 115 // STUN timeout with all retransmissions is a total of 9500ms. |
114 static const int kStunTimeout = 9500; | 116 static const int kStunTimeout = 9500; |
115 | 117 |
116 static const char kFakeDtlsFingerprint[] = | 118 static const char kFakeDtlsFingerprint[] = |
117 "BB:CD:72:F7:2F:D0:BA:43:F3:68:B1:0C:23:72:B6:4A:" | 119 "BB:CD:72:F7:2F:D0:BA:43:F3:68:B1:0C:23:72:B6:4A:" |
118 "0F:DE:34:06:BC:E0:FE:01:BC:73:C8:6D:F4:65:D5:24"; | 120 "0F:DE:34:06:BC:E0:FE:01:BC:73:C8:6D:F4:65:D5:24"; |
119 | 121 |
120 static const char kTooLongIceUfragPwd[] = | 122 static const char kTooLongIceUfragPwd[] = |
121 "IceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfrag" | 123 "IceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfragIceUfrag" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 bool oncandidatesready_; | 206 bool oncandidatesready_; |
205 std::vector<cricket::Candidate> mline_0_candidates_; | 207 std::vector<cricket::Candidate> mline_0_candidates_; |
206 std::vector<cricket::Candidate> mline_1_candidates_; | 208 std::vector<cricket::Candidate> mline_1_candidates_; |
207 PeerConnectionInterface::IceConnectionState ice_connection_state_; | 209 PeerConnectionInterface::IceConnectionState ice_connection_state_; |
208 PeerConnectionInterface::IceGatheringState ice_gathering_state_; | 210 PeerConnectionInterface::IceGatheringState ice_gathering_state_; |
209 std::vector<PeerConnectionInterface::IceConnectionState> | 211 std::vector<PeerConnectionInterface::IceConnectionState> |
210 ice_connection_state_history_; | 212 ice_connection_state_history_; |
211 size_t num_candidates_removed_ = 0; | 213 size_t num_candidates_removed_ = 0; |
212 }; | 214 }; |
213 | 215 |
| 216 // Used for tests in this file to verify that WebRtcSession responds to signals |
| 217 // from the SctpTransport correctly, and calls Start with the correct |
| 218 // local/remote ports. |
| 219 class FakeSctpTransport : public cricket::SctpTransportInternal { |
| 220 public: |
| 221 void SetTransportChannel(cricket::TransportChannel* channel) override {} |
| 222 bool Start(int local_port, int remote_port) override { |
| 223 local_port_ = local_port; |
| 224 remote_port_ = remote_port; |
| 225 return true; |
| 226 } |
| 227 bool OpenStream(int sid) override { return true; } |
| 228 bool ResetStream(int sid) override { return true; } |
| 229 bool SendData(const cricket::SendDataParams& params, |
| 230 const rtc::CopyOnWriteBuffer& payload, |
| 231 cricket::SendDataResult* result = nullptr) override { |
| 232 return true; |
| 233 } |
| 234 bool ReadyToSendData() override { return true; } |
| 235 void set_debug_name_for_testing(const char* debug_name) override {} |
| 236 |
| 237 int local_port() const { return local_port_; } |
| 238 int remote_port() const { return remote_port_; } |
| 239 |
| 240 private: |
| 241 int local_port_ = -1; |
| 242 int remote_port_ = -1; |
| 243 }; |
| 244 |
| 245 class FakeSctpTransportFactory : public cricket::SctpTransportInternalFactory { |
| 246 public: |
| 247 std::unique_ptr<cricket::SctpTransportInternal> CreateSctpTransport( |
| 248 cricket::TransportChannel*) override { |
| 249 last_fake_sctp_transport_ = new FakeSctpTransport(); |
| 250 return std::unique_ptr<cricket::SctpTransportInternal>( |
| 251 last_fake_sctp_transport_); |
| 252 } |
| 253 |
| 254 FakeSctpTransport* last_fake_sctp_transport() { |
| 255 return last_fake_sctp_transport_; |
| 256 } |
| 257 |
| 258 private: |
| 259 FakeSctpTransport* last_fake_sctp_transport_ = nullptr; |
| 260 }; |
| 261 |
214 class WebRtcSessionForTest : public webrtc::WebRtcSession { | 262 class WebRtcSessionForTest : public webrtc::WebRtcSession { |
215 public: | 263 public: |
216 WebRtcSessionForTest( | 264 WebRtcSessionForTest( |
217 webrtc::MediaControllerInterface* media_controller, | 265 webrtc::MediaControllerInterface* media_controller, |
218 rtc::Thread* network_thread, | 266 rtc::Thread* network_thread, |
219 rtc::Thread* worker_thread, | 267 rtc::Thread* worker_thread, |
220 rtc::Thread* signaling_thread, | 268 rtc::Thread* signaling_thread, |
221 cricket::PortAllocator* port_allocator, | 269 cricket::PortAllocator* port_allocator, |
222 webrtc::IceObserver* ice_observer, | 270 webrtc::IceObserver* ice_observer, |
223 std::unique_ptr<cricket::TransportController> transport_controller) | 271 std::unique_ptr<cricket::TransportController> transport_controller, |
| 272 std::unique_ptr<FakeSctpTransportFactory> sctp_factory) |
224 : WebRtcSession(media_controller, | 273 : WebRtcSession(media_controller, |
225 network_thread, | 274 network_thread, |
226 worker_thread, | 275 worker_thread, |
227 signaling_thread, | 276 signaling_thread, |
228 port_allocator, | 277 port_allocator, |
229 std::move(transport_controller)) { | 278 std::move(transport_controller), |
| 279 std::move(sctp_factory)) { |
230 RegisterIceObserver(ice_observer); | 280 RegisterIceObserver(ice_observer); |
231 } | 281 } |
232 virtual ~WebRtcSessionForTest() {} | 282 virtual ~WebRtcSessionForTest() {} |
233 | 283 |
234 // Note that these methods are only safe to use if the signaling thread | 284 // Note that these methods are only safe to use if the signaling thread |
235 // is the same as the worker thread | 285 // is the same as the worker thread |
236 rtc::PacketTransportInterface* voice_rtp_transport_channel() { | 286 rtc::PacketTransportInterface* voice_rtp_transport_channel() { |
237 return rtp_transport_channel(voice_channel()); | 287 return rtp_transport_channel(voice_channel()); |
238 } | 288 } |
239 | 289 |
240 rtc::PacketTransportInterface* voice_rtcp_transport_channel() { | 290 rtc::PacketTransportInterface* voice_rtcp_transport_channel() { |
241 return rtcp_transport_channel(voice_channel()); | 291 return rtcp_transport_channel(voice_channel()); |
242 } | 292 } |
243 | 293 |
244 rtc::PacketTransportInterface* video_rtp_transport_channel() { | 294 rtc::PacketTransportInterface* video_rtp_transport_channel() { |
245 return rtp_transport_channel(video_channel()); | 295 return rtp_transport_channel(video_channel()); |
246 } | 296 } |
247 | 297 |
248 rtc::PacketTransportInterface* video_rtcp_transport_channel() { | 298 rtc::PacketTransportInterface* video_rtcp_transport_channel() { |
249 return rtcp_transport_channel(video_channel()); | 299 return rtcp_transport_channel(video_channel()); |
250 } | 300 } |
251 | 301 |
252 rtc::PacketTransportInterface* data_rtp_transport_channel() { | |
253 return rtp_transport_channel(data_channel()); | |
254 } | |
255 | |
256 rtc::PacketTransportInterface* data_rtcp_transport_channel() { | |
257 return rtcp_transport_channel(data_channel()); | |
258 } | |
259 | |
260 private: | 302 private: |
261 rtc::PacketTransportInterface* rtp_transport_channel( | 303 rtc::PacketTransportInterface* rtp_transport_channel( |
262 cricket::BaseChannel* ch) { | 304 cricket::BaseChannel* ch) { |
263 if (!ch) { | 305 if (!ch) { |
264 return nullptr; | 306 return nullptr; |
265 } | 307 } |
266 return ch->transport_channel(); | 308 return ch->transport_channel(); |
267 } | 309 } |
268 | 310 |
269 rtc::PacketTransportInterface* rtcp_transport_channel( | 311 rtc::PacketTransportInterface* rtcp_transport_channel( |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 } | 421 } |
380 | 422 |
381 // If |cert_generator| != null or |rtc_configuration| contains |certificates| | 423 // If |cert_generator| != null or |rtc_configuration| contains |certificates| |
382 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| | 424 // then DTLS will be enabled unless explicitly disabled by |rtc_configuration| |
383 // options. When DTLS is enabled a certificate will be used if provided, | 425 // options. When DTLS is enabled a certificate will be used if provided, |
384 // otherwise one will be generated using the |cert_generator|. | 426 // otherwise one will be generated using the |cert_generator|. |
385 void Init( | 427 void Init( |
386 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, | 428 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
387 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | 429 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { |
388 ASSERT_TRUE(session_.get() == NULL); | 430 ASSERT_TRUE(session_.get() == NULL); |
| 431 fake_sctp_transport_factory_ = new FakeSctpTransportFactory(); |
389 session_.reset(new WebRtcSessionForTest( | 432 session_.reset(new WebRtcSessionForTest( |
390 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), | 433 media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(), |
391 rtc::Thread::Current(), allocator_.get(), &observer_, | 434 rtc::Thread::Current(), allocator_.get(), &observer_, |
392 std::unique_ptr<cricket::TransportController>( | 435 std::unique_ptr<cricket::TransportController>( |
393 new cricket::TransportController(rtc::Thread::Current(), | 436 new cricket::TransportController(rtc::Thread::Current(), |
394 rtc::Thread::Current(), | 437 rtc::Thread::Current(), |
395 allocator_.get())))); | 438 allocator_.get())), |
| 439 std::unique_ptr<FakeSctpTransportFactory>( |
| 440 fake_sctp_transport_factory_))); |
396 session_->SignalDataChannelOpenMessage.connect( | 441 session_->SignalDataChannelOpenMessage.connect( |
397 this, &WebRtcSessionTest::OnDataChannelOpenMessage); | 442 this, &WebRtcSessionTest::OnDataChannelOpenMessage); |
398 session_->GetOnDestroyedSignal()->connect( | 443 session_->GetOnDestroyedSignal()->connect( |
399 this, &WebRtcSessionTest::OnSessionDestroyed); | 444 this, &WebRtcSessionTest::OnSessionDestroyed); |
400 | 445 |
401 configuration_.rtcp_mux_policy = rtcp_mux_policy; | 446 configuration_.rtcp_mux_policy = rtcp_mux_policy; |
402 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, | 447 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
403 observer_.ice_connection_state_); | 448 observer_.ice_connection_state_); |
404 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, | 449 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
405 observer_.ice_gathering_state_); | 450 observer_.ice_gathering_state_); |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 turn_server.ports.push_back( | 1534 turn_server.ports.push_back( |
1490 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP)); | 1535 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP)); |
1491 allocator_->AddTurnServer(turn_server); | 1536 allocator_->AddTurnServer(turn_server); |
1492 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 1537 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
1493 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP); | 1538 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP); |
1494 } | 1539 } |
1495 | 1540 |
1496 webrtc::RtcEventLogNullImpl event_log_; | 1541 webrtc::RtcEventLogNullImpl event_log_; |
1497 cricket::FakeMediaEngine* media_engine_; | 1542 cricket::FakeMediaEngine* media_engine_; |
1498 cricket::FakeDataEngine* data_engine_; | 1543 cricket::FakeDataEngine* data_engine_; |
| 1544 // Actually owned by session_. |
| 1545 FakeSctpTransportFactory* fake_sctp_transport_factory_ = nullptr; |
1499 std::unique_ptr<cricket::ChannelManager> channel_manager_; | 1546 std::unique_ptr<cricket::ChannelManager> channel_manager_; |
1500 cricket::FakeCall fake_call_; | 1547 cricket::FakeCall fake_call_; |
1501 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_; | 1548 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_; |
1502 std::unique_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; | 1549 std::unique_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; |
1503 std::unique_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; | 1550 std::unique_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; |
1504 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | 1551 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
1505 std::unique_ptr<rtc::VirtualSocketServer> vss_; | 1552 std::unique_ptr<rtc::VirtualSocketServer> vss_; |
1506 std::unique_ptr<rtc::FirewallSocketServer> fss_; | 1553 std::unique_ptr<rtc::FirewallSocketServer> fss_; |
1507 rtc::SocketServerScope ss_scope_; | 1554 rtc::SocketServerScope ss_scope_; |
1508 rtc::SocketAddress stun_socket_addr_; | 1555 rtc::SocketAddress stun_socket_addr_; |
(...skipping 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3868 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 3915 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
3869 cricket::PORTALLOCATOR_DISABLE_RELAY); | 3916 cricket::PORTALLOCATOR_DISABLE_RELAY); |
3870 TestLoopbackCall(); | 3917 TestLoopbackCall(); |
3871 } | 3918 } |
3872 | 3919 |
3873 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { | 3920 TEST_F(WebRtcSessionTest, TestRtpDataChannel) { |
3874 configuration_.enable_rtp_data_channel = true; | 3921 configuration_.enable_rtp_data_channel = true; |
3875 Init(); | 3922 Init(); |
3876 SetLocalDescriptionWithDataChannel(); | 3923 SetLocalDescriptionWithDataChannel(); |
3877 ASSERT_TRUE(data_engine_); | 3924 ASSERT_TRUE(data_engine_); |
3878 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); | 3925 EXPECT_NE(nullptr, data_engine_->GetChannel(0)); |
3879 } | 3926 } |
3880 | 3927 |
3881 TEST_P(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { | 3928 TEST_P(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { |
3882 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3929 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3883 | 3930 |
3884 configuration_.enable_rtp_data_channel = true; | 3931 configuration_.enable_rtp_data_channel = true; |
3885 options_.disable_sctp_data_channels = false; | 3932 options_.disable_sctp_data_channels = false; |
3886 | 3933 |
3887 InitWithDtls(GetParam()); | 3934 InitWithDtls(GetParam()); |
3888 | 3935 |
3889 SetLocalDescriptionWithDataChannel(); | 3936 SetLocalDescriptionWithDataChannel(); |
3890 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); | 3937 EXPECT_NE(nullptr, data_engine_->GetChannel(0)); |
| 3938 } |
| 3939 |
| 3940 // Test that sctp_content_name/sctp_transport_name (used for stats) are correct |
| 3941 // before and after BUNDLE is negotiated. |
| 3942 TEST_P(WebRtcSessionTest, SctpContentAndTransportName) { |
| 3943 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3944 SetFactoryDtlsSrtp(); |
| 3945 InitWithDtls(GetParam()); |
| 3946 |
| 3947 // Initially these fields should be empty. |
| 3948 EXPECT_FALSE(session_->sctp_content_name()); |
| 3949 EXPECT_FALSE(session_->sctp_transport_name()); |
| 3950 |
| 3951 // Create offer with audio/video/data. |
| 3952 // Default bundle policy is "balanced", so data should be using its own |
| 3953 // transport. |
| 3954 SendAudioVideoStream1(); |
| 3955 CreateDataChannel(); |
| 3956 InitiateCall(); |
| 3957 ASSERT_TRUE(session_->sctp_content_name()); |
| 3958 ASSERT_TRUE(session_->sctp_transport_name()); |
| 3959 EXPECT_EQ("data", *session_->sctp_content_name()); |
| 3960 EXPECT_EQ("data", *session_->sctp_transport_name()); |
| 3961 |
| 3962 // Create answer that finishes BUNDLE negotiation, which means everything |
| 3963 // should be bundled on the first transport (audio). |
| 3964 cricket::MediaSessionOptions answer_options; |
| 3965 answer_options.recv_video = true; |
| 3966 answer_options.bundle_enabled = true; |
| 3967 answer_options.data_channel_type = cricket::DCT_SCTP; |
| 3968 SetRemoteDescriptionWithoutError(CreateRemoteAnswer( |
| 3969 session_->local_description(), answer_options, cricket::SEC_DISABLED)); |
| 3970 ASSERT_TRUE(session_->sctp_content_name()); |
| 3971 ASSERT_TRUE(session_->sctp_transport_name()); |
| 3972 EXPECT_EQ("data", *session_->sctp_content_name()); |
| 3973 EXPECT_EQ("audio", *session_->sctp_transport_name()); |
3891 } | 3974 } |
3892 | 3975 |
3893 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { | 3976 TEST_P(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { |
3894 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3977 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3895 | 3978 |
3896 InitWithDtls(GetParam()); | 3979 InitWithDtls(GetParam()); |
3897 | 3980 |
3898 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3981 std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
3899 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); | 3982 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); |
3900 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); | 3983 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); |
(...skipping 11 matching lines...) Expand all Loading... |
3912 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 3995 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
3913 SetRemoteDescriptionWithoutError(offer); | 3996 SetRemoteDescriptionWithoutError(offer); |
3914 | 3997 |
3915 // Verifies the answer contains SCTP. | 3998 // Verifies the answer contains SCTP. |
3916 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); | 3999 std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer()); |
3917 EXPECT_TRUE(answer != NULL); | 4000 EXPECT_TRUE(answer != NULL); |
3918 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); | 4001 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); |
3919 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); | 4002 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); |
3920 } | 4003 } |
3921 | 4004 |
| 4005 // Test that if DTLS is disabled, we don't end up with an SctpTransport |
| 4006 // created (or an RtpDataChannel). |
3922 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { | 4007 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { |
3923 configuration_.enable_dtls_srtp = rtc::Optional<bool>(false); | 4008 configuration_.enable_dtls_srtp = rtc::Optional<bool>(false); |
3924 InitWithDtls(GetParam()); | 4009 InitWithDtls(GetParam()); |
3925 | 4010 |
3926 SetLocalDescriptionWithDataChannel(); | 4011 SetLocalDescriptionWithDataChannel(); |
3927 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); | 4012 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); |
| 4013 EXPECT_EQ(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); |
3928 } | 4014 } |
3929 | 4015 |
| 4016 // Test that if DTLS is enabled, we end up with an SctpTransport created |
| 4017 // (and not an RtpDataChannel). |
3930 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithDtls) { | 4018 TEST_P(WebRtcSessionTest, TestSctpDataChannelWithDtls) { |
3931 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 4019 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3932 | 4020 |
3933 InitWithDtls(GetParam()); | 4021 InitWithDtls(GetParam()); |
3934 | 4022 |
3935 SetLocalDescriptionWithDataChannel(); | 4023 SetLocalDescriptionWithDataChannel(); |
3936 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); | 4024 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); |
| 4025 EXPECT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); |
3937 } | 4026 } |
3938 | 4027 |
| 4028 // Test that if SCTP is disabled, we don't end up with an SctpTransport |
| 4029 // created (or an RtpDataChannel). |
3939 TEST_P(WebRtcSessionTest, TestDisableSctpDataChannels) { | 4030 TEST_P(WebRtcSessionTest, TestDisableSctpDataChannels) { |
3940 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 4031 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3941 options_.disable_sctp_data_channels = true; | 4032 options_.disable_sctp_data_channels = true; |
3942 InitWithDtls(GetParam()); | 4033 InitWithDtls(GetParam()); |
3943 | 4034 |
3944 SetLocalDescriptionWithDataChannel(); | 4035 SetLocalDescriptionWithDataChannel(); |
3945 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); | 4036 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); |
| 4037 EXPECT_EQ(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); |
3946 } | 4038 } |
3947 | 4039 |
3948 TEST_P(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) { | 4040 TEST_P(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) { |
3949 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 4041 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
3950 const int new_send_port = 9998; | 4042 const int new_send_port = 9998; |
3951 const int new_recv_port = 7775; | 4043 const int new_recv_port = 7775; |
3952 | 4044 |
3953 InitWithDtls(GetParam()); | 4045 InitWithDtls(GetParam()); |
3954 SetFactoryDtlsSrtp(); | 4046 SetFactoryDtlsSrtp(); |
3955 | 4047 |
(...skipping 10 matching lines...) Expand all Loading... |
3966 | 4058 |
3967 SessionDescriptionInterface* answer = | 4059 SessionDescriptionInterface* answer = |
3968 ChangeSDPSctpPort(new_recv_port, CreateAnswer()); | 4060 ChangeSDPSctpPort(new_recv_port, CreateAnswer()); |
3969 ASSERT_TRUE(answer != NULL); | 4061 ASSERT_TRUE(answer != NULL); |
3970 | 4062 |
3971 // Now set the local description, which'll take ownership of the answer. | 4063 // Now set the local description, which'll take ownership of the answer. |
3972 SetLocalDescriptionWithoutError(answer); | 4064 SetLocalDescriptionWithoutError(answer); |
3973 | 4065 |
3974 // TEST PLAN: Set the port number to something new, set it in the SDP, | 4066 // TEST PLAN: Set the port number to something new, set it in the SDP, |
3975 // and pass it all the way down. | 4067 // and pass it all the way down. |
3976 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); | 4068 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); |
3977 CreateDataChannel(); | 4069 CreateDataChannel(); |
3978 | 4070 ASSERT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); |
3979 cricket::FakeDataMediaChannel* ch = data_engine_->GetChannel(0); | 4071 EXPECT_EQ( |
3980 int portnum = -1; | 4072 new_recv_port, |
3981 ASSERT_TRUE(ch != NULL); | 4073 fake_sctp_transport_factory_->last_fake_sctp_transport()->local_port()); |
3982 ASSERT_EQ(1UL, ch->send_codecs().size()); | 4074 EXPECT_EQ( |
3983 EXPECT_EQ(cricket::kGoogleSctpDataCodecPlType, ch->send_codecs()[0].id); | 4075 new_send_port, |
3984 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName, | 4076 fake_sctp_transport_factory_->last_fake_sctp_transport()->remote_port()); |
3985 ch->send_codecs()[0].name.c_str())); | |
3986 EXPECT_TRUE(ch->send_codecs()[0].GetParam(cricket::kCodecParamPort, | |
3987 &portnum)); | |
3988 EXPECT_EQ(new_send_port, portnum); | |
3989 | |
3990 ASSERT_EQ(1UL, ch->recv_codecs().size()); | |
3991 EXPECT_EQ(cricket::kGoogleSctpDataCodecPlType, ch->recv_codecs()[0].id); | |
3992 EXPECT_EQ(0, strcmp(cricket::kGoogleSctpDataCodecName, | |
3993 ch->recv_codecs()[0].name.c_str())); | |
3994 EXPECT_TRUE(ch->recv_codecs()[0].GetParam(cricket::kCodecParamPort, | |
3995 &portnum)); | |
3996 EXPECT_EQ(new_recv_port, portnum); | |
3997 } | 4077 } |
3998 | 4078 |
3999 // Verifies that when a session's DataChannel receives an OPEN message, | 4079 // Verifies that when a session's SctpTransport receives an OPEN message, |
4000 // WebRtcSession signals the DataChannel creation request with the expected | 4080 // WebRtcSession signals the SctpTransport creation request with the expected |
4001 // config. | 4081 // config. |
4002 TEST_P(WebRtcSessionTest, TestSctpDataChannelOpenMessage) { | 4082 TEST_P(WebRtcSessionTest, TestSctpDataChannelOpenMessage) { |
4003 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 4083 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
4004 | 4084 |
4005 InitWithDtls(GetParam()); | 4085 InitWithDtls(GetParam()); |
4006 | 4086 |
4007 SetLocalDescriptionWithDataChannel(); | 4087 SetLocalDescriptionWithDataChannel(); |
4008 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); | 4088 EXPECT_EQ(nullptr, data_engine_->GetChannel(0)); |
| 4089 ASSERT_NE(nullptr, fake_sctp_transport_factory_->last_fake_sctp_transport()); |
4009 | 4090 |
| 4091 // Make the fake SCTP transport pretend it received an OPEN message. |
4010 webrtc::DataChannelInit config; | 4092 webrtc::DataChannelInit config; |
4011 config.id = 1; | 4093 config.id = 1; |
4012 rtc::CopyOnWriteBuffer payload; | 4094 rtc::CopyOnWriteBuffer payload; |
4013 webrtc::WriteDataChannelOpenMessage("a", config, &payload); | 4095 webrtc::WriteDataChannelOpenMessage("a", config, &payload); |
4014 cricket::ReceiveDataParams params; | 4096 cricket::ReceiveDataParams params; |
4015 params.ssrc = config.id; | 4097 params.ssrc = config.id; |
4016 params.type = cricket::DMT_CONTROL; | 4098 params.type = cricket::DMT_CONTROL; |
| 4099 fake_sctp_transport_factory_->last_fake_sctp_transport()->SignalDataReceived( |
| 4100 params, payload); |
4017 | 4101 |
4018 cricket::DataChannel* data_channel = session_->data_channel(); | 4102 EXPECT_EQ_WAIT("a", last_data_channel_label_, kDefaultTimeout); |
4019 data_channel->SignalDataReceived(data_channel, params, payload); | |
4020 | |
4021 EXPECT_EQ("a", last_data_channel_label_); | |
4022 EXPECT_EQ(config.id, last_data_channel_config_.id); | 4103 EXPECT_EQ(config.id, last_data_channel_config_.id); |
4023 EXPECT_FALSE(last_data_channel_config_.negotiated); | 4104 EXPECT_FALSE(last_data_channel_config_.negotiated); |
4024 EXPECT_EQ(webrtc::InternalDataChannelInit::kAcker, | 4105 EXPECT_EQ(webrtc::InternalDataChannelInit::kAcker, |
4025 last_data_channel_config_.open_handshake_role); | 4106 last_data_channel_config_.open_handshake_role); |
4026 } | 4107 } |
4027 | 4108 |
4028 TEST_P(WebRtcSessionTest, TestUsesProvidedCertificate) { | 4109 TEST_P(WebRtcSessionTest, TestUsesProvidedCertificate) { |
4029 rtc::scoped_refptr<rtc::RTCCertificate> certificate = | 4110 rtc::scoped_refptr<rtc::RTCCertificate> certificate = |
4030 FakeRTCCertificateGenerator::GenerateCertificate(); | 4111 FakeRTCCertificateGenerator::GenerateCertificate(); |
4031 | 4112 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4361 } | 4442 } |
4362 | 4443 |
4363 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4444 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4364 // currently fails because upon disconnection and reconnection OnIceComplete is | 4445 // currently fails because upon disconnection and reconnection OnIceComplete is |
4365 // called more than once without returning to IceGatheringGathering. | 4446 // called more than once without returning to IceGatheringGathering. |
4366 | 4447 |
4367 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4448 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4368 WebRtcSessionTest, | 4449 WebRtcSessionTest, |
4369 testing::Values(ALREADY_GENERATED, | 4450 testing::Values(ALREADY_GENERATED, |
4370 DTLS_IDENTITY_STORE)); | 4451 DTLS_IDENTITY_STORE)); |
OLD | NEW |