| 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, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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/jsepicecandidate.h" | 29 #include "talk/app/webrtc/jsepicecandidate.h" |
| 30 #include "talk/app/webrtc/jsepsessiondescription.h" | 30 #include "talk/app/webrtc/jsepsessiondescription.h" |
| 31 #include "talk/app/webrtc/mediastreamsignaling.h" | 31 #include "talk/app/webrtc/mediastreamsignaling.h" |
| 32 #include "talk/app/webrtc/streamcollection.h" | 32 #include "talk/app/webrtc/streamcollection.h" |
| 33 #include "talk/app/webrtc/test/fakeconstraints.h" | 33 #include "talk/app/webrtc/test/fakeconstraints.h" |
| 34 #include "talk/app/webrtc/test/fakedtlsidentityservice.h" | 34 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" |
| 35 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" | 35 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" |
| 36 #include "talk/app/webrtc/videotrack.h" | 36 #include "talk/app/webrtc/videotrack.h" |
| 37 #include "talk/app/webrtc/webrtcsession.h" | 37 #include "talk/app/webrtc/webrtcsession.h" |
| 38 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" | 38 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" |
| 39 #include "talk/media/base/fakemediaengine.h" | 39 #include "talk/media/base/fakemediaengine.h" |
| 40 #include "talk/media/base/fakevideorenderer.h" | 40 #include "talk/media/base/fakevideorenderer.h" |
| 41 #include "talk/media/base/mediachannel.h" | 41 #include "talk/media/base/mediachannel.h" |
| 42 #include "talk/media/devices/fakedevicemanager.h" | 42 #include "talk/media/devices/fakedevicemanager.h" |
| 43 #include "webrtc/p2p/base/stunserver.h" | 43 #include "webrtc/p2p/base/stunserver.h" |
| 44 #include "webrtc/p2p/base/teststunserver.h" | 44 #include "webrtc/p2p/base/teststunserver.h" |
| 45 #include "webrtc/p2p/base/testturnserver.h" | 45 #include "webrtc/p2p/base/testturnserver.h" |
| 46 #include "webrtc/p2p/base/transportchannel.h" | 46 #include "webrtc/p2p/base/transportchannel.h" |
| 47 #include "webrtc/p2p/client/basicportallocator.h" | 47 #include "webrtc/p2p/client/basicportallocator.h" |
| 48 #include "talk/session/media/channelmanager.h" | 48 #include "talk/session/media/channelmanager.h" |
| 49 #include "talk/session/media/mediasession.h" | 49 #include "talk/session/media/mediasession.h" |
| 50 #include "webrtc/base/fakenetwork.h" | 50 #include "webrtc/base/fakenetwork.h" |
| 51 #include "webrtc/base/firewallsocketserver.h" | 51 #include "webrtc/base/firewallsocketserver.h" |
| 52 #include "webrtc/base/gunit.h" | 52 #include "webrtc/base/gunit.h" |
| 53 #include "webrtc/base/logging.h" | 53 #include "webrtc/base/logging.h" |
| 54 #include "webrtc/base/network.h" | 54 #include "webrtc/base/network.h" |
| 55 #include "webrtc/base/physicalsocketserver.h" | 55 #include "webrtc/base/physicalsocketserver.h" |
| 56 #include "webrtc/base/ssladapter.h" | 56 #include "webrtc/base/ssladapter.h" |
| 57 #include "webrtc/base/sslidentity.h" |
| 57 #include "webrtc/base/sslstreamadapter.h" | 58 #include "webrtc/base/sslstreamadapter.h" |
| 58 #include "webrtc/base/stringutils.h" | 59 #include "webrtc/base/stringutils.h" |
| 59 #include "webrtc/base/thread.h" | 60 #include "webrtc/base/thread.h" |
| 60 #include "webrtc/base/virtualsocketserver.h" | 61 #include "webrtc/base/virtualsocketserver.h" |
| 61 | 62 |
| 62 #define MAYBE_SKIP_TEST(feature) \ | 63 #define MAYBE_SKIP_TEST(feature) \ |
| 63 if (!(feature())) { \ | 64 if (!(feature())) { \ |
| 64 LOG(LS_INFO) << "Feature disabled... skipping"; \ | 65 LOG(LS_INFO) << "Feature disabled... skipping"; \ |
| 65 return; \ | 66 return; \ |
| 66 } | 67 } |
| 67 | 68 |
| 68 using cricket::BaseSession; | 69 using cricket::BaseSession; |
| 69 using cricket::DF_PLAY; | 70 using cricket::DF_PLAY; |
| 70 using cricket::DF_SEND; | 71 using cricket::DF_SEND; |
| 71 using cricket::FakeVoiceMediaChannel; | 72 using cricket::FakeVoiceMediaChannel; |
| 72 using cricket::NS_GINGLE_P2P; | 73 using cricket::NS_GINGLE_P2P; |
| 73 using cricket::NS_JINGLE_ICE_UDP; | 74 using cricket::NS_JINGLE_ICE_UDP; |
| 74 using cricket::TransportInfo; | 75 using cricket::TransportInfo; |
| 75 using rtc::SocketAddress; | 76 using rtc::SocketAddress; |
| 76 using rtc::scoped_ptr; | 77 using rtc::scoped_ptr; |
| 77 using rtc::Thread; | 78 using rtc::Thread; |
| 78 using webrtc::CreateSessionDescription; | 79 using webrtc::CreateSessionDescription; |
| 79 using webrtc::CreateSessionDescriptionObserver; | 80 using webrtc::CreateSessionDescriptionObserver; |
| 80 using webrtc::CreateSessionDescriptionRequest; | 81 using webrtc::CreateSessionDescriptionRequest; |
| 81 using webrtc::DTLSIdentityRequestObserver; | 82 using webrtc::DtlsIdentityStoreInterface; |
| 82 using webrtc::DTLSIdentityServiceInterface; | |
| 83 using webrtc::FakeConstraints; | 83 using webrtc::FakeConstraints; |
| 84 using webrtc::IceCandidateCollection; | 84 using webrtc::IceCandidateCollection; |
| 85 using webrtc::JsepIceCandidate; | 85 using webrtc::JsepIceCandidate; |
| 86 using webrtc::JsepSessionDescription; | 86 using webrtc::JsepSessionDescription; |
| 87 using webrtc::PeerConnectionFactoryInterface; | 87 using webrtc::PeerConnectionFactoryInterface; |
| 88 using webrtc::PeerConnectionInterface; | 88 using webrtc::PeerConnectionInterface; |
| 89 using webrtc::SessionDescriptionInterface; | 89 using webrtc::SessionDescriptionInterface; |
| 90 using webrtc::StreamCollection; | 90 using webrtc::StreamCollection; |
| 91 using webrtc::WebRtcSession; | 91 using webrtc::WebRtcSession; |
| 92 using webrtc::kBundleWithoutRtcpMux; | 92 using webrtc::kBundleWithoutRtcpMux; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 EXPECT_TRUE(channel_manager_->Init()); | 375 EXPECT_TRUE(channel_manager_->Init()); |
| 376 desc_factory_->set_add_legacy_streams(false); | 376 desc_factory_->set_add_legacy_streams(false); |
| 377 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 377 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
| 378 } | 378 } |
| 379 | 379 |
| 380 void AddInterface(const SocketAddress& addr) { | 380 void AddInterface(const SocketAddress& addr) { |
| 381 network_manager_.AddInterface(addr); | 381 network_manager_.AddInterface(addr); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void Init( | 384 void Init( |
| 385 DTLSIdentityServiceInterface* identity_service, | 385 webrtc::DtlsIdentityStoreInterface* dtls_identity_store, |
| 386 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { | 386 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { |
| 387 ASSERT_TRUE(session_.get() == NULL); | 387 ASSERT_TRUE(session_.get() == NULL); |
| 388 session_.reset(new WebRtcSessionForTest( | 388 session_.reset(new WebRtcSessionForTest( |
| 389 channel_manager_.get(), rtc::Thread::Current(), | 389 channel_manager_.get(), rtc::Thread::Current(), |
| 390 rtc::Thread::Current(), allocator_.get(), | 390 rtc::Thread::Current(), allocator_.get(), |
| 391 &observer_, | 391 &observer_, |
| 392 &mediastream_signaling_)); | 392 &mediastream_signaling_)); |
| 393 | 393 |
| 394 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, | 394 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
| 395 observer_.ice_connection_state_); | 395 observer_.ice_connection_state_); |
| 396 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, | 396 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
| 397 observer_.ice_gathering_state_); | 397 observer_.ice_gathering_state_); |
| 398 | 398 |
| 399 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), | 399 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), |
| 400 identity_service, rtc_configuration)); | 400 rtc_configuration, dtls_identity_store, |
| 401 rtc::KT_DEFAULT)); |
| 401 session_->set_metrics_observer(&metrics_observer_); | 402 session_->set_metrics_observer(&metrics_observer_); |
| 402 } | 403 } |
| 403 | 404 |
| 404 void Init() { | 405 void Init() { |
| 405 PeerConnectionInterface::RTCConfiguration configuration; | 406 PeerConnectionInterface::RTCConfiguration configuration; |
| 406 Init(NULL, configuration); | 407 Init(NULL, configuration); |
| 407 } | 408 } |
| 408 | 409 |
| 409 void InitWithIceTransport( | 410 void InitWithIceTransport( |
| 410 PeerConnectionInterface::IceTransportsType ice_transport_type) { | 411 PeerConnectionInterface::IceTransportsType ice_transport_type) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 421 } | 422 } |
| 422 | 423 |
| 423 void InitWithRtcpMuxPolicy( | 424 void InitWithRtcpMuxPolicy( |
| 424 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { | 425 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) { |
| 425 PeerConnectionInterface::RTCConfiguration configuration; | 426 PeerConnectionInterface::RTCConfiguration configuration; |
| 426 configuration.rtcp_mux_policy = rtcp_mux_policy; | 427 configuration.rtcp_mux_policy = rtcp_mux_policy; |
| 427 Init(NULL, configuration); | 428 Init(NULL, configuration); |
| 428 } | 429 } |
| 429 | 430 |
| 430 void InitWithDtls(bool identity_request_should_fail = false) { | 431 void InitWithDtls(bool identity_request_should_fail = false) { |
| 431 FakeIdentityService* identity_service = new FakeIdentityService(); | 432 dtls_identity_store_.reset(new FakeDtlsIdentityStoreRSA()); |
| 432 identity_service->set_should_fail(identity_request_should_fail); | 433 dtls_identity_store_->set_should_fail(identity_request_should_fail); |
| 433 PeerConnectionInterface::RTCConfiguration configuration; | 434 PeerConnectionInterface::RTCConfiguration configuration; |
| 434 Init(identity_service, configuration); | 435 Init(dtls_identity_store_.get(), configuration); |
| 435 } | 436 } |
| 436 | 437 |
| 437 void InitWithDtmfCodec() { | 438 void InitWithDtmfCodec() { |
| 438 // Add kTelephoneEventCodec for dtmf test. | 439 // Add kTelephoneEventCodec for dtmf test. |
| 439 const cricket::AudioCodec kTelephoneEventCodec( | 440 const cricket::AudioCodec kTelephoneEventCodec( |
| 440 106, "telephone-event", 8000, 0, 1, 0); | 441 106, "telephone-event", 8000, 0, 1, 0); |
| 441 std::vector<cricket::AudioCodec> codecs; | 442 std::vector<cricket::AudioCodec> codecs; |
| 442 codecs.push_back(kTelephoneEventCodec); | 443 codecs.push_back(kTelephoneEventCodec); |
| 443 media_engine_->SetAudioCodecs(codecs); | 444 media_engine_->SetAudioCodecs(codecs); |
| 444 desc_factory_->set_audio_codecs(codecs); | 445 desc_factory_->set_audio_codecs(codecs); |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 rtc::FakeNetworkManager network_manager_; | 1275 rtc::FakeNetworkManager network_manager_; |
| 1275 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; | 1276 rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; |
| 1276 PeerConnectionFactoryInterface::Options options_; | 1277 PeerConnectionFactoryInterface::Options options_; |
| 1277 rtc::scoped_ptr<FakeConstraints> constraints_; | 1278 rtc::scoped_ptr<FakeConstraints> constraints_; |
| 1278 FakeMediaStreamSignaling mediastream_signaling_; | 1279 FakeMediaStreamSignaling mediastream_signaling_; |
| 1279 rtc::scoped_ptr<WebRtcSessionForTest> session_; | 1280 rtc::scoped_ptr<WebRtcSessionForTest> session_; |
| 1280 MockIceObserver observer_; | 1281 MockIceObserver observer_; |
| 1281 cricket::FakeVideoMediaChannel* video_channel_; | 1282 cricket::FakeVideoMediaChannel* video_channel_; |
| 1282 cricket::FakeVoiceMediaChannel* voice_channel_; | 1283 cricket::FakeVoiceMediaChannel* voice_channel_; |
| 1283 FakeMetricsObserver metrics_observer_; | 1284 FakeMetricsObserver metrics_observer_; |
| 1285 rtc::scoped_ptr<FakeDtlsIdentityStoreRSA> dtls_identity_store_; |
| 1284 }; | 1286 }; |
| 1285 | 1287 |
| 1286 TEST_F(WebRtcSessionTest, TestInitializeWithDtls) { | 1288 TEST_F(WebRtcSessionTest, TestInitializeWithDtls) { |
| 1287 InitWithDtls(); | 1289 InitWithDtls(); |
| 1288 // SDES is disabled when DTLS is on. | 1290 // SDES is disabled when DTLS is on. |
| 1289 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy()); | 1291 EXPECT_EQ(cricket::SEC_DISABLED, session_->SdesPolicy()); |
| 1290 } | 1292 } |
| 1291 | 1293 |
| 1292 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) { | 1294 TEST_F(WebRtcSessionTest, TestInitializeWithoutDtls) { |
| 1293 Init(); | 1295 Init(); |
| (...skipping 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3874 EXPECT_EQ(4000, option_val); | 3876 EXPECT_EQ(4000, option_val); |
| 3875 | 3877 |
| 3876 EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( | 3878 EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( |
| 3877 rtc::Socket::Option::OPT_RCVBUF, &option_val)); | 3879 rtc::Socket::Option::OPT_RCVBUF, &option_val)); |
| 3878 EXPECT_EQ(8000, option_val); | 3880 EXPECT_EQ(8000, option_val); |
| 3879 } | 3881 } |
| 3880 | 3882 |
| 3881 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 3883 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 3882 // currently fails because upon disconnection and reconnection OnIceComplete is | 3884 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 3883 // called more than once without returning to IceGatheringGathering. | 3885 // called more than once without returning to IceGatheringGathering. |
| OLD | NEW |