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 14 matching lines...) Expand all Loading... |
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/fakemetricsobserver.h" | 29 #include "talk/app/webrtc/fakemetricsobserver.h" |
30 #include "talk/app/webrtc/jsepicecandidate.h" | 30 #include "talk/app/webrtc/jsepicecandidate.h" |
31 #include "talk/app/webrtc/jsepsessiondescription.h" | 31 #include "talk/app/webrtc/jsepsessiondescription.h" |
32 #include "talk/app/webrtc/mediastreamsignaling.h" | 32 #include "talk/app/webrtc/mediastreamsignaling.h" |
33 #include "talk/app/webrtc/streamcollection.h" | 33 #include "talk/app/webrtc/streamcollection.h" |
34 #include "talk/app/webrtc/test/fakeconstraints.h" | 34 #include "talk/app/webrtc/test/fakeconstraints.h" |
35 #include "talk/app/webrtc/test/fakedtlsidentityservice.h" | 35 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" |
36 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" | 36 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" |
37 #include "talk/app/webrtc/videotrack.h" | 37 #include "talk/app/webrtc/videotrack.h" |
38 #include "talk/app/webrtc/webrtcsession.h" | 38 #include "talk/app/webrtc/webrtcsession.h" |
39 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" | 39 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" |
40 #include "talk/media/base/fakemediaengine.h" | 40 #include "talk/media/base/fakemediaengine.h" |
41 #include "talk/media/base/fakevideorenderer.h" | 41 #include "talk/media/base/fakevideorenderer.h" |
42 #include "talk/media/base/mediachannel.h" | 42 #include "talk/media/base/mediachannel.h" |
43 #include "talk/media/devices/fakedevicemanager.h" | 43 #include "talk/media/devices/fakedevicemanager.h" |
44 #include "webrtc/p2p/base/stunserver.h" | 44 #include "webrtc/p2p/base/stunserver.h" |
45 #include "webrtc/p2p/base/teststunserver.h" | 45 #include "webrtc/p2p/base/teststunserver.h" |
46 #include "webrtc/p2p/base/testturnserver.h" | 46 #include "webrtc/p2p/base/testturnserver.h" |
47 #include "webrtc/p2p/base/transportchannel.h" | 47 #include "webrtc/p2p/base/transportchannel.h" |
48 #include "webrtc/p2p/client/basicportallocator.h" | 48 #include "webrtc/p2p/client/basicportallocator.h" |
49 #include "talk/session/media/channelmanager.h" | 49 #include "talk/session/media/channelmanager.h" |
50 #include "talk/session/media/mediasession.h" | 50 #include "talk/session/media/mediasession.h" |
51 #include "webrtc/base/fakenetwork.h" | 51 #include "webrtc/base/fakenetwork.h" |
52 #include "webrtc/base/firewallsocketserver.h" | 52 #include "webrtc/base/firewallsocketserver.h" |
53 #include "webrtc/base/gunit.h" | 53 #include "webrtc/base/gunit.h" |
54 #include "webrtc/base/logging.h" | 54 #include "webrtc/base/logging.h" |
55 #include "webrtc/base/network.h" | 55 #include "webrtc/base/network.h" |
56 #include "webrtc/base/physicalsocketserver.h" | 56 #include "webrtc/base/physicalsocketserver.h" |
57 #include "webrtc/base/ssladapter.h" | 57 #include "webrtc/base/ssladapter.h" |
| 58 #include "webrtc/base/sslidentity.h" |
58 #include "webrtc/base/sslstreamadapter.h" | 59 #include "webrtc/base/sslstreamadapter.h" |
59 #include "webrtc/base/stringutils.h" | 60 #include "webrtc/base/stringutils.h" |
60 #include "webrtc/base/thread.h" | 61 #include "webrtc/base/thread.h" |
61 #include "webrtc/base/virtualsocketserver.h" | 62 #include "webrtc/base/virtualsocketserver.h" |
62 | 63 |
63 #define MAYBE_SKIP_TEST(feature) \ | 64 #define MAYBE_SKIP_TEST(feature) \ |
64 if (!(feature())) { \ | 65 if (!(feature())) { \ |
65 LOG(LS_INFO) << "Feature disabled... skipping"; \ | 66 LOG(LS_INFO) << "Feature disabled... skipping"; \ |
66 return; \ | 67 return; \ |
67 } | 68 } |
68 | 69 |
69 using cricket::BaseSession; | 70 using cricket::BaseSession; |
70 using cricket::DF_PLAY; | 71 using cricket::DF_PLAY; |
71 using cricket::DF_SEND; | 72 using cricket::DF_SEND; |
72 using cricket::FakeVoiceMediaChannel; | 73 using cricket::FakeVoiceMediaChannel; |
73 using cricket::NS_GINGLE_P2P; | 74 using cricket::NS_GINGLE_P2P; |
74 using cricket::NS_JINGLE_ICE_UDP; | 75 using cricket::NS_JINGLE_ICE_UDP; |
75 using cricket::TransportInfo; | 76 using cricket::TransportInfo; |
76 using rtc::SocketAddress; | 77 using rtc::SocketAddress; |
77 using rtc::scoped_ptr; | 78 using rtc::scoped_ptr; |
78 using rtc::Thread; | 79 using rtc::Thread; |
79 using webrtc::CreateSessionDescription; | 80 using webrtc::CreateSessionDescription; |
80 using webrtc::CreateSessionDescriptionObserver; | 81 using webrtc::CreateSessionDescriptionObserver; |
81 using webrtc::CreateSessionDescriptionRequest; | 82 using webrtc::CreateSessionDescriptionRequest; |
82 using webrtc::DTLSIdentityRequestObserver; | 83 using webrtc::DtlsIdentityStoreInterface; |
83 using webrtc::DTLSIdentityServiceInterface; | |
84 using webrtc::FakeConstraints; | 84 using webrtc::FakeConstraints; |
85 using webrtc::FakeMetricsObserver; | 85 using webrtc::FakeMetricsObserver; |
86 using webrtc::IceCandidateCollection; | 86 using webrtc::IceCandidateCollection; |
87 using webrtc::JsepIceCandidate; | 87 using webrtc::JsepIceCandidate; |
88 using webrtc::JsepSessionDescription; | 88 using webrtc::JsepSessionDescription; |
89 using webrtc::PeerConnectionFactoryInterface; | 89 using webrtc::PeerConnectionFactoryInterface; |
90 using webrtc::PeerConnectionInterface; | 90 using webrtc::PeerConnectionInterface; |
91 using webrtc::SessionDescriptionInterface; | 91 using webrtc::SessionDescriptionInterface; |
92 using webrtc::StreamCollection; | 92 using webrtc::StreamCollection; |
93 using webrtc::WebRtcSession; | 93 using webrtc::WebRtcSession; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 EXPECT_TRUE(channel_manager_->Init()); | 351 EXPECT_TRUE(channel_manager_->Init()); |
352 desc_factory_->set_add_legacy_streams(false); | 352 desc_factory_->set_add_legacy_streams(false); |
353 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 353 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
354 } | 354 } |
355 | 355 |
356 void AddInterface(const SocketAddress& addr) { | 356 void AddInterface(const SocketAddress& addr) { |
357 network_manager_.AddInterface(addr); | 357 network_manager_.AddInterface(addr); |
358 } | 358 } |
359 | 359 |
360 void Init( | 360 void Init( |
361 DTLSIdentityServiceInterface* identity_service, | 361 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store, |
362 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { | 362 const PeerConnectionInterface::RTCConfiguration& rtc_configuration) { |
363 ASSERT_TRUE(session_.get() == NULL); | 363 ASSERT_TRUE(session_.get() == NULL); |
364 session_.reset(new WebRtcSessionForTest( | 364 session_.reset(new WebRtcSessionForTest( |
365 channel_manager_.get(), rtc::Thread::Current(), | 365 channel_manager_.get(), rtc::Thread::Current(), |
366 rtc::Thread::Current(), allocator_.get(), | 366 rtc::Thread::Current(), allocator_.get(), |
367 &observer_, | 367 &observer_, |
368 &mediastream_signaling_)); | 368 &mediastream_signaling_)); |
369 | 369 |
370 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, | 370 EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, |
371 observer_.ice_connection_state_); | 371 observer_.ice_connection_state_); |
372 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, | 372 EXPECT_EQ(PeerConnectionInterface::kIceGatheringNew, |
373 observer_.ice_gathering_state_); | 373 observer_.ice_gathering_state_); |
374 | 374 |
375 EXPECT_TRUE(session_->Initialize(options_, constraints_.get(), | 375 EXPECT_TRUE(session_->Initialize( |
376 identity_service, rtc_configuration)); | 376 options_, constraints_.get(), dtls_identity_store.Pass(), |
| 377 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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, configuration); |
404 } | 405 } |
405 | 406 |
406 void InitWithDtls(bool identity_request_should_fail = false) { | 407 void InitWithDtls(bool identity_request_should_fail = false) { |
407 FakeIdentityService* identity_service = new FakeIdentityService(); | 408 rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store( |
408 identity_service->set_should_fail(identity_request_should_fail); | 409 new FakeDtlsIdentityStore()); |
| 410 dtls_identity_store->set_should_fail(identity_request_should_fail); |
409 PeerConnectionInterface::RTCConfiguration configuration; | 411 PeerConnectionInterface::RTCConfiguration configuration; |
410 Init(identity_service, configuration); | 412 Init(dtls_identity_store.Pass(), configuration); |
411 } | 413 } |
412 | 414 |
413 void InitWithDtmfCodec() { | 415 void InitWithDtmfCodec() { |
414 // Add kTelephoneEventCodec for dtmf test. | 416 // Add kTelephoneEventCodec for dtmf test. |
415 const cricket::AudioCodec kTelephoneEventCodec( | 417 const cricket::AudioCodec kTelephoneEventCodec( |
416 106, "telephone-event", 8000, 0, 1, 0); | 418 106, "telephone-event", 8000, 0, 1, 0); |
417 std::vector<cricket::AudioCodec> codecs; | 419 std::vector<cricket::AudioCodec> codecs; |
418 codecs.push_back(kTelephoneEventCodec); | 420 codecs.push_back(kTelephoneEventCodec); |
419 media_engine_->SetAudioCodecs(codecs); | 421 media_engine_->SetAudioCodecs(codecs); |
420 desc_factory_->set_audio_codecs(codecs); | 422 desc_factory_->set_audio_codecs(codecs); |
(...skipping 3520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3941 // terminated. The offer creation may or may not have succeeded, but we | 3943 // terminated. The offer creation may or may not have succeeded, but we |
3942 // must have received a notification which, so the only invalid state | 3944 // must have received a notification which, so the only invalid state |
3943 // is kInit. | 3945 // is kInit. |
3944 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); | 3946 EXPECT_NE(WebRtcSessionCreateSDPObserverForTest::kInit, o->state()); |
3945 } | 3947 } |
3946 } | 3948 } |
3947 | 3949 |
3948 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 3950 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
3949 // currently fails because upon disconnection and reconnection OnIceComplete is | 3951 // currently fails because upon disconnection and reconnection OnIceComplete is |
3950 // called more than once without returning to IceGatheringGathering. | 3952 // called more than once without returning to IceGatheringGathering. |
OLD | NEW |