diff --git a/talk/app/webrtc/java/jni/classreferenceholder.cc b/talk/app/webrtc/java/jni/classreferenceholder.cc index d22f79238e..bc4339deab 100644 --- a/talk/app/webrtc/java/jni/classreferenceholder.cc +++ b/talk/app/webrtc/java/jni/classreferenceholder.cc @@ -98,6 +98,7 @@ ClassReferenceHolder::ClassReferenceHolder(JNIEnv* jni) { LoadClass(jni, "org/webrtc/MediaStream"); LoadClass(jni, "org/webrtc/MediaStreamTrack$State"); LoadClass(jni, "org/webrtc/PeerConnection$BundlePolicy"); + LoadClass(jni, "org/webrtc/PeerConnection$ContinualGatheringPolicy"); LoadClass(jni, "org/webrtc/PeerConnection$RtcpMuxPolicy"); LoadClass(jni, "org/webrtc/PeerConnection$IceConnectionState"); LoadClass(jni, "org/webrtc/PeerConnection$IceGatheringState"); diff --git a/talk/app/webrtc/java/jni/peerconnection_jni.cc b/talk/app/webrtc/java/jni/peerconnection_jni.cc index 8e274a4721..6fe2c61473 100644 --- a/talk/app/webrtc/java/jni/peerconnection_jni.cc +++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc @@ -1322,6 +1322,23 @@ static rtc::KeyType JavaKeyTypeToNativeType(JNIEnv* jni, jobject j_key_type) { return rtc::KT_ECDSA; } +static PeerConnectionInterface::ContinualGatheringPolicy + JavaContinualGatheringPolicyToNativeType( + JNIEnv* jni, jobject j_gathering_policy) { + std::string enum_name = GetJavaEnumName( + jni, "org/webrtc/PeerConnection$ContinualGatheringPolicy", + j_gathering_policy); + if (enum_name == "GATHER_ONCE") + return PeerConnectionInterface::GATHER_ONCE; + + if (enum_name == "GATHER_CONTINUALLY") + return PeerConnectionInterface::GATHER_CONTINUALLY; + + RTC_CHECK(false) << "Unexpected ContinualGatheringPolicy enum name " + << enum_name; + return PeerConnectionInterface::GATHER_ONCE; +} + static void JavaIceServersToJsepIceServers( JNIEnv* jni, jobject j_ice_servers, PeerConnectionInterface::IceServers* ice_servers) { @@ -1409,6 +1426,12 @@ JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)( "Lorg/webrtc/PeerConnection$KeyType;"); jobject j_key_type = GetObjectField(jni, j_rtc_config, j_key_type_id); + jfieldID j_continual_gathering_policy_id = + GetFieldID(jni, j_rtc_config_class, "continualGatheringPolicy", + "Lorg/webrtc/PeerConnection$ContinualGatheringPolicy;"); + jobject j_continual_gathering_policy = + GetObjectField(jni, j_rtc_config, j_continual_gathering_policy_id); + PeerConnectionInterface::RTCConfiguration rtc_config; rtc_config.type = JavaIceTransportsTypeToNativeType(jni, j_ice_transports_type); @@ -1424,6 +1447,9 @@ JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)( jni, j_rtc_config, j_audio_jitter_buffer_fast_accelerate_id); rtc_config.ice_connection_receiving_timeout = GetIntField(jni, j_rtc_config, j_ice_connection_receiving_timeout_id); + rtc_config.continual_gathering_policy = + JavaContinualGatheringPolicyToNativeType( + jni, j_continual_gathering_policy); // Create ECDSA certificate. if (JavaKeyTypeToNativeType(jni, j_key_type) == rtc::KT_ECDSA) { diff --git a/talk/app/webrtc/java/src/org/webrtc/PeerConnection.java b/talk/app/webrtc/java/src/org/webrtc/PeerConnection.java index 8730af96c9..f09c58fc1f 100644 --- a/talk/app/webrtc/java/src/org/webrtc/PeerConnection.java +++ b/talk/app/webrtc/java/src/org/webrtc/PeerConnection.java @@ -135,6 +135,11 @@ public class PeerConnection { RSA, ECDSA } + /** Java version of PeerConnectionInterface.ContinualGatheringPolicy */ + public enum ContinualGatheringPolicy { + GATHER_ONCE, GATHER_CONTINUALLY + } + /** Java version of PeerConnectionInterface.RTCConfiguration */ public static class RTCConfiguration { public IceTransportsType iceTransportsType; @@ -146,6 +151,7 @@ public class PeerConnection { public boolean audioJitterBufferFastAccelerate; public int iceConnectionReceivingTimeout; public KeyType keyType; + public ContinualGatheringPolicy continualGatheringPolicy; public RTCConfiguration(List iceServers) { iceTransportsType = IceTransportsType.ALL; @@ -157,6 +163,7 @@ public class PeerConnection { audioJitterBufferFastAccelerate = false; iceConnectionReceivingTimeout = -1; keyType = KeyType.ECDSA; + continualGatheringPolicy = ContinualGatheringPolicy.GATHER_ONCE; } }; diff --git a/talk/app/webrtc/peerconnection.cc b/talk/app/webrtc/peerconnection.cc index 121565593d..f934b61b6f 100644 --- a/talk/app/webrtc/peerconnection.cc +++ b/talk/app/webrtc/peerconnection.cc @@ -696,8 +696,7 @@ bool PeerConnection::UpdateIce(const RTCConfiguration& config) { } } } - session_->SetIceConnectionReceivingTimeout( - config.ice_connection_receiving_timeout); + session_->SetIceConfig(session_->ParseIceConfig(config)); return session_->SetIceTransports(config.type); } diff --git a/talk/app/webrtc/peerconnectioninterface.h b/talk/app/webrtc/peerconnectioninterface.h index ca853385e6..2f33b41548 100644 --- a/talk/app/webrtc/peerconnectioninterface.h +++ b/talk/app/webrtc/peerconnectioninterface.h @@ -225,6 +225,11 @@ class PeerConnectionInterface : public rtc::RefCountInterface { kTcpCandidatePolicyDisabled }; + enum ContinualGatheringPolicy { + GATHER_ONCE, + GATHER_CONTINUALLY + }; + // TODO(hbos): Change into class with private data and public getters. struct RTCConfiguration { static const int kUndefined = -1; @@ -245,6 +250,7 @@ class PeerConnectionInterface : public rtc::RefCountInterface { int audio_jitter_buffer_max_packets; bool audio_jitter_buffer_fast_accelerate; int ice_connection_receiving_timeout; + ContinualGatheringPolicy continual_gathering_policy; std::vector> certificates; RTCConfiguration() @@ -255,7 +261,8 @@ class PeerConnectionInterface : public rtc::RefCountInterface { tcp_candidate_policy(kTcpCandidatePolicyEnabled), audio_jitter_buffer_max_packets(kAudioJitterBufferMaxPackets), audio_jitter_buffer_fast_accelerate(false), - ice_connection_receiving_timeout(kUndefined) {} + ice_connection_receiving_timeout(kUndefined), + continual_gathering_policy(GATHER_ONCE) {} }; struct RTCOfferAnswerOptions { diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc index bd1cd1a0ac..7f71961682 100644 --- a/talk/app/webrtc/webrtcsession.cc +++ b/talk/app/webrtc/webrtcsession.cc @@ -608,8 +608,7 @@ bool WebRtcSession::Initialize( certificate = rtc_configuration.certificates[0]; } - SetIceConnectionReceivingTimeout( - rtc_configuration.ice_connection_receiving_timeout); + SetIceConfig(ParseIceConfig(rtc_configuration)); // TODO(perkj): Take |constraints| into consideration. Return false if not all // mandatory constraints can be fulfilled. Note that |constraints| @@ -782,6 +781,15 @@ bool WebRtcSession::Initialize( return true; } +cricket::IceConfig WebRtcSession::ParseIceConfig( + const PeerConnectionInterface::RTCConfiguration& config) const { + cricket::IceConfig ice_config; + ice_config.receiving_timeout_ms = config.ice_connection_receiving_timeout; + ice_config.gather_continually = (config.continual_gathering_policy == + PeerConnectionInterface::GATHER_CONTINUALLY); + return ice_config; +} + void WebRtcSession::Terminate() { SetState(STATE_RECEIVEDTERMINATE); RemoveUnusedChannels(NULL); diff --git a/talk/app/webrtc/webrtcsession.h b/talk/app/webrtc/webrtcsession.h index 1ad9a69e59..b3d76bf6b4 100644 --- a/talk/app/webrtc/webrtcsession.h +++ b/talk/app/webrtc/webrtcsession.h @@ -178,6 +178,9 @@ class WebRtcSession : public cricket::BaseSession, bool SetIceTransports(PeerConnectionInterface::IceTransportsType type); + cricket::IceConfig ParseIceConfig( + const PeerConnectionInterface::RTCConfiguration& config) const; + const SessionDescriptionInterface* local_description() const { return local_desc_.get(); } diff --git a/webrtc/p2p/base/dtlstransportchannel.h b/webrtc/p2p/base/dtlstransportchannel.h index ea6a579dfb..e52ca10d1d 100644 --- a/webrtc/p2p/base/dtlstransportchannel.h +++ b/webrtc/p2p/base/dtlstransportchannel.h @@ -197,8 +197,8 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { channel_->AddRemoteCandidate(candidate); } - void SetReceivingTimeout(int receiving_timeout_ms) override { - channel_->SetReceivingTimeout(receiving_timeout_ms); + void SetIceConfig(const IceConfig& config) override { + channel_->SetIceConfig(config); } // Needed by DtlsTransport. diff --git a/webrtc/p2p/base/faketransportcontroller.h b/webrtc/p2p/base/faketransportcontroller.h index e356e814b7..826b1a6384 100644 --- a/webrtc/p2p/base/faketransportcontroller.h +++ b/webrtc/p2p/base/faketransportcontroller.h @@ -182,11 +182,13 @@ class FakeTransportChannel : public TransportChannelImpl, void SetReceiving(bool receiving) { set_receiving(receiving); } - void SetReceivingTimeout(int timeout) override { - receiving_timeout_ = timeout; + void SetIceConfig(const IceConfig& config) override { + receiving_timeout_ = config.receiving_timeout_ms; + gather_continually_ = config.gather_continually; } int receiving_timeout() const { return receiving_timeout_; } + bool gather_continually() const { return gather_continually_; } int SendPacket(const char* data, size_t len, @@ -319,6 +321,7 @@ class FakeTransportChannel : public TransportChannelImpl, std::vector srtp_ciphers_; std::string chosen_srtp_cipher_; int receiving_timeout_ = -1; + bool gather_continually_ = false; IceRole role_ = ICEROLE_UNKNOWN; uint64 tiebreaker_ = 0; std::string ice_ufrag_; diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc index 2a851f5c72..15ac006872 100644 --- a/webrtc/p2p/base/p2ptransportchannel.cc +++ b/webrtc/p2p/base/p2ptransportchannel.cc @@ -355,19 +355,22 @@ void P2PTransportChannel::SetRemoteIceMode(IceMode mode) { remote_ice_mode_ = mode; } -void P2PTransportChannel::SetReceivingTimeout(int receiving_timeout_ms) { - if (receiving_timeout_ms < 0) { +void P2PTransportChannel::SetIceConfig(const IceConfig& config) { + gather_continually_ = config.gather_continually; + LOG(LS_INFO) << "Set gather_continually to " << gather_continually_; + + if (config.receiving_timeout_ms < 0) { return; } - receiving_timeout_ = receiving_timeout_ms; + receiving_timeout_ = config.receiving_timeout_ms; check_receiving_delay_ = std::max(MIN_CHECK_RECEIVING_DELAY, receiving_timeout_ / 10); for (Connection* connection : connections_) { connection->set_receiving_timeout(receiving_timeout_); } - LOG(LS_VERBOSE) << "Set ICE receiving timeout to " << receiving_timeout_ - << " milliseconds"; + LOG(LS_INFO) << "Set ICE receiving timeout to " << receiving_timeout_ + << " milliseconds"; } // Go into the state of processing candidates, and running in general diff --git a/webrtc/p2p/base/p2ptransportchannel.h b/webrtc/p2p/base/p2ptransportchannel.h index 51426239db..3f7b696002 100644 --- a/webrtc/p2p/base/p2ptransportchannel.h +++ b/webrtc/p2p/base/p2ptransportchannel.h @@ -74,9 +74,9 @@ class P2PTransportChannel : public TransportChannelImpl, return gathering_state_; } void AddRemoteCandidate(const Candidate& candidate) override; - // Sets the receiving timeout in milliseconds. + // Sets the receiving timeout and gather_continually. // This also sets the check_receiving_delay proportionally. - void SetReceivingTimeout(int receiving_timeout_ms) override; + void SetIceConfig(const IceConfig& config) override; // From TransportChannel: int SendPacket(const char* data, @@ -250,6 +250,7 @@ class P2PTransportChannel : public TransportChannelImpl, int check_receiving_delay_; int receiving_timeout_; uint32 last_ping_sent_ms_ = 0; + bool gather_continually_ = false; RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); }; diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc index 2987ba5b23..8c25d82068 100644 --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc @@ -100,6 +100,14 @@ enum { MSG_CANDIDATE }; +static cricket::IceConfig CreateIceConfig(int receiving_timeout_ms, + bool gather_continually) { + cricket::IceConfig config; + config.receiving_timeout_ms = receiving_timeout_ms; + config.gather_continually = gather_continually; + return config; +} + // This test simulates 2 P2P endpoints that want to establish connectivity // with each other over various network topologies and conditions, which can be // specified in each individial test. @@ -386,7 +394,6 @@ class P2PTransportChannelTestBase : public testing::Test, void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { return GetEndpoint(endpoint)->SetAllowTcpListen(allow_tcp_listen); } - bool IsLocalToPrflxOrTheReverse(const Result& expected) { return ( (expected.local_type == "local" && expected.remote_type == "prflx") || @@ -1498,8 +1505,9 @@ TEST_F(P2PTransportChannelMultihomedTest, TestFailoverControlledSide) { CreateChannels(1); // Make the receiving timeout shorter for testing. - ep1_ch1()->SetReceivingTimeout(1000); - ep2_ch1()->SetReceivingTimeout(1000); + cricket::IceConfig config = CreateIceConfig(1000, false); + ep1_ch1()->SetIceConfig(config); + ep2_ch1()->SetIceConfig(config); EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && ep2_ch1()->receiving() && ep2_ch1()->writable(), @@ -1549,8 +1557,9 @@ TEST_F(P2PTransportChannelMultihomedTest, TestFailoverControllingSide) { // Create channels and let them go writable, as usual. CreateChannels(1); // Make the receiving timeout shorter for testing. - ep1_ch1()->SetReceivingTimeout(1000); - ep2_ch1()->SetReceivingTimeout(1000); + cricket::IceConfig config = CreateIceConfig(1000, false); + ep1_ch1()->SetIceConfig(config); + ep2_ch1()->SetIceConfig(config); EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && ep2_ch1()->receiving() && ep2_ch1()->writable(), 1000); @@ -1796,7 +1805,7 @@ TEST_F(P2PTransportChannelPingTest, TestReceivingStateChange) { // small. EXPECT_LE(1000, ch.receiving_timeout()); EXPECT_LE(200, ch.check_receiving_delay()); - ch.SetReceivingTimeout(500); + ch.SetIceConfig(CreateIceConfig(500, false)); EXPECT_EQ(500, ch.receiving_timeout()); EXPECT_EQ(50, ch.check_receiving_delay()); ch.Connect(); @@ -2018,7 +2027,7 @@ TEST_F(P2PTransportChannelPingTest, TestDontPruneWhenWeak) { conn2->SignalNominated(conn2); EXPECT_TRUE_WAIT(conn1->pruned(), 3000); - ch.SetReceivingTimeout(500); + ch.SetIceConfig(CreateIceConfig(500, false)); // Wait until conn2 becomes not receiving. EXPECT_TRUE_WAIT(!conn2->receiving(), 3000); diff --git a/webrtc/p2p/base/session.cc b/webrtc/p2p/base/session.cc index 83edb63ea5..5e5a88f8d1 100644 --- a/webrtc/p2p/base/session.cc +++ b/webrtc/p2p/base/session.cc @@ -206,8 +206,8 @@ void BaseSession::SetError(Error error, const std::string& error_desc) { } } -void BaseSession::SetIceConnectionReceivingTimeout(int timeout_ms) { - transport_controller_->SetIceConnectionReceivingTimeout(timeout_ms); +void BaseSession::SetIceConfig(const IceConfig& config) { + transport_controller_->SetIceConfig(config); } void BaseSession::MaybeStartGathering() { diff --git a/webrtc/p2p/base/session.h b/webrtc/p2p/base/session.h index d8721fd0f8..2cf8c8a52f 100644 --- a/webrtc/p2p/base/session.h +++ b/webrtc/p2p/base/session.h @@ -146,7 +146,7 @@ class BaseSession : public sigslot::has_slots<>, // TODO(ronghuawu): remove the SetError method that doesn't take |error_desc|. virtual void SetError(Error error, const std::string& error_desc); - void SetIceConnectionReceivingTimeout(int timeout_ms); + void SetIceConfig(const IceConfig& ice_config); // Start gathering candidates for any new transports, or transports doing an // ICE restart. diff --git a/webrtc/p2p/base/transport.cc b/webrtc/p2p/base/transport.cc index b7aba7540a..3e5f1b9f3a 100644 --- a/webrtc/p2p/base/transport.cc +++ b/webrtc/p2p/base/transport.cc @@ -125,10 +125,10 @@ bool Transport::GetRemoteSSLCertificate(rtc::SSLCertificate** cert) { return iter->second->GetRemoteSSLCertificate(cert); } -void Transport::SetChannelReceivingTimeout(int timeout_ms) { - channel_receiving_timeout_ = timeout_ms; +void Transport::SetIceConfig(const IceConfig& config) { + ice_config_ = config; for (const auto& kv : channels_) { - kv.second->SetReceivingTimeout(timeout_ms); + kv.second->SetIceConfig(ice_config_); } } @@ -229,7 +229,7 @@ TransportChannelImpl* Transport::CreateChannel(int component) { // Push down our transport state to the new channel. impl->SetIceRole(ice_role_); impl->SetIceTiebreaker(tiebreaker_); - impl->SetReceivingTimeout(channel_receiving_timeout_); + impl->SetIceConfig(ice_config_); // TODO(ronghuawu): Change CreateChannel to be able to return error since // below Apply**Description calls can fail. if (local_description_) diff --git a/webrtc/p2p/base/transport.h b/webrtc/p2p/base/transport.h index cd763ab3bc..10b289ce20 100644 --- a/webrtc/p2p/base/transport.h +++ b/webrtc/p2p/base/transport.h @@ -139,6 +139,14 @@ struct TransportStats { TransportChannelStatsList channel_stats; }; +// Information about ICE configuration. +struct IceConfig { + // The ICE connection receiving timeout value. + int receiving_timeout_ms = -1; + // If true, the most recent port allocator session will keep on running. + bool gather_continually = false; +}; + bool BadTransportDescription(const std::string& desc, std::string* err_desc); bool IceCredentialsChanged(const std::string& old_ufrag, @@ -197,7 +205,7 @@ class Transport : public sigslot::has_slots<> { void SetIceTiebreaker(uint64 IceTiebreaker) { tiebreaker_ = IceTiebreaker; } uint64 IceTiebreaker() { return tiebreaker_; } - void SetChannelReceivingTimeout(int timeout_ms); + void SetIceConfig(const IceConfig& config); // Must be called before applying local session description. virtual void SetLocalCertificate( @@ -399,7 +407,7 @@ class Transport : public sigslot::has_slots<> { IceRole ice_role_ = ICEROLE_UNKNOWN; uint64 tiebreaker_ = 0; IceMode remote_ice_mode_ = ICEMODE_FULL; - int channel_receiving_timeout_ = -1; + IceConfig ice_config_; rtc::scoped_ptr local_description_; rtc::scoped_ptr remote_description_; bool local_description_set_ = false; diff --git a/webrtc/p2p/base/transportchannelimpl.h b/webrtc/p2p/base/transportchannelimpl.h index ddddf15a03..ab3a31e1e9 100644 --- a/webrtc/p2p/base/transportchannelimpl.h +++ b/webrtc/p2p/base/transportchannelimpl.h @@ -59,7 +59,7 @@ class TransportChannelImpl : public TransportChannel { // SetRemoteIceMode must be implemented only by the ICE transport channels. virtual void SetRemoteIceMode(IceMode mode) = 0; - virtual void SetReceivingTimeout(int timeout_ms) = 0; + virtual void SetIceConfig(const IceConfig& config) = 0; // Begins the process of attempting to make a connection to the other client. virtual void Connect() = 0; diff --git a/webrtc/p2p/base/transportcontroller.cc b/webrtc/p2p/base/transportcontroller.cc index 4d9e403d3b..d84d574f15 100644 --- a/webrtc/p2p/base/transportcontroller.cc +++ b/webrtc/p2p/base/transportcontroller.cc @@ -53,10 +53,9 @@ bool TransportController::SetSslMaxProtocolVersion( &TransportController::SetSslMaxProtocolVersion_w, this, version)); } -void TransportController::SetIceConnectionReceivingTimeout(int timeout_ms) { +void TransportController::SetIceConfig(const IceConfig& config) { worker_thread_->Invoke( - rtc::Bind(&TransportController::SetIceConnectionReceivingTimeout_w, this, - timeout_ms)); + rtc::Bind(&TransportController::SetIceConfig_w, this, config)); } void TransportController::SetIceRole(IceRole ice_role) { @@ -235,7 +234,7 @@ Transport* TransportController::GetOrCreateTransport_w( // The stuff below happens outside of CreateTransport_w so that unit tests // can override CreateTransport_w to return a different type of transport. transport->SetSslMaxProtocolVersion(ssl_max_version_); - transport->SetChannelReceivingTimeout(ice_receiving_timeout_ms_); + transport->SetIceConfig(ice_config_); transport->SetIceRole(ice_role_); transport->SetIceTiebreaker(ice_tiebreaker_); if (certificate_) { @@ -297,11 +296,11 @@ bool TransportController::SetSslMaxProtocolVersion_w( return true; } -void TransportController::SetIceConnectionReceivingTimeout_w(int timeout_ms) { +void TransportController::SetIceConfig_w(const IceConfig& config) { RTC_DCHECK(worker_thread_->IsCurrent()); - ice_receiving_timeout_ms_ = timeout_ms; + ice_config_ = config; for (const auto& kv : transports_) { - kv.second->SetChannelReceivingTimeout(timeout_ms); + kv.second->SetIceConfig(ice_config_); } } diff --git a/webrtc/p2p/base/transportcontroller.h b/webrtc/p2p/base/transportcontroller.h index e31eb83aff..f506e01bcf 100644 --- a/webrtc/p2p/base/transportcontroller.h +++ b/webrtc/p2p/base/transportcontroller.h @@ -45,7 +45,7 @@ class TransportController : public sigslot::has_slots<>, // and WebRtcSession are combined bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version); - void SetIceConnectionReceivingTimeout(int timeout_ms); + void SetIceConfig(const IceConfig& config); void SetIceRole(IceRole ice_role); // TODO(deadbeef) - Return role of each transport, as role may differ from @@ -126,7 +126,7 @@ class TransportController : public sigslot::has_slots<>, void DestroyAllTransports_w(); bool SetSslMaxProtocolVersion_w(rtc::SSLProtocolVersion version); - void SetIceConnectionReceivingTimeout_w(int timeout_ms); + void SetIceConfig_w(const IceConfig& config); void SetIceRole_w(IceRole ice_role); bool GetSslRole_w(rtc::SSLRole* role); bool SetLocalCertificate_w( @@ -180,10 +180,7 @@ class TransportController : public sigslot::has_slots<>, IceGatheringState gathering_state_ = kIceGatheringNew; // TODO(deadbeef): Move the fields below down to the transports themselves - - // Timeout value in milliseconds for which no ICE connection receives - // any packets - int ice_receiving_timeout_ms_ = -1; + IceConfig ice_config_; IceRole ice_role_ = ICEROLE_CONTROLLING; // Flag which will be set to true after the first role switch bool ice_role_switch_ = false; diff --git a/webrtc/p2p/base/transportcontroller_unittest.cc b/webrtc/p2p/base/transportcontroller_unittest.cc index c78352591b..23e4dc8067 100644 --- a/webrtc/p2p/base/transportcontroller_unittest.cc +++ b/webrtc/p2p/base/transportcontroller_unittest.cc @@ -134,6 +134,14 @@ class TransportControllerTest : public testing::Test, channel2->SetConnectionCount(1); } + cricket::IceConfig CreateIceConfig(int receiving_timeout_ms, + bool gather_continually) { + cricket::IceConfig config; + config.receiving_timeout_ms = receiving_timeout_ms; + config.gather_continually = gather_continually; + return config; + } + protected: void OnConnectionState(IceConnectionState state) { if (!signaling_thread_->IsCurrent()) { @@ -189,17 +197,19 @@ class TransportControllerTest : public testing::Test, bool signaled_on_non_signaling_thread_ = false; }; -TEST_F(TransportControllerTest, TestSetIceReceivingTimeout) { +TEST_F(TransportControllerTest, TestSetIceConfig) { FakeTransportChannel* channel1 = CreateChannel("audio", 1); ASSERT_NE(nullptr, channel1); - transport_controller_->SetIceConnectionReceivingTimeout(1000); + transport_controller_->SetIceConfig(CreateIceConfig(1000, true)); EXPECT_EQ(1000, channel1->receiving_timeout()); + EXPECT_TRUE(channel1->gather_continually()); // Test that value stored in controller is applied to new channels. FakeTransportChannel* channel2 = CreateChannel("video", 1); ASSERT_NE(nullptr, channel2); EXPECT_EQ(1000, channel2->receiving_timeout()); + EXPECT_TRUE(channel2->gather_continually()); } TEST_F(TransportControllerTest, TestSetSslMaxProtocolVersion) {