| 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 "talk/app/webrtc/audiotrack.h" | 28 #include "talk/app/webrtc/audiotrack.h" |
| 29 #include "talk/app/webrtc/dtlscertificate.h" |
| 29 #include "talk/app/webrtc/fakemetricsobserver.h" | 30 #include "talk/app/webrtc/fakemetricsobserver.h" |
| 30 #include "talk/app/webrtc/jsepicecandidate.h" | 31 #include "talk/app/webrtc/jsepicecandidate.h" |
| 31 #include "talk/app/webrtc/jsepsessiondescription.h" | 32 #include "talk/app/webrtc/jsepsessiondescription.h" |
| 32 #include "talk/app/webrtc/mediastreamsignaling.h" | 33 #include "talk/app/webrtc/mediastreamsignaling.h" |
| 33 #include "talk/app/webrtc/streamcollection.h" | 34 #include "talk/app/webrtc/streamcollection.h" |
| 34 #include "talk/app/webrtc/test/fakeconstraints.h" | 35 #include "talk/app/webrtc/test/fakeconstraints.h" |
| 35 #include "talk/app/webrtc/test/fakedtlsidentityservice.h" | 36 #include "talk/app/webrtc/test/fakedtlsidentityservice.h" |
| 36 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" | 37 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" |
| 37 #include "talk/app/webrtc/videotrack.h" | 38 #include "talk/app/webrtc/videotrack.h" |
| 38 #include "talk/app/webrtc/webrtcsession.h" | 39 #include "talk/app/webrtc/webrtcsession.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 EXPECT_TRUE(channel_manager_->Init()); | 352 EXPECT_TRUE(channel_manager_->Init()); |
| 352 desc_factory_->set_add_legacy_streams(false); | 353 desc_factory_->set_add_legacy_streams(false); |
| 353 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 354 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
| 354 } | 355 } |
| 355 | 356 |
| 356 void AddInterface(const SocketAddress& addr) { | 357 void AddInterface(const SocketAddress& addr) { |
| 357 network_manager_.AddInterface(addr); | 358 network_manager_.AddInterface(addr); |
| 358 } | 359 } |
| 359 | 360 |
| 360 void Init( | 361 void Init( |
| 361 DTLSIdentityServiceInterface* identity_service, | 362 rtc::scoped_refptr<webrtc::DtlsCertificate> certificate, |
| 362 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { | 363 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { |
| 363 ASSERT_TRUE(session_.get() == NULL); | 364 ASSERT_TRUE(session_.get() == NULL); |
| 364 session_.reset(new WebRtcSessionForTest( | 365 session_.reset(new WebRtcSessionForTest( |
| 365 channel_manager_.get(), rtc::Thread::Current(), | 366 channel_manager_.get(), rtc::Thread::Current(), |
| 366 rtc::Thread::Current(), allocator_.get(), | 367 rtc::Thread::Current(), allocator_.get(), |
| 367 &observer_, | 368 &observer_, |
| 368 &mediastream_signaling_)); | 369 &mediastream_signaling_)); |
| 369 | 370 |
| 370 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, | 371 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
| 371 observer_.ice_connection_state_); | 372 observer_.ice_connection_state_); |
| 372 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, | 373 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
| 373 observer_.ice_gathering_state_); | 374 observer_.ice_gathering_state_); |
| 374 | 375 |
| 375 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), | 376 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), |
| 376 identity_service, rtc_configuration)); | 377 certificate, rtc_configuration)); |
| 377 session_->set_metrics_observer(metrics_observer_); | 378 session_->set_metrics_observer(metrics_observer_); |
| 378 } | 379 } |
| 379 | 380 |
| 380 void Init() { | 381 void Init() { |
| 381 PeerConnectionInterface::RTCConfiguration configuration; | 382 PeerConnectionInterface::RTCConfiguration configuration; |
| 382 Init(NULL, configuration); | 383 Init(NULL, configuration); |
| 383 } | 384 } |
| 384 | 385 |
| 385 void InitWithIceTransport( | 386 void InitWithIceTransport( |
| 386 PeerConnectionInterface::IceTransportsType ice_transport_type) { | 387 PeerConnectionInterface::IceTransportsType ice_transport_type) { |
| 387 PeerConnectionInterface::RTCConfiguration configuration; | 388 PeerConnectionInterface::RTCConfiguration configuration; |
| 388 configuration.type = ice_transport_type; | 389 configuration.type = ice_transport_type; |
| 389 Init(NULL, configuration); | 390 Init(NULL, configuration); |
| 390 } | 391 } |
| 391 | 392 |
| 392 void InitWithBundlePolicy( | 393 void InitWithBundlePolicy( |
| 393 PeerConnectionInterface::BundlePolicy bundle_policy) { | 394 PeerConnectionInterface::BundlePolicy bundle_policy) { |
| 394 PeerConnectionInterface::RTCConfiguration configuration; | 395 PeerConnectionInterface::RTCConfiguration configuration; |
| 395 configuration.bundle_policy = bundle_policy; | 396 configuration.bundle_policy = bundle_policy; |
| 396 Init(NULL, configuration); | 397 Init(NULL, configuration); |
| 397 } | 398 } |
| 398 | 399 |
| 399 void InitWithRtcpMuxPolicy( | 400 void InitWithRtcpMuxPolicy( |
| 400 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | 401 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { |
| 401 PeerConnectionInterface::RTCConfiguration configuration; | 402 PeerConnectionInterface::RTCConfiguration configuration; |
| 402 configuration.rtcp_mux_policy = rtcp_mux_policy; | 403 configuration.rtcp_mux_policy = rtcp_mux_policy; |
| 403 Init(NULL, configuration); | 404 Init(NULL, configuration); |
| 404 } | 405 } |
| 405 | 406 |
| 406 void InitWithDtls(bool identity_request_should_fail = false) { | 407 void InitWithCertificate() { |
| 407 FakeIdentityService* identity_service = new FakeIdentityService(); | |
| 408 identity_service->set_should_fail(identity_request_should_fail); | |
| 409 PeerConnectionInterface::RTCConfiguration configuration; | 408 PeerConnectionInterface::RTCConfiguration configuration; |
| 410 Init(identity_service, configuration); | 409 Init(FakeIdentityService::GenerateCertificate(), configuration); |
| 411 } | 410 } |
| 412 | 411 |
| 413 void InitWithDtmfCodec() { | 412 void InitWithDtmfCodec() { |
| 414 // Add kTelephoneEventCodec for dtmf test. | 413 // Add kTelephoneEventCodec for dtmf test. |
| 415 const cricket::AudioCodec kTelephoneEventCodec( | 414 const cricket::AudioCodec kTelephoneEventCodec( |
| 416 106, "telephone-event", 8000, 0, 1, 0); | 415 106, "telephone-event", 8000, 0, 1, 0); |
| 417 std::vector<cricket::AudioCodec> codecs; | 416 std::vector<cricket::AudioCodec> codecs; |
| 418 codecs.push_back(kTelephoneEventCodec); | 417 codecs.push_back(kTelephoneEventCodec); |
| 419 media_engine_->SetAudioCodecs(codecs); | 418 media_engine_->SetAudioCodecs(codecs); |
| 420 desc_factory_->set_audio_codecs(codecs); | 419 desc_factory_->set_audio_codecs(codecs); |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 | 1174 |
| 1176 void SetLocalDescriptionWithDataChannel() { | 1175 void SetLocalDescriptionWithDataChannel() { |
| 1177 webrtc::InternalDataChannelInit dci; | 1176 webrtc::InternalDataChannelInit dci; |
| 1178 dci.reliable = false; | 1177 dci.reliable = false; |
| 1179 session_->CreateDataChannel("datachannel", &dci); | 1178 session_->CreateDataChannel("datachannel", &dci); |
| 1180 SessionDescriptionInterface* offer = CreateOffer(); | 1179 SessionDescriptionInterface* offer = CreateOffer(); |
| 1181 SetLocalDescriptionWithoutError(offer); | 1180 SetLocalDescriptionWithoutError(offer); |
| 1182 } | 1181 } |
| 1183 | 1182 |
| 1184 void VerifyMultipleAsyncCreateDescription( | 1183 void VerifyMultipleAsyncCreateDescription( |
| 1185 bool success, CreateSessionDescriptionRequest::Type type) { | 1184 CreateSessionDescriptionRequest::Type type) { |
| 1186 InitWithDtls(!success); | 1185 InitWithCertificate(); |
| 1187 SetFactoryDtlsSrtp(); | 1186 SetFactoryDtlsSrtp(); |
| 1188 if (type == CreateSessionDescriptionRequest::kAnswer) { | 1187 if (type == CreateSessionDescriptionRequest::kAnswer) { |
| 1189 cricket::MediaSessionOptions options; | 1188 cricket::MediaSessionOptions options; |
| 1190 scoped_ptr<JsepSessionDescription> offer( | 1189 scoped_ptr<JsepSessionDescription> offer( |
| 1191 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 1190 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
| 1192 ASSERT_TRUE(offer.get() != NULL); | 1191 ASSERT_TRUE(offer.get() != NULL); |
| 1193 SetRemoteDescriptionWithoutError(offer.release()); | 1192 SetRemoteDescriptionWithoutError(offer.release()); |
| 1194 } | 1193 } |
| 1195 | 1194 |
| 1196 PeerConnectionInterface::RTCOfferAnswerOptions options; | 1195 PeerConnectionInterface::RTCOfferAnswerOptions options; |
| 1197 const int kNumber = 3; | 1196 const int kNumber = 3; |
| 1198 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> | 1197 rtc::scoped_refptr<WebRtcSessionCreateSDPObserverForTest> |
| 1199 observers[kNumber]; | 1198 observers[kNumber]; |
| 1200 for (int i = 0; i < kNumber; ++i) { | 1199 for (int i = 0; i < kNumber; ++i) { |
| 1201 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); | 1200 observers[i] = new WebRtcSessionCreateSDPObserverForTest(); |
| 1202 if (type == CreateSessionDescriptionRequest::kOffer) { | 1201 if (type == CreateSessionDescriptionRequest::kOffer) { |
| 1203 session_->CreateOffer(observers[i], options); | 1202 session_->CreateOffer(observers[i], options); |
| 1204 } else { | 1203 } else { |
| 1205 session_->CreateAnswer(observers[i], NULL); | 1204 session_->CreateAnswer(observers[i], NULL); |
| 1206 } | 1205 } |
| 1207 } | 1206 } |
| 1208 | 1207 |
| 1209 WebRtcSessionCreateSDPObserverForTest::State expected_state = | |
| 1210 success ? WebRtcSessionCreateSDPObserverForTest::kSucceeded : | |
| 1211 WebRtcSessionCreateSDPObserverForTest::kFailed; | |
| 1212 | |
| 1213 for (int i = 0; i < kNumber; ++i) { | 1208 for (int i = 0; i < kNumber; ++i) { |
| 1214 EXPECT_EQ_WAIT(expected_state, observers[i]->state(), 1000); | 1209 EXPECT_EQ_WAIT(WebRtcSessionCreateSDPObserverForTest::kSucceeded, |
| 1215 if (success) { | 1210 observers[i]->state(), 1000); |
| 1216 EXPECT_TRUE(observers[i]->description() != NULL); | 1211 EXPECT_TRUE(observers[i]->description() != NULL); |
| 1217 } else { | |
| 1218 EXPECT_TRUE(observers[i]->description() == NULL); | |
| 1219 } | |
| 1220 } | 1212 } |
| 1221 } | 1213 } |
| 1222 | 1214 |
| 1223 void ConfigureAllocatorWithTurn() { | 1215 void ConfigureAllocatorWithTurn() { |
| 1224 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); | 1216 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); |
| 1225 cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword); | 1217 cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword); |
| 1226 relay_server.credentials = credentials; | 1218 relay_server.credentials = credentials; |
| 1227 relay_server.ports.push_back(cricket::ProtocolAddress( | 1219 relay_server.ports.push_back(cricket::ProtocolAddress( |
| 1228 kTurnUdpIntAddr, cricket::PROTO_UDP, false)); | 1220 kTurnUdpIntAddr, cricket::PROTO_UDP, false)); |
| 1229 allocator_->AddRelay(relay_server); | 1221 allocator_->AddRelay(relay_server); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1251 PeerConnectionFactoryInterface::Options options_; | 1243 PeerConnectionFactoryInterface::Options options_; |
| 1252 rtc::scoped_ptr<FakeConstraints> constraints_; | 1244 rtc::scoped_ptr<FakeConstraints> constraints_; |
| 1253 FakeMediaStreamSignaling mediastream_signaling_; | 1245 FakeMediaStreamSignaling mediastream_signaling_; |
| 1254 rtc::scoped_ptr<WebRtcSessionForTest> session_; | 1246 rtc::scoped_ptr<WebRtcSessionForTest> session_; |
| 1255 MockIceObserver observer_; | 1247 MockIceObserver observer_; |
| 1256 cricket::FakeVideoMediaChannel* video_channel_; | 1248 cricket::FakeVideoMediaChannel* video_channel_; |
| 1257 cricket::FakeVoiceMediaChannel* voice_channel_; | 1249 cricket::FakeVoiceMediaChannel* voice_channel_; |
| 1258 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; | 1250 rtc::scoped_refptr<FakeMetricsObserver> metrics_observer_; |
| 1259 }; | 1251 }; |
| 1260 | 1252 |
| 1261 TEST_F(WebRtcSessionTest, TestInitializeWithDtls) { | 1253 TEST_F(WebRtcSessionTest, TestInitializeWithCertificate) { |
| 1262 InitWithDtls(); | 1254 InitWithCertificate(); |
| 1263 // SDES is disabled when DTLS is on. | 1255 // SDES is disabled when DTLS is on. |
| 1264 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy()); | 1256 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy()); |
| 1265 } | 1257 } |
| 1266 | 1258 |
| 1267 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) { | 1259 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) { |
| 1268 Init(); | 1260 Init(); |
| 1269 // SDES is required if DTLS is off. | 1261 // SDES is required if DTLS is off. |
| 1270 EXPECT_EQ(cricket::SEC_REQUIRED, session_->SdesPolicy()); | 1262 EXPECT_EQ(cricket::SEC_REQUIRED, session_->SdesPolicy()); |
| 1271 } | 1263 } |
| 1272 | 1264 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 // the offer. | 1554 // the offer. |
| 1563 SetLocalDescriptionWithoutError(offer); | 1555 SetLocalDescriptionWithoutError(offer); |
| 1564 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); | 1556 SetRemoteDescriptionAnswerExpectError(kSdpWithoutSdesCrypto, answer); |
| 1565 } | 1557 } |
| 1566 | 1558 |
| 1567 // Test that we accept an offer with a DTLS fingerprint when DTLS is on | 1559 // Test that we accept an offer with a DTLS fingerprint when DTLS is on |
| 1568 // and that we return an answer with a DTLS fingerprint. | 1560 // and that we return an answer with a DTLS fingerprint. |
| 1569 TEST_F(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { | 1561 TEST_F(WebRtcSessionTest, TestReceiveDtlsOfferCreateDtlsAnswer) { |
| 1570 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1562 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 1571 mediastream_signaling_.SendAudioVideoStream1(); | 1563 mediastream_signaling_.SendAudioVideoStream1(); |
| 1572 InitWithDtls(); | 1564 InitWithCertificate(); |
| 1573 SetFactoryDtlsSrtp(); | 1565 SetFactoryDtlsSrtp(); |
| 1574 cricket::MediaSessionOptions options; | 1566 cricket::MediaSessionOptions options; |
| 1575 options.recv_video = true; | 1567 options.recv_video = true; |
| 1576 JsepSessionDescription* offer = | 1568 JsepSessionDescription* offer = |
| 1577 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 1569 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 1578 ASSERT_TRUE(offer != NULL); | 1570 ASSERT_TRUE(offer != NULL); |
| 1579 VerifyFingerprintStatus(offer->description(), true); | 1571 VerifyFingerprintStatus(offer->description(), true); |
| 1580 VerifyNoCryptoParams(offer->description(), true); | 1572 VerifyNoCryptoParams(offer->description(), true); |
| 1581 | 1573 |
| 1582 // SetRemoteDescription will take the ownership of the offer. | 1574 // SetRemoteDescription will take the ownership of the offer. |
| 1583 SetRemoteDescriptionWithoutError(offer); | 1575 SetRemoteDescriptionWithoutError(offer); |
| 1584 | 1576 |
| 1585 // Verify that we get a crypto fingerprint in the answer. | 1577 // Verify that we get a crypto fingerprint in the answer. |
| 1586 SessionDescriptionInterface* answer = CreateAnswer(NULL); | 1578 SessionDescriptionInterface* answer = CreateAnswer(NULL); |
| 1587 ASSERT_TRUE(answer != NULL); | 1579 ASSERT_TRUE(answer != NULL); |
| 1588 VerifyFingerprintStatus(answer->description(), true); | 1580 VerifyFingerprintStatus(answer->description(), true); |
| 1589 // Check that we don't have an a=crypto line in the answer. | 1581 // Check that we don't have an a=crypto line in the answer. |
| 1590 VerifyNoCryptoParams(answer->description(), true); | 1582 VerifyNoCryptoParams(answer->description(), true); |
| 1591 | 1583 |
| 1592 // Now set the local description, which should work, even without a=crypto. | 1584 // Now set the local description, which should work, even without a=crypto. |
| 1593 SetLocalDescriptionWithoutError(answer); | 1585 SetLocalDescriptionWithoutError(answer); |
| 1594 } | 1586 } |
| 1595 | 1587 |
| 1596 // Test that we set a local offer with a DTLS fingerprint when DTLS is on | 1588 // Test that we set a local offer with a DTLS fingerprint when DTLS is on |
| 1597 // and then we accept a remote answer with a DTLS fingerprint successfully. | 1589 // and then we accept a remote answer with a DTLS fingerprint successfully. |
| 1598 TEST_F(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) { | 1590 TEST_F(WebRtcSessionTest, TestCreateDtlsOfferReceiveDtlsAnswer) { |
| 1599 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1591 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 1600 mediastream_signaling_.SendAudioVideoStream1(); | 1592 mediastream_signaling_.SendAudioVideoStream1(); |
| 1601 InitWithDtls(); | 1593 InitWithCertificate(); |
| 1602 SetFactoryDtlsSrtp(); | 1594 SetFactoryDtlsSrtp(); |
| 1603 | 1595 |
| 1604 // Verify that we get a crypto fingerprint in the answer. | 1596 // Verify that we get a crypto fingerprint in the answer. |
| 1605 SessionDescriptionInterface* offer = CreateOffer(); | 1597 SessionDescriptionInterface* offer = CreateOffer(); |
| 1606 ASSERT_TRUE(offer != NULL); | 1598 ASSERT_TRUE(offer != NULL); |
| 1607 VerifyFingerprintStatus(offer->description(), true); | 1599 VerifyFingerprintStatus(offer->description(), true); |
| 1608 // Check that we don't have an a=crypto line in the offer. | 1600 // Check that we don't have an a=crypto line in the offer. |
| 1609 VerifyNoCryptoParams(offer->description(), true); | 1601 VerifyNoCryptoParams(offer->description(), true); |
| 1610 | 1602 |
| 1611 // Now set the local description, which should work, even without a=crypto. | 1603 // Now set the local description, which should work, even without a=crypto. |
| 1612 SetLocalDescriptionWithoutError(offer); | 1604 SetLocalDescriptionWithoutError(offer); |
| 1613 | 1605 |
| 1614 cricket::MediaSessionOptions options; | 1606 cricket::MediaSessionOptions options; |
| 1615 options.recv_video = true; | 1607 options.recv_video = true; |
| 1616 JsepSessionDescription* answer = | 1608 JsepSessionDescription* answer = |
| 1617 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 1609 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 1618 ASSERT_TRUE(answer != NULL); | 1610 ASSERT_TRUE(answer != NULL); |
| 1619 VerifyFingerprintStatus(answer->description(), true); | 1611 VerifyFingerprintStatus(answer->description(), true); |
| 1620 VerifyNoCryptoParams(answer->description(), true); | 1612 VerifyNoCryptoParams(answer->description(), true); |
| 1621 | 1613 |
| 1622 // SetRemoteDescription will take the ownership of the answer. | 1614 // SetRemoteDescription will take the ownership of the answer. |
| 1623 SetRemoteDescriptionWithoutError(answer); | 1615 SetRemoteDescriptionWithoutError(answer); |
| 1624 } | 1616 } |
| 1625 | 1617 |
| 1626 // Test that if we support DTLS and the other side didn't offer a fingerprint, | 1618 // Test that if we support DTLS and the other side didn't offer a fingerprint, |
| 1627 // we will fail to set the remote description. | 1619 // we will fail to set the remote description. |
| 1628 TEST_F(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { | 1620 TEST_F(WebRtcSessionTest, TestReceiveNonDtlsOfferWhenDtlsOn) { |
| 1629 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1621 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 1630 InitWithDtls(); | 1622 InitWithCertificate(); |
| 1631 cricket::MediaSessionOptions options; | 1623 cricket::MediaSessionOptions options; |
| 1632 options.recv_video = true; | 1624 options.recv_video = true; |
| 1633 options.bundle_enabled = true; | 1625 options.bundle_enabled = true; |
| 1634 JsepSessionDescription* offer = CreateRemoteOffer( | 1626 JsepSessionDescription* offer = CreateRemoteOffer( |
| 1635 options, cricket::SEC_REQUIRED); | 1627 options, cricket::SEC_REQUIRED); |
| 1636 ASSERT_TRUE(offer != NULL); | 1628 ASSERT_TRUE(offer != NULL); |
| 1637 VerifyFingerprintStatus(offer->description(), false); | 1629 VerifyFingerprintStatus(offer->description(), false); |
| 1638 VerifyCryptoParams(offer->description()); | 1630 VerifyCryptoParams(offer->description()); |
| 1639 | 1631 |
| 1640 // SetRemoteDescription will take the ownership of the offer. | 1632 // SetRemoteDescription will take the ownership of the offer. |
| 1641 SetRemoteDescriptionOfferExpectError( | 1633 SetRemoteDescriptionOfferExpectError( |
| 1642 kSdpWithoutDtlsFingerprint, offer); | 1634 kSdpWithoutDtlsFingerprint, offer); |
| 1643 | 1635 |
| 1644 offer = CreateRemoteOffer(options, cricket::SEC_REQUIRED); | 1636 offer = CreateRemoteOffer(options, cricket::SEC_REQUIRED); |
| 1645 // SetLocalDescription will take the ownership of the offer. | 1637 // SetLocalDescription will take the ownership of the offer. |
| 1646 SetLocalDescriptionOfferExpectError( | 1638 SetLocalDescriptionOfferExpectError( |
| 1647 kSdpWithoutDtlsFingerprint, offer); | 1639 kSdpWithoutDtlsFingerprint, offer); |
| 1648 } | 1640 } |
| 1649 | 1641 |
| 1650 // Test that we return a failure when applying a local answer that doesn't have | 1642 // Test that we return a failure when applying a local answer that doesn't have |
| 1651 // a DTLS fingerprint when DTLS is required. | 1643 // a DTLS fingerprint when DTLS is required. |
| 1652 TEST_F(WebRtcSessionTest, TestSetLocalNonDtlsAnswerWhenDtlsOn) { | 1644 TEST_F(WebRtcSessionTest, TestSetLocalNonDtlsAnswerWhenDtlsOn) { |
| 1653 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1645 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 1654 InitWithDtls(); | 1646 InitWithCertificate(); |
| 1655 SessionDescriptionInterface* offer = NULL; | 1647 SessionDescriptionInterface* offer = NULL; |
| 1656 SessionDescriptionInterface* answer = NULL; | 1648 SessionDescriptionInterface* answer = NULL; |
| 1657 CreateDtlsOfferAndNonDtlsAnswer(&offer, &answer); | 1649 CreateDtlsOfferAndNonDtlsAnswer(&offer, &answer); |
| 1658 | 1650 |
| 1659 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1651 // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1660 // the offer and answer. | 1652 // the offer and answer. |
| 1661 SetRemoteDescriptionWithoutError(offer); | 1653 SetRemoteDescriptionWithoutError(offer); |
| 1662 SetLocalDescriptionAnswerExpectError( | 1654 SetLocalDescriptionAnswerExpectError( |
| 1663 kSdpWithoutDtlsFingerprint, answer); | 1655 kSdpWithoutDtlsFingerprint, answer); |
| 1664 } | 1656 } |
| 1665 | 1657 |
| 1666 // Test that we return a failure when applying a remote answer that doesn't have | 1658 // Test that we return a failure when applying a remote answer that doesn't have |
| 1667 // a DTLS fingerprint when DTLS is required. | 1659 // a DTLS fingerprint when DTLS is required. |
| 1668 TEST_F(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { | 1660 TEST_F(WebRtcSessionTest, TestSetRemoteNonDtlsAnswerWhenDtlsOn) { |
| 1669 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 1661 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 1670 // Enable both SDES and DTLS, so that offer won't be outright rejected as a | 1662 // 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. | 1663 // result of using the "UDP/TLS/RTP/SAVPF" profile. |
| 1672 InitWithDtls(); | 1664 InitWithCertificate(); |
| 1673 session_->SetSdesPolicy(cricket::SEC_ENABLED); | 1665 session_->SetSdesPolicy(cricket::SEC_ENABLED); |
| 1674 SessionDescriptionInterface* offer = CreateOffer(); | 1666 SessionDescriptionInterface* offer = CreateOffer(); |
| 1675 cricket::MediaSessionOptions options; | 1667 cricket::MediaSessionOptions options; |
| 1676 options.recv_video = true; | 1668 options.recv_video = true; |
| 1677 JsepSessionDescription* answer = | 1669 JsepSessionDescription* answer = |
| 1678 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED); | 1670 CreateRemoteAnswer(offer, options, cricket::SEC_ENABLED); |
| 1679 | 1671 |
| 1680 // SetRemoteDescription and SetLocalDescription will take the ownership of | 1672 // SetRemoteDescription and SetLocalDescription will take the ownership of |
| 1681 // the offer and answer. | 1673 // the offer and answer. |
| 1682 SetLocalDescriptionWithoutError(offer); | 1674 SetLocalDescriptionWithoutError(offer); |
| 1683 SetRemoteDescriptionAnswerExpectError( | 1675 SetRemoteDescriptionAnswerExpectError( |
| 1684 kSdpWithoutDtlsFingerprint, answer); | 1676 kSdpWithoutDtlsFingerprint, answer); |
| 1685 } | 1677 } |
| 1686 | 1678 |
| 1687 // Test that we create a local offer without SDES or DTLS and accept a remote | 1679 // 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. | 1680 // answer without SDES or DTLS when encryption is disabled. |
| 1689 TEST_F(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { | 1681 TEST_F(WebRtcSessionTest, TestCreateOfferReceiveAnswerWithoutEncryption) { |
| 1690 mediastream_signaling_.SendAudioVideoStream1(); | 1682 mediastream_signaling_.SendAudioVideoStream1(); |
| 1691 options_.disable_encryption = true; | 1683 options_.disable_encryption = true; |
| 1692 InitWithDtls(); | 1684 InitWithCertificate(); |
| 1693 | 1685 |
| 1694 // Verify that we get a crypto fingerprint in the answer. | 1686 // Verify that we get a crypto fingerprint in the answer. |
| 1695 SessionDescriptionInterface* offer = CreateOffer(); | 1687 SessionDescriptionInterface* offer = CreateOffer(); |
| 1696 ASSERT_TRUE(offer != NULL); | 1688 ASSERT_TRUE(offer != NULL); |
| 1697 VerifyFingerprintStatus(offer->description(), false); | 1689 VerifyFingerprintStatus(offer->description(), false); |
| 1698 // Check that we don't have an a=crypto line in the offer. | 1690 // Check that we don't have an a=crypto line in the offer. |
| 1699 VerifyNoCryptoParams(offer->description(), false); | 1691 VerifyNoCryptoParams(offer->description(), false); |
| 1700 | 1692 |
| 1701 // Now set the local description, which should work, even without a=crypto. | 1693 // Now set the local description, which should work, even without a=crypto. |
| 1702 SetLocalDescriptionWithoutError(offer); | 1694 SetLocalDescriptionWithoutError(offer); |
| 1703 | 1695 |
| 1704 cricket::MediaSessionOptions options; | 1696 cricket::MediaSessionOptions options; |
| 1705 options.recv_video = true; | 1697 options.recv_video = true; |
| 1706 JsepSessionDescription* answer = | 1698 JsepSessionDescription* answer = |
| 1707 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); | 1699 CreateRemoteAnswer(offer, options, cricket::SEC_DISABLED); |
| 1708 ASSERT_TRUE(answer != NULL); | 1700 ASSERT_TRUE(answer != NULL); |
| 1709 VerifyFingerprintStatus(answer->description(), false); | 1701 VerifyFingerprintStatus(answer->description(), false); |
| 1710 VerifyNoCryptoParams(answer->description(), false); | 1702 VerifyNoCryptoParams(answer->description(), false); |
| 1711 | 1703 |
| 1712 // SetRemoteDescription will take the ownership of the answer. | 1704 // SetRemoteDescription will take the ownership of the answer. |
| 1713 SetRemoteDescriptionWithoutError(answer); | 1705 SetRemoteDescriptionWithoutError(answer); |
| 1714 } | 1706 } |
| 1715 | 1707 |
| 1716 // Test that we create a local answer without SDES or DTLS and accept a remote | 1708 // Test that we create a local answer without SDES or DTLS and accept a remote |
| 1717 // offer without SDES or DTLS when encryption is disabled. | 1709 // offer without SDES or DTLS when encryption is disabled. |
| 1718 TEST_F(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { | 1710 TEST_F(WebRtcSessionTest, TestCreateAnswerReceiveOfferWithoutEncryption) { |
| 1719 options_.disable_encryption = true; | 1711 options_.disable_encryption = true; |
| 1720 InitWithDtls(); | 1712 InitWithCertificate(); |
| 1721 | 1713 |
| 1722 cricket::MediaSessionOptions options; | 1714 cricket::MediaSessionOptions options; |
| 1723 options.recv_video = true; | 1715 options.recv_video = true; |
| 1724 JsepSessionDescription* offer = | 1716 JsepSessionDescription* offer = |
| 1725 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 1717 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 1726 ASSERT_TRUE(offer != NULL); | 1718 ASSERT_TRUE(offer != NULL); |
| 1727 VerifyFingerprintStatus(offer->description(), false); | 1719 VerifyFingerprintStatus(offer->description(), false); |
| 1728 VerifyNoCryptoParams(offer->description(), false); | 1720 VerifyNoCryptoParams(offer->description(), false); |
| 1729 | 1721 |
| 1730 // SetRemoteDescription will take the ownership of the offer. | 1722 // SetRemoteDescription will take the ownership of the offer. |
| (...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3411 } | 3403 } |
| 3412 | 3404 |
| 3413 TEST_F(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { | 3405 TEST_F(WebRtcSessionTest, TestRtpDataChannelConstraintTakesPrecedence) { |
| 3414 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3406 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3415 | 3407 |
| 3416 constraints_.reset(new FakeConstraints()); | 3408 constraints_.reset(new FakeConstraints()); |
| 3417 constraints_->AddOptional( | 3409 constraints_->AddOptional( |
| 3418 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); | 3410 webrtc::MediaConstraintsInterface::kEnableRtpDataChannels, true); |
| 3419 options_.disable_sctp_data_channels = false; | 3411 options_.disable_sctp_data_channels = false; |
| 3420 | 3412 |
| 3421 InitWithDtls(); | 3413 InitWithCertificate(); |
| 3422 | 3414 |
| 3423 SetLocalDescriptionWithDataChannel(); | 3415 SetLocalDescriptionWithDataChannel(); |
| 3424 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); | 3416 EXPECT_EQ(cricket::DCT_RTP, data_engine_->last_channel_type()); |
| 3425 } | 3417 } |
| 3426 | 3418 |
| 3427 TEST_F(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { | 3419 TEST_F(WebRtcSessionTest, TestCreateOfferWithSctpEnabledWithoutStreams) { |
| 3428 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3420 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3429 | 3421 |
| 3430 InitWithDtls(); | 3422 InitWithCertificate(); |
| 3431 | 3423 |
| 3432 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3424 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 3433 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); | 3425 EXPECT_TRUE(offer->description()->GetContentByName("data") == NULL); |
| 3434 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); | 3426 EXPECT_TRUE(offer->description()->GetTransportInfoByName("data") == NULL); |
| 3435 } | 3427 } |
| 3436 | 3428 |
| 3437 TEST_F(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { | 3429 TEST_F(WebRtcSessionTest, TestCreateAnswerWithSctpInOfferAndNoStreams) { |
| 3438 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3430 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3439 SetFactoryDtlsSrtp(); | 3431 SetFactoryDtlsSrtp(); |
| 3440 InitWithDtls(); | 3432 InitWithCertificate(); |
| 3441 | 3433 |
| 3442 // Create remote offer with SCTP. | 3434 // Create remote offer with SCTP. |
| 3443 cricket::MediaSessionOptions options; | 3435 cricket::MediaSessionOptions options; |
| 3444 options.data_channel_type = cricket::DCT_SCTP; | 3436 options.data_channel_type = cricket::DCT_SCTP; |
| 3445 JsepSessionDescription* offer = | 3437 JsepSessionDescription* offer = |
| 3446 CreateRemoteOffer(options, cricket::SEC_DISABLED); | 3438 CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 3447 SetRemoteDescriptionWithoutError(offer); | 3439 SetRemoteDescriptionWithoutError(offer); |
| 3448 | 3440 |
| 3449 // Verifies the answer contains SCTP. | 3441 // Verifies the answer contains SCTP. |
| 3450 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); | 3442 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); |
| 3451 EXPECT_TRUE(answer != NULL); | 3443 EXPECT_TRUE(answer != NULL); |
| 3452 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); | 3444 EXPECT_TRUE(answer->description()->GetContentByName("data") != NULL); |
| 3453 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); | 3445 EXPECT_TRUE(answer->description()->GetTransportInfoByName("data") != NULL); |
| 3454 } | 3446 } |
| 3455 | 3447 |
| 3456 TEST_F(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { | 3448 TEST_F(WebRtcSessionTest, TestSctpDataChannelWithoutDtls) { |
| 3457 constraints_.reset(new FakeConstraints()); | 3449 constraints_.reset(new FakeConstraints()); |
| 3458 constraints_->AddOptional( | 3450 constraints_->AddOptional( |
| 3459 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); | 3451 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false); |
| 3460 InitWithDtls(); | 3452 InitWithCertificate(); |
| 3461 | 3453 |
| 3462 SetLocalDescriptionWithDataChannel(); | 3454 SetLocalDescriptionWithDataChannel(); |
| 3463 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); | 3455 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); |
| 3464 } | 3456 } |
| 3465 | 3457 |
| 3466 TEST_F(WebRtcSessionTest, TestSctpDataChannelWithDtls) { | 3458 TEST_F(WebRtcSessionTest, TestSctpDataChannelWithDtls) { |
| 3467 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3459 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3468 | 3460 |
| 3469 InitWithDtls(); | 3461 InitWithCertificate(); |
| 3470 | 3462 |
| 3471 SetLocalDescriptionWithDataChannel(); | 3463 SetLocalDescriptionWithDataChannel(); |
| 3472 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); | 3464 EXPECT_EQ(cricket::DCT_SCTP, data_engine_->last_channel_type()); |
| 3473 } | 3465 } |
| 3474 | 3466 |
| 3475 TEST_F(WebRtcSessionTest, TestDisableSctpDataChannels) { | 3467 TEST_F(WebRtcSessionTest, TestDisableSctpDataChannels) { |
| 3476 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3468 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3477 options_.disable_sctp_data_channels = true; | 3469 options_.disable_sctp_data_channels = true; |
| 3478 InitWithDtls(); | 3470 InitWithCertificate(); |
| 3479 | 3471 |
| 3480 SetLocalDescriptionWithDataChannel(); | 3472 SetLocalDescriptionWithDataChannel(); |
| 3481 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); | 3473 EXPECT_EQ(cricket::DCT_NONE, data_engine_->last_channel_type()); |
| 3482 } | 3474 } |
| 3483 | 3475 |
| 3484 TEST_F(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) { | 3476 TEST_F(WebRtcSessionTest, TestSctpDataChannelSendPortParsing) { |
| 3485 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3477 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3486 const int new_send_port = 9998; | 3478 const int new_send_port = 9998; |
| 3487 const int new_recv_port = 7775; | 3479 const int new_recv_port = 7775; |
| 3488 | 3480 |
| 3489 InitWithDtls(); | 3481 InitWithCertificate(); |
| 3490 SetFactoryDtlsSrtp(); | 3482 SetFactoryDtlsSrtp(); |
| 3491 | 3483 |
| 3492 // By default, don't actually add the codecs to desc_factory_; they don't | 3484 // By default, don't actually add the codecs to desc_factory_; they don't |
| 3493 // actually get serialized for SCTP in BuildMediaDescription(). Instead, | 3485 // actually get serialized for SCTP in BuildMediaDescription(). Instead, |
| 3494 // let the session description get parsed. That'll get the proper codecs | 3486 // let the session description get parsed. That'll get the proper codecs |
| 3495 // into the stream. | 3487 // into the stream. |
| 3496 cricket::MediaSessionOptions options; | 3488 cricket::MediaSessionOptions options; |
| 3497 JsepSessionDescription* offer = CreateRemoteOfferWithSctpPort( | 3489 JsepSessionDescription* offer = CreateRemoteOfferWithSctpPort( |
| 3498 "stream1", new_send_port, options); | 3490 "stream1", new_send_port, options); |
| 3499 | 3491 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3532 ch->recv_codecs()[0].name.c_str())); | 3524 ch->recv_codecs()[0].name.c_str())); |
| 3533 EXPECT_TRUE(ch->recv_codecs()[0].GetParam(cricket::kCodecParamPort, | 3525 EXPECT_TRUE(ch->recv_codecs()[0].GetParam(cricket::kCodecParamPort, |
| 3534 &portnum)); | 3526 &portnum)); |
| 3535 EXPECT_EQ(new_recv_port, portnum); | 3527 EXPECT_EQ(new_recv_port, portnum); |
| 3536 } | 3528 } |
| 3537 | 3529 |
| 3538 // Verifies that CreateOffer succeeds when CreateOffer is called before async | 3530 // Verifies that CreateOffer succeeds when CreateOffer is called before async |
| 3539 // identity generation is finished. | 3531 // identity generation is finished. |
| 3540 TEST_F(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { | 3532 TEST_F(WebRtcSessionTest, TestCreateOfferBeforeIdentityRequestReturnSuccess) { |
| 3541 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3533 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3542 InitWithDtls(); | 3534 InitWithCertificate(); |
| 3543 | 3535 |
| 3544 EXPECT_TRUE(session_->waiting_for_identity()); | 3536 EXPECT_TRUE(session_->waiting_for_certificate()); |
| 3545 mediastream_signaling_.SendAudioVideoStream1(); | 3537 mediastream_signaling_.SendAudioVideoStream1(); |
| 3546 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3538 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 3547 | 3539 |
| 3548 EXPECT_TRUE(offer != NULL); | 3540 EXPECT_TRUE(offer != NULL); |
| 3549 VerifyNoCryptoParams(offer->description(), true); | 3541 VerifyNoCryptoParams(offer->description(), true); |
| 3550 VerifyFingerprintStatus(offer->description(), true); | 3542 VerifyFingerprintStatus(offer->description(), true); |
| 3551 } | 3543 } |
| 3552 | 3544 |
| 3553 // Verifies that CreateAnswer succeeds when CreateOffer is called before async | 3545 // Verifies that CreateAnswer succeeds when CreateOffer is called before async |
| 3554 // identity generation is finished. | 3546 // identity generation is finished. |
| 3555 TEST_F(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { | 3547 TEST_F(WebRtcSessionTest, TestCreateAnswerBeforeIdentityRequestReturnSuccess) { |
| 3556 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3548 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3557 InitWithDtls(); | 3549 InitWithCertificate(); |
| 3558 SetFactoryDtlsSrtp(); | 3550 SetFactoryDtlsSrtp(); |
| 3559 | 3551 |
| 3560 cricket::MediaSessionOptions options; | 3552 cricket::MediaSessionOptions options; |
| 3561 options.recv_video = true; | 3553 options.recv_video = true; |
| 3562 scoped_ptr<JsepSessionDescription> offer( | 3554 scoped_ptr<JsepSessionDescription> offer( |
| 3563 CreateRemoteOffer(options, cricket::SEC_DISABLED)); | 3555 CreateRemoteOffer(options, cricket::SEC_DISABLED)); |
| 3564 ASSERT_TRUE(offer.get() != NULL); | 3556 ASSERT_TRUE(offer.get() != NULL); |
| 3565 SetRemoteDescriptionWithoutError(offer.release()); | 3557 SetRemoteDescriptionWithoutError(offer.release()); |
| 3566 | 3558 |
| 3567 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); | 3559 rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(NULL)); |
| 3568 EXPECT_TRUE(answer != NULL); | 3560 EXPECT_TRUE(answer != NULL); |
| 3569 VerifyNoCryptoParams(answer->description(), true); | 3561 VerifyNoCryptoParams(answer->description(), true); |
| 3570 VerifyFingerprintStatus(answer->description(), true); | 3562 VerifyFingerprintStatus(answer->description(), true); |
| 3571 } | 3563 } |
| 3572 | 3564 |
| 3573 // Verifies that CreateOffer succeeds when CreateOffer is called after async | 3565 // Verifies that CreateOffer succeeds when CreateOffer is called after async |
| 3574 // identity generation is finished. | 3566 // identity generation is finished. |
| 3575 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { | 3567 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnSuccess) { |
| 3576 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3568 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3577 InitWithDtls(); | 3569 InitWithCertificate(); |
| 3578 | 3570 |
| 3579 EXPECT_TRUE_WAIT(!session_->waiting_for_identity(), 1000); | 3571 EXPECT_TRUE_WAIT(!session_->waiting_for_certificate(), 1000); |
| 3580 | 3572 |
| 3581 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | 3573 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); |
| 3582 EXPECT_TRUE(offer != NULL); | 3574 EXPECT_TRUE(offer != NULL); |
| 3583 } | 3575 } |
| 3584 | 3576 |
| 3585 // Verifies that CreateOffer fails when CreateOffer is called after async | |
| 3586 // identity generation fails. | |
| 3587 TEST_F(WebRtcSessionTest, TestCreateOfferAfterIdentityRequestReturnFailure) { | |
| 3588 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
| 3589 InitWithDtls(true); | |
| 3590 | |
| 3591 EXPECT_TRUE_WAIT(!session_->waiting_for_identity(), 1000); | |
| 3592 | |
| 3593 rtc::scoped_ptr<SessionDescriptionInterface> offer(CreateOffer()); | |
| 3594 EXPECT_TRUE(offer == NULL); | |
| 3595 } | |
| 3596 | |
| 3597 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made | 3577 // Verifies that CreateOffer succeeds when Multiple CreateOffer calls are made |
| 3598 // before async identity generation is finished. | 3578 // before async identity generation is finished. |
| 3599 TEST_F(WebRtcSessionTest, | 3579 TEST_F(WebRtcSessionTest, |
| 3600 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { | 3580 TestMultipleCreateOfferBeforeIdentityRequestReturnSuccess) { |
| 3601 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3581 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3602 VerifyMultipleAsyncCreateDescription( | 3582 VerifyMultipleAsyncCreateDescription( |
| 3603 true, CreateSessionDescriptionRequest::kOffer); | 3583 CreateSessionDescriptionRequest::kOffer); |
| 3604 } | |
| 3605 | |
| 3606 // Verifies that CreateOffer fails when Multiple CreateOffer calls are made | |
| 3607 // before async identity generation fails. | |
| 3608 TEST_F(WebRtcSessionTest, | |
| 3609 TestMultipleCreateOfferBeforeIdentityRequestReturnFailure) { | |
| 3610 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
| 3611 VerifyMultipleAsyncCreateDescription( | |
| 3612 false, CreateSessionDescriptionRequest::kOffer); | |
| 3613 } | 3584 } |
| 3614 | 3585 |
| 3615 // Verifies that CreateAnswer succeeds when Multiple CreateAnswer calls are made | 3586 // Verifies that CreateAnswer succeeds when Multiple CreateAnswer calls are made |
| 3616 // before async identity generation is finished. | 3587 // before async identity generation is finished. |
| 3617 TEST_F(WebRtcSessionTest, | 3588 TEST_F(WebRtcSessionTest, |
| 3618 TestMultipleCreateAnswerBeforeIdentityRequestReturnSuccess) { | 3589 TestMultipleCreateAnswerBeforeIdentityRequestReturnSuccess) { |
| 3619 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3590 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3620 VerifyMultipleAsyncCreateDescription( | 3591 VerifyMultipleAsyncCreateDescription( |
| 3621 true, CreateSessionDescriptionRequest::kAnswer); | 3592 CreateSessionDescriptionRequest::kAnswer); |
| 3622 } | |
| 3623 | |
| 3624 // Verifies that CreateAnswer fails when Multiple CreateAnswer calls are made | |
| 3625 // before async identity generation fails. | |
| 3626 TEST_F(WebRtcSessionTest, | |
| 3627 TestMultipleCreateAnswerBeforeIdentityRequestReturnFailure) { | |
| 3628 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | |
| 3629 VerifyMultipleAsyncCreateDescription( | |
| 3630 false, CreateSessionDescriptionRequest::kAnswer); | |
| 3631 } | 3593 } |
| 3632 | 3594 |
| 3633 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote | 3595 // Verifies that setRemoteDescription fails when DTLS is disabled and the remote |
| 3634 // offer has no SDES crypto but only DTLS fingerprint. | 3596 // offer has no SDES crypto but only DTLS fingerprint. |
| 3635 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { | 3597 TEST_F(WebRtcSessionTest, TestSetRemoteOfferFailIfDtlsDisabledAndNoCrypto) { |
| 3636 // Init without DTLS. | 3598 // Init without DTLS. |
| 3637 Init(); | 3599 Init(); |
| 3638 // Create a remote offer with secured transport disabled. | 3600 // Create a remote offer with secured transport disabled. |
| 3639 cricket::MediaSessionOptions options; | 3601 cricket::MediaSessionOptions options; |
| 3640 JsepSessionDescription* offer(CreateRemoteOffer( | 3602 JsepSessionDescription* offer(CreateRemoteOffer( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3723 cricket::AudioOptions audio_options; | 3685 cricket::AudioOptions audio_options; |
| 3724 EXPECT_TRUE(voice_channel_->GetOptions(&audio_options)); | 3686 EXPECT_TRUE(voice_channel_->GetOptions(&audio_options)); |
| 3725 EXPECT_TRUE( | 3687 EXPECT_TRUE( |
| 3726 audio_options.combined_audio_video_bwe.GetWithDefaultIfUnset(false)); | 3688 audio_options.combined_audio_video_bwe.GetWithDefaultIfUnset(false)); |
| 3727 } | 3689 } |
| 3728 | 3690 |
| 3729 // Tests that we can renegotiate new media content with ICE candidates in the | 3691 // Tests that we can renegotiate new media content with ICE candidates in the |
| 3730 // new remote SDP. | 3692 // new remote SDP. |
| 3731 TEST_F(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) { | 3693 TEST_F(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesInSdp) { |
| 3732 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3694 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3733 InitWithDtls(); | 3695 InitWithCertificate(); |
| 3734 SetFactoryDtlsSrtp(); | 3696 SetFactoryDtlsSrtp(); |
| 3735 | 3697 |
| 3736 mediastream_signaling_.UseOptionsAudioOnly(); | 3698 mediastream_signaling_.UseOptionsAudioOnly(); |
| 3737 SessionDescriptionInterface* offer = CreateOffer(); | 3699 SessionDescriptionInterface* offer = CreateOffer(); |
| 3738 SetLocalDescriptionWithoutError(offer); | 3700 SetLocalDescriptionWithoutError(offer); |
| 3739 | 3701 |
| 3740 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 3702 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 3741 SetRemoteDescriptionWithoutError(answer); | 3703 SetRemoteDescriptionWithoutError(answer); |
| 3742 | 3704 |
| 3743 cricket::MediaSessionOptions options; | 3705 cricket::MediaSessionOptions options; |
| 3744 options.recv_video = true; | 3706 options.recv_video = true; |
| 3745 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); | 3707 offer = CreateRemoteOffer(options, cricket::SEC_DISABLED); |
| 3746 | 3708 |
| 3747 cricket::Candidate candidate1; | 3709 cricket::Candidate candidate1; |
| 3748 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); | 3710 candidate1.set_address(rtc::SocketAddress("1.1.1.1", 5000)); |
| 3749 candidate1.set_component(1); | 3711 candidate1.set_component(1); |
| 3750 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, | 3712 JsepIceCandidate ice_candidate(kMediaContentName1, kMediaContentIndex1, |
| 3751 candidate1); | 3713 candidate1); |
| 3752 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); | 3714 EXPECT_TRUE(offer->AddCandidate(&ice_candidate)); |
| 3753 SetRemoteDescriptionWithoutError(offer); | 3715 SetRemoteDescriptionWithoutError(offer); |
| 3754 | 3716 |
| 3755 answer = CreateAnswer(NULL); | 3717 answer = CreateAnswer(NULL); |
| 3756 SetLocalDescriptionWithoutError(answer); | 3718 SetLocalDescriptionWithoutError(answer); |
| 3757 } | 3719 } |
| 3758 | 3720 |
| 3759 // Tests that we can renegotiate new media content with ICE candidates separated | 3721 // Tests that we can renegotiate new media content with ICE candidates separated |
| 3760 // from the remote SDP. | 3722 // from the remote SDP. |
| 3761 TEST_F(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { | 3723 TEST_F(WebRtcSessionTest, TestRenegotiateNewMediaWithCandidatesSeparated) { |
| 3762 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); | 3724 MAYBE_SKIP_TEST(rtc::SSLStreamAdapter::HaveDtlsSrtp); |
| 3763 InitWithDtls(); | 3725 InitWithCertificate(); |
| 3764 SetFactoryDtlsSrtp(); | 3726 SetFactoryDtlsSrtp(); |
| 3765 | 3727 |
| 3766 mediastream_signaling_.UseOptionsAudioOnly(); | 3728 mediastream_signaling_.UseOptionsAudioOnly(); |
| 3767 SessionDescriptionInterface* offer = CreateOffer(); | 3729 SessionDescriptionInterface* offer = CreateOffer(); |
| 3768 SetLocalDescriptionWithoutError(offer); | 3730 SetLocalDescriptionWithoutError(offer); |
| 3769 | 3731 |
| 3770 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); | 3732 SessionDescriptionInterface* answer = CreateRemoteAnswer(offer); |
| 3771 SetRemoteDescriptionWithoutError(answer); | 3733 SetRemoteDescriptionWithoutError(answer); |
| 3772 | 3734 |
| 3773 cricket::MediaSessionOptions options; | 3735 cricket::MediaSessionOptions options; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3884 // terminated. The offer creation may or may not have succeeded, but we | 3846 // terminated. The offer creation may or may not have succeeded, but we |
| 3885 // must have received a notification which, so the only invalid state | 3847 // must have received a notification which, so the only invalid state |
| 3886 // is kInit. | 3848 // is kInit. |
| 3887 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); | 3849 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
| 3888 } | 3850 } |
| 3889 } | 3851 } |
| 3890 | 3852 |
| 3891 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 3853 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 3892 // currently fails because upon disconnection and reconnection OnIceComplete is | 3854 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 3893 // called more than once without returning to IceGatheringGathering. | 3855 // called more than once without returning to IceGatheringGathering. |
| OLD | NEW |