Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: talk/app/webrtc/webrtcsession_unittest.cc

Issue 1350523003: TransportController refactoring. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing Mac test. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/app/webrtc/webrtcsession.cc ('k') | talk/app/webrtc/webrtcsessiondescriptionfactory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 // Call mediastream_signaling_.UseOptionsWithStreamX() before this function 750 // Call mediastream_signaling_.UseOptionsWithStreamX() before this function
716 // to decide which local and remote streams to create. 751 // to decide which local and remote streams to create.
717 void CreateAndSetRemoteOfferAndLocalAnswer() { 752 void CreateAndSetRemoteOfferAndLocalAnswer() {
718 SessionDescriptionInterface* offer = CreateRemoteOffer(); 753 SessionDescriptionInterface* offer = CreateRemoteOffer();
719 SetRemoteDescriptionWithoutError(offer); 754 SetRemoteDescriptionWithoutError(offer);
720 SessionDescriptionInterface* answer = CreateAnswer(NULL); 755 SessionDescriptionInterface* answer = CreateAnswer(NULL);
721 SetLocalDescriptionWithoutError(answer); 756 SetLocalDescriptionWithoutError(answer);
722 } 757 }
723 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) { 758 void SetLocalDescriptionWithoutError(SessionDescriptionInterface* desc) {
724 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL)); 759 EXPECT_TRUE(session_->SetLocalDescription(desc, NULL));
760 session_->MaybeStartGathering();
725 } 761 }
726 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc, 762 void SetLocalDescriptionExpectState(SessionDescriptionInterface* desc,
727 BaseSession::State expected_state) { 763 BaseSession::State expected_state) {
728 SetLocalDescriptionWithoutError(desc); 764 SetLocalDescriptionWithoutError(desc);
729 EXPECT_EQ(expected_state, session_->state()); 765 EXPECT_EQ(expected_state, session_->state());
730 } 766 }
731 void SetLocalDescriptionExpectError(const std::string& action, 767 void SetLocalDescriptionExpectError(const std::string& action,
732 const std::string& expected_error, 768 const std::string& expected_error,
733 SessionDescriptionInterface* desc) { 769 SessionDescriptionInterface* desc) {
734 std::string error; 770 std::string error;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 &sdp); 997 &sdp);
962 } 998 }
963 999
964 SessionDescriptionInterface* new_answer = CreateSessionDescription( 1000 SessionDescriptionInterface* new_answer = CreateSessionDescription(
965 JsepSessionDescription::kAnswer, sdp, NULL); 1001 JsepSessionDescription::kAnswer, sdp, NULL);
966 1002
967 // SetRemoteDescription to enable rtcp mux. 1003 // SetRemoteDescription to enable rtcp mux.
968 SetRemoteDescriptionWithoutError(new_answer); 1004 SetRemoteDescriptionWithoutError(new_answer);
969 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 1005 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
970 EXPECT_EQ(expected_candidate_num, observer_.mline_0_candidates_.size()); 1006 EXPECT_EQ(expected_candidate_num, observer_.mline_0_candidates_.size());
971 EXPECT_EQ(expected_candidate_num, observer_.mline_1_candidates_.size()); 1007 if (bundle) {
972 for (size_t i = 0; i < observer_.mline_0_candidates_.size(); ++i) { 1008 EXPECT_EQ(0, observer_.mline_1_candidates_.size());
973 cricket::Candidate c0 = observer_.mline_0_candidates_[i]; 1009 } else {
974 cricket::Candidate c1 = observer_.mline_1_candidates_[i]; 1010 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 } 1011 }
981 } 1012 }
982 // Tests that we can only send DTMF when the dtmf codec is supported. 1013 // Tests that we can only send DTMF when the dtmf codec is supported.
983 void TestCanInsertDtmf(bool can) { 1014 void TestCanInsertDtmf(bool can) {
984 if (can) { 1015 if (can) {
985 InitWithDtmfCodec(); 1016 InitWithDtmfCodec();
986 } else { 1017 } else {
987 Init(); 1018 Init();
988 } 1019 }
989 mediastream_signaling_.SendAudioVideoStream1(); 1020 mediastream_signaling_.SendAudioVideoStream1();
990 CreateAndSetRemoteOfferAndLocalAnswer(); 1021 CreateAndSetRemoteOfferAndLocalAnswer();
991 EXPECT_FALSE(session_->CanInsertDtmf("")); 1022 EXPECT_FALSE(session_->CanInsertDtmf(""));
992 EXPECT_EQ(can, session_->CanInsertDtmf(kAudioTrack1)); 1023 EXPECT_EQ(can, session_->CanInsertDtmf(kAudioTrack1));
993 } 1024 }
994 1025
995 // Helper class to configure loopback network and verify Best 1026 // Helper class to configure loopback network and verify Best
996 // Connection using right IP protocol for TestLoopbackCall 1027 // Connection using right IP protocol for TestLoopbackCall
997 // method. LoopbackNetworkManager applies firewall rules to block 1028 // method. LoopbackNetworkManager applies firewall rules to block
998 // all ping traffic once ICE completed, and remove them to observe 1029 // all ping traffic once ICE completed, and remove them to observe
999 // ICE reconnected again. This LoopbackNetworkConfiguration struct 1030 // ICE reconnected again. This LoopbackNetworkConfiguration struct
1000 // verifies the best connection is using the right IP protocol after 1031 // verifies the best connection is using the right IP protocol after
1001 // initial ICE convergences. 1032 // initial ICE convergences.
1002 1033
1003 class LoopbackNetworkConfiguration { 1034 class LoopbackNetworkConfiguration {
1004 public: 1035 public:
1005 LoopbackNetworkConfiguration() 1036 LoopbackNetworkConfiguration()
1006 : test_ipv6_network_(false), 1037 : test_ipv6_network_(false),
1007 test_extra_ipv4_network_(false), 1038 test_extra_ipv4_network_(false),
1008 best_connection_after_initial_ice_converged_(1, 0) {} 1039 best_connection_after_initial_ice_converged_(1, 0) {}
1009 1040
1010 // Used to track the expected best connection count in each IP protocol. 1041 // Used to track the expected best connection count in each IP protocol.
1011 struct ExpectedBestConnection { 1042 struct ExpectedBestConnection {
1012 ExpectedBestConnection(int ipv4_count, int ipv6_count) 1043 ExpectedBestConnection(int ipv4_count, int ipv6_count)
1013 : ipv4_count_(ipv4_count), 1044 : ipv4_count_(ipv4_count),
1014 ipv6_count_(ipv6_count) {} 1045 ipv6_count_(ipv6_count) {}
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 1174
1144 LOG(LS_INFO) << "Firewall Rules applied"; 1175 LOG(LS_INFO) << "Firewall Rules applied";
1145 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, 1176 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected,
1146 observer_.ice_connection_state_, 1177 observer_.ice_connection_state_,
1147 kIceCandidatesTimeout); 1178 kIceCandidatesTimeout);
1148 1179
1149 metrics_observer_->Reset(); 1180 metrics_observer_->Reset();
1150 1181
1151 // Clearing the rules, session should move back to completed state. 1182 // Clearing the rules, session should move back to completed state.
1152 loopback_network_manager.ClearRules(fss_.get()); 1183 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 1184
1156 LOG(LS_INFO) << "Firewall Rules cleared"; 1185 LOG(LS_INFO) << "Firewall Rules cleared";
1157
1158 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, 1186 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
1159 observer_.ice_connection_state_, 1187 observer_.ice_connection_state_,
1160 kIceCandidatesTimeout); 1188 kIceCandidatesTimeout);
1161 1189
1162 // Now we block ping requests and wait until the ICE connection transitions 1190 // 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 1191 // to the Failed state. This will take at least 30 seconds because it must
1164 // wait for the Port to timeout. 1192 // wait for the Port to timeout.
1165 int port_timeout = 30000; 1193 int port_timeout = 30000;
1166 1194
1167 loopback_network_manager.ApplyFirewallRules(fss_.get()); 1195 loopback_network_manager.ApplyFirewallRules(fss_.get());
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 // the offer and answer. 1728 // the offer and answer.
1701 SetRemoteDescriptionWithoutError(offer); 1729 SetRemoteDescriptionWithoutError(offer);
1702 SetLocalDescriptionAnswerExpectError( 1730 SetLocalDescriptionAnswerExpectError(
1703 kSdpWithoutDtlsFingerprint, answer); 1731 kSdpWithoutDtlsFingerprint, answer);
1704 } 1732 }
1705 1733
1706 // Test that we return a failure when applying a remote answer that doesn't have 1734 // Test that we return a failure when applying a remote answer that doesn't have
1707 // a DTLS fingerprint when DTLS is required. 1735 // a DTLS fingerprint when DTLS is required.
1708 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { 1736 TEST_P(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) {
1709 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 1737 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()); 1738 InitWithDtls(GetParam());
1713 session_->SetSdesPolicy(cricket::SEC_ENABLED);
1714 SessionDescriptionInterface* offer = CreateOffer(); 1739 SessionDescriptionInterface* offer = CreateOffer();
1715 cricket::MediaSessionOptions options; 1740 cricket::MediaSessionOptions options;
1716 options.recv_video = true; 1741 options.recv_video = true;
1742 rtc::scoped_ptr<SessionDescriptionInterface> temp_offer(
1743 CreateRemoteOffer(options, cricket::SEC_ENABLED));
1717 JsepSessionDescription* answer = 1744 JsepSessionDescription* answer =
1718 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED); 1745 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED);
1719 1746
1720 // SetRemoteDescription and SetLocalDescription will take the ownership of 1747 // SetRemoteDescription and SetLocalDescription will take the ownership of
1721 // the offer and answer. 1748 // the offer and answer.
1722 SetLocalDescriptionWithoutError(offer); 1749 SetLocalDescriptionWithoutError(offer);
1723 SetRemoteDescriptionAnswerExpectError( 1750 SetRemoteDescriptionAnswerExpectError(
1724 kSdpWithoutDtlsFingerprint, answer); 1751 kSdpWithoutDtlsFingerprint, answer);
1725 } 1752 }
1726 1753
1727 // Test that we create a local offer without SDES or DTLS and accept a remote 1754 // 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. 1755 // answer without SDES or DTLS when encryption is disabled.
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 EXPECT_EQ(0u, candidates->count()); 2037 EXPECT_EQ(0u, candidates->count());
2011 2038
2012 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 2039 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
2013 2040
2014 local_desc = session_->local_description(); 2041 local_desc = session_->local_description();
2015 candidates = local_desc->candidates(kMediaContentIndex0); 2042 candidates = local_desc->candidates(kMediaContentIndex0);
2016 ASSERT_TRUE(candidates != NULL); 2043 ASSERT_TRUE(candidates != NULL);
2017 EXPECT_LT(0u, candidates->count()); 2044 EXPECT_LT(0u, candidates->count());
2018 candidates = local_desc->candidates(1); 2045 candidates = local_desc->candidates(1);
2019 ASSERT_TRUE(candidates != NULL); 2046 ASSERT_TRUE(candidates != NULL);
2020 EXPECT_LT(0u, candidates->count()); 2047 EXPECT_EQ(0u, candidates->count());
2021 2048
2022 // Update the session descriptions. 2049 // Update the session descriptions.
2023 mediastream_signaling_.SendAudioVideoStream1(); 2050 mediastream_signaling_.SendAudioVideoStream1();
2024 CreateAndSetRemoteOfferAndLocalAnswer(); 2051 CreateAndSetRemoteOfferAndLocalAnswer();
2025 2052
2026 local_desc = session_->local_description(); 2053 local_desc = session_->local_description();
2027 candidates = local_desc->candidates(kMediaContentIndex0); 2054 candidates = local_desc->candidates(kMediaContentIndex0);
2028 ASSERT_TRUE(candidates != NULL); 2055 ASSERT_TRUE(candidates != NULL);
2029 EXPECT_LT(0u, candidates->count()); 2056 EXPECT_LT(0u, candidates->count());
2030 candidates = local_desc->candidates(1); 2057 candidates = local_desc->candidates(1);
2031 ASSERT_TRUE(candidates != NULL); 2058 ASSERT_TRUE(candidates != NULL);
2032 EXPECT_LT(0u, candidates->count()); 2059 EXPECT_EQ(0u, candidates->count());
2033 } 2060 }
2034 2061
2035 // Test that we can set a remote session description with remote candidates. 2062 // Test that we can set a remote session description with remote candidates.
2036 TEST_F(WebRtcSessionTest, TestSetRemoteSessionDescriptionWithCandidates) { 2063 TEST_F(WebRtcSessionTest, TestSetRemoteSessionDescriptionWithCandidates) {
2037 Init(); 2064 Init();
2038 2065
2039 cricket::Candidate candidate1; 2066 cricket::Candidate candidate1;
2040 candidate1.set_component(1); 2067 candidate1.set_component(1);
2041 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, 2068 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0,
2042 candidate1); 2069 candidate1);
(...skipping 23 matching lines...) Expand all
2066 Init(); 2093 Init();
2067 mediastream_signaling_.SendAudioVideoStream1(); 2094 mediastream_signaling_.SendAudioVideoStream1();
2068 // Ice is started but candidates are not provided until SetLocalDescription 2095 // Ice is started but candidates are not provided until SetLocalDescription
2069 // is called. 2096 // is called.
2070 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); 2097 EXPECT_EQ(0u, observer_.mline_0_candidates_.size());
2071 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); 2098 EXPECT_EQ(0u, observer_.mline_1_candidates_.size());
2072 CreateAndSetRemoteOfferAndLocalAnswer(); 2099 CreateAndSetRemoteOfferAndLocalAnswer();
2073 // Wait until at least one local candidate has been collected. 2100 // Wait until at least one local candidate has been collected.
2074 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), 2101 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(),
2075 kIceCandidatesTimeout); 2102 kIceCandidatesTimeout);
2076 EXPECT_TRUE_WAIT(0u < observer_.mline_1_candidates_.size(),
2077 kIceCandidatesTimeout);
2078 2103
2079 rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); 2104 rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer());
2080 2105
2081 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); 2106 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL);
2082 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); 2107 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 2108
2086 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); 2109 SessionDescriptionInterface* remote_offer(CreateRemoteOffer());
2087 SetRemoteDescriptionWithoutError(remote_offer); 2110 SetRemoteDescriptionWithoutError(remote_offer);
2088 SessionDescriptionInterface* answer = CreateAnswer(NULL); 2111 SessionDescriptionInterface* answer = CreateAnswer(NULL);
2089 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); 2112 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL);
2090 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); 2113 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); 2114 SetLocalDescriptionWithoutError(answer);
2094 } 2115 }
2095 2116
2096 // Verifies TransportProxy and media channels are created with content names 2117 // Verifies TransportProxy and media channels are created with content names
2097 // present in the SessionDescription. 2118 // present in the SessionDescription.
2098 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { 2119 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) {
2099 Init(); 2120 Init();
2100 mediastream_signaling_.SendAudioVideoStream1(); 2121 mediastream_signaling_.SendAudioVideoStream1();
2101 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2122 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
2102 2123
(...skipping 21 matching lines...) Expand all
2124 2145
2125 SessionDescriptionInterface* modified_offer = 2146 SessionDescriptionInterface* modified_offer =
2126 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); 2147 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL);
2127 2148
2128 SetRemoteDescriptionWithoutError(modified_offer); 2149 SetRemoteDescriptionWithoutError(modified_offer);
2129 2150
2130 SessionDescriptionInterface* answer = 2151 SessionDescriptionInterface* answer =
2131 CreateAnswer(NULL); 2152 CreateAnswer(NULL);
2132 SetLocalDescriptionWithoutError(answer); 2153 SetLocalDescriptionWithoutError(answer);
2133 2154
2134 EXPECT_TRUE(session_->GetTransportProxy("audio_content_name") != NULL); 2155 cricket::TransportChannel* voice_transport_channel =
2135 EXPECT_TRUE(session_->GetTransportProxy("video_content_name") != NULL); 2156 session_->voice_rtp_transport_channel();
2157 EXPECT_TRUE(voice_transport_channel != NULL);
2158 EXPECT_EQ(voice_transport_channel->transport_name(), "audio_content_name");
2159 cricket::TransportChannel* video_transport_channel =
2160 session_->video_rtp_transport_channel();
2161 EXPECT_TRUE(video_transport_channel != NULL);
2162 EXPECT_EQ(video_transport_channel->transport_name(), "video_content_name");
2136 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); 2163 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL);
2137 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); 2164 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL);
2138 } 2165 }
2139 2166
2140 // Test that an offer contains the correct media content descriptions based on 2167 // Test that an offer contains the correct media content descriptions based on
2141 // the send streams when no constraints have been set. 2168 // the send streams when no constraints have been set.
2142 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { 2169 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) {
2143 Init(); 2170 Init();
2144 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 2171 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
2145 2172
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
2685 2712
2686 PeerConnectionInterface::RTCOfferAnswerOptions options; 2713 PeerConnectionInterface::RTCOfferAnswerOptions options;
2687 options.use_rtp_mux = true; 2714 options.use_rtp_mux = true;
2688 2715
2689 SessionDescriptionInterface* offer = CreateRemoteOffer(); 2716 SessionDescriptionInterface* offer = CreateRemoteOffer();
2690 SetRemoteDescriptionWithoutError(offer); 2717 SetRemoteDescriptionWithoutError(offer);
2691 2718
2692 SessionDescriptionInterface* answer = CreateAnswer(NULL); 2719 SessionDescriptionInterface* answer = CreateAnswer(NULL);
2693 SetLocalDescriptionWithoutError(answer); 2720 SetLocalDescriptionWithoutError(answer);
2694 2721
2695 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), 2722 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2696 session_->GetTransportProxy("video")->impl()); 2723 session_->video_rtp_transport_channel());
2697 2724
2698 cricket::Transport* t = session_->GetTransport("audio"); 2725 cricket::BaseChannel* voice_channel = session_->voice_channel();
2726 ASSERT(voice_channel != NULL);
2699 2727
2700 // Checks if one of the transport channels contains a connection using a given 2728 // Checks if one of the transport channels contains a connection using a given
2701 // port. 2729 // port.
2702 auto connection_with_remote_port = [t](int port) { 2730 auto connection_with_remote_port = [this, voice_channel](int port) {
2703 cricket::TransportStats stats; 2731 cricket::SessionStats stats;
2704 t->GetStats(&stats); 2732 session_->GetChannelTransportStats(voice_channel, &stats);
2705 for (auto& chan_stat : stats.channel_stats) { 2733 for (auto& kv : stats.transport_stats) {
2706 for (auto& conn_info : chan_stat.connection_infos) { 2734 for (auto& chan_stat : kv.second.channel_stats) {
2707 if (conn_info.remote_candidate.address().port() == port) { 2735 for (auto& conn_info : chan_stat.connection_infos) {
2708 return true; 2736 if (conn_info.remote_candidate.address().port() == port) {
2737 return true;
2738 }
2709 } 2739 }
2710 } 2740 }
2711 } 2741 }
2712 return false; 2742 return false;
2713 }; 2743 };
2714 2744
2715 EXPECT_FALSE(connection_with_remote_port(5000)); 2745 EXPECT_FALSE(connection_with_remote_port(5000));
2716 EXPECT_FALSE(connection_with_remote_port(5001)); 2746 EXPECT_FALSE(connection_with_remote_port(5001));
2717 EXPECT_FALSE(connection_with_remote_port(6000)); 2747 EXPECT_FALSE(connection_with_remote_port(6000));
2718 2748
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2751 2781
2752 EXPECT_TRUE_WAIT(connection_with_remote_port(5000), 1000); 2782 EXPECT_TRUE_WAIT(connection_with_remote_port(5000), 1000);
2753 EXPECT_TRUE_WAIT(connection_with_remote_port(5001), 1000); 2783 EXPECT_TRUE_WAIT(connection_with_remote_port(5001), 1000);
2754 2784
2755 // No need here for a _WAIT check since we are checking that state hasn't 2785 // 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 2786 // 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. 2787 // is true then there will be no messages processed anyways.
2758 EXPECT_FALSE(connection_with_remote_port(6000)); 2788 EXPECT_FALSE(connection_with_remote_port(6000));
2759 } 2789 }
2760 2790
2761 // kBundlePolicyBalanced bundle policy and answer contains BUNDLE. 2791 // kBundlePolicyBalanced BUNDLE policy and answer contains BUNDLE.
2762 TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) { 2792 TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) {
2763 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); 2793 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced);
2764 mediastream_signaling_.SendAudioVideoStream1(); 2794 mediastream_signaling_.SendAudioVideoStream1();
2765 2795
2766 PeerConnectionInterface::RTCOfferAnswerOptions options; 2796 PeerConnectionInterface::RTCOfferAnswerOptions options;
2767 options.use_rtp_mux = true; 2797 options.use_rtp_mux = true;
2768 2798
2769 SessionDescriptionInterface* offer = CreateOffer(options); 2799 SessionDescriptionInterface* offer = CreateOffer(options);
2770 SetLocalDescriptionWithoutError(offer); 2800 SetLocalDescriptionWithoutError(offer);
2771 2801
2772 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), 2802 EXPECT_NE(session_->voice_rtp_transport_channel(),
2773 session_->GetTransportProxy("video")->impl()); 2803 session_->video_rtp_transport_channel());
2774 2804
2775 mediastream_signaling_.SendAudioVideoStream2(); 2805 mediastream_signaling_.SendAudioVideoStream2();
2776 SessionDescriptionInterface* answer = 2806 SessionDescriptionInterface* answer =
2777 CreateRemoteAnswer(session_->local_description()); 2807 CreateRemoteAnswer(session_->local_description());
2778 SetRemoteDescriptionWithoutError(answer); 2808 SetRemoteDescriptionWithoutError(answer);
2779 2809
2780 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), 2810 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2781 session_->GetTransportProxy("video")->impl()); 2811 session_->video_rtp_transport_channel());
2782 } 2812 }
2783 2813
2784 // kBundlePolicyBalanced bundle policy but no BUNDLE in the answer. 2814 // kBundlePolicyBalanced BUNDLE policy but no BUNDLE in the answer.
2785 TEST_F(WebRtcSessionTest, TestBalancedNoBundleInAnswer) { 2815 TEST_F(WebRtcSessionTest, TestBalancedNoBundleInAnswer) {
2786 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); 2816 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced);
2787 mediastream_signaling_.SendAudioVideoStream1(); 2817 mediastream_signaling_.SendAudioVideoStream1();
2788 2818
2789 PeerConnectionInterface::RTCOfferAnswerOptions options; 2819 PeerConnectionInterface::RTCOfferAnswerOptions options;
2790 options.use_rtp_mux = true; 2820 options.use_rtp_mux = true;
2791 2821
2792 SessionDescriptionInterface* offer = CreateOffer(options); 2822 SessionDescriptionInterface* offer = CreateOffer(options);
2793 SetLocalDescriptionWithoutError(offer); 2823 SetLocalDescriptionWithoutError(offer);
2794 2824
2795 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), 2825 EXPECT_NE(session_->voice_rtp_transport_channel(),
2796 session_->GetTransportProxy("video")->impl()); 2826 session_->video_rtp_transport_channel());
2797 2827
2798 mediastream_signaling_.SendAudioVideoStream2(); 2828 mediastream_signaling_.SendAudioVideoStream2();
2799 2829
2800 // Remove BUNDLE from the answer. 2830 // Remove BUNDLE from the answer.
2801 rtc::scoped_ptr<SessionDescriptionInterface> answer( 2831 rtc::scoped_ptr<SessionDescriptionInterface> answer(
2802 CreateRemoteAnswer(session_->local_description())); 2832 CreateRemoteAnswer(session_->local_description()));
2803 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 2833 cricket::SessionDescription* answer_copy = answer->description()->Copy();
2804 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); 2834 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
2805 JsepSessionDescription* modified_answer = 2835 JsepSessionDescription* modified_answer =
2806 new JsepSessionDescription(JsepSessionDescription::kAnswer); 2836 new JsepSessionDescription(JsepSessionDescription::kAnswer);
2807 modified_answer->Initialize(answer_copy, "1", "1"); 2837 modified_answer->Initialize(answer_copy, "1", "1");
2808 SetRemoteDescriptionWithoutError(modified_answer); // 2838 SetRemoteDescriptionWithoutError(modified_answer); //
2809 2839
2810 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), 2840 EXPECT_NE(session_->voice_rtp_transport_channel(),
2811 session_->GetTransportProxy("video")->impl()); 2841 session_->video_rtp_transport_channel());
2812 } 2842 }
2813 2843
2814 // kBundlePolicyMaxBundle policy with BUNDLE in the answer. 2844 // kBundlePolicyMaxBundle policy with BUNDLE in the answer.
2815 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInAnswer) { 2845 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInAnswer) {
2816 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); 2846 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
2817 mediastream_signaling_.SendAudioVideoStream1(); 2847 mediastream_signaling_.SendAudioVideoStream1();
2818 2848
2819 PeerConnectionInterface::RTCOfferAnswerOptions options; 2849 PeerConnectionInterface::RTCOfferAnswerOptions options;
2820 options.use_rtp_mux = true; 2850 options.use_rtp_mux = true;
2821 2851
2822 SessionDescriptionInterface* offer = CreateOffer(options); 2852 SessionDescriptionInterface* offer = CreateOffer(options);
2823 SetLocalDescriptionWithoutError(offer); 2853 SetLocalDescriptionWithoutError(offer);
2824 2854
2825 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), 2855 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2826 session_->GetTransportProxy("video")->impl()); 2856 session_->video_rtp_transport_channel());
2827 2857
2828 mediastream_signaling_.SendAudioVideoStream2(); 2858 mediastream_signaling_.SendAudioVideoStream2();
2829 SessionDescriptionInterface* answer = 2859 SessionDescriptionInterface* answer =
2830 CreateRemoteAnswer(session_->local_description()); 2860 CreateRemoteAnswer(session_->local_description());
2831 SetRemoteDescriptionWithoutError(answer); 2861 SetRemoteDescriptionWithoutError(answer);
2832 2862
2833 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), 2863 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2834 session_->GetTransportProxy("video")->impl()); 2864 session_->video_rtp_transport_channel());
2865 }
2866
2867 // kBundlePolicyMaxBundle policy with BUNDLE in the answer, but no
2868 // audio content in the answer.
2869 TEST_F(WebRtcSessionTest, TestMaxBundleRejectAudio) {
2870 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
2871 mediastream_signaling_.SendAudioVideoStream1();
2872
2873 PeerConnectionInterface::RTCOfferAnswerOptions options;
2874 options.use_rtp_mux = true;
2875
2876 SessionDescriptionInterface* offer = CreateOffer(options);
2877 SetLocalDescriptionWithoutError(offer);
2878
2879 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2880 session_->video_rtp_transport_channel());
2881
2882 mediastream_signaling_.SendAudioVideoStream2();
2883 cricket::MediaSessionOptions recv_options;
2884 recv_options.recv_audio = false;
2885 recv_options.recv_video = true;
2886 SessionDescriptionInterface* answer =
2887 CreateRemoteAnswer(session_->local_description(), recv_options);
2888 SetRemoteDescriptionWithoutError(answer);
2889
2890 EXPECT_TRUE(NULL == session_->voice_channel());
2891 EXPECT_TRUE(NULL != session_->video_rtp_transport_channel());
2892
2893 session_->Terminate();
2894 EXPECT_TRUE(NULL == session_->voice_rtp_transport_channel());
2895 EXPECT_TRUE(NULL == session_->voice_rtcp_transport_channel());
2896 EXPECT_TRUE(NULL == session_->video_rtp_transport_channel());
2897 EXPECT_TRUE(NULL == session_->video_rtcp_transport_channel());
2835 } 2898 }
2836 2899
2837 // kBundlePolicyMaxBundle policy but no BUNDLE in the answer. 2900 // kBundlePolicyMaxBundle policy but no BUNDLE in the answer.
2838 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) { 2901 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) {
2839 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); 2902 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
2840 mediastream_signaling_.SendAudioVideoStream1(); 2903 mediastream_signaling_.SendAudioVideoStream1();
2841 2904
2842 PeerConnectionInterface::RTCOfferAnswerOptions options; 2905 PeerConnectionInterface::RTCOfferAnswerOptions options;
2843 options.use_rtp_mux = true; 2906 options.use_rtp_mux = true;
2844 2907
2845 SessionDescriptionInterface* offer = CreateOffer(options); 2908 SessionDescriptionInterface* offer = CreateOffer(options);
2846 SetLocalDescriptionWithoutError(offer); 2909 SetLocalDescriptionWithoutError(offer);
2847 2910
2848 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), 2911 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2849 session_->GetTransportProxy("video")->impl()); 2912 session_->video_rtp_transport_channel());
2850 2913
2851 mediastream_signaling_.SendAudioVideoStream2(); 2914 mediastream_signaling_.SendAudioVideoStream2();
2852 2915
2853 // Remove BUNDLE from the answer. 2916 // Remove BUNDLE from the answer.
2854 rtc::scoped_ptr<SessionDescriptionInterface> answer( 2917 rtc::scoped_ptr<SessionDescriptionInterface> answer(
2855 CreateRemoteAnswer(session_->local_description())); 2918 CreateRemoteAnswer(session_->local_description()));
2856 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 2919 cricket::SessionDescription* answer_copy = answer->description()->Copy();
2857 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); 2920 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
2858 JsepSessionDescription* modified_answer = 2921 JsepSessionDescription* modified_answer =
2859 new JsepSessionDescription(JsepSessionDescription::kAnswer); 2922 new JsepSessionDescription(JsepSessionDescription::kAnswer);
2860 modified_answer->Initialize(answer_copy, "1", "1"); 2923 modified_answer->Initialize(answer_copy, "1", "1");
2861 SetRemoteDescriptionWithoutError(modified_answer); 2924 SetRemoteDescriptionWithoutError(modified_answer);
2862 2925
2863 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), 2926 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2864 session_->GetTransportProxy("video")->impl()); 2927 session_->video_rtp_transport_channel());
2928 }
2929
2930 // kBundlePolicyMaxBundle policy with BUNDLE in the remote offer.
2931 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInRemoteOffer) {
2932 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
2933 mediastream_signaling_.SendAudioVideoStream1();
2934
2935 SessionDescriptionInterface* offer = CreateRemoteOffer();
2936 SetRemoteDescriptionWithoutError(offer);
2937
2938 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2939 session_->video_rtp_transport_channel());
2940
2941 mediastream_signaling_.SendAudioVideoStream2();
2942 SessionDescriptionInterface* answer = CreateAnswer(nullptr);
2943 SetLocalDescriptionWithoutError(answer);
2944
2945 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2946 session_->video_rtp_transport_channel());
2947 }
2948
2949 // kBundlePolicyMaxBundle policy but no BUNDLE in the remote offer.
2950 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInRemoteOffer) {
2951 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
2952 mediastream_signaling_.SendAudioVideoStream1();
2953
2954 // Remove BUNDLE from the offer.
2955 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateRemoteOffer());
2956 cricket::SessionDescription* offer_copy = offer->description()->Copy();
2957 offer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
2958 JsepSessionDescription* modified_offer =
2959 new JsepSessionDescription(JsepSessionDescription::kOffer);
2960 modified_offer->Initialize(offer_copy, "1", "1");
2961
2962 // Expect an error when applying the remote description
2963 SetRemoteDescriptionExpectError(JsepSessionDescription::kOffer,
2964 kCreateChannelFailed, modified_offer);
2865 } 2965 }
2866 2966
2867 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. 2967 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE.
2868 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { 2968 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) {
2869 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); 2969 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat);
2870 mediastream_signaling_.SendAudioVideoStream1(); 2970 mediastream_signaling_.SendAudioVideoStream1();
2871 2971
2872 PeerConnectionInterface::RTCOfferAnswerOptions options; 2972 PeerConnectionInterface::RTCOfferAnswerOptions options;
2873 options.use_rtp_mux = true; 2973 options.use_rtp_mux = true;
2874 2974
2875 SessionDescriptionInterface* offer = CreateOffer(options); 2975 SessionDescriptionInterface* offer = CreateOffer(options);
2876 SetLocalDescriptionWithoutError(offer); 2976 SetLocalDescriptionWithoutError(offer);
2877 2977
2878 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), 2978 EXPECT_NE(session_->voice_rtp_transport_channel(),
2879 session_->GetTransportProxy("video")->impl()); 2979 session_->video_rtp_transport_channel());
2880 2980
2881 mediastream_signaling_.SendAudioVideoStream2(); 2981 mediastream_signaling_.SendAudioVideoStream2();
2882 SessionDescriptionInterface* answer = 2982 SessionDescriptionInterface* answer =
2883 CreateRemoteAnswer(session_->local_description()); 2983 CreateRemoteAnswer(session_->local_description());
2884 SetRemoteDescriptionWithoutError(answer); 2984 SetRemoteDescriptionWithoutError(answer);
2885 2985
2886 // This should lead to an audio-only call but isn't implemented 2986 // This should lead to an audio-only call but isn't implemented
2887 // correctly yet. 2987 // correctly yet.
2888 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), 2988 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2889 session_->GetTransportProxy("video")->impl()); 2989 session_->video_rtp_transport_channel());
2890 } 2990 }
2891 2991
2892 // kBundlePolicyMaxCompat bundle policy but no BUNDLE in the answer. 2992 // kBundlePolicyMaxCompat BUNDLE policy but no BUNDLE in the answer.
2893 TEST_F(WebRtcSessionTest, TestMaxCompatNoBundleInAnswer) { 2993 TEST_F(WebRtcSessionTest, TestMaxCompatNoBundleInAnswer) {
2894 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); 2994 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat);
2895 mediastream_signaling_.SendAudioVideoStream1(); 2995 mediastream_signaling_.SendAudioVideoStream1();
2896 PeerConnectionInterface::RTCOfferAnswerOptions options; 2996 PeerConnectionInterface::RTCOfferAnswerOptions options;
2897 options.use_rtp_mux = true; 2997 options.use_rtp_mux = true;
2898 2998
2899 SessionDescriptionInterface* offer = CreateOffer(options); 2999 SessionDescriptionInterface* offer = CreateOffer(options);
2900 SetLocalDescriptionWithoutError(offer); 3000 SetLocalDescriptionWithoutError(offer);
2901 3001
2902 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), 3002 EXPECT_NE(session_->voice_rtp_transport_channel(),
2903 session_->GetTransportProxy("video")->impl()); 3003 session_->video_rtp_transport_channel());
2904 3004
2905 mediastream_signaling_.SendAudioVideoStream2(); 3005 mediastream_signaling_.SendAudioVideoStream2();
2906 3006
2907 // Remove BUNDLE from the answer. 3007 // Remove BUNDLE from the answer.
2908 rtc::scoped_ptr<SessionDescriptionInterface> answer( 3008 rtc::scoped_ptr<SessionDescriptionInterface> answer(
2909 CreateRemoteAnswer(session_->local_description())); 3009 CreateRemoteAnswer(session_->local_description()));
2910 cricket::SessionDescription* answer_copy = answer->description()->Copy(); 3010 cricket::SessionDescription* answer_copy = answer->description()->Copy();
2911 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); 3011 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
2912 JsepSessionDescription* modified_answer = 3012 JsepSessionDescription* modified_answer =
2913 new JsepSessionDescription(JsepSessionDescription::kAnswer); 3013 new JsepSessionDescription(JsepSessionDescription::kAnswer);
2914 modified_answer->Initialize(answer_copy, "1", "1"); 3014 modified_answer->Initialize(answer_copy, "1", "1");
2915 SetRemoteDescriptionWithoutError(modified_answer); // 3015 SetRemoteDescriptionWithoutError(modified_answer); //
2916 3016
2917 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), 3017 EXPECT_NE(session_->voice_rtp_transport_channel(),
2918 session_->GetTransportProxy("video")->impl()); 3018 session_->video_rtp_transport_channel());
2919 } 3019 }
2920 3020
2921 // kBundlePolicyMaxbundle and then we call SetRemoteDescription first. 3021 // kBundlePolicyMaxbundle and then we call SetRemoteDescription first.
2922 TEST_F(WebRtcSessionTest, TestMaxBundleWithSetRemoteDescriptionFirst) { 3022 TEST_F(WebRtcSessionTest, TestMaxBundleWithSetRemoteDescriptionFirst) {
2923 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); 3023 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
2924 mediastream_signaling_.SendAudioVideoStream1(); 3024 mediastream_signaling_.SendAudioVideoStream1();
2925 3025
2926 PeerConnectionInterface::RTCOfferAnswerOptions options; 3026 PeerConnectionInterface::RTCOfferAnswerOptions options;
2927 options.use_rtp_mux = true; 3027 options.use_rtp_mux = true;
2928 3028
2929 SessionDescriptionInterface* offer = CreateOffer(options); 3029 SessionDescriptionInterface* offer = CreateOffer(options);
2930 SetRemoteDescriptionWithoutError(offer); 3030 SetRemoteDescriptionWithoutError(offer);
2931 3031
2932 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), 3032 EXPECT_EQ(session_->voice_rtp_transport_channel(),
2933 session_->GetTransportProxy("video")->impl()); 3033 session_->video_rtp_transport_channel());
2934 } 3034 }
2935 3035
2936 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { 3036 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) {
2937 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); 3037 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire);
2938 mediastream_signaling_.SendAudioVideoStream1(); 3038 mediastream_signaling_.SendAudioVideoStream1();
2939 3039
2940 PeerConnectionInterface::RTCOfferAnswerOptions options; 3040 PeerConnectionInterface::RTCOfferAnswerOptions options;
2941 SessionDescriptionInterface* offer = CreateOffer(options); 3041 SessionDescriptionInterface* offer = CreateOffer(options);
2942 SetLocalDescriptionWithoutError(offer); 3042 SetLocalDescriptionWithoutError(offer);
2943 3043
2944 EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); 3044 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL);
2945 EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); 3045 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL);
2946 3046
2947 mediastream_signaling_.SendAudioVideoStream2(); 3047 mediastream_signaling_.SendAudioVideoStream2();
2948 SessionDescriptionInterface* answer = 3048 SessionDescriptionInterface* answer =
2949 CreateRemoteAnswer(session_->local_description()); 3049 CreateRemoteAnswer(session_->local_description());
2950 SetRemoteDescriptionWithoutError(answer); 3050 SetRemoteDescriptionWithoutError(answer);
2951 3051
2952 EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); 3052 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL);
2953 EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); 3053 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL);
2954 } 3054 }
2955 3055
2956 TEST_F(WebRtcSessionTest, TestNegotiateRtcpMux) { 3056 TEST_F(WebRtcSessionTest, TestNegotiateRtcpMux) {
2957 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyNegotiate); 3057 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyNegotiate);
2958 mediastream_signaling_.SendAudioVideoStream1(); 3058 mediastream_signaling_.SendAudioVideoStream1();
2959 3059
2960 PeerConnectionInterface::RTCOfferAnswerOptions options; 3060 PeerConnectionInterface::RTCOfferAnswerOptions options;
2961 SessionDescriptionInterface* offer = CreateOffer(options); 3061 SessionDescriptionInterface* offer = CreateOffer(options);
2962 SetLocalDescriptionWithoutError(offer); 3062 SetLocalDescriptionWithoutError(offer);
2963 3063
2964 EXPECT_TRUE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); 3064 EXPECT_TRUE(session_->voice_rtcp_transport_channel() != NULL);
2965 EXPECT_TRUE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); 3065 EXPECT_TRUE(session_->video_rtcp_transport_channel() != NULL);
2966 3066
2967 mediastream_signaling_.SendAudioVideoStream2(); 3067 mediastream_signaling_.SendAudioVideoStream2();
2968 SessionDescriptionInterface* answer = 3068 SessionDescriptionInterface* answer =
2969 CreateRemoteAnswer(session_->local_description()); 3069 CreateRemoteAnswer(session_->local_description());
2970 SetRemoteDescriptionWithoutError(answer); 3070 SetRemoteDescriptionWithoutError(answer);
2971 3071
2972 EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); 3072 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL);
2973 EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); 3073 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL);
2974 } 3074 }
2975 3075
2976 // This test verifies that SetLocalDescription and SetRemoteDescription fails 3076 // This test verifies that SetLocalDescription and SetRemoteDescription fails
2977 // if BUNDLE is enabled but rtcp-mux is disabled in m-lines. 3077 // if BUNDLE is enabled but rtcp-mux is disabled in m-lines.
2978 TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) { 3078 TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) {
2979 Init(); 3079 Init();
2980 mediastream_signaling_.SendAudioVideoStream1(); 3080 mediastream_signaling_.SendAudioVideoStream1();
2981 3081
2982 PeerConnectionInterface::RTCOfferAnswerOptions options; 3082 PeerConnectionInterface::RTCOfferAnswerOptions options;
2983 options.use_rtp_mux = true; 3083 options.use_rtp_mux = true;
2984 3084
2985 SessionDescriptionInterface* offer = CreateOffer(options); 3085 SessionDescriptionInterface* offer = CreateOffer(options);
2986 std::string offer_str; 3086 std::string offer_str;
2987 offer->ToString(&offer_str); 3087 offer->ToString(&offer_str);
2988 // Disable rtcp-mux 3088 // Disable rtcp-mux
2989 const std::string rtcp_mux = "rtcp-mux"; 3089 const std::string rtcp_mux = "rtcp-mux";
2990 const std::string xrtcp_mux = "xrtcp-mux"; 3090 const std::string xrtcp_mux = "xrtcp-mux";
2991 rtc::replace_substrs(rtcp_mux.c_str(), rtcp_mux.length(), 3091 rtc::replace_substrs(rtcp_mux.c_str(), rtcp_mux.length(),
2992 xrtcp_mux.c_str(), xrtcp_mux.length(), 3092 xrtcp_mux.c_str(), xrtcp_mux.length(),
2993 &offer_str); 3093 &offer_str);
2994 JsepSessionDescription *local_offer = 3094 JsepSessionDescription* local_offer =
2995 new JsepSessionDescription(JsepSessionDescription::kOffer); 3095 new JsepSessionDescription(JsepSessionDescription::kOffer);
2996 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL)); 3096 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL));
2997 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer); 3097 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer);
2998 JsepSessionDescription *remote_offer = 3098 JsepSessionDescription* remote_offer =
2999 new JsepSessionDescription(JsepSessionDescription::kOffer); 3099 new JsepSessionDescription(JsepSessionDescription::kOffer);
3000 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL)); 3100 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL));
3001 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer); 3101 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer);
3002 // Trying unmodified SDP. 3102 // Trying unmodified SDP.
3003 SetLocalDescriptionWithoutError(offer); 3103 SetLocalDescriptionWithoutError(offer);
3004 } 3104 }
3005 3105
3006 TEST_F(WebRtcSessionTest, SetAudioPlayout) { 3106 TEST_F(WebRtcSessionTest, SetAudioPlayout) {
3007 Init(); 3107 Init();
3008 mediastream_signaling_.SendAudioVideoStream1(); 3108 mediastream_signaling_.SendAudioVideoStream1();
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
3251 candidate.set_component(1); 3351 candidate.set_component(1);
3252 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, 3352 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0,
3253 candidate); 3353 candidate);
3254 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); 3354 EXPECT_TRUE(offer->AddCandidate(&ice_candidate));
3255 cricket::Candidate candidate1; 3355 cricket::Candidate candidate1;
3256 candidate1.set_component(1); 3356 candidate1.set_component(1);
3257 JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1, 3357 JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1,
3258 candidate1); 3358 candidate1);
3259 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1)); 3359 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1));
3260 SetRemoteDescriptionWithoutError(offer); 3360 SetRemoteDescriptionWithoutError(offer);
3261 ASSERT_TRUE(session_->GetTransportProxy("audio") != NULL); 3361 ASSERT_TRUE(session_->voice_rtp_transport_channel() != NULL);
3262 ASSERT_TRUE(session_->GetTransportProxy("video") != NULL); 3362 ASSERT_TRUE(session_->video_rtp_transport_channel() != NULL);
3263 3363
3264 // Pump for 1 second and verify that no candidates are generated. 3364 // Pump for 1 second and verify that no candidates are generated.
3265 rtc::Thread::Current()->ProcessMessages(1000); 3365 rtc::Thread::Current()->ProcessMessages(1000);
3266 EXPECT_TRUE(observer_.mline_0_candidates_.empty()); 3366 EXPECT_TRUE(observer_.mline_0_candidates_.empty());
3267 EXPECT_TRUE(observer_.mline_1_candidates_.empty()); 3367 EXPECT_TRUE(observer_.mline_1_candidates_.empty());
3268 3368
3269 SessionDescriptionInterface* answer = CreateAnswer(NULL); 3369 SessionDescriptionInterface* answer = CreateAnswer(NULL);
3270 SetLocalDescriptionWithoutError(answer); 3370 SetLocalDescriptionWithoutError(answer);
3271 EXPECT_TRUE(session_->GetTransportProxy("audio")->negotiated());
3272 EXPECT_TRUE(session_->GetTransportProxy("video")->negotiated());
3273 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); 3371 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout);
3274 } 3372 }
3275 3373
3276 // This test verifies that crypto parameter is updated in local session 3374 // This test verifies that crypto parameter is updated in local session
3277 // description as per security policy set in MediaSessionDescriptionFactory. 3375 // description as per security policy set in MediaSessionDescriptionFactory.
3278 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) { 3376 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) {
3279 Init(); 3377 Init();
3280 mediastream_signaling_.SendAudioVideoStream1(); 3378 mediastream_signaling_.SendAudioVideoStream1();
3281 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3379 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
3282 3380
(...skipping 14 matching lines...) Expand all
3297 options_.disable_encryption = true; 3395 options_.disable_encryption = true;
3298 Init(); 3396 Init();
3299 mediastream_signaling_.SendAudioVideoStream1(); 3397 mediastream_signaling_.SendAudioVideoStream1();
3300 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3398 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
3301 3399
3302 // Making sure SetLocalDescription correctly sets crypto value in 3400 // Making sure SetLocalDescription correctly sets crypto value in
3303 // SessionDescription object after de-serialization of sdp string. The value 3401 // SessionDescription object after de-serialization of sdp string. The value
3304 // will be set as per MediaSessionDescriptionFactory. 3402 // will be set as per MediaSessionDescriptionFactory.
3305 std::string offer_str; 3403 std::string offer_str;
3306 offer->ToString(&offer_str); 3404 offer->ToString(&offer_str);
3307 SessionDescriptionInterface *jsep_offer_str = 3405 SessionDescriptionInterface* jsep_offer_str =
3308 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); 3406 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL);
3309 SetLocalDescriptionWithoutError(jsep_offer_str); 3407 SetLocalDescriptionWithoutError(jsep_offer_str);
3310 EXPECT_FALSE(session_->voice_channel()->secure_required()); 3408 EXPECT_FALSE(session_->voice_channel()->secure_required());
3311 EXPECT_FALSE(session_->video_channel()->secure_required()); 3409 EXPECT_FALSE(session_->video_channel()->secure_required());
3312 } 3410 }
3313 3411
3314 // This test verifies that an answer contains new ufrag and password if an offer 3412 // This test verifies that an answer contains new ufrag and password if an offer
3315 // with new ufrag and password is received. 3413 // with new ufrag and password is received.
3316 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { 3414 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) {
3317 Init(); 3415 Init();
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
3650 3748
3651 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); 3749 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer());
3652 EXPECT_TRUE(offer == NULL); 3750 EXPECT_TRUE(offer == NULL);
3653 } 3751 }
3654 3752
3655 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made 3753 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made
3656 // before async identity generation is finished. 3754 // before async identity generation is finished.
3657 TEST_P(WebRtcSessionTest, 3755 TEST_P(WebRtcSessionTest,
3658 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { 3756 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) {
3659 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3757 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3660 VerifyMultipleAsyncCreateDescription( 3758 VerifyMultipleAsyncCreateDescription(GetParam(),
3661 GetParam(), CreateSessionDescriptionRequest::kOffer); 3759 CreateSessionDescriptionRequest::kOffer);
3662 } 3760 }
3663 3761
3664 // Verifies that CreateOffer fails when Multiple CreateOffer calls are made 3762 // Verifies that CreateOffer fails when Multiple CreateOffer calls are made
3665 // before async identity generation fails. 3763 // before async identity generation fails.
3666 TEST_F(WebRtcSessionTest, 3764 TEST_F(WebRtcSessionTest,
3667 TestMultipleCreateOfferBeforeIdentityRequestReturnFailure) { 3765 TestMultipleCreateOfferBeforeIdentityRequestReturnFailure) {
3668 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); 3766 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp);
3669 VerifyMultipleAsyncCreateDescriptionIdentityGenFailure( 3767 VerifyMultipleAsyncCreateDescriptionIdentityGenFailure(
3670 CreateSessionDescriptionRequest::kOffer); 3768 CreateSessionDescriptionRequest::kOffer);
3671 } 3769 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
3874 SessionDescriptionInterface* offer = CreateOffer(options); 3972 SessionDescriptionInterface* offer = CreateOffer(options);
3875 SetLocalDescriptionWithoutError(offer); 3973 SetLocalDescriptionWithoutError(offer);
3876 3974
3877 session_->video_channel()->SetOption(cricket::BaseChannel::ST_RTP, 3975 session_->video_channel()->SetOption(cricket::BaseChannel::ST_RTP,
3878 rtc::Socket::Option::OPT_SNDBUF, 4000); 3976 rtc::Socket::Option::OPT_SNDBUF, 4000);
3879 3977
3880 session_->voice_channel()->SetOption(cricket::BaseChannel::ST_RTP, 3978 session_->voice_channel()->SetOption(cricket::BaseChannel::ST_RTP,
3881 rtc::Socket::Option::OPT_RCVBUF, 8000); 3979 rtc::Socket::Option::OPT_RCVBUF, 8000);
3882 3980
3883 int option_val; 3981 int option_val;
3884 EXPECT_TRUE(session_->video_channel()->transport_channel()->GetOption( 3982 EXPECT_TRUE(session_->video_rtp_transport_channel()->GetOption(
3885 rtc::Socket::Option::OPT_SNDBUF, &option_val)); 3983 rtc::Socket::Option::OPT_SNDBUF, &option_val));
3886 EXPECT_EQ(4000, option_val); 3984 EXPECT_EQ(4000, option_val);
3887 EXPECT_FALSE(session_->voice_channel()->transport_channel()->GetOption( 3985 EXPECT_FALSE(session_->voice_rtp_transport_channel()->GetOption(
3888 rtc::Socket::Option::OPT_SNDBUF, &option_val)); 3986 rtc::Socket::Option::OPT_SNDBUF, &option_val));
3889 3987
3890 EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( 3988 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption(
3891 rtc::Socket::Option::OPT_RCVBUF, &option_val)); 3989 rtc::Socket::Option::OPT_RCVBUF, &option_val));
3892 EXPECT_EQ(8000, option_val); 3990 EXPECT_EQ(8000, option_val);
3893 EXPECT_FALSE(session_->video_channel()->transport_channel()->GetOption( 3991 EXPECT_FALSE(session_->video_rtp_transport_channel()->GetOption(
3894 rtc::Socket::Option::OPT_RCVBUF, &option_val)); 3992 rtc::Socket::Option::OPT_RCVBUF, &option_val));
3895 3993
3896 EXPECT_NE(session_->voice_channel()->transport_channel(), 3994 EXPECT_NE(session_->voice_rtp_transport_channel(),
3897 session_->video_channel()->transport_channel()); 3995 session_->video_rtp_transport_channel());
3898 3996
3899 mediastream_signaling_.SendAudioVideoStream2(); 3997 mediastream_signaling_.SendAudioVideoStream2();
3900 SessionDescriptionInterface* answer = 3998 SessionDescriptionInterface* answer =
3901 CreateRemoteAnswer(session_->local_description()); 3999 CreateRemoteAnswer(session_->local_description());
3902 SetRemoteDescriptionWithoutError(answer); 4000 SetRemoteDescriptionWithoutError(answer);
3903 4001
3904 EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( 4002 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption(
3905 rtc::Socket::Option::OPT_SNDBUF, &option_val)); 4003 rtc::Socket::Option::OPT_SNDBUF, &option_val));
3906 EXPECT_EQ(4000, option_val); 4004 EXPECT_EQ(4000, option_val);
3907 4005
3908 EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( 4006 EXPECT_TRUE(session_->voice_rtp_transport_channel()->GetOption(
3909 rtc::Socket::Option::OPT_RCVBUF, &option_val)); 4007 rtc::Socket::Option::OPT_RCVBUF, &option_val));
3910 EXPECT_EQ(8000, option_val); 4008 EXPECT_EQ(8000, option_val);
3911 } 4009 }
3912 4010
3913 // Test creating a session, request multiple offers, destroy the session 4011 // Test creating a session, request multiple offers, destroy the session
3914 // and make sure we got success/failure callbacks for all of the requests. 4012 // and make sure we got success/failure callbacks for all of the requests.
3915 // Background: crbug.com/507307 4013 // Background: crbug.com/507307
3916 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) { 4014 TEST_F(WebRtcSessionTest, CreateOffersAndShutdown) {
3917 Init(); 4015 Init();
3918 4016
(...skipping 15 matching lines...) Expand all
3934 // must have received a notification which, so the only invalid state 4032 // must have received a notification which, so the only invalid state
3935 // is kInit. 4033 // is kInit.
3936 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); 4034 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state());
3937 } 4035 }
3938 } 4036 }
3939 4037
3940 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4038 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
3941 // currently fails because upon disconnection and reconnection OnIceComplete is 4039 // currently fails because upon disconnection and reconnection OnIceComplete is
3942 // called more than once without returning to IceGatheringGathering. 4040 // called more than once without returning to IceGatheringGathering.
3943 4041
3944 INSTANTIATE_TEST_CASE_P( 4042 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
3945 WebRtcSessionTests, WebRtcSessionTest, 4043 WebRtcSessionTest,
3946 testing::Values(ALREADY_GENERATED, DTLS_IDENTITY_STORE)); 4044 testing::Values(ALREADY_GENERATED,
4045 DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « talk/app/webrtc/webrtcsession.cc ('k') | talk/app/webrtc/webrtcsessiondescriptionfactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698