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

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

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