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 rtc::scoped_ptr<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( |
400 identity_service, rtc_configuration)); | 400 options_, constraints_.get(), dtls_identity_store.Pass(), |
| 401 rtc_configuration)); |
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(nullptr, configuration); |
407 } | 408 } |
408 | 409 |
409 void InitWithIceTransport( | 410 void InitWithIceTransport( |
410 PeerConnectionInterface::IceTransportsType ice_transport_type) { | 411 PeerConnectionInterface::IceTransportsType ice_transport_type) { |
411 PeerConnectionInterface::RTCConfiguration configuration; | 412 PeerConnectionInterface::RTCConfiguration configuration; |
412 configuration.type = ice_transport_type; | 413 configuration.type = ice_transport_type; |
413 Init(NULL, configuration); | 414 Init(nullptr, configuration); |
414 } | 415 } |
415 | 416 |
416 void InitWithBundlePolicy( | 417 void InitWithBundlePolicy( |
417 PeerConnectionInterface::BundlePolicy bundle_policy) { | 418 PeerConnectionInterface::BundlePolicy bundle_policy) { |
418 PeerConnectionInterface::RTCConfiguration configuration; | 419 PeerConnectionInterface::RTCConfiguration configuration; |
419 configuration.bundle_policy = bundle_policy; | 420 configuration.bundle_policy = bundle_policy; |
420 Init(NULL, configuration); | 421 Init(nullptr, configuration); |
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(nullptr, 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 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
432 identity_service->set_should_fail(identity_request_should_fail); | 433 new FakeDtlsIdentityStore()); |
| 434 dtls_identity_store->set_should_fail(identity_request_should_fail); |
433 PeerConnectionInterface::RTCConfiguration configuration; | 435 PeerConnectionInterface::RTCConfiguration configuration; |
434 Init(identity_service, configuration); | 436 Init(dtls_identity_store.Pass(), configuration); |
435 } | 437 } |
436 | 438 |
437 void InitWithDtmfCodec() { | 439 void InitWithDtmfCodec() { |
438 // Add kTelephoneEventCodec for dtmf test. | 440 // Add kTelephoneEventCodec for dtmf test. |
439 const cricket::AudioCodec kTelephoneEventCodec( | 441 const cricket::AudioCodec kTelephoneEventCodec( |
440 106, "telephone-event", 8000, 0, 1, 0); | 442 106, "telephone-event", 8000, 0, 1, 0); |
441 std::vector<cricket::AudioCodec> codecs; | 443 std::vector<cricket::AudioCodec> codecs; |
442 codecs.push_back(kTelephoneEventCodec); | 444 codecs.push_back(kTelephoneEventCodec); |
443 media_engine_->SetAudioCodecs(codecs); | 445 media_engine_->SetAudioCodecs(codecs); |
444 desc_factory_->set_audio_codecs(codecs); | 446 desc_factory_->set_audio_codecs(codecs); |
(...skipping 3429 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 |