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