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