| 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/fakedtlsidentityservice.h" | 37 #include "talk/app/webrtc/test/fakedtlsidentityservice.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 199 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { | 381 metrics_observer_(new rtc::RefCountedObject<FakeMetricsObserver>()) { |
| 340 tdesc_factory_->set_protocol(cricket::ICEPROTO_HYBRID); | 382 tdesc_factory_->set_protocol(cricket::ICEPROTO_HYBRID); |
| 341 | 383 |
| 342 cricket::ServerAddresses stun_servers; | 384 cricket::ServerAddresses stun_servers; |
| 343 stun_servers.insert(stun_socket_addr_); | 385 stun_servers.insert(stun_socket_addr_); |
| 344 allocator_.reset(new cricket::BasicPortAllocator( | 386 allocator_.reset(new cricket::BasicPortAllocator( |
| 345 &network_manager_, | 387 &network_manager_, |
| 346 stun_servers, | 388 stun_servers, |
| 347 SocketAddress(), SocketAddress(), SocketAddress())); | 389 SocketAddress(), SocketAddress(), SocketAddress())); |
| 348 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | | 390 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP | |
| 349 cricket::PORTALLOCATOR_DISABLE_RELAY | | 391 cricket::PORTALLOCATOR_DISABLE_RELAY | |
| 350 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); | 392 cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |
| 351 EXPECT_TRUE(channel_manager_->Init()); | 393 EXPECT_TRUE(channel_manager_->Init()); |
| 352 desc_factory_->set_add_legacy_streams(false); | 394 desc_factory_->set_add_legacy_streams(false); |
| 353 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 395 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
| 354 } | 396 } |
| 355 | 397 |
| 356 void AddInterface(const SocketAddress& addr) { | 398 void AddInterface(const SocketAddress& addr) { |
| 357 network_manager_.AddInterface(addr); | 399 network_manager_.AddInterface(addr); |
| 358 } | 400 } |
| 359 | 401 |
| 360 void Init( | 402 void Init( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, | 502 observer->state() != WebRtcSessionCreateSDPObserverForTest::kInit, |
| 461 2000); | 503 2000); |
| 462 return observer->ReleaseDescription(); | 504 return observer->ReleaseDescription(); |
| 463 } | 505 } |
| 464 | 506 |
| 465 bool ChannelsExist() const { | 507 bool ChannelsExist() const { |
| 466 return (session_->voice_channel() != NULL && | 508 return (session_->voice_channel() != NULL && |
| 467 session_->video_channel() != NULL); | 509 session_->video_channel() != NULL); |
| 468 } | 510 } |
| 469 | 511 |
| 470 void CheckTransportChannels() const { | |
| 471 EXPECT_TRUE(session_->GetChannel(cricket::CN_AUDIO, 1) != NULL); | |
| 472 EXPECT_TRUE(session_->GetChannel(cricket::CN_AUDIO, 2) != NULL); | |
| 473 EXPECT_TRUE(session_->GetChannel(cricket::CN_VIDEO, 1) != NULL); | |
| 474 EXPECT_TRUE(session_->GetChannel(cricket::CN_VIDEO, 2) != NULL); | |
| 475 } | |
| 476 | |
| 477 void VerifyCryptoParams(const cricket::SessionDescription* sdp) { | 512 void VerifyCryptoParams(const cricket::SessionDescription* sdp) { |
| 478 ASSERT_TRUE(session_.get() != NULL); | 513 ASSERT_TRUE(session_.get() != NULL); |
| 479 const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp); | 514 const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp); |
| 480 ASSERT_TRUE(content != NULL); | 515 ASSERT_TRUE(content != NULL); |
| 481 const cricket::AudioContentDescription* audio_content = | 516 const cricket::AudioContentDescription* audio_content = |
| 482 static_cast<const cricket::AudioContentDescription*>( | 517 static_cast<const cricket::AudioContentDescription*>( |
| 483 content->description); | 518 content->description); |
| 484 ASSERT_TRUE(audio_content != NULL); | 519 ASSERT_TRUE(audio_content != NULL); |
| 485 ASSERT_EQ(1U, audio_content->cryptos().size()); | 520 ASSERT_EQ(1U, audio_content->cryptos().size()); |
| 486 ASSERT_EQ(47U, audio_content->cryptos()[0].key_params.size()); | 521 ASSERT_EQ(47U, audio_content->cryptos()[0].key_params.size()); |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 &sdp); | 972 &sdp); |
| 938 } | 973 } |
| 939 | 974 |
| 940 SessionDescriptionInterface* new_answer = CreateSessionDescription( | 975 SessionDescriptionInterface* new_answer = CreateSessionDescription( |
| 941 JsepSessionDescription::kAnswer, sdp, NULL); | 976 JsepSessionDescription::kAnswer, sdp, NULL); |
| 942 | 977 |
| 943 // SetRemoteDescription to enable rtcp mux. | 978 // SetRemoteDescription to enable rtcp mux. |
| 944 SetRemoteDescriptionWithoutError(new_answer); | 979 SetRemoteDescriptionWithoutError(new_answer); |
| 945 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); | 980 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 946 EXPECT_EQ(expected_candidate_num, observer_.mline_0_candidates_.size()); | 981 EXPECT_EQ(expected_candidate_num, observer_.mline_0_candidates_.size()); |
| 947 EXPECT_EQ(expected_candidate_num, observer_.mline_1_candidates_.size()); | 982 if (bundle) { |
| 948 for (size_t i = 0; i < observer_.mline_0_candidates_.size(); ++i) { | 983 EXPECT_EQ(0, observer_.mline_1_candidates_.size()); |
| 949 cricket::Candidate c0 = observer_.mline_0_candidates_[i]; | 984 } else { |
| 950 cricket::Candidate c1 = observer_.mline_1_candidates_[i]; | 985 EXPECT_EQ(expected_candidate_num, observer_.mline_1_candidates_.size()); |
| 951 if (bundle) { | |
| 952 EXPECT_TRUE(c0.IsEquivalent(c1)); | |
| 953 } else { | |
| 954 EXPECT_FALSE(c0.IsEquivalent(c1)); | |
| 955 } | |
| 956 } | 986 } |
| 957 } | 987 } |
| 958 // Tests that we can only send DTMF when the dtmf codec is supported. | 988 // Tests that we can only send DTMF when the dtmf codec is supported. |
| 959 void TestCanInsertDtmf(bool can) { | 989 void TestCanInsertDtmf(bool can) { |
| 960 if (can) { | 990 if (can) { |
| 961 InitWithDtmfCodec(); | 991 InitWithDtmfCodec(); |
| 962 } else { | 992 } else { |
| 963 Init(); | 993 Init(); |
| 964 } | 994 } |
| 965 mediastream_signaling_.SendAudioVideoStream1(); | 995 mediastream_signaling_.SendAudioVideoStream1(); |
| 966 CreateAndSetRemoteOfferAndLocalAnswer(); | 996 CreateAndSetRemoteOfferAndLocalAnswer(); |
| 967 EXPECT_FALSE(session_->CanInsertDtmf("")); | 997 EXPECT_FALSE(session_->CanInsertDtmf("")); |
| 968 EXPECT_EQ(can, session_->CanInsertDtmf(kAudioTrack1)); | 998 EXPECT_EQ(can, session_->CanInsertDtmf(kAudioTrack1)); |
| 969 } | 999 } |
| 970 | 1000 |
| 971 // Helper class to configure loopback network and verify Best | 1001 // Helper class to configure loopback network and verify Best |
| 972 // Connection using right IP protocol for TestLoopbackCall | 1002 // Connection using right IP protocol for TestLoopbackCall |
| 973 // method. LoopbackNetworkManager applies firewall rules to block | 1003 // method. LoopbackNetworkManager applies firewall rules to block |
| 974 // all ping traffic once ICE completed, and remove them to observe | 1004 // all ping traffic once ICE completed, and remove them to observe |
| 975 // ICE reconnected again. This LoopbackNetworkConfiguration struct | 1005 // ICE reconnected again. This LoopbackNetworkConfiguration struct |
| 976 // verifies the best connection is using the right IP protocol after | 1006 // verifies the best connection is using the right IP protocol after |
| 977 // initial ICE convergences. | 1007 // initial ICE convergences. |
| 978 | 1008 |
| 979 class LoopbackNetworkConfiguration { | 1009 class LoopbackNetworkConfiguration { |
| 980 public: | 1010 public: |
| 981 LoopbackNetworkConfiguration() | 1011 LoopbackNetworkConfiguration() |
| 982 : test_ipv6_network_(false), | 1012 : test_ipv6_network_(false), |
| 983 test_extra_ipv4_network_(false), | 1013 test_extra_ipv4_network_(false), |
| 984 best_connection_after_initial_ice_converged_(1, 0) {} | 1014 best_connection_after_initial_ice_converged_(1, 0) {} |
| 985 | 1015 |
| 986 // Used to track the expected best connection count in each IP protocol. | 1016 // Used to track the expected best connection count in each IP protocol. |
| 987 struct ExpectedBestConnection { | 1017 struct ExpectedBestConnection { |
| 988 ExpectedBestConnection(int ipv4_count, int ipv6_count) | 1018 ExpectedBestConnection(int ipv4_count, int ipv6_count) |
| 989 : ipv4_count_(ipv4_count), | 1019 : ipv4_count_(ipv4_count), |
| 990 ipv6_count_(ipv6_count) {} | 1020 ipv6_count_(ipv6_count) {} |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 | 1137 |
| 1108 LOG(LS_INFO) << "Firewall Rules applied"; | 1138 LOG(LS_INFO) << "Firewall Rules applied"; |
| 1109 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, | 1139 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, |
| 1110 observer_.ice_connection_state_, | 1140 observer_.ice_connection_state_, |
| 1111 kIceCandidatesTimeout); | 1141 kIceCandidatesTimeout); |
| 1112 | 1142 |
| 1113 metrics_observer_->Reset(); | 1143 metrics_observer_->Reset(); |
| 1114 | 1144 |
| 1115 // Clearing the rules, session should move back to completed state. | 1145 // Clearing the rules, session should move back to completed state. |
| 1116 loopback_network_manager.ClearRules(fss_.get()); | 1146 loopback_network_manager.ClearRules(fss_.get()); |
| 1117 // Session is automatically calling OnSignalingReady after creation of | |
| 1118 // new portallocator session which will allocate new set of candidates. | |
| 1119 | 1147 |
| 1120 LOG(LS_INFO) << "Firewall Rules cleared"; | 1148 LOG(LS_INFO) << "Firewall Rules cleared"; |
| 1121 | |
| 1122 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, | 1149 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted, |
| 1123 observer_.ice_connection_state_, | 1150 observer_.ice_connection_state_, |
| 1124 kIceCandidatesTimeout); | 1151 kIceCandidatesTimeout); |
| 1125 | 1152 |
| 1126 // Now we block ping requests and wait until the ICE connection transitions | 1153 // Now we block ping requests and wait until the ICE connection transitions |
| 1127 // to the Failed state. This will take at least 30 seconds because it must | 1154 // to the Failed state. This will take at least 30 seconds because it must |
| 1128 // wait for the Port to timeout. | 1155 // wait for the Port to timeout. |
| 1129 int port_timeout = 30000; | 1156 int port_timeout = 30000; |
| 1130 | 1157 |
| 1131 loopback_network_manager.ApplyFirewallRules(fss_.get()); | 1158 loopback_network_manager.ApplyFirewallRules(fss_.get()); |
| 1132 LOG(LS_INFO) << "Firewall Rules applied again"; | 1159 LOG(LS_INFO) << "Firewall Rules applied again"; |
| 1133 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, | 1160 EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionDisconnected, |
| 1134 observer_.ice_connection_state_, | 1161 observer_.ice_connection_state_, |
| 1135 kIceCandidatesTimeout + port_timeout); | 1162 kIceCandidatesTimeout + port_timeout); |
| 1136 } | 1163 } |
| 1137 | 1164 |
| 1138 void TestLoopbackCall() { | 1165 void TestLoopbackCall() { |
| 1139 LoopbackNetworkConfiguration config; | 1166 LoopbackNetworkConfiguration config; |
| 1140 TestLoopbackCall(config); | 1167 TestLoopbackCall(config); |
| 1141 } | 1168 } |
| 1142 | 1169 |
| 1143 void VerifyTransportType(const std::string& content_name, | 1170 void VerifyTransportType(const std::string& content_name, |
| 1144 cricket::TransportProtocol protocol) { | 1171 cricket::TransportProtocol protocol) { |
| 1145 const cricket::Transport* transport = session_->GetTransport(content_name); | 1172 // TODO(deadbeef): this gets deleted with Peter's CL |
| 1146 ASSERT_TRUE(transport != NULL); | 1173 // const cricket::Transport* transport = session_->GetTransport(content_name); |
| 1147 EXPECT_EQ(protocol, transport->protocol()); | 1174 // ASSERT_TRUE(transport != NULL); |
| 1175 // EXPECT_EQ(protocol, transport->protocol()); |
| 1148 } | 1176 } |
| 1149 | 1177 |
| 1150 // Adds CN codecs to FakeMediaEngine and MediaDescriptionFactory. | 1178 // Adds CN codecs to FakeMediaEngine and MediaDescriptionFactory. |
| 1151 void AddCNCodecs() { | 1179 void AddCNCodecs() { |
| 1152 const cricket::AudioCodec kCNCodec1(102, "CN", 8000, 0, 1, 0); | 1180 const cricket::AudioCodec kCNCodec1(102, "CN", 8000, 0, 1, 0); |
| 1153 const cricket::AudioCodec kCNCodec2(103, "CN", 16000, 0, 1, 0); | 1181 const cricket::AudioCodec kCNCodec2(103, "CN", 16000, 0, 1, 0); |
| 1154 | 1182 |
| 1155 // Add kCNCodec for dtmf test. | 1183 // Add kCNCodec for dtmf test. |
| 1156 std::vector<cricket::AudioCodec> codecs = media_engine_->audio_codecs();; | 1184 std::vector<cricket::AudioCodec> codecs = media_engine_->audio_codecs();; |
| 1157 codecs.push_back(kCNCodec1); | 1185 codecs.push_back(kCNCodec1); |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 // the offer and answer. | 1688 // the offer and answer. |
| 1661 SetRemoteDescriptionWithoutError(offer); | 1689 SetRemoteDescriptionWithoutError(offer); |
| 1662 SetLocalDescriptionAnswerExpectError( | 1690 SetLocalDescriptionAnswerExpectError( |
| 1663 kSdpWithoutDtlsFingerprint, answer); | 1691 kSdpWithoutDtlsFingerprint, answer); |
| 1664 } | 1692 } |
| 1665 | 1693 |
| 1666 // Test that we return a failure when applying a remote answer that doesn't have | 1694 // Test that we return a failure when applying a remote answer that doesn't have |
| 1667 // a DTLS fingerprint when DTLS is required. | 1695 // a DTLS fingerprint when DTLS is required. |
| 1668 TEST_F(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { | 1696 TEST_F(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { |
| 1669 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1697 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 1670 // Enable both SDES and DTLS, so that offer won't be outright rejected as a | |
| 1671 // result of using the "UDP/TLS/RTP/SAVPF" profile. | |
| 1672 InitWithDtls(); | 1698 InitWithDtls(); |
| 1673 session_->SetSdesPolicy(cricket::SEC_ENABLED); | |
| 1674 SessionDescriptionInterface* offer = CreateOffer(); | 1699 SessionDescriptionInterface* offer = CreateOffer(); |
| 1675 cricket::MediaSessionOptions options; | 1700 cricket::MediaSessionOptions options; |
| 1676 options.recv_video = true; | 1701 options.recv_video = true; |
| 1702 rtc::scoped_ptr<SessionDescriptionInterface> temp_offer( |
| 1703 CreateRemoteOffer(options, cricket::SEC_ENABLED)); |
| 1677 JsepSessionDescription* answer = | 1704 JsepSessionDescription* answer = |
| 1678 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED); | 1705 CreateRemoteAnswer(temp_offer.get(), options, cricket::SEC_ENABLED); |
| 1679 | 1706 |
| 1680 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1707 // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1681 // the offer and answer. | 1708 // the offer and answer. |
| 1682 SetLocalDescriptionWithoutError(offer); | 1709 SetLocalDescriptionWithoutError(offer); |
| 1683 SetRemoteDescriptionAnswerExpectError( | 1710 SetRemoteDescriptionAnswerExpectError( |
| 1684 kSdpWithoutDtlsFingerprint, answer); | 1711 kSdpWithoutDtlsFingerprint, answer); |
| 1685 } | 1712 } |
| 1686 | 1713 |
| 1687 // Test that we create a local offer without SDES or DTLS and accept a remote | 1714 // Test that we create a local offer without SDES or DTLS and accept a remote |
| 1688 // answer without SDES or DTLS when encryption is disabled. | 1715 // answer without SDES or DTLS when encryption is disabled. |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1970 EXPECT_EQ(0u, candidates->count()); | 1997 EXPECT_EQ(0u, candidates->count()); |
| 1971 | 1998 |
| 1972 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); | 1999 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 1973 | 2000 |
| 1974 local_desc = session_->local_description(); | 2001 local_desc = session_->local_description(); |
| 1975 candidates = local_desc->candidates(kMediaContentIndex0); | 2002 candidates = local_desc->candidates(kMediaContentIndex0); |
| 1976 ASSERT_TRUE(candidates != NULL); | 2003 ASSERT_TRUE(candidates != NULL); |
| 1977 EXPECT_LT(0u, candidates->count()); | 2004 EXPECT_LT(0u, candidates->count()); |
| 1978 candidates = local_desc->candidates(1); | 2005 candidates = local_desc->candidates(1); |
| 1979 ASSERT_TRUE(candidates != NULL); | 2006 ASSERT_TRUE(candidates != NULL); |
| 1980 EXPECT_LT(0u, candidates->count()); | 2007 EXPECT_EQ(0u, candidates->count()); |
| 1981 | 2008 |
| 1982 // Update the session descriptions. | 2009 // Update the session descriptions. |
| 1983 mediastream_signaling_.SendAudioVideoStream1(); | 2010 mediastream_signaling_.SendAudioVideoStream1(); |
| 1984 CreateAndSetRemoteOfferAndLocalAnswer(); | 2011 CreateAndSetRemoteOfferAndLocalAnswer(); |
| 1985 | 2012 |
| 1986 local_desc = session_->local_description(); | 2013 local_desc = session_->local_description(); |
| 1987 candidates = local_desc->candidates(kMediaContentIndex0); | 2014 candidates = local_desc->candidates(kMediaContentIndex0); |
| 1988 ASSERT_TRUE(candidates != NULL); | 2015 ASSERT_TRUE(candidates != NULL); |
| 1989 EXPECT_LT(0u, candidates->count()); | 2016 EXPECT_LT(0u, candidates->count()); |
| 1990 candidates = local_desc->candidates(1); | 2017 candidates = local_desc->candidates(1); |
| 1991 ASSERT_TRUE(candidates != NULL); | 2018 ASSERT_TRUE(candidates != NULL); |
| 1992 EXPECT_LT(0u, candidates->count()); | 2019 EXPECT_EQ(0u, candidates->count()); |
| 1993 } | 2020 } |
| 1994 | 2021 |
| 1995 // Test that we can set a remote session description with remote candidates. | 2022 // Test that we can set a remote session description with remote candidates. |
| 1996 TEST_F(WebRtcSessionTest, TestSetRemoteSessionDescriptionWithCandidates) { | 2023 TEST_F(WebRtcSessionTest, TestSetRemoteSessionDescriptionWithCandidates) { |
| 1997 Init(); | 2024 Init(); |
| 1998 | 2025 |
| 1999 cricket::Candidate candidate1; | 2026 cricket::Candidate candidate1; |
| 2000 candidate1.set_component(1); | 2027 candidate1.set_component(1); |
| 2001 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, | 2028 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, |
| 2002 candidate1); | 2029 candidate1); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2026 Init(); | 2053 Init(); |
| 2027 mediastream_signaling_.SendAudioVideoStream1(); | 2054 mediastream_signaling_.SendAudioVideoStream1(); |
| 2028 // Ice is started but candidates are not provided until SetLocalDescription | 2055 // Ice is started but candidates are not provided until SetLocalDescription |
| 2029 // is called. | 2056 // is called. |
| 2030 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); | 2057 EXPECT_EQ(0u, observer_.mline_0_candidates_.size()); |
| 2031 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); | 2058 EXPECT_EQ(0u, observer_.mline_1_candidates_.size()); |
| 2032 CreateAndSetRemoteOfferAndLocalAnswer(); | 2059 CreateAndSetRemoteOfferAndLocalAnswer(); |
| 2033 // Wait until at least one local candidate has been collected. | 2060 // Wait until at least one local candidate has been collected. |
| 2034 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), | 2061 EXPECT_TRUE_WAIT(0u < observer_.mline_0_candidates_.size(), |
| 2035 kIceCandidatesTimeout); | 2062 kIceCandidatesTimeout); |
| 2036 EXPECT_TRUE_WAIT(0u < observer_.mline_1_candidates_.size(), | |
| 2037 kIceCandidatesTimeout); | |
| 2038 | 2063 |
| 2039 rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); | 2064 rtc::scoped_ptr<SessionDescriptionInterface> local_offer(CreateOffer()); |
| 2040 | 2065 |
| 2041 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); | 2066 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex0) != NULL); |
| 2042 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); | 2067 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex0)->count()); |
| 2043 ASSERT_TRUE(local_offer->candidates(kMediaContentIndex1) != NULL); | |
| 2044 EXPECT_LT(0u, local_offer->candidates(kMediaContentIndex1)->count()); | |
| 2045 | 2068 |
| 2046 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); | 2069 SessionDescriptionInterface* remote_offer(CreateRemoteOffer()); |
| 2047 SetRemoteDescriptionWithoutError(remote_offer); | 2070 SetRemoteDescriptionWithoutError(remote_offer); |
| 2048 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 2071 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 2049 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); | 2072 ASSERT_TRUE(answer->candidates(kMediaContentIndex0) != NULL); |
| 2050 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); | 2073 EXPECT_LT(0u, answer->candidates(kMediaContentIndex0)->count()); |
| 2051 ASSERT_TRUE(answer->candidates(kMediaContentIndex1) != NULL); | |
| 2052 EXPECT_LT(0u, answer->candidates(kMediaContentIndex1)->count()); | |
| 2053 SetLocalDescriptionWithoutError(answer); | 2074 SetLocalDescriptionWithoutError(answer); |
| 2054 } | 2075 } |
| 2055 | 2076 |
| 2056 // Verifies TransportProxy and media channels are created with content names | 2077 // Verifies TransportProxy and media channels are created with content names |
| 2057 // present in the SessionDescription. | 2078 // present in the SessionDescription. |
| 2058 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { | 2079 TEST_F(WebRtcSessionTest, TestChannelCreationsWithContentNames) { |
| 2059 Init(); | 2080 Init(); |
| 2060 mediastream_signaling_.SendAudioVideoStream1(); | 2081 mediastream_signaling_.SendAudioVideoStream1(); |
| 2061 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2082 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2062 | 2083 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2084 | 2105 |
| 2085 SessionDescriptionInterface* modified_offer = | 2106 SessionDescriptionInterface* modified_offer = |
| 2086 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2107 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2087 | 2108 |
| 2088 SetRemoteDescriptionWithoutError(modified_offer); | 2109 SetRemoteDescriptionWithoutError(modified_offer); |
| 2089 | 2110 |
| 2090 SessionDescriptionInterface* answer = | 2111 SessionDescriptionInterface* answer = |
| 2091 CreateAnswer(NULL); | 2112 CreateAnswer(NULL); |
| 2092 SetLocalDescriptionWithoutError(answer); | 2113 SetLocalDescriptionWithoutError(answer); |
| 2093 | 2114 |
| 2094 EXPECT_TRUE(session_->GetTransportProxy("audio_content_name") != NULL); | 2115 cricket::TransportChannel* voice_transport_channel = |
| 2095 EXPECT_TRUE(session_->GetTransportProxy("video_content_name") != NULL); | 2116 session_->voice_rtp_transport_channel(); |
| 2117 EXPECT_TRUE(voice_transport_channel != NULL); |
| 2118 EXPECT_EQ(voice_transport_channel->content_name(), "audio_content_name"); |
| 2119 cricket::TransportChannel* video_transport_channel = |
| 2120 session_->video_rtp_transport_channel(); |
| 2121 EXPECT_TRUE(video_transport_channel != NULL); |
| 2122 EXPECT_EQ(video_transport_channel->content_name(), "video_content_name"); |
| 2096 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); | 2123 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); |
| 2097 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); | 2124 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); |
| 2098 } | 2125 } |
| 2099 | 2126 |
| 2100 // Test that an offer contains the correct media content descriptions based on | 2127 // Test that an offer contains the correct media content descriptions based on |
| 2101 // the send streams when no constraints have been set. | 2128 // the send streams when no constraints have been set. |
| 2102 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { | 2129 TEST_F(WebRtcSessionTest, CreateOfferWithoutConstraintsOrStreams) { |
| 2103 Init(); | 2130 Init(); |
| 2104 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 2131 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 2105 | 2132 |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2647 | 2674 |
| 2648 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2675 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2649 options.use_rtp_mux = true; | 2676 options.use_rtp_mux = true; |
| 2650 | 2677 |
| 2651 SessionDescriptionInterface* offer = CreateRemoteOffer(); | 2678 SessionDescriptionInterface* offer = CreateRemoteOffer(); |
| 2652 SetRemoteDescriptionWithoutError(offer); | 2679 SetRemoteDescriptionWithoutError(offer); |
| 2653 | 2680 |
| 2654 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 2681 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 2655 SetLocalDescriptionWithoutError(answer); | 2682 SetLocalDescriptionWithoutError(answer); |
| 2656 | 2683 |
| 2657 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2684 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2658 session_->GetTransportProxy("video")->impl()); | 2685 session_->video_rtp_transport_channel()); |
| 2659 | 2686 |
| 2660 cricket::Transport* t = session_->GetTransport("audio"); | 2687 cricket::BaseChannel* voice_channel = session_->voice_channel(); |
| 2688 ASSERT(voice_channel != NULL); |
| 2661 | 2689 |
| 2662 // Checks if one of the transport channels contains a connection using a given | 2690 // Checks if one of the transport channels contains a connection using a given |
| 2663 // port. | 2691 // port. |
| 2664 auto connection_with_remote_port = [t](int port) { | 2692 auto connection_with_remote_port = [this, voice_channel](int port) { |
| 2665 cricket::TransportStats stats; | 2693 cricket::SessionStats stats; |
| 2666 t->GetStats(&stats); | 2694 session_->GetChannelTransportStats(voice_channel, &stats); |
| 2667 for (auto& chan_stat : stats.channel_stats) { | 2695 for (auto& kv : stats.transport_stats) { |
| 2668 for (auto& conn_info : chan_stat.connection_infos) { | 2696 for (auto& chan_stat : kv.second.channel_stats) { |
| 2669 if (conn_info.remote_candidate.address().port() == port) { | 2697 for (auto& conn_info : chan_stat.connection_infos) { |
| 2670 return true; | 2698 if (conn_info.remote_candidate.address().port() == port) { |
| 2699 return true; |
| 2700 } |
| 2671 } | 2701 } |
| 2672 } | 2702 } |
| 2673 } | 2703 } |
| 2674 return false; | 2704 return false; |
| 2675 }; | 2705 }; |
| 2676 | 2706 |
| 2677 EXPECT_FALSE(connection_with_remote_port(5000)); | 2707 EXPECT_FALSE(connection_with_remote_port(5000)); |
| 2678 EXPECT_FALSE(connection_with_remote_port(5001)); | 2708 EXPECT_FALSE(connection_with_remote_port(5001)); |
| 2679 EXPECT_FALSE(connection_with_remote_port(6000)); | 2709 EXPECT_FALSE(connection_with_remote_port(6000)); |
| 2680 | 2710 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2713 | 2743 |
| 2714 EXPECT_TRUE_WAIT(connection_with_remote_port(5000), 1000); | 2744 EXPECT_TRUE_WAIT(connection_with_remote_port(5000), 1000); |
| 2715 EXPECT_TRUE_WAIT(connection_with_remote_port(5001), 1000); | 2745 EXPECT_TRUE_WAIT(connection_with_remote_port(5001), 1000); |
| 2716 | 2746 |
| 2717 // No need here for a _WAIT check since we are checking that state hasn't | 2747 // No need here for a _WAIT check since we are checking that state hasn't |
| 2718 // changed: if this is false we would be doing waits for nothing and if this | 2748 // changed: if this is false we would be doing waits for nothing and if this |
| 2719 // is true then there will be no messages processed anyways. | 2749 // is true then there will be no messages processed anyways. |
| 2720 EXPECT_FALSE(connection_with_remote_port(6000)); | 2750 EXPECT_FALSE(connection_with_remote_port(6000)); |
| 2721 } | 2751 } |
| 2722 | 2752 |
| 2723 // kBundlePolicyBalanced bundle policy and answer contains BUNDLE. | 2753 // kBundlePolicyBalanced BUNDLE policy and answer contains BUNDLE. |
| 2724 TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) { | 2754 TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) { |
| 2725 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 2755 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 2726 mediastream_signaling_.SendAudioVideoStream1(); | 2756 mediastream_signaling_.SendAudioVideoStream1(); |
| 2727 | 2757 |
| 2728 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2758 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2729 options.use_rtp_mux = true; | 2759 options.use_rtp_mux = true; |
| 2730 | 2760 |
| 2731 SessionDescriptionInterface* offer = CreateOffer(options); | 2761 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2732 SetLocalDescriptionWithoutError(offer); | 2762 SetLocalDescriptionWithoutError(offer); |
| 2733 | 2763 |
| 2734 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 2764 EXPECT_NE(session_->voice_channel()->transport_channel(), |
| 2735 session_->GetTransportProxy("video")->impl()); | 2765 session_->video_channel()->transport_channel()); |
| 2736 | 2766 |
| 2737 mediastream_signaling_.SendAudioVideoStream2(); | 2767 mediastream_signaling_.SendAudioVideoStream2(); |
| 2738 SessionDescriptionInterface* answer = | 2768 SessionDescriptionInterface* answer = |
| 2739 CreateRemoteAnswer(session_->local_description()); | 2769 CreateRemoteAnswer(session_->local_description()); |
| 2740 SetRemoteDescriptionWithoutError(answer); | 2770 SetRemoteDescriptionWithoutError(answer); |
| 2741 | 2771 |
| 2742 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2772 EXPECT_EQ(session_->voice_channel()->transport_channel(), |
| 2743 session_->GetTransportProxy("video")->impl()); | 2773 session_->video_channel()->transport_channel()); |
| 2744 } | 2774 } |
| 2745 | 2775 |
| 2746 // kBundlePolicyBalanced bundle policy but no BUNDLE in the answer. | 2776 // kBundlePolicyBalanced BUNDLE policy but no BUNDLE in the answer. |
| 2747 TEST_F(WebRtcSessionTest, TestBalancedNoBundleInAnswer) { | 2777 TEST_F(WebRtcSessionTest, TestBalancedNoBundleInAnswer) { |
| 2748 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); | 2778 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced); |
| 2749 mediastream_signaling_.SendAudioVideoStream1(); | 2779 mediastream_signaling_.SendAudioVideoStream1(); |
| 2750 | 2780 |
| 2751 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2781 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2752 options.use_rtp_mux = true; | 2782 options.use_rtp_mux = true; |
| 2753 | 2783 |
| 2754 SessionDescriptionInterface* offer = CreateOffer(options); | 2784 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2755 SetLocalDescriptionWithoutError(offer); | 2785 SetLocalDescriptionWithoutError(offer); |
| 2756 | 2786 |
| 2757 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 2787 EXPECT_NE(session_->voice_channel()->transport_channel(), |
| 2758 session_->GetTransportProxy("video")->impl()); | 2788 session_->video_channel()->transport_channel()); |
| 2759 | 2789 |
| 2760 mediastream_signaling_.SendAudioVideoStream2(); | 2790 mediastream_signaling_.SendAudioVideoStream2(); |
| 2761 | 2791 |
| 2762 // Remove BUNDLE from the answer. | 2792 // Remove BUNDLE from the answer. |
| 2763 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 2793 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 2764 CreateRemoteAnswer(session_->local_description())); | 2794 CreateRemoteAnswer(session_->local_description())); |
| 2765 cricket::SessionDescription* answer_copy = answer->description()->Copy(); | 2795 cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
| 2766 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); | 2796 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); |
| 2767 JsepSessionDescription* modified_answer = | 2797 JsepSessionDescription* modified_answer = |
| 2768 new JsepSessionDescription(JsepSessionDescription::kAnswer); | 2798 new JsepSessionDescription(JsepSessionDescription::kAnswer); |
| 2769 modified_answer->Initialize(answer_copy, "1", "1"); | 2799 modified_answer->Initialize(answer_copy, "1", "1"); |
| 2770 SetRemoteDescriptionWithoutError(modified_answer); // | 2800 SetRemoteDescriptionWithoutError(modified_answer); // |
| 2771 | 2801 |
| 2772 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 2802 EXPECT_NE(session_->voice_channel()->transport_channel(), |
| 2773 session_->GetTransportProxy("video")->impl()); | 2803 session_->video_channel()->transport_channel()); |
| 2774 } | 2804 } |
| 2775 | 2805 |
| 2776 // kBundlePolicyMaxBundle policy with BUNDLE in the answer. | 2806 // kBundlePolicyMaxBundle policy with BUNDLE in the answer. |
| 2777 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInAnswer) { | 2807 TEST_F(WebRtcSessionTest, TestMaxBundleBundleInAnswer) { |
| 2778 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); | 2808 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2779 mediastream_signaling_.SendAudioVideoStream1(); | 2809 mediastream_signaling_.SendAudioVideoStream1(); |
| 2780 | 2810 |
| 2781 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2811 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2782 options.use_rtp_mux = true; | 2812 options.use_rtp_mux = true; |
| 2783 | 2813 |
| 2784 SessionDescriptionInterface* offer = CreateOffer(options); | 2814 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2785 SetLocalDescriptionWithoutError(offer); | 2815 SetLocalDescriptionWithoutError(offer); |
| 2786 | 2816 |
| 2787 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2817 EXPECT_EQ(session_->voice_channel()->transport_channel(), |
| 2788 session_->GetTransportProxy("video")->impl()); | 2818 session_->video_channel()->transport_channel()); |
| 2789 | 2819 |
| 2790 mediastream_signaling_.SendAudioVideoStream2(); | 2820 mediastream_signaling_.SendAudioVideoStream2(); |
| 2791 SessionDescriptionInterface* answer = | 2821 SessionDescriptionInterface* answer = |
| 2792 CreateRemoteAnswer(session_->local_description()); | 2822 CreateRemoteAnswer(session_->local_description()); |
| 2793 SetRemoteDescriptionWithoutError(answer); | 2823 SetRemoteDescriptionWithoutError(answer); |
| 2794 | 2824 |
| 2795 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2825 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2796 session_->GetTransportProxy("video")->impl()); | 2826 session_->video_rtp_transport_channel()); |
| 2827 } |
| 2828 |
| 2829 // kBundlePolicyMaxBundle policy with BUNDLE in the answer, but no |
| 2830 // audio content in the answer. |
| 2831 TEST_F(WebRtcSessionTest, TestMaxBundleRejectAudio) { |
| 2832 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2833 mediastream_signaling_.SendAudioVideoStream1(); |
| 2834 |
| 2835 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2836 options.use_rtp_mux = true; |
| 2837 |
| 2838 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2839 SetLocalDescriptionWithoutError(offer); |
| 2840 |
| 2841 std::string voice_content_name = |
| 2842 session_->voice_channel()->content_name(); |
| 2843 std::string video_content_name = |
| 2844 session_->video_channel()->content_name(); |
| 2845 EXPECT_EQ(session_->voice_channel()->transport_channel(), |
| 2846 session_->video_channel()->transport_channel()); |
| 2847 |
| 2848 mediastream_signaling_.SendAudioVideoStream2(); |
| 2849 cricket::MediaSessionOptions recv_options; |
| 2850 recv_options.recv_audio = false; |
| 2851 recv_options.recv_video = true; |
| 2852 SessionDescriptionInterface* answer = |
| 2853 CreateRemoteAnswer(session_->local_description(), recv_options); |
| 2854 SetRemoteDescriptionWithoutError(answer); |
| 2855 |
| 2856 EXPECT_TRUE(NULL == session_->voice_channel()); |
| 2857 EXPECT_TRUE(NULL != session_->video_channel()->transport_channel()); |
| 2858 |
| 2859 session_->Terminate(); |
| 2860 EXPECT_TRUE(NULL == session_->voice_rtp_transport_channel()); |
| 2861 EXPECT_TRUE(NULL == session_->voice_rtcp_transport_channel()); |
| 2862 EXPECT_TRUE(NULL == session_->video_rtp_transport_channel()); |
| 2863 EXPECT_TRUE(NULL == session_->video_rtcp_transport_channel()); |
| 2797 } | 2864 } |
| 2798 | 2865 |
| 2799 // kBundlePolicyMaxBundle policy but no BUNDLE in the answer. | 2866 // kBundlePolicyMaxBundle policy but no BUNDLE in the answer. |
| 2800 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) { | 2867 TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) { |
| 2801 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); | 2868 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2802 mediastream_signaling_.SendAudioVideoStream1(); | 2869 mediastream_signaling_.SendAudioVideoStream1(); |
| 2803 | 2870 |
| 2804 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2871 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2805 options.use_rtp_mux = true; | 2872 options.use_rtp_mux = true; |
| 2806 | 2873 |
| 2807 SessionDescriptionInterface* offer = CreateOffer(options); | 2874 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2808 SetLocalDescriptionWithoutError(offer); | 2875 SetLocalDescriptionWithoutError(offer); |
| 2809 | 2876 |
| 2810 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2877 EXPECT_EQ(session_->voice_channel()->transport_channel(), |
| 2811 session_->GetTransportProxy("video")->impl()); | 2878 session_->video_channel()->transport_channel()); |
| 2812 | 2879 |
| 2813 mediastream_signaling_.SendAudioVideoStream2(); | 2880 mediastream_signaling_.SendAudioVideoStream2(); |
| 2814 | 2881 |
| 2815 // Remove BUNDLE from the answer. | 2882 // Remove BUNDLE from the answer. |
| 2816 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 2883 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 2817 CreateRemoteAnswer(session_->local_description())); | 2884 CreateRemoteAnswer(session_->local_description())); |
| 2818 cricket::SessionDescription* answer_copy = answer->description()->Copy(); | 2885 cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
| 2819 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); | 2886 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); |
| 2820 JsepSessionDescription* modified_answer = | 2887 JsepSessionDescription* modified_answer = |
| 2821 new JsepSessionDescription(JsepSessionDescription::kAnswer); | 2888 new JsepSessionDescription(JsepSessionDescription::kAnswer); |
| 2822 modified_answer->Initialize(answer_copy, "1", "1"); | 2889 modified_answer->Initialize(answer_copy, "1", "1"); |
| 2823 SetRemoteDescriptionWithoutError(modified_answer); | 2890 SetRemoteDescriptionWithoutError(modified_answer); |
| 2824 | 2891 |
| 2825 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2892 EXPECT_EQ(session_->voice_channel()->transport_channel(), |
| 2826 session_->GetTransportProxy("video")->impl()); | 2893 session_->video_channel()->transport_channel()); |
| 2827 } | 2894 } |
| 2828 | 2895 |
| 2829 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. | 2896 // kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE. |
| 2830 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { | 2897 TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) { |
| 2831 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); | 2898 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); |
| 2832 mediastream_signaling_.SendAudioVideoStream1(); | 2899 mediastream_signaling_.SendAudioVideoStream1(); |
| 2833 | 2900 |
| 2834 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2901 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2835 options.use_rtp_mux = true; | 2902 options.use_rtp_mux = true; |
| 2836 | 2903 |
| 2837 SessionDescriptionInterface* offer = CreateOffer(options); | 2904 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2838 SetLocalDescriptionWithoutError(offer); | 2905 SetLocalDescriptionWithoutError(offer); |
| 2839 | 2906 |
| 2840 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 2907 EXPECT_NE(session_->voice_channel()->transport_channel(), |
| 2841 session_->GetTransportProxy("video")->impl()); | 2908 session_->video_channel()->transport_channel()); |
| 2842 | 2909 |
| 2843 mediastream_signaling_.SendAudioVideoStream2(); | 2910 mediastream_signaling_.SendAudioVideoStream2(); |
| 2844 SessionDescriptionInterface* answer = | 2911 SessionDescriptionInterface* answer = |
| 2845 CreateRemoteAnswer(session_->local_description()); | 2912 CreateRemoteAnswer(session_->local_description()); |
| 2846 SetRemoteDescriptionWithoutError(answer); | 2913 SetRemoteDescriptionWithoutError(answer); |
| 2847 | 2914 |
| 2848 // This should lead to an audio-only call but isn't implemented | 2915 // This should lead to an audio-only call but isn't implemented |
| 2849 // correctly yet. | 2916 // correctly yet. |
| 2850 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2917 EXPECT_EQ(session_->voice_channel()->transport_channel(), |
| 2851 session_->GetTransportProxy("video")->impl()); | 2918 session_->video_channel()->transport_channel()); |
| 2852 } | 2919 } |
| 2853 | 2920 |
| 2854 // kBundlePolicyMaxCompat bundle policy but no BUNDLE in the answer. | 2921 // kBundlePolicyMaxCompat BUNDLE policy but no BUNDLE in the answer. |
| 2855 TEST_F(WebRtcSessionTest, TestMaxCompatNoBundleInAnswer) { | 2922 TEST_F(WebRtcSessionTest, TestMaxCompatNoBundleInAnswer) { |
| 2856 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); | 2923 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat); |
| 2857 mediastream_signaling_.SendAudioVideoStream1(); | 2924 mediastream_signaling_.SendAudioVideoStream1(); |
| 2858 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2925 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2859 options.use_rtp_mux = true; | 2926 options.use_rtp_mux = true; |
| 2860 | 2927 |
| 2861 SessionDescriptionInterface* offer = CreateOffer(options); | 2928 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2862 SetLocalDescriptionWithoutError(offer); | 2929 SetLocalDescriptionWithoutError(offer); |
| 2863 | 2930 |
| 2864 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 2931 EXPECT_NE(session_->voice_channel()->transport_channel(), |
| 2865 session_->GetTransportProxy("video")->impl()); | 2932 session_->video_channel()->transport_channel()); |
| 2866 | 2933 |
| 2867 mediastream_signaling_.SendAudioVideoStream2(); | 2934 mediastream_signaling_.SendAudioVideoStream2(); |
| 2868 | 2935 |
| 2869 // Remove BUNDLE from the answer. | 2936 // Remove BUNDLE from the answer. |
| 2870 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 2937 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 2871 CreateRemoteAnswer(session_->local_description())); | 2938 CreateRemoteAnswer(session_->local_description())); |
| 2872 cricket::SessionDescription* answer_copy = answer->description()->Copy(); | 2939 cricket::SessionDescription* answer_copy = answer->description()->Copy(); |
| 2873 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); | 2940 answer_copy->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE); |
| 2874 JsepSessionDescription* modified_answer = | 2941 JsepSessionDescription* modified_answer = |
| 2875 new JsepSessionDescription(JsepSessionDescription::kAnswer); | 2942 new JsepSessionDescription(JsepSessionDescription::kAnswer); |
| 2876 modified_answer->Initialize(answer_copy, "1", "1"); | 2943 modified_answer->Initialize(answer_copy, "1", "1"); |
| 2877 SetRemoteDescriptionWithoutError(modified_answer); // | 2944 SetRemoteDescriptionWithoutError(modified_answer); // |
| 2878 | 2945 |
| 2879 EXPECT_NE(session_->GetTransportProxy("audio")->impl(), | 2946 EXPECT_NE(session_->voice_channel()->transport_channel(), |
| 2880 session_->GetTransportProxy("video")->impl()); | 2947 session_->video_channel()->transport_channel()); |
| 2881 } | 2948 } |
| 2882 | 2949 |
| 2883 // kBundlePolicyMaxbundle and then we call SetRemoteDescription first. | 2950 // kBundlePolicyMaxbundle and then we call SetRemoteDescription first. |
| 2884 TEST_F(WebRtcSessionTest, TestMaxBundleWithSetRemoteDescriptionFirst) { | 2951 TEST_F(WebRtcSessionTest, TestMaxBundleWithSetRemoteDescriptionFirst) { |
| 2885 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); | 2952 InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle); |
| 2886 mediastream_signaling_.SendAudioVideoStream1(); | 2953 mediastream_signaling_.SendAudioVideoStream1(); |
| 2887 | 2954 |
| 2888 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2955 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2889 options.use_rtp_mux = true; | 2956 options.use_rtp_mux = true; |
| 2890 | 2957 |
| 2891 SessionDescriptionInterface* offer = CreateOffer(options); | 2958 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2892 SetRemoteDescriptionWithoutError(offer); | 2959 SetRemoteDescriptionWithoutError(offer); |
| 2893 | 2960 |
| 2894 EXPECT_EQ(session_->GetTransportProxy("audio")->impl(), | 2961 EXPECT_EQ(session_->voice_rtp_transport_channel(), |
| 2895 session_->GetTransportProxy("video")->impl()); | 2962 session_->video_rtp_transport_channel()); |
| 2896 } | 2963 } |
| 2897 | 2964 |
| 2898 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { | 2965 TEST_F(WebRtcSessionTest, TestRequireRtcpMux) { |
| 2899 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); | 2966 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyRequire); |
| 2900 mediastream_signaling_.SendAudioVideoStream1(); | 2967 mediastream_signaling_.SendAudioVideoStream1(); |
| 2901 | 2968 |
| 2902 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2969 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2903 SessionDescriptionInterface* offer = CreateOffer(options); | 2970 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2904 SetLocalDescriptionWithoutError(offer); | 2971 SetLocalDescriptionWithoutError(offer); |
| 2905 | 2972 |
| 2906 EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); | 2973 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); |
| 2907 EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); | 2974 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); |
| 2908 | 2975 |
| 2909 mediastream_signaling_.SendAudioVideoStream2(); | 2976 mediastream_signaling_.SendAudioVideoStream2(); |
| 2910 SessionDescriptionInterface* answer = | 2977 SessionDescriptionInterface* answer = |
| 2911 CreateRemoteAnswer(session_->local_description()); | 2978 CreateRemoteAnswer(session_->local_description()); |
| 2912 SetRemoteDescriptionWithoutError(answer); | 2979 SetRemoteDescriptionWithoutError(answer); |
| 2913 | 2980 |
| 2914 EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); | 2981 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); |
| 2915 EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); | 2982 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); |
| 2916 } | 2983 } |
| 2917 | 2984 |
| 2918 TEST_F(WebRtcSessionTest, TestNegotiateRtcpMux) { | 2985 TEST_F(WebRtcSessionTest, TestNegotiateRtcpMux) { |
| 2919 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyNegotiate); | 2986 InitWithRtcpMuxPolicy(PeerConnectionInterface::kRtcpMuxPolicyNegotiate); |
| 2920 mediastream_signaling_.SendAudioVideoStream1(); | 2987 mediastream_signaling_.SendAudioVideoStream1(); |
| 2921 | 2988 |
| 2922 PeerConnectionInterface::RTCOfferAnswerOptions options; | 2989 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2923 SessionDescriptionInterface* offer = CreateOffer(options); | 2990 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2924 SetLocalDescriptionWithoutError(offer); | 2991 SetLocalDescriptionWithoutError(offer); |
| 2925 | 2992 |
| 2926 EXPECT_TRUE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); | 2993 EXPECT_TRUE(session_->voice_rtcp_transport_channel() != NULL); |
| 2927 EXPECT_TRUE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); | 2994 EXPECT_TRUE(session_->video_rtcp_transport_channel() != NULL); |
| 2928 | 2995 |
| 2929 mediastream_signaling_.SendAudioVideoStream2(); | 2996 mediastream_signaling_.SendAudioVideoStream2(); |
| 2930 SessionDescriptionInterface* answer = | 2997 SessionDescriptionInterface* answer = |
| 2931 CreateRemoteAnswer(session_->local_description()); | 2998 CreateRemoteAnswer(session_->local_description()); |
| 2932 SetRemoteDescriptionWithoutError(answer); | 2999 SetRemoteDescriptionWithoutError(answer); |
| 2933 | 3000 |
| 2934 EXPECT_FALSE(session_->GetTransportProxy("audio")->impl()->HasChannel(2)); | 3001 EXPECT_TRUE(session_->voice_rtcp_transport_channel() == NULL); |
| 2935 EXPECT_FALSE(session_->GetTransportProxy("video")->impl()->HasChannel(2)); | 3002 EXPECT_TRUE(session_->video_rtcp_transport_channel() == NULL); |
| 2936 } | 3003 } |
| 2937 | 3004 |
| 2938 // This test verifies that SetLocalDescription and SetRemoteDescription fails | 3005 // This test verifies that SetLocalDescription and SetRemoteDescription fails |
| 2939 // if BUNDLE is enabled but rtcp-mux is disabled in m-lines. | 3006 // if BUNDLE is enabled but rtcp-mux is disabled in m-lines. |
| 2940 TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) { | 3007 TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) { |
| 2941 Init(); | 3008 Init(); |
| 2942 mediastream_signaling_.SendAudioVideoStream1(); | 3009 mediastream_signaling_.SendAudioVideoStream1(); |
| 2943 | 3010 |
| 2944 PeerConnectionInterface::RTCOfferAnswerOptions options; | 3011 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 2945 options.use_rtp_mux = true; | 3012 options.use_rtp_mux = true; |
| 2946 | 3013 |
| 2947 SessionDescriptionInterface* offer = CreateOffer(options); | 3014 SessionDescriptionInterface* offer = CreateOffer(options); |
| 2948 std::string offer_str; | 3015 std::string offer_str; |
| 2949 offer->ToString(&offer_str); | 3016 offer->ToString(&offer_str); |
| 2950 // Disable rtcp-mux | 3017 // Disable rtcp-mux |
| 2951 const std::string rtcp_mux = "rtcp-mux"; | 3018 const std::string rtcp_mux = "rtcp-mux"; |
| 2952 const std::string xrtcp_mux = "xrtcp-mux"; | 3019 const std::string xrtcp_mux = "xrtcp-mux"; |
| 2953 rtc::replace_substrs(rtcp_mux.c_str(), rtcp_mux.length(), | 3020 rtc::replace_substrs(rtcp_mux.c_str(), rtcp_mux.length(), |
| 2954 xrtcp_mux.c_str(), xrtcp_mux.length(), | 3021 xrtcp_mux.c_str(), xrtcp_mux.length(), |
| 2955 &offer_str); | 3022 &offer_str); |
| 2956 JsepSessionDescription *local_offer = | 3023 JsepSessionDescription* local_offer = |
| 2957 new JsepSessionDescription(JsepSessionDescription::kOffer); | 3024 new JsepSessionDescription(JsepSessionDescription::kOffer); |
| 2958 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL)); | 3025 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL)); |
| 2959 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer); | 3026 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer); |
| 2960 JsepSessionDescription *remote_offer = | 3027 JsepSessionDescription* remote_offer = |
| 2961 new JsepSessionDescription(JsepSessionDescription::kOffer); | 3028 new JsepSessionDescription(JsepSessionDescription::kOffer); |
| 2962 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL)); | 3029 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL)); |
| 2963 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer); | 3030 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer); |
| 2964 // Trying unmodified SDP. | 3031 // Trying unmodified SDP. |
| 2965 SetLocalDescriptionWithoutError(offer); | 3032 SetLocalDescriptionWithoutError(offer); |
| 2966 } | 3033 } |
| 2967 | 3034 |
| 2968 TEST_F(WebRtcSessionTest, SetAudioPlayout) { | 3035 TEST_F(WebRtcSessionTest, SetAudioPlayout) { |
| 2969 Init(); | 3036 Init(); |
| 2970 mediastream_signaling_.SendAudioVideoStream1(); | 3037 mediastream_signaling_.SendAudioVideoStream1(); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3161 // if ICE RFC5245 is supported in answer. | 3228 // if ICE RFC5245 is supported in answer. |
| 3162 TEST_F(WebRtcSessionTest, TestInitiatorIceInAnswer) { | 3229 TEST_F(WebRtcSessionTest, TestInitiatorIceInAnswer) { |
| 3163 Init(); | 3230 Init(); |
| 3164 mediastream_signaling_.SendAudioVideoStream1(); | 3231 mediastream_signaling_.SendAudioVideoStream1(); |
| 3165 SessionDescriptionInterface* offer = CreateOffer(); | 3232 SessionDescriptionInterface* offer = CreateOffer(); |
| 3166 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 3233 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 3167 SetLocalDescriptionWithoutError(offer); | 3234 SetLocalDescriptionWithoutError(offer); |
| 3168 | 3235 |
| 3169 SetRemoteDescriptionWithoutError(answer); | 3236 SetRemoteDescriptionWithoutError(answer); |
| 3170 VerifyTransportType("audio", cricket::ICEPROTO_RFC5245); | 3237 VerifyTransportType("audio", cricket::ICEPROTO_RFC5245); |
| 3171 VerifyTransportType("video", cricket::ICEPROTO_RFC5245); | |
| 3172 } | 3238 } |
| 3173 | 3239 |
| 3174 // This test verifies the ice protocol type at receiver side of the call if | 3240 // This test verifies the ice protocol type at receiver side of the call if |
| 3175 // receiver decides to use ice RFC 5245. | 3241 // receiver decides to use ice RFC 5245. |
| 3176 TEST_F(WebRtcSessionTest, TestReceiverIceInOffer) { | 3242 TEST_F(WebRtcSessionTest, TestReceiverIceInOffer) { |
| 3177 Init(); | 3243 Init(); |
| 3178 mediastream_signaling_.SendAudioVideoStream1(); | 3244 mediastream_signaling_.SendAudioVideoStream1(); |
| 3179 SessionDescriptionInterface* offer = CreateOffer(); | 3245 SessionDescriptionInterface* offer = CreateOffer(); |
| 3180 SetRemoteDescriptionWithoutError(offer); | 3246 SetRemoteDescriptionWithoutError(offer); |
| 3181 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 3247 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 3182 SetLocalDescriptionWithoutError(answer); | 3248 SetLocalDescriptionWithoutError(answer); |
| 3183 VerifyTransportType("audio", cricket::ICEPROTO_RFC5245); | 3249 VerifyTransportType("audio", cricket::ICEPROTO_RFC5245); |
| 3184 VerifyTransportType("video", cricket::ICEPROTO_RFC5245); | |
| 3185 } | 3250 } |
| 3186 | 3251 |
| 3187 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. | 3252 // Verifing local offer and remote answer have matching m-lines as per RFC 3264. |
| 3188 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { | 3253 TEST_F(WebRtcSessionTest, TestIncorrectMLinesInRemoteAnswer) { |
| 3189 Init(); | 3254 Init(); |
| 3190 mediastream_signaling_.SendAudioVideoStream1(); | 3255 mediastream_signaling_.SendAudioVideoStream1(); |
| 3191 SessionDescriptionInterface* offer = CreateOffer(); | 3256 SessionDescriptionInterface* offer = CreateOffer(); |
| 3192 SetLocalDescriptionWithoutError(offer); | 3257 SetLocalDescriptionWithoutError(offer); |
| 3193 rtc::scoped_ptr<SessionDescriptionInterface> answer( | 3258 rtc::scoped_ptr<SessionDescriptionInterface> answer( |
| 3194 CreateRemoteAnswer(session_->local_description())); | 3259 CreateRemoteAnswer(session_->local_description())); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3262 candidate.set_component(1); | 3327 candidate.set_component(1); |
| 3263 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, | 3328 JsepIceCandidate ice_candidate(kMediaContentName0, kMediaContentIndex0, |
| 3264 candidate); | 3329 candidate); |
| 3265 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); | 3330 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); |
| 3266 cricket::Candidate candidate1; | 3331 cricket::Candidate candidate1; |
| 3267 candidate1.set_component(1); | 3332 candidate1.set_component(1); |
| 3268 JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1, | 3333 JsepIceCandidate ice_candidate1(kMediaContentName1, kMediaContentIndex1, |
| 3269 candidate1); | 3334 candidate1); |
| 3270 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1)); | 3335 EXPECT_TRUE(offer->AddCandidate(&ice_candidate1)); |
| 3271 SetRemoteDescriptionWithoutError(offer); | 3336 SetRemoteDescriptionWithoutError(offer); |
| 3272 ASSERT_TRUE(session_->GetTransportProxy("audio") != NULL); | 3337 ASSERT_TRUE(session_->voice_rtp_transport_channel() != NULL); |
| 3273 ASSERT_TRUE(session_->GetTransportProxy("video") != NULL); | 3338 ASSERT_TRUE(session_->video_rtp_transport_channel() != NULL); |
| 3274 | 3339 |
| 3275 // Pump for 1 second and verify that no candidates are generated. | 3340 // Pump for 1 second and verify that no candidates are generated. |
| 3276 rtc::Thread::Current()->ProcessMessages(1000); | 3341 rtc::Thread::Current()->ProcessMessages(1000); |
| 3277 EXPECT_TRUE(observer_.mline_0_candidates_.empty()); | 3342 EXPECT_TRUE(observer_.mline_0_candidates_.empty()); |
| 3278 EXPECT_TRUE(observer_.mline_1_candidates_.empty()); | 3343 EXPECT_TRUE(observer_.mline_1_candidates_.empty()); |
| 3279 | 3344 |
| 3280 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 3345 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 3281 SetLocalDescriptionWithoutError(answer); | 3346 SetLocalDescriptionWithoutError(answer); |
| 3282 EXPECT_TRUE(session_->GetTransportProxy("audio")->negotiated()); | |
| 3283 EXPECT_TRUE(session_->GetTransportProxy("video")->negotiated()); | |
| 3284 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); | 3347 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); |
| 3285 } | 3348 } |
| 3286 | 3349 |
| 3287 // This test verifies that crypto parameter is updated in local session | 3350 // This test verifies that crypto parameter is updated in local session |
| 3288 // description as per security policy set in MediaSessionDescriptionFactory. | 3351 // description as per security policy set in MediaSessionDescriptionFactory. |
| 3289 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) { | 3352 TEST_F(WebRtcSessionTest, TestCryptoAfterSetLocalDescription) { |
| 3290 Init(); | 3353 Init(); |
| 3291 mediastream_signaling_.SendAudioVideoStream1(); | 3354 mediastream_signaling_.SendAudioVideoStream1(); |
| 3292 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3355 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 3293 | 3356 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3308 options_.disable_encryption = true; | 3371 options_.disable_encryption = true; |
| 3309 Init(); | 3372 Init(); |
| 3310 mediastream_signaling_.SendAudioVideoStream1(); | 3373 mediastream_signaling_.SendAudioVideoStream1(); |
| 3311 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3374 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 3312 | 3375 |
| 3313 // Making sure SetLocalDescription correctly sets crypto value in | 3376 // Making sure SetLocalDescription correctly sets crypto value in |
| 3314 // SessionDescription object after de-serialization of sdp string. The value | 3377 // SessionDescription object after de-serialization of sdp string. The value |
| 3315 // will be set as per MediaSessionDescriptionFactory. | 3378 // will be set as per MediaSessionDescriptionFactory. |
| 3316 std::string offer_str; | 3379 std::string offer_str; |
| 3317 offer->ToString(&offer_str); | 3380 offer->ToString(&offer_str); |
| 3318 SessionDescriptionInterface *jsep_offer_str = | 3381 SessionDescriptionInterface* jsep_offer_str = |
| 3319 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); | 3382 CreateSessionDescription(JsepSessionDescription::kOffer, offer_str, NULL); |
| 3320 SetLocalDescriptionWithoutError(jsep_offer_str); | 3383 SetLocalDescriptionWithoutError(jsep_offer_str); |
| 3321 EXPECT_FALSE(session_->voice_channel()->secure_required()); | 3384 EXPECT_FALSE(session_->voice_channel()->secure_required()); |
| 3322 EXPECT_FALSE(session_->video_channel()->secure_required()); | 3385 EXPECT_FALSE(session_->video_channel()->secure_required()); |
| 3323 } | 3386 } |
| 3324 | 3387 |
| 3325 // This test verifies that an answer contains new ufrag and password if an offer | 3388 // This test verifies that an answer contains new ufrag and password if an offer |
| 3326 // with new ufrag and password is received. | 3389 // with new ufrag and password is received. |
| 3327 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { | 3390 TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) { |
| 3328 Init(); | 3391 Init(); |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3941 // terminated. The offer creation may or may not have succeeded, but we | 4004 // terminated. The offer creation may or may not have succeeded, but we |
| 3942 // must have received a notification which, so the only invalid state | 4005 // must have received a notification which, so the only invalid state |
| 3943 // is kInit. | 4006 // is kInit. |
| 3944 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); | 4007 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
| 3945 } | 4008 } |
| 3946 } | 4009 } |
| 3947 | 4010 |
| 3948 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4011 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 3949 // currently fails because upon disconnection and reconnection OnIceComplete is | 4012 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 3950 // called more than once without returning to IceGatheringGathering. | 4013 // called more than once without returning to IceGatheringGathering. |
| OLD | NEW |