| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
| 12 * and/or other materials provided with the distribution. | 12 * and/or other materials provided with the distribution. |
| 13 * 3. The name of the author may not be used to endorse or promote products | 13 * 3. The name of the author may not be used to endorse or promote products |
| 14 * derived from this software without specific prior written permission. | 14 * derived from this software without specific prior written permission. |
| 15 * | 15 * |
| 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include <vector> |
| 29 |
| 28 #include "talk/app/webrtc/audiotrack.h" | 30 #include "talk/app/webrtc/audiotrack.h" |
| 29 #include "talk/app/webrtc/fakemetricsobserver.h" | 31 #include "talk/app/webrtc/fakemetricsobserver.h" |
| 30 #include "talk/app/webrtc/jsepicecandidate.h" | 32 #include "talk/app/webrtc/jsepicecandidate.h" |
| 31 #include "talk/app/webrtc/jsepsessiondescription.h" | 33 #include "talk/app/webrtc/jsepsessiondescription.h" |
| 32 #include "talk/app/webrtc/mediastreamsignaling.h" | 34 #include "talk/app/webrtc/mediastreamsignaling.h" |
| 33 #include "talk/app/webrtc/streamcollection.h" | 35 #include "talk/app/webrtc/streamcollection.h" |
| 34 #include "talk/app/webrtc/test/fakeconstraints.h" | 36 #include "talk/app/webrtc/test/fakeconstraints.h" |
| 35 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" | 37 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" |
| 36 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" | 38 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" |
| 37 #include "talk/app/webrtc/videotrack.h" | 39 #include "talk/app/webrtc/videotrack.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 "a=rtpmap:96 rtx/90000\r\n" | 158 "a=rtpmap:96 rtx/90000\r\n" |
| 157 "a=fmtp:96 apt=0\r\n"; | 159 "a=fmtp:96 apt=0\r\n"; |
| 158 | 160 |
| 159 enum RTCCertificateGenerationMethod { ALREADY_GENERATED, DTLS_IDENTITY_STORE }; | 161 enum RTCCertificateGenerationMethod { ALREADY_GENERATED, DTLS_IDENTITY_STORE }; |
| 160 | 162 |
| 161 // Add some extra |newlines| to the |message| after |line|. | 163 // Add some extra |newlines| to the |message| after |line|. |
| 162 static void InjectAfter(const std::string& line, | 164 static void InjectAfter(const std::string& line, |
| 163 const std::string& newlines, | 165 const std::string& newlines, |
| 164 std::string* message) { | 166 std::string* message) { |
| 165 const std::string tmp = line + newlines; | 167 const std::string tmp = line + newlines; |
| 166 rtc::replace_substrs(line.c_str(), line.length(), | 168 rtc::replace_substrs(line.c_str(), line.length(), tmp.c_str(), tmp.length(), |
| 167 tmp.c_str(), tmp.length(), message); | 169 message); |
| 168 } | 170 } |
| 169 | 171 |
| 170 class MockIceObserver : public webrtc::IceObserver { | 172 class MockIceObserver : public webrtc::IceObserver { |
| 171 public: | 173 public: |
| 172 MockIceObserver() | 174 MockIceObserver() |
| 173 : oncandidatesready_(false), | 175 : oncandidatesready_(false), |
| 174 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), | 176 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), |
| 175 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { | 177 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { |
| 176 } | 178 } |
| 177 | 179 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 rtc::Thread* worker_thread, | 239 rtc::Thread* worker_thread, |
| 238 cricket::PortAllocator* port_allocator, | 240 cricket::PortAllocator* port_allocator, |
| 239 webrtc::IceObserver* ice_observer, | 241 webrtc::IceObserver* ice_observer, |
| 240 webrtc::MediaStreamSignaling* mediastream_signaling) | 242 webrtc::MediaStreamSignaling* mediastream_signaling) |
| 241 : WebRtcSession(cmgr, signaling_thread, worker_thread, port_allocator, | 243 : WebRtcSession(cmgr, signaling_thread, worker_thread, port_allocator, |
| 242 mediastream_signaling) { | 244 mediastream_signaling) { |
| 243 RegisterIceObserver(ice_observer); | 245 RegisterIceObserver(ice_observer); |
| 244 } | 246 } |
| 245 virtual ~WebRtcSessionForTest() {} | 247 virtual ~WebRtcSessionForTest() {} |
| 246 | 248 |
| 247 using cricket::BaseSession::GetTransportProxy; | 249 // Note that these methods are only safe to use if the signaling thread |
| 250 // is the same as the worker thread |
| 251 cricket::TransportChannel* voice_rtp_transport_channel() { |
| 252 return rtp_transport_channel(voice_channel()); |
| 253 } |
| 254 |
| 255 cricket::TransportChannel* voice_rtcp_transport_channel() { |
| 256 return rtcp_transport_channel(voice_channel()); |
| 257 } |
| 258 |
| 259 cricket::TransportChannel* video_rtp_transport_channel() { |
| 260 return rtp_transport_channel(video_channel()); |
| 261 } |
| 262 |
| 263 cricket::TransportChannel* video_rtcp_transport_channel() { |
| 264 return rtcp_transport_channel(video_channel()); |
| 265 } |
| 266 |
| 267 cricket::TransportChannel* data_rtp_transport_channel() { |
| 268 return rtp_transport_channel(data_channel()); |
| 269 } |
| 270 |
| 271 cricket::TransportChannel* data_rtcp_transport_channel() { |
| 272 return rtcp_transport_channel(data_channel()); |
| 273 } |
| 274 |
| 248 using webrtc::WebRtcSession::SetAudioPlayout; | 275 using webrtc::WebRtcSession::SetAudioPlayout; |
| 249 using webrtc::WebRtcSession::SetAudioSend; | 276 using webrtc::WebRtcSession::SetAudioSend; |
| 250 using webrtc::WebRtcSession::SetCaptureDevice; | 277 using webrtc::WebRtcSession::SetCaptureDevice; |
| 251 using webrtc::WebRtcSession::SetVideoPlayout; | 278 using webrtc::WebRtcSession::SetVideoPlayout; |
| 252 using webrtc::WebRtcSession::SetVideoSend; | 279 using webrtc::WebRtcSession::SetVideoSend; |
| 280 |
| 281 private: |
| 282 cricket::TransportChannel* rtp_transport_channel(cricket::BaseChannel* ch) { |
| 283 if (!ch) { |
| 284 return nullptr; |
| 285 } |
| 286 return ch->transport_channel(); |
| 287 } |
| 288 |
| 289 cricket::TransportChannel* rtcp_transport_channel(cricket::BaseChannel* ch) { |
| 290 if (!ch) { |
| 291 return nullptr; |
| 292 } |
| 293 return ch->rtcp_transport_channel(); |
| 294 } |
| 253 }; | 295 }; |
| 254 | 296 |
| 255 class WebRtcSessionCreateSDPObserverForTest | 297 class WebRtcSessionCreateSDPObserverForTest |
| 256 : public rtc::RefCountedObject<CreateSessionDescriptionObserver> { | 298 : public rtc::RefCountedObject<CreateSessionDescriptionObserver> { |
| 257 public: | 299 public: |
| 258 enum State { | 300 enum State { |
| 259 kInit, | 301 kInit, |
| 260 kFailed, | 302 kFailed, |
| 261 kSucceeded, | 303 kSucceeded, |
| 262 }; | 304 }; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 channel_manager_.get(), rtc::Thread::Current(), | 410 channel_manager_.get(), rtc::Thread::Current(), |
| 369 rtc::Thread::Current(), allocator_.get(), | 411 rtc::Thread::Current(), allocator_.get(), |
| 370 &observer_, | 412 &observer_, |
| 371 &mediastream_signaling_)); | 413 &mediastream_signaling_)); |
| 372 | 414 |
| 373 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, | 415 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
| 374 observer_.ice_connection_state_); | 416 observer_.ice_connection_state_); |
| 375 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, | 417 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
| 376 observer_.ice_gathering_state_); | 418 observer_.ice_gathering_state_); |
| 377 | 419 |
| 378 EXPECT_TRUE(session_->Initialize( | 420 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), |
| 379 options_, constraints_.get(), dtls_identity_store.Pass(), | 421 dtls_identity_store.Pass(), |
| 380 rtc_configuration)); | 422 rtc_configuration)); |
| 381 session_->set_metrics_observer(metrics_observer_); | 423 session_->set_metrics_observer(metrics_observer_); |
| 382 } | 424 } |
| 383 | 425 |
| 384 void Init() { | 426 void Init() { |
| 385 PeerConnectionInterface::RTCConfiguration configuration; | 427 PeerConnectionInterface::RTCConfiguration configuration; |
| 386 Init(nullptr, configuration); | 428 Init(nullptr, configuration); |
| 387 } | 429 } |
| 388 | 430 |
| 389 void InitWithIceTransport( | 431 void InitWithIceTransport( |
| 390 PeerConnectionInterface::IceTransportsType ice_transport_type) { | 432 PeerConnectionInterface::IceTransportsType ice_transport_type) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, | 525 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
| 484 2000); | 526 2000); |
| 485 return observer->ReleaseDescription(); | 527 return observer->ReleaseDescription(); |
| 486 } | 528 } |
| 487 | 529 |
| 488 bool ChannelsExist() const { | 530 bool ChannelsExist() const { |
| 489 return (session_->voice_channel() != NULL && | 531 return (session_->voice_channel() != NULL && |
| 490 session_->video_channel() != NULL); | 532 session_->video_channel() != NULL); |
| 491 } | 533 } |
| 492 | 534 |
| 493 void CheckTransportChannels() const { | |
| 494 EXPECT_TRUE(session_->GetChannel(cricket::CN_AUDIO, 1) != NULL); | |
| 495 EXPECT_TRUE(session_->GetChannel(cricket::CN_AUDIO, 2) != NULL); | |
| 496 EXPECT_TRUE(session_->GetChannel(cricket::CN_VIDEO, 1) != NULL); | |
| 497 EXPECT_TRUE(session_->GetChannel(cricket::CN_VIDEO, 2) != NULL); | |
| 498 } | |
| 499 | |
| 500 void VerifyCryptoParams(const cricket::SessionDescription* sdp) { | 535 void VerifyCryptoParams(const cricket::SessionDescription* sdp) { |
| 501 ASSERT_TRUE(session_.get() != NULL); | 536 ASSERT_TRUE(session_.get() != NULL); |
| 502 const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp); | 537 const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp); |
| 503 ASSERT_TRUE(content != NULL); | 538 ASSERT_TRUE(content != NULL); |
| 504 const cricket::AudioContentDescription* audio_content = | 539 const cricket::AudioContentDescription* audio_content = |
| 505 static_cast<const cricket::AudioContentDescription*>( | 540 static_cast<const cricket::AudioContentDescription*>( |
| 506 content->description); | 541 content->description); |
| 507 ASSERT_TRUE(audio_content != NULL); | 542 ASSERT_TRUE(audio_content != NULL); |
| 508 ASSERT_EQ(1U, audio_content->cryptos().size()); | 543 ASSERT_EQ(1U, audio_content->cryptos().size()); |
| 509 ASSERT_EQ(47U, audio_content->cryptos()[0].key_params.size()); | 544 ASSERT_EQ(47U, audio_content->cryptos()[0].key_params.size()); |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 &sdp); | 996 &sdp); |
| 962 } | 997 } |
| 963 | 998 |
| 964 SessionDescriptionInterface* new_answer = CreateSessionDescription( | 999 SessionDescriptionInterface* new_answer = CreateSessionDescription( |
| 965 JsepSessionDescription::kAnswer, sdp, NULL); | 1000 JsepSessionDescription::kAnswer, sdp, NULL); |
| 966 | 1001 |
| 967 // SetRemoteDescription to enable rtcp mux. | 1002 // SetRemoteDescription to enable rtcp mux. |
| 968 SetRemoteDescriptionWithoutError(new_answer); | 1003 SetRemoteDescriptionWithoutError(new_answer); |
| 969 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); | 1004 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 970 EXPECT_EQ(expected_candidate_num, observer_.mline_0_candidates_.size()); | 1005 EXPECT_EQ(expected_candidate_num, observer_.mline_0_candidates_.size()); |
| 971 EXPECT_EQ(expected_candidate_num, observer_.mline_1_candidates_.size()); | 1006 if (bundle) { |
| 972 for (size_t i = 0; i < observer_.mline_0_candidates_.size(); ++i) { | 1007 EXPECT_EQ(0, observer_.mline_1_candidates_.size()); |
| 973 cricket::Candidate c0 = observer_.mline_0_candidates_[i]; | 1008 } else { |
| 974 cricket::Candidate c1 = observer_.mline_1_candidates_[i]; | 1009 EXPECT_EQ(expected_candidate_num, observer_.mline_1_candidates_.size()); |
| 975 if (bundle) { | |
| 976 EXPECT_TRUE(c0.IsEquivalent(c1)); | |
| 977 } else { | |
| 978 EXPECT_FALSE(c0.IsEquivalent(c1)); | |
| 979 } | |
| 980 } | 1010 } |
| 981 } | 1011 } |
| 982 // Tests that we can only send DTMF when the dtmf codec is supported. | 1012 // Tests that we can only send DTMF when the dtmf codec is supported. |
| 983 void TestCanInsertDtmf(bool can) { | 1013 void TestCanInsertDtmf(bool can) { |
| 984 if (can) { | 1014 if (can) { |
| 985 InitWithDtmfCodec(); | 1015 InitWithDtmfCodec(); |
| 986 } else { | 1016 } else { |
| 987 Init(); | 1017 Init(); |
| 988 } | 1018 } |
| 989 mediastream_signaling_.SendAudioVideoStream1(); | 1019 mediastream_signaling_.SendAudioVideoStream1(); |
| 990 CreateAndSetRemoteOfferAndLocalAnswer(); | 1020 CreateAndSetRemoteOfferAndLocalAnswer(); |
| 991 EXPECT_FALSE(session_->CanInsertDtmf("")); | 1021 EXPECT_FALSE(session_->CanInsertDtmf("")); |
| 992 EXPECT_EQ(can, session_->CanInsertDtmf(kAudioTrack1)); | 1022 EXPECT_EQ(can, session_->CanInsertDtmf(kAudioTrack1)); |
| 993 } | 1023 } |
| 994 | 1024 |
| 995 // Helper class to configure loopback network and verify Best | 1025 // Helper class to configure loopback network and verify Best |
| 996 // Connection using right IP protocol for TestLoopbackCall | 1026 // Connection using right IP protocol for TestLoopbackCall |
| 997 // method. LoopbackNetworkManager applies firewall rules to block | 1027 // method. LoopbackNetworkManager applies firewall rules to block |
| 998 // all ping traffic once ICE completed, and remove them to observe | 1028 // all ping traffic once ICE completed, and remove them to observe |
| 999 // ICE reconnected again. This LoopbackNetworkConfiguration struct | 1029 // ICE reconnected again. This LoopbackNetworkConfiguration struct |
| 1000 // verifies the best connection is using the right IP protocol after | 1030 // verifies the best connection is using the right IP protocol after |
| 1001 // initial ICE convergences. | 1031 // initial ICE convergences. |
| 1002 | 1032 |
| 1003 class LoopbackNetworkConfiguration { | 1033 class LoopbackNetworkConfiguration { |
| 1004 public: | 1034 public: |
| 1005 LoopbackNetworkConfiguration() | 1035 LoopbackNetworkConfiguration() |
| 1006 : test_ipv6_network_(false), | 1036 : test_ipv6_network_(false), |
| 1007 test_extra_ipv4_network_(false), | 1037 test_extra_ipv4_network_(false), |
| 1008 best_connection_after_initial_ice_converged_(1, 0) {} | 1038 best_connection_after_initial_ice_converged_(1, 0) {} |
| 1009 | 1039 |
| 1010 // Used to track the expected best connection count in each IP protocol. | 1040 // Used to track the expected best connection count in each IP protocol. |
| 1011 struct ExpectedBestConnection { | 1041 struct ExpectedBestConnection { |
| 1012 ExpectedBestConnection(int ipv4_count, int ipv6_count) | 1042 ExpectedBestConnection(int ipv4_count, int ipv6_count) |
| 1013 : ipv4_count_(ipv4_count), | 1043 : ipv4_count_(ipv4_count), |
| 1014 ipv6_count_(ipv6_count) {} | 1044 ipv6_count_(ipv6_count) {} |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 | 1173 |
| 1144 LOG(LS_INFO) << "Firewall Rules applied"; | 1174 LOG(LS_INFO) << "Firewall Rules applied"; |
| 1145 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, | 1175 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, |
| 1146 observer_.ice_connection_state_, | 1176 observer_.ice_connection_state_, |
| 1147 kIceCandidatesTimeout); | 1177 kIceCandidatesTimeout); |
| 1148 | 1178 |
| 1149 metrics_observer_->Reset(); | 1179 metrics_observer_->Reset(); |
| 1150 | 1180 |
| 1151 // Clearing the rules, session should move back to completed state. | 1181 // Clearing the rules, session should move back to completed state. |
| 1152 loopback_network_manager.ClearRules(fss_.get()); | 1182 loopback_network_manager.ClearRules(fss_.get()); |
| 1153 // Session is automatically calling OnSignalingReady after creation of | |
| 1154 // new portallocator session which will allocate new set of candidates. | |
| 1155 | 1183 |
| 1156 LOG(LS_INFO) << "Firewall Rules cleared"; | 1184 LOG(LS_INFO) << "Firewall Rules cleared"; |
| 1157 | |
| 1158 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, | 1185 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, |
| 1159 observer_.ice_connection_state_, | 1186 observer_.ice_connection_state_, |
| 1160 kIceCandidatesTimeout); | 1187 kIceCandidatesTimeout); |
| 1161 | 1188 |
| 1162 // Now we block ping requests and wait until the ICE connection transitions | 1189 // Now we block ping requests and wait until the ICE connection transitions |
| 1163 // to the Failed state. This will take at least 30 seconds because it must | 1190 // to the Failed state. This will take at least 30 seconds because it must |
| 1164 // wait for the Port to timeout. | 1191 // wait for the Port to timeout. |
| 1165 int port_timeout = 30000; | 1192 int port_timeout = 30000; |
| 1166 | 1193 |
| 1167 loopback_network_manager.ApplyFirewallRules(fss_.get()); | 1194 loopback_network_manager.ApplyFirewallRules(fss_.get()); |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1700 // the offer and answer. | 1727 // the offer and answer. |
| 1701 SetRemoteDescriptionWithoutError(offer); | 1728 SetRemoteDescriptionWithoutError(offer); |
| 1702 SetLocalDescriptionAnswerExpectError( | 1729 SetLocalDescriptionAnswerExpectError( |
| 1703 kSdpWithoutDtlsFingerprint, answer); | 1730 kSdpWithoutDtlsFingerprint, answer); |
| 1704 } | 1731 } |
| 1705 | 1732 |
| 1706 // Test that we return a failure when applying a remote answer that doesn't have | 1733 // Test that we return a failure when applying a remote answer that doesn't have |
| 1707 // a DTLS fingerprint when DTLS is required. | 1734 // a DTLS fingerprint when DTLS is required. |
| 1708 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { | 1735 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { |
| 1709 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1736 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 1710 // Enable both SDES and DTLS, so that offer won't be outright rejected as a | |
| 1711 // result of using the "UDP/TLS/RTP/SAVPF" profile. | |
| 1712 InitWithDtls(GetParam()); | 1737 InitWithDtls(GetParam()); |
| 1713 session_->SetSdesPolicy(cricket::SEC_ENABLED); | |
| 1714 SessionDescriptionInterface* offer = CreateOffer(); | 1738 SessionDescriptionInterface* offer = CreateOffer(); |
| 1715 cricket::MediaSessionOptions options; | 1739 cricket::MediaSessionOptions options; |
| 1716 options.recv_video = true; | 1740 options.recv_video = true; |
| 1741 rtc::scoped_ptr<SessionDescriptionInterface> temp_offer( |
| 1742 CreateRemoteOffer(options, cricket::SEC_ENABLED)); |
| 1717 JsepSessionDescription* answer = | 1743 JsepSessionDescription* answer = |
| 1718 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED); | 1744 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); |
| 1719 | 1745 |
| 1720 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1746 // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1721 // the offer and answer. | 1747 // the offer and answer. |
| 1722 SetLocalDescriptionWithoutError(offer); | 1748 SetLocalDescriptionWithoutError(offer); |
| 1723 SetRemoteDescriptionAnswerExpectError( | 1749 SetRemoteDescriptionAnswerExpectError( |
| 1724 kSdpWithoutDtlsFingerprint, answer); | 1750 kSdpWithoutDtlsFingerprint, answer); |
| 1725 } | 1751 } |
| 1726 | 1752 |
| 1727 // Test that we create a local offer without SDES or DTLS and accept a remote | 1753 // Test that we create a local offer without SDES or DTLS and accept a remote |
| 1728 // answer without SDES or DTLS when encryption is disabled. | 1754 // answer without SDES or DTLS when encryption is disabled. |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 EXPECT_EQ(0u, candidates->count()); | 2036 EXPECT_EQ(0u, candidates->count()); |
| 2011 | 2037 |
| 2012 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); | 2038 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 2013 | 2039 |
| 2014 local_desc = session_->local_description(); | 2040 local_desc = session_->local_description(); |
| 2015 candidates = local_desc->candidates(kMediaContentIndex0); | 2041 candidates = local_desc->candidates(kMediaContentIndex0); |
| 2016 ASSERT_TRUE(candidates != NULL); | 2042 ASSERT_TRUE(candidates != NULL); |
| 2017 EXPECT_LT(0u, candidates->count()); | 2043 EXPECT_LT(0u, candidates->count()); |
| 2018 candidates = local_desc->candidates(1); | 2044 candidates = local_desc->candidates(1); |
| 2019 ASSERT_TRUE(candidates != NULL); | 2045 ASSERT_TRUE(candidates != NULL); |
| 2020 EXPECT_LT(0u, candidates->count()); | 2046 EXPECT_EQ(0u, candidates->count()); |
| 2021 | 2047 |
| 2022 // Update the session descriptions. | 2048 // Update the session descriptions. |
| 2023 mediastream_signaling_.SendAudioVideoStream1(); | 2049 mediastream_signaling_.SendAudioVideoStream1(); |
| 2024 CreateAndSetRemoteOfferAndLocalAnswer(); | 2050 CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2025 | 2051 |
| 2026 local_desc = session_->local_description(); | 2052 local_desc = session_->local_description(); |
| 2027 candidates = local_desc->candidates(kMediaContentIndex0); | 2053 candidates = local_desc->candidates(kMediaContentIndex0); |
| 2028 ASSERT_TRUE(candidates != NULL); | 2054 ASSERT_TRUE(candidates != NULL); |
| 2029 EXPECT_LT(0u, candidates->count()); | 2055 EXPECT_LT(0u, candidates->count()); |
| 2030 candidates = local_desc->candidates(1); | 2056 candidates = local_desc->candidates(1); |
| 2031 ASSERT_TRUE(candidates != NULL); | 2057 ASSERT_TRUE(candidates != NULL); |
| 2032 EXPECT_LT(0u, candidates->count()); | 2058 EXPECT_EQ(0u, candidates->count()); |
| 2033 } | 2059 } |
| 2034 | 2060 |
| 2035 // Test that we can set a remote session description with remote candidates. | 2061 // Test that we can set a remote session description with remote candidates. |
| 2036 TEST_F(WebRtcSessionTest, TestSetRemoteSessionDescriptionWithCandidates) { | 2062 TEST_F(WebRtcSessionTest, TestSetRemoteSessionDescriptionWithCandidates) { |
| 2037 Init(); | 2063 Init(); |
| 2038 | 2064 |
| 2039 cricket::Candidate candidate1; | 2065 cricket::Candidate candidate1; |
| 2040 candidate1.set_component(1); | 2066 candidate1.set_component(1); |
| 2041 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, | 2067 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, |
| 2042 candidate1); | 2068 candidate1); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2066 Init(); | 2092 Init(); |
| 2067 mediastream_signaling_.SendAudioVideoStream1(); | 2093 mediastream_signaling_.SendAudioVideoStream1(); |
| 2068 // Ice is started but candidates are not provided until SetLocalDescription | 2094 // Ice is started but candidates are not provided until SetLocalDescription |
| 2069 // is called. | 2095 // is called. |
| 2070 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); | 2096 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); |
| 2071 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); | 2097 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); |
| 2072 CreateAndSetRemoteOfferAndLocalAnswer(); | 2098 CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2073 // Wait until at least one local candidate has been collected. | 2099 // Wait until at least one local candidate has been collected. |
| 2074 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), | 2100 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), |
| 2075 kIceCandidatesTimeout); | 2101 kIceCandidatesTimeout); |
| 2076 EXPECT_TRUE_WAIT(0u < observer_.mline_1_candidates_.size(), | |
| 2077 kIceCandidatesTimeout); | |
| 2078 | 2102 |
| 2079 rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); | 2103 rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); |
| 2080 | 2104 |
| 2081 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); | 2105 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); |
| 2082 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); | 2106 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); |
| 2083 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex1) != NULL); | |
| 2084 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex1)->count()); | |
| 2085 | 2107 |
| 2086 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); | 2108 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); |
| 2087 SetRemoteDescriptionWithoutError(remote_offer); | 2109 SetRemoteDescriptionWithoutError(remote_offer); |
| 2088 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 2110 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 2089 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); | 2111 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); |
| 2090 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); | 2112 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); |
| 2091 ASSERT_TRUE(answer->candidates(kMediaContentIndex1) != NULL); | |
| 2092 EXPECT_LT(0u, answer->candidates(kMediaContentIndex1)->count()); | |
| 2093 SetLocalDescriptionWithoutError(answer); | 2113 SetLocalDescriptionWithoutError(answer); |
| 2094 } | 2114 } |
| 2095 | 2115 |
| 2096 // Verifies TransportProxy and media channels are created with content names | 2116 // Verifies TransportProxy and media channels are created with content names |
| 2097 // present in the SessionDescription. | 2117 // present in the SessionDescription. |
| 2098 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { | 2118 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { |
| 2099 Init(); | 2119 Init(); |
| 2100 mediastream_signaling_.SendAudioVideoStream1(); | 2120 mediastream_signaling_.SendAudioVideoStream1(); |
| 2101 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2121 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2102 | 2122 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2124 | 2144 |
| 2125 SessionDescriptionInterface* modified_offer = | 2145 SessionDescriptionInterface* modified_offer = |
| 2126 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2146 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2127 | 2147 |
| 2128 SetRemoteDescriptionWithoutError(modified_offer); | 2148 SetRemoteDescriptionWithoutError(modified_offer); |
| 2129 | 2149 |
| 2130 SessionDescriptionInterface* answer = | 2150 SessionDescriptionInterface* answer = |
| 2131 CreateAnswer(NULL); | 2151 CreateAnswer(NULL); |
| 2132 SetLocalDescriptionWithoutError(answer); | 2152 SetLocalDescriptionWithoutError(answer); |
| 2133 | 2153 |
| 2134 EXPECT_TRUE(session_->GetTransportProxy("audio_content_name") != NULL); | 2154 cricket::TransportChannel* voice_transport_channel = |
| 2135 EXPECT_TRUE(session_->GetTransportProxy("video_content_name") != NULL); | 2155 session_->voice_rtp_transport_channel(); |
| 2156 EXPECT_TRUE(voice_transport_channel != NULL); |
| 2157 EXPECT_EQ(voice_transport_channel->transport_name(), "audio_content_name"); |
| 2158 cricket::TransportChannel* video_transport_channel = |
| 2159 session_->video_rtp_transport_channel(); |
| 2160 EXPECT_TRUE(video_transport_channel != NULL); |
| 2161 EXPECT_EQ(video_transport_channel->transport_name(), "video_content_name"); |
| 2136 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); | 2162 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); |
| 2137 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); | 2163 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); |
| 2138 } | 2164 } |
| 2139 | 2165 |
| 2140 // Test that an offer contains the correct media content descriptions based on | 2166 // Test that an offer contains the correct media content descriptions based on |
| 2141 // the send streams when no constraints have been set. | 2167 // the send streams when no constraints have been set. |
| 2142 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { | 2168 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { |
| 2143 Init(); | 2169 Init(); |
| 2144 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2170 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2145 | 2171 |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2685 | 2711 |
| 2686 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2712 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2687 options.use_rtp_mux = true; | 2713 options.use_rtp_mux = true; |
| 2688 | 2714 |
| 2689 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 2715 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 2690 SetRemoteDescriptionWithoutError(offer); | 2716 SetRemoteDescriptionWithoutError(offer); |
| 2691 | 2717 |
| 2692 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 2718 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 2693 SetLocalDescriptionWithoutError(answer); | 2719 SetLocalDescriptionWithoutError(answer); |
| 2694 | 2720 |
| 2695 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2721 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2696 session_->GetTransportProxy("video")->impl()); | 2722 session_->video_rtp_transport_channel()); |
| 2697 | 2723 |
| 2698 cricket::Transport* t = session_->GetTransport("audio"); | 2724 cricket::BaseChannel* voice_channel = session_->voice_channel(); |
| 2725 ASSERT(voice_channel != NULL); |
| 2699 | 2726 |
| 2700 // Checks if one of the transport channels contains a connection using a given | 2727 // Checks if one of the transport channels contains a connection using a given |
| 2701 // port. | 2728 // port. |
| 2702 auto connection_with_remote_port = [t](int port) { | 2729 auto connection_with_remote_port = [this, voice_channel](int port) { |
| 2703 cricket::TransportStats stats; | 2730 cricket::SessionStats stats; |
| 2704 t->GetStats(&stats); | 2731 session_->GetChannelTransportStats(voice_channel, &stats); |
| 2705 for (auto& chan_stat : stats.channel_stats) { | 2732 for (auto& kv : stats.transport_stats) { |
| 2706 for (auto& conn_info : chan_stat.connection_infos) { | 2733 for (auto& chan_stat : kv.second.channel_stats) { |
| 2707 if (conn_info.remote_candidate.address().port() == port) { | 2734 for (auto& conn_info : chan_stat.connection_infos) { |
| 2708 return true; | 2735 if (conn_info.remote_candidate.address().port() == port) { |
| 2736 return true; |
| 2737 } |
| 2709 } | 2738 } |
| 2710 } | 2739 } |
| 2711 } | 2740 } |
| 2712 return false; | 2741 return false; |
| 2713 }; | 2742 }; |
| 2714 | 2743 |
| 2715 EXPECT_FALSE(connection_with_remote_port(5000)); | 2744 EXPECT_FALSE(connection_with_remote_port(5000)); |
| 2716 EXPECT_FALSE(connection_with_remote_port(5001)); | 2745 EXPECT_FALSE(connection_with_remote_port(5001)); |
| 2717 EXPECT_FALSE(connection_with_remote_port(6000)); | 2746 EXPECT_FALSE(connection_with_remote_port(6000)); |
| 2718 | 2747 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2751 | 2780 |
| 2752 EXPECT_TRUE_WAIT(connection_with_remote_port(5000), 1000); | 2781 EXPECT_TRUE_WAIT(connection_with_remote_port(5000), 1000); |
| 2753 EXPECT_TRUE_WAIT(connection_with_remote_port(5001), 1000); | 2782 EXPECT_TRUE_WAIT(connection_with_remote_port(5001), 1000); |
| 2754 | 2783 |
| 2755 // No need here for a _WAIT check since we are checking that state hasn't | 2784 // No need here for a _WAIT check since we are checking that state hasn't |
| 2756 // changed: if this is false we would be doing waits for nothing and if this | 2785 // changed: if this is false we would be doing waits for nothing and if this |
| 2757 // is true then there will be no messages processed anyways. | 2786 // is true then there will be no messages processed anyways. |
| 2758 EXPECT_FALSE(connection_with_remote_port(6000)); | 2787 EXPECT_FALSE(connection_with_remote_port(6000)); |
| 2759 } | 2788 } |
| 2760 | 2789 |
| 2761 // kBundlePolicyBalanced bundle policy and answer contains BUNDLE. | 2790 // kBundlePolicyBalanced BUNDLE policy and answer contains BUNDLE. |
| 2762 TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) { | 2791 TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) { |
| 2763 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 2792 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 2764 mediastream_signaling_.SendAudioVideoStream1(); | 2793 mediastream_signaling_.SendAudioVideoStream1(); |
| 2765 | 2794 |
| 2766 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2795 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2767 options.use_rtp_mux = true; | 2796 options.use_rtp_mux = true; |
| 2768 | 2797 |
| 2769 SessionDescriptionInterface* offer = CreateOffer(options); | 2798 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2770 SetLocalDescriptionWithoutError(offer); | 2799 SetLocalDescriptionWithoutError(offer); |
| 2771 | 2800 |
| 2772 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 2801 EXPECT_NE(session_->voice_rtp_transport_channel(), |
| 2773 session_->GetTransportProxy("video")->impl()); | 2802 session_->video_rtp_transport_channel()); |
| 2774 | 2803 |
| 2775 mediastream_signaling_.SendAudioVideoStream2(); | 2804 mediastream_signaling_.SendAudioVideoStream2(); |
| 2776 SessionDescriptionInterface* answer = | 2805 SessionDescriptionInterface* answer = |
| 2777 CreateRemoteAnswer(session_->local_description()); | 2806 CreateRemoteAnswer(session_->local_description()); |
| 2778 SetRemoteDescriptionWithoutError(answer); | 2807 SetRemoteDescriptionWithoutError(answer); |
| 2779 | 2808 |
| 2780 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2809 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2781 session_->GetTransportProxy("video")->impl()); | 2810 session_->video_rtp_transport_channel()); |
| 2782 } | 2811 } |
| 2783 | 2812 |
| 2784 // kBundlePolicyBalanced bundle policy but no BUNDLE in the answer. | 2813 // kBundlePolicyBalanced BUNDLE policy but no BUNDLE in the answer. |
| 2785 TEST_F(WebRtcSessionTest, TestBalancedNoBundleInAnswer) { | 2814 TEST_F(WebRtcSessionTest, TestBalancedNoBundleInAnswer) { |
| 2786 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 2815 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 2787 mediastream_signaling_.SendAudioVideoStream1(); | 2816 mediastream_signaling_.SendAudioVideoStream1(); |
| 2788 | 2817 |
| 2789 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2818 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2790 options.use_rtp_mux = true; | 2819 options.use_rtp_mux = true; |
| 2791 | 2820 |
| 2792 SessionDescriptionInterface* offer = CreateOffer(options); | 2821 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2793 SetLocalDescriptionWithoutError(offer); | 2822 SetLocalDescriptionWithoutError(offer); |
| 2794 | 2823 |
| 2795 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 2824 EXPECT_NE(session_->voice_rtp_transport_channel(), |
| 2796 session_->GetTransportProxy("video")->impl()); | 2825 session_->video_rtp_transport_channel()); |
| 2797 | 2826 |
| 2798 mediastream_signaling_.SendAudioVideoStream2(); | 2827 mediastream_signaling_.SendAudioVideoStream2(); |
| 2799 | 2828 |
| 2800 // Remove BUNDLE from the answer. | 2829 // Remove BUNDLE from the answer. |
| 2801 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 2830 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 2802 CreateRemoteAnswer(session_->local_description())); | 2831 CreateRemoteAnswer(session_->local_description())); |
| 2803 cricket::SessionDescription* answer_copy = answer->description()->Copy(); | 2832 cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
| 2804 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); | 2833 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); |
| 2805 JsepSessionDescription* modified_answer = | 2834 JsepSessionDescription* modified_answer = |
| 2806 new JsepSessionDescription(JsepSessionDescription::kAnswer); | 2835 new JsepSessionDescription(JsepSessionDescription::kAnswer); |
| 2807 modified_answer->Initialize(answer_copy, "1", "1"); | 2836 modified_answer->Initialize(answer_copy, "1", "1"); |
| 2808 SetRemoteDescriptionWithoutError(modified_answer); // | 2837 SetRemoteDescriptionWithoutError(modified_answer); // |
| 2809 | 2838 |
| 2810 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 2839 EXPECT_NE(session_->voice_rtp_transport_channel(), |
| 2811 session_->GetTransportProxy("video")->impl()); | 2840 session_->video_rtp_transport_channel()); |
| 2812 } | 2841 } |
| 2813 | 2842 |
| 2814 // kBundlePolicyMaxBundle policy with BUNDLE in the answer. | 2843 // kBundlePolicyMaxBundle policy with BUNDLE in the answer. |
| 2815 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInAnswer) { | 2844 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInAnswer) { |
| 2816 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); | 2845 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2817 mediastream_signaling_.SendAudioVideoStream1(); | 2846 mediastream_signaling_.SendAudioVideoStream1(); |
| 2818 | 2847 |
| 2819 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2848 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2820 options.use_rtp_mux = true; | 2849 options.use_rtp_mux = true; |
| 2821 | 2850 |
| 2822 SessionDescriptionInterface* offer = CreateOffer(options); | 2851 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2823 SetLocalDescriptionWithoutError(offer); | 2852 SetLocalDescriptionWithoutError(offer); |
| 2824 | 2853 |
| 2825 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2854 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2826 session_->GetTransportProxy("video")->impl()); | 2855 session_->video_rtp_transport_channel()); |
| 2827 | 2856 |
| 2828 mediastream_signaling_.SendAudioVideoStream2(); | 2857 mediastream_signaling_.SendAudioVideoStream2(); |
| 2829 SessionDescriptionInterface* answer = | 2858 SessionDescriptionInterface* answer = |
| 2830 CreateRemoteAnswer(session_->local_description()); | 2859 CreateRemoteAnswer(session_->local_description()); |
| 2831 SetRemoteDescriptionWithoutError(answer); | 2860 SetRemoteDescriptionWithoutError(answer); |
| 2832 | 2861 |
| 2833 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2862 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2834 session_->GetTransportProxy("video")->impl()); | 2863 session_->video_rtp_transport_channel()); |
| 2864 } |
| 2865 |
| 2866 // kBundlePolicyMaxBundle policy with BUNDLE in the answer, but no |
| 2867 // audio content in the answer. |
| 2868 TEST_F(WebRtcSessionTest, TestMaxBundleRejectAudio) { |
| 2869 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2870 mediastream_signaling_.SendAudioVideoStream1(); |
| 2871 |
| 2872 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2873 options.use_rtp_mux = true; |
| 2874 |
| 2875 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2876 SetLocalDescriptionWithoutError(offer); |
| 2877 |
| 2878 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2879 session_->video_rtp_transport_channel()); |
| 2880 |
| 2881 mediastream_signaling_.SendAudioVideoStream2(); |
| 2882 cricket::MediaSessionOptions recv_options; |
| 2883 recv_options.recv_audio = false; |
| 2884 recv_options.recv_video = true; |
| 2885 SessionDescriptionInterface* answer = |
| 2886 CreateRemoteAnswer(session_->local_description(), recv_options); |
| 2887 SetRemoteDescriptionWithoutError(answer); |
| 2888 |
| 2889 EXPECT_TRUE(NULL == session_->voice_channel()); |
| 2890 EXPECT_TRUE(NULL != session_->video_rtp_transport_channel()); |
| 2891 |
| 2892 session_->Terminate(); |
| 2893 EXPECT_TRUE(NULL == session_->voice_rtp_transport_channel()); |
| 2894 EXPECT_TRUE(NULL == session_->voice_rtcp_transport_channel()); |
| 2895 EXPECT_TRUE(NULL == session_->video_rtp_transport_channel()); |
| 2896 EXPECT_TRUE(NULL == session_->video_rtcp_transport_channel()); |
| 2835 } | 2897 } |
| 2836 | 2898 |
| 2837 // kBundlePolicyMaxBundle policy but no BUNDLE in the answer. | 2899 // kBundlePolicyMaxBundle policy but no BUNDLE in the answer. |
| 2838 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) { | 2900 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) { |
| 2839 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); | 2901 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2840 mediastream_signaling_.SendAudioVideoStream1(); | 2902 mediastream_signaling_.SendAudioVideoStream1(); |
| 2841 | 2903 |
| 2842 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2904 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2843 options.use_rtp_mux = true; | 2905 options.use_rtp_mux = true; |
| 2844 | 2906 |
| 2845 SessionDescriptionInterface* offer = CreateOffer(options); | 2907 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2846 SetLocalDescriptionWithoutError(offer); | 2908 SetLocalDescriptionWithoutError(offer); |
| 2847 | 2909 |
| 2848 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2910 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2849 session_->GetTransportProxy("video")->impl()); | 2911 session_->video_rtp_transport_channel()); |
| 2850 | 2912 |
| 2851 mediastream_signaling_.SendAudioVideoStream2(); | 2913 mediastream_signaling_.SendAudioVideoStream2(); |
| 2852 | 2914 |
| 2853 // Remove BUNDLE from the answer. | 2915 // Remove BUNDLE from the answer. |
| 2854 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 2916 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 2855 CreateRemoteAnswer(session_->local_description())); | 2917 CreateRemoteAnswer(session_->local_description())); |
| 2856 cricket::SessionDescription* answer_copy = answer->description()->Copy(); | 2918 cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
| 2857 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); | 2919 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); |
| 2858 JsepSessionDescription* modified_answer = | 2920 JsepSessionDescription* modified_answer = |
| 2859 new JsepSessionDescription(JsepSessionDescription::kAnswer); | 2921 new JsepSessionDescription(JsepSessionDescription::kAnswer); |
| 2860 modified_answer->Initialize(answer_copy, "1", "1"); | 2922 modified_answer->Initialize(answer_copy, "1", "1"); |
| 2861 SetRemoteDescriptionWithoutError(modified_answer); | 2923 SetRemoteDescriptionWithoutError(modified_answer); |
| 2862 | 2924 |
| 2863 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2925 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2864 session_->GetTransportProxy("video")->impl()); | 2926 session_->video_rtp_transport_channel()); |
| 2927 } |
| 2928 |
| 2929 // kBundlePolicyMaxBundle policy with BUNDLE in the remote offer. |
| 2930 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInRemoteOffer) { |
| 2931 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2932 mediastream_signaling_.SendAudioVideoStream1(); |
| 2933 |
| 2934 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 2935 SetRemoteDescriptionWithoutError(offer); |
| 2936 |
| 2937 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2938 session_->video_rtp_transport_channel()); |
| 2939 |
| 2940 mediastream_signaling_.SendAudioVideoStream2(); |
| 2941 SessionDescriptionInterface* answer = CreateAnswer(nullptr); |
| 2942 SetLocalDescriptionWithoutError(answer); |
| 2943 |
| 2944 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2945 session_->video_rtp_transport_channel()); |
| 2946 } |
| 2947 |
| 2948 // kBundlePolicyMaxBundle policy but no BUNDLE in the remote offer. |
| 2949 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInRemoteOffer) { |
| 2950 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2951 mediastream_signaling_.SendAudioVideoStream1(); |
| 2952 |
| 2953 // Remove BUNDLE from the offer. |
| 2954 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer()); |
| 2955 cricket::SessionDescription* offer_copy = offer->description()->Copy(); |
| 2956 offer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); |
| 2957 JsepSessionDescription* modified_offer = |
| 2958 new JsepSessionDescription(JsepSessionDescription::kOffer); |
| 2959 modified_offer->Initialize(offer_copy, "1", "1"); |
| 2960 |
| 2961 // Expect an error when applying the remote description |
| 2962 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer, |
| 2963 kCreateChannelFailed, modified_offer); |
| 2865 } | 2964 } |
| 2866 | 2965 |
| 2867 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. | 2966 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. |
| 2868 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { | 2967 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { |
| 2869 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); | 2968 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); |
| 2870 mediastream_signaling_.SendAudioVideoStream1(); | 2969 mediastream_signaling_.SendAudioVideoStream1(); |
| 2871 | 2970 |
| 2872 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2971 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2873 options.use_rtp_mux = true; | 2972 options.use_rtp_mux = true; |
| 2874 | 2973 |
| 2875 SessionDescriptionInterface* offer = CreateOffer(options); | 2974 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2876 SetLocalDescriptionWithoutError(offer); | 2975 SetLocalDescriptionWithoutError(offer); |
| 2877 | 2976 |
| 2878 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 2977 EXPECT_NE(session_->voice_rtp_transport_channel(), |
| 2879 session_->GetTransportProxy("video")->impl()); | 2978 session_->video_rtp_transport_channel()); |
| 2880 | 2979 |
| 2881 mediastream_signaling_.SendAudioVideoStream2(); | 2980 mediastream_signaling_.SendAudioVideoStream2(); |
| 2882 SessionDescriptionInterface* answer = | 2981 SessionDescriptionInterface* answer = |
| 2883 CreateRemoteAnswer(session_->local_description()); | 2982 CreateRemoteAnswer(session_->local_description()); |
| 2884 SetRemoteDescriptionWithoutError(answer); | 2983 SetRemoteDescriptionWithoutError(answer); |
| 2885 | 2984 |
| 2886 // This should lead to an audio-only call but isn't implemented | 2985 // This should lead to an audio-only call but isn't implemented |
| 2887 // correctly yet. | 2986 // correctly yet. |
| 2888 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2987 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2889 session_->GetTransportProxy("video")->impl()); | 2988 session_->video_rtp_transport_channel()); |
| 2890 } | 2989 } |
| 2891 | 2990 |
| 2892 // kBundlePolicyMaxCompat bundle policy but no BUNDLE in the answer. | 2991 // kBundlePolicyMaxCompat BUNDLE policy but no BUNDLE in the answer. |
| 2893 TEST_F(WebRtcSessionTest, TestMaxCompatNoBundleInAnswer) { | 2992 TEST_F(WebRtcSessionTest, TestMaxCompatNoBundleInAnswer) { |
| 2894 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); | 2993 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); |
| 2895 mediastream_signaling_.SendAudioVideoStream1(); | 2994 mediastream_signaling_.SendAudioVideoStream1(); |
| 2896 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2995 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2897 options.use_rtp_mux = true; | 2996 options.use_rtp_mux = true; |
| 2898 | 2997 |
| 2899 SessionDescriptionInterface* offer = CreateOffer(options); | 2998 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2900 SetLocalDescriptionWithoutError(offer); | 2999 SetLocalDescriptionWithoutError(offer); |
| 2901 | 3000 |
| 2902 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 3001 EXPECT_NE(session_->voice_rtp_transport_channel(), |
| 2903 session_->GetTransportProxy("video")->impl()); | 3002 session_->video_rtp_transport_channel()); |
| 2904 | 3003 |
| 2905 mediastream_signaling_.SendAudioVideoStream2(); | 3004 mediastream_signaling_.SendAudioVideoStream2(); |
| 2906 | 3005 |
| 2907 // Remove BUNDLE from the answer. | 3006 // Remove BUNDLE from the answer. |
| 2908 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 3007 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 2909 CreateRemoteAnswer(session_->local_description())); | 3008 CreateRemoteAnswer(session_->local_description())); |
| 2910 cricket::SessionDescription* answer_copy = answer->description()->Copy(); | 3009 cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
| 2911 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); | 3010 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); |
| 2912 JsepSessionDescription* modified_answer = | 3011 JsepSessionDescription* modified_answer = |
| 2913 new JsepSessionDescription(JsepSessionDescription::kAnswer); | 3012 new JsepSessionDescription(JsepSessionDescription::kAnswer); |
| 2914 modified_answer->Initialize(answer_copy, "1", "1"); | 3013 modified_answer->Initialize(answer_copy, "1", "1"); |
| 2915 SetRemoteDescriptionWithoutError(modified_answer); // | 3014 SetRemoteDescriptionWithoutError(modified_answer); // |
| 2916 | 3015 |
| 2917 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 3016 EXPECT_NE(session_->voice_rtp_transport_channel(), |
| 2918 session_->GetTransportProxy("video")->impl()); | 3017 session_->video_rtp_transport_channel()); |
| 2919 } | 3018 } |
| 2920 | 3019 |
| 2921 // kBundlePolicyMaxbundle and then we call SetRemoteDescription first. | 3020 // kBundlePolicyMaxbundle and then we call SetRemoteDescription first. |
| 2922 TEST_F(WebRtcSessionTest, TestMaxBundleWithSetRemoteDescriptionFirst) { | 3021 TEST_F(WebRtcSessionTest, TestMaxBundleWithSetRemoteDescriptionFirst) { |
| 2923 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); | 3022 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2924 mediastream_signaling_.SendAudioVideoStream1(); | 3023 mediastream_signaling_.SendAudioVideoStream1(); |
| 2925 | 3024 |
| 2926 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3025 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2927 options.use_rtp_mux = true; | 3026 options.use_rtp_mux = true; |
| 2928 | 3027 |
| 2929 SessionDescriptionInterface* offer = CreateOffer(options); | 3028 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2930 SetRemoteDescriptionWithoutError(offer); | 3029 SetRemoteDescriptionWithoutError(offer); |
| 2931 | 3030 |
| 2932 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 3031 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2933 session_->GetTransportProxy("video")->impl()); | 3032 session_->video_rtp_transport_channel()); |
| 2934 } | 3033 } |
| 2935 | 3034 |
| 2936 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { | 3035 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { |
| 2937 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); | 3036 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); |
| 2938 mediastream_signaling_.SendAudioVideoStream1(); | 3037 mediastream_signaling_.SendAudioVideoStream1(); |
| 2939 | 3038 |
| 2940 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3039 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2941 SessionDescriptionInterface* offer = CreateOffer(options); | 3040 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2942 SetLocalDescriptionWithoutError(offer); | 3041 SetLocalDescriptionWithoutError(offer); |
| 2943 | 3042 |
| 2944 EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); | 3043 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); |
| 2945 EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); | 3044 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); |
| 2946 | 3045 |
| 2947 mediastream_signaling_.SendAudioVideoStream2(); | 3046 mediastream_signaling_.SendAudioVideoStream2(); |
| 2948 SessionDescriptionInterface* answer = | 3047 SessionDescriptionInterface* answer = |
| 2949 CreateRemoteAnswer(session_->local_description()); | 3048 CreateRemoteAnswer(session_->local_description()); |
| 2950 SetRemoteDescriptionWithoutError(answer); | 3049 SetRemoteDescriptionWithoutError(answer); |
| 2951 | 3050 |
| 2952 EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); | 3051 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); |
| 2953 EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); | 3052 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); |
| 2954 } | 3053 } |
| 2955 | 3054 |
| 2956 TEST_F(WebRtcSessionTest, TestNegotiateRtcpMux) { | 3055 TEST_F(WebRtcSessionTest, TestNegotiateRtcpMux) { |
| 2957 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyNegotiate); | 3056 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyNegotiate); |
| 2958 mediastream_signaling_.SendAudioVideoStream1(); | 3057 mediastream_signaling_.SendAudioVideoStream1(); |
| 2959 | 3058 |
| 2960 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3059 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2961 SessionDescriptionInterface* offer = CreateOffer(options); | 3060 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2962 SetLocalDescriptionWithoutError(offer); | 3061 SetLocalDescriptionWithoutError(offer); |
| 2963 | 3062 |
| 2964 EXPECT_TRUE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); | 3063 EXPECT_TRUE(session_->voice_rtcp_transport_channel() != NULL); |
| 2965 EXPECT_TRUE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); | 3064 EXPECT_TRUE(session_->video_rtcp_transport_channel() != NULL); |
| 2966 | 3065 |
| 2967 mediastream_signaling_.SendAudioVideoStream2(); | 3066 mediastream_signaling_.SendAudioVideoStream2(); |
| 2968 SessionDescriptionInterface* answer = | 3067 SessionDescriptionInterface* answer = |
| 2969 CreateRemoteAnswer(session_->local_description()); | 3068 CreateRemoteAnswer(session_->local_description()); |
| 2970 SetRemoteDescriptionWithoutError(answer); | 3069 SetRemoteDescriptionWithoutError(answer); |
| 2971 | 3070 |
| 2972 EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); | 3071 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); |
| 2973 EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); | 3072 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); |
| 2974 } | 3073 } |
| 2975 | 3074 |
| 2976 // This test verifies that SetLocalDescription and SetRemoteDescription fails | 3075 // This test verifies that SetLocalDescription and SetRemoteDescription fails |
| 2977 // if BUNDLE is enabled but rtcp-mux is disabled in m-lines. | 3076 // if BUNDLE is enabled but rtcp-mux is disabled in m-lines. |
| 2978 TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) { | 3077 TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) { |
| 2979 Init(); | 3078 Init(); |
| 2980 mediastream_signaling_.SendAudioVideoStream1(); | 3079 mediastream_signaling_.SendAudioVideoStream1(); |
| 2981 | 3080 |
| 2982 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3081 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2983 options.use_rtp_mux = true; | 3082 options.use_rtp_mux = true; |
| 2984 | 3083 |
| 2985 SessionDescriptionInterface* offer = CreateOffer(options); | 3084 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2986 std::string offer_str; | 3085 std::string offer_str; |
| 2987 offer->ToString(&offer_str); | 3086 offer->ToString(&offer_str); |
| 2988 // Disable rtcp-mux | 3087 // Disable rtcp-mux |
| 2989 const std::string rtcp_mux = "rtcp-mux"; | 3088 const std::string rtcp_mux = "rtcp-mux"; |
| 2990 const std::string xrtcp_mux = "xrtcp-mux"; | 3089 const std::string xrtcp_mux = "xrtcp-mux"; |
| 2991 rtc::replace_substrs(rtcp_mux.c_str(), rtcp_mux.length(), | 3090 rtc::replace_substrs(rtcp_mux.c_str(), rtcp_mux.length(), |
| 2992 xrtcp_mux.c_str(), xrtcp_mux.length(), | 3091 xrtcp_mux.c_str(), xrtcp_mux.length(), |
| 2993 &offer_str); | 3092 &offer_str); |
| 2994 JsepSessionDescription *local_offer = | 3093 JsepSessionDescription* local_offer = |
| 2995 new JsepSessionDescription(JsepSessionDescription::kOffer); | 3094 new JsepSessionDescription(JsepSessionDescription::kOffer); |
| 2996 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL)); | 3095 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL)); |
| 2997 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer); | 3096 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer); |
| 2998 JsepSessionDescription *remote_offer = | 3097 JsepSessionDescription* remote_offer = |
| 2999 new JsepSessionDescription(JsepSessionDescription::kOffer); | 3098 new JsepSessionDescription(JsepSessionDescription::kOffer); |
| 3000 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL)); | 3099 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL)); |
| 3001 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer); | 3100 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer); |
| 3002 // Trying unmodified SDP. | 3101 // Trying unmodified SDP. |
| 3003 SetLocalDescriptionWithoutError(offer); | 3102 SetLocalDescriptionWithoutError(offer); |
| 3004 } | 3103 } |
| 3005 | 3104 |
| 3006 TEST_F(WebRtcSessionTest, SetAudioPlayout) { | 3105 TEST_F(WebRtcSessionTest, SetAudioPlayout) { |
| 3007 Init(); | 3106 Init(); |
| 3008 mediastream_signaling_.SendAudioVideoStream1(); | 3107 mediastream_signaling_.SendAudioVideoStream1(); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3251 candidate.set_component(1); | 3350 candidate.set_component(1); |
| 3252 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, | 3351 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, |
| 3253 candidate); | 3352 candidate); |
| 3254 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); | 3353 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); |
| 3255 cricket::Candidate candidate1; | 3354 cricket::Candidate candidate1; |
| 3256 candidate1.set_component(1); | 3355 candidate1.set_component(1); |
| 3257 JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1, | 3356 JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1, |
| 3258 candidate1); | 3357 candidate1); |
| 3259 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1)); | 3358 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1)); |
| 3260 SetRemoteDescriptionWithoutError(offer); | 3359 SetRemoteDescriptionWithoutError(offer); |
| 3261 ASSERT_TRUE(session_->GetTransportProxy("audio") != NULL); | 3360 ASSERT_TRUE(session_->voice_rtp_transport_channel() != NULL); |
| 3262 ASSERT_TRUE(session_->GetTransportProxy("video") != NULL); | 3361 ASSERT_TRUE(session_->video_rtp_transport_channel() != NULL); |
| 3263 | 3362 |
| 3264 // Pump for 1 second and verify that no candidates are generated. | 3363 // Pump for 1 second and verify that no candidates are generated. |
| 3265 rtc::Thread::Current()->ProcessMessages(1000); | 3364 rtc::Thread::Current()->ProcessMessages(1000); |
| 3266 EXPECT_TRUE(observer_.mline_0_candidates_.empty()); | 3365 EXPECT_TRUE(observer_.mline_0_candidates_.empty()); |
| 3267 EXPECT_TRUE(observer_.mline_1_candidates_.empty()); | 3366 EXPECT_TRUE(observer_.mline_1_candidates_.empty()); |
| 3268 | 3367 |
| 3269 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 3368 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 3270 SetLocalDescriptionWithoutError(answer); | 3369 SetLocalDescriptionWithoutError(answer); |
| 3271 EXPECT_TRUE(session_->GetTransportProxy("audio")->negotiated()); | |
| 3272 EXPECT_TRUE(session_->GetTransportProxy("video")->negotiated()); | |
| 3273 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); | 3370 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 3274 } | 3371 } |
| 3275 | 3372 |
| 3276 // This test verifies that crypto parameter is updated in local session | 3373 // This test verifies that crypto parameter is updated in local session |
| 3277 // description as per security policy set in MediaSessionDescriptionFactory. | 3374 // description as per security policy set in MediaSessionDescriptionFactory. |
| 3278 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) { | 3375 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) { |
| 3279 Init(); | 3376 Init(); |
| 3280 mediastream_signaling_.SendAudioVideoStream1(); | 3377 mediastream_signaling_.SendAudioVideoStream1(); |
| 3281 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3378 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 3282 | 3379 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3297 options_.disable_encryption = true; | 3394 options_.disable_encryption = true; |
| 3298 Init(); | 3395 Init(); |
| 3299 mediastream_signaling_.SendAudioVideoStream1(); | 3396 mediastream_signaling_.SendAudioVideoStream1(); |
| 3300 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3397 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 3301 | 3398 |
| 3302 // Making sure SetLocalDescription correctly sets crypto value in | 3399 // Making sure SetLocalDescription correctly sets crypto value in |
| 3303 // SessionDescription object after de-serialization of sdp string. The value | 3400 // SessionDescription object after de-serialization of sdp string. The value |
| 3304 // will be set as per MediaSessionDescriptionFactory. | 3401 // will be set as per MediaSessionDescriptionFactory. |
| 3305 std::string offer_str; | 3402 std::string offer_str; |
| 3306 offer->ToString(&offer_str); | 3403 offer->ToString(&offer_str); |
| 3307 SessionDescriptionInterface *jsep_offer_str = | 3404 SessionDescriptionInterface* jsep_offer_str = |
| 3308 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); | 3405 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); |
| 3309 SetLocalDescriptionWithoutError(jsep_offer_str); | 3406 SetLocalDescriptionWithoutError(jsep_offer_str); |
| 3310 EXPECT_FALSE(session_->voice_channel()->secure_required()); | 3407 EXPECT_FALSE(session_->voice_channel()->secure_required()); |
| 3311 EXPECT_FALSE(session_->video_channel()->secure_required()); | 3408 EXPECT_FALSE(session_->video_channel()->secure_required()); |
| 3312 } | 3409 } |
| 3313 | 3410 |
| 3314 // This test verifies that an answer contains new ufrag and password if an offer | 3411 // This test verifies that an answer contains new ufrag and password if an offer |
| 3315 // with new ufrag and password is received. | 3412 // with new ufrag and password is received. |
| 3316 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { | 3413 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { |
| 3317 Init(); | 3414 Init(); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3650 | 3747 |
| 3651 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3748 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 3652 EXPECT_TRUE(offer == NULL); | 3749 EXPECT_TRUE(offer == NULL); |
| 3653 } | 3750 } |
| 3654 | 3751 |
| 3655 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made | 3752 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made |
| 3656 // before async identity generation is finished. | 3753 // before async identity generation is finished. |
| 3657 TEST_P(WebRtcSessionTest, | 3754 TEST_P(WebRtcSessionTest, |
| 3658 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { | 3755 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { |
| 3659 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3756 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3660 VerifyMultipleAsyncCreateDescription( | 3757 VerifyMultipleAsyncCreateDescription(GetParam(), |
| 3661 GetParam(), CreateSessionDescriptionRequest::kOffer); | 3758 CreateSessionDescriptionRequest::kOffer); |
| 3662 } | 3759 } |
| 3663 | 3760 |
| 3664 // Verifies that CreateOffer fails when Multiple CreateOffer calls are made | 3761 // Verifies that CreateOffer fails when Multiple CreateOffer calls are made |
| 3665 // before async identity generation fails. | 3762 // before async identity generation fails. |
| 3666 TEST_F(WebRtcSessionTest, | 3763 TEST_F(WebRtcSessionTest, |
| 3667 TestMultipleCreateOfferBeforeIdentityRequestReturnFailure) { | 3764 TestMultipleCreateOfferBeforeIdentityRequestReturnFailure) { |
| 3668 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3765 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3669 VerifyMultipleAsyncCreateDescriptionIdentityGenFailure( | 3766 VerifyMultipleAsyncCreateDescriptionIdentityGenFailure( |
| 3670 CreateSessionDescriptionRequest::kOffer); | 3767 CreateSessionDescriptionRequest::kOffer); |
| 3671 } | 3768 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3874 SessionDescriptionInterface* offer = CreateOffer(options); | 3971 SessionDescriptionInterface* offer = CreateOffer(options); |
| 3875 SetLocalDescriptionWithoutError(offer); | 3972 SetLocalDescriptionWithoutError(offer); |
| 3876 | 3973 |
| 3877 session_->video_channel()->SetOption(cricket::BaseChannel::ST_RTP, | 3974 session_->video_channel()->SetOption(cricket::BaseChannel::ST_RTP, |
| 3878 rtc::Socket::Option::OPT_SNDBUF, 4000); | 3975 rtc::Socket::Option::OPT_SNDBUF, 4000); |
| 3879 | 3976 |
| 3880 session_->voice_channel()->SetOption(cricket::BaseChannel::ST_RTP, | 3977 session_->voice_channel()->SetOption(cricket::BaseChannel::ST_RTP, |
| 3881 rtc::Socket::Option::OPT_RCVBUF, 8000); | 3978 rtc::Socket::Option::OPT_RCVBUF, 8000); |
| 3882 | 3979 |
| 3883 int option_val; | 3980 int option_val; |
| 3884 EXPECT_TRUE(session_->video_channel()->transport_channel()->GetOption( | 3981 EXPECT_TRUE(session_->video_rtp_transport_channel()->GetOption( |
| 3885 rtc::Socket::Option::OPT_SNDBUF, &option_val)); | 3982 rtc::Socket::Option::OPT_SNDBUF, &option_val)); |
| 3886 EXPECT_EQ(4000, option_val); | 3983 EXPECT_EQ(4000, option_val); |
| 3887 EXPECT_FALSE(session_->voice_channel()->transport_channel()->GetOption( | 3984 EXPECT_FALSE(session_->voice_rtp_transport_channel()->GetOption( |
| 3888 rtc::Socket::Option::OPT_SNDBUF, &option_val)); | 3985 rtc::Socket::Option::OPT_SNDBUF, &option_val)); |
| 3889 | 3986 |
| 3890 EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( | 3987 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption( |
| 3891 rtc::Socket::Option::OPT_RCVBUF, &option_val)); | 3988 rtc::Socket::Option::OPT_RCVBUF, &option_val)); |
| 3892 EXPECT_EQ(8000, option_val); | 3989 EXPECT_EQ(8000, option_val); |
| 3893 EXPECT_FALSE(session_->video_channel()->transport_channel()->GetOption( | 3990 EXPECT_FALSE(session_->video_rtp_transport_channel()->GetOption( |
| 3894 rtc::Socket::Option::OPT_RCVBUF, &option_val)); | 3991 rtc::Socket::Option::OPT_RCVBUF, &option_val)); |
| 3895 | 3992 |
| 3896 EXPECT_NE(session_->voice_channel()->transport_channel(), | 3993 EXPECT_NE(session_->voice_rtp_transport_channel(), |
| 3897 session_->video_channel()->transport_channel()); | 3994 session_->video_rtp_transport_channel()); |
| 3898 | 3995 |
| 3899 mediastream_signaling_.SendAudioVideoStream2(); | 3996 mediastream_signaling_.SendAudioVideoStream2(); |
| 3900 SessionDescriptionInterface* answer = | 3997 SessionDescriptionInterface* answer = |
| 3901 CreateRemoteAnswer(session_->local_description()); | 3998 CreateRemoteAnswer(session_->local_description()); |
| 3902 SetRemoteDescriptionWithoutError(answer); | 3999 SetRemoteDescriptionWithoutError(answer); |
| 3903 | 4000 |
| 3904 EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( | 4001 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption( |
| 3905 rtc::Socket::Option::OPT_SNDBUF, &option_val)); | 4002 rtc::Socket::Option::OPT_SNDBUF, &option_val)); |
| 3906 EXPECT_EQ(4000, option_val); | 4003 EXPECT_EQ(4000, option_val); |
| 3907 | 4004 |
| 3908 EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( | 4005 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption( |
| 3909 rtc::Socket::Option::OPT_RCVBUF, &option_val)); | 4006 rtc::Socket::Option::OPT_RCVBUF, &option_val)); |
| 3910 EXPECT_EQ(8000, option_val); | 4007 EXPECT_EQ(8000, option_val); |
| 3911 } | 4008 } |
| 3912 | 4009 |
| 3913 // Test creating a session, request multiple offers, destroy the session | 4010 // Test creating a session, request multiple offers, destroy the session |
| 3914 // and make sure we got success/failure callbacks for all of the requests. | 4011 // and make sure we got success/failure callbacks for all of the requests. |
| 3915 // Background: crbug.com/507307 | 4012 // Background: crbug.com/507307 |
| 3916 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { | 4013 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { |
| 3917 Init(); | 4014 Init(); |
| 3918 | 4015 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3934 // must have received a notification which, so the only invalid state | 4031 // must have received a notification which, so the only invalid state |
| 3935 // is kInit. | 4032 // is kInit. |
| 3936 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); | 4033 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
| 3937 } | 4034 } |
| 3938 } | 4035 } |
| 3939 | 4036 |
| 3940 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4037 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 3941 // currently fails because upon disconnection and reconnection OnIceComplete is | 4038 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 3942 // called more than once without returning to IceGatheringGathering. | 4039 // called more than once without returning to IceGatheringGathering. |
| 3943 | 4040 |
| 3944 INSTANTIATE_TEST_CASE_P( | 4041 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
| 3945 WebRtcSessionTests, WebRtcSessionTest, | 4042 WebRtcSessionTest, |
| 3946 testing::Values(ALREADY_GENERATED, DTLS_IDENTITY_STORE)); | 4043 testing::Values(ALREADY_GENERATED, |
| 4044 DTLS_IDENTITY_STORE)); |
| OLD | NEW |