Add a switch to redetermine role when ICE restarts.
R=pthatcher@webrtc.org
Review URL: https://codereview.webrtc.org/2295493002 .
Cr-Commit-Position: refs/heads/master@{#13982}
diff --git a/webrtc/api/android/jni/peerconnection_jni.cc b/webrtc/api/android/jni/peerconnection_jni.cc
index 5095b15..f47787f 100644
--- a/webrtc/api/android/jni/peerconnection_jni.cc
+++ b/webrtc/api/android/jni/peerconnection_jni.cc
@@ -1668,7 +1668,8 @@
reinterpret_cast<PeerConnectionFactoryInterface*>(
factoryFromJava(factory)));
- PeerConnectionInterface::RTCConfiguration rtc_config;
+ PeerConnectionInterface::RTCConfiguration rtc_config =
+ PeerConnectionInterface::RTCConfiguration::AggressiveConfiguration();
JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config);
jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config);
@@ -1809,7 +1810,8 @@
JOW(jboolean, PeerConnection_setConfiguration)(
JNIEnv* jni, jobject j_pc, jobject j_rtc_config) {
- PeerConnectionInterface::RTCConfiguration rtc_config;
+ PeerConnectionInterface::RTCConfiguration rtc_config =
+ PeerConnectionInterface::RTCConfiguration::AggressiveConfiguration();
JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config);
return ExtractNativePC(jni, j_pc)->SetConfiguration(rtc_config);
}
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
index c675015..b13113a 100644
--- a/webrtc/api/peerconnection.cc
+++ b/webrtc/api/peerconnection.cc
@@ -627,7 +627,9 @@
factory_->worker_thread(), factory_->signaling_thread(),
port_allocator_.get(),
std::unique_ptr<cricket::TransportController>(
- factory_->CreateTransportController(port_allocator_.get()))));
+ factory_->CreateTransportController(
+ port_allocator_.get(),
+ configuration.redetermine_role_on_ice_restart))));
stats_.reset(new StatsCollector(this));
diff --git a/webrtc/api/peerconnectionfactory.cc b/webrtc/api/peerconnectionfactory.cc
index 82cd5d4..f49c291 100644
--- a/webrtc/api/peerconnectionfactory.cc
+++ b/webrtc/api/peerconnectionfactory.cc
@@ -309,10 +309,12 @@
}
cricket::TransportController* PeerConnectionFactory::CreateTransportController(
- cricket::PortAllocator* port_allocator) {
+ cricket::PortAllocator* port_allocator,
+ bool redetermine_role_on_ice_restart) {
RTC_DCHECK(signaling_thread_->IsCurrent());
return new cricket::TransportController(signaling_thread_, network_thread_,
- port_allocator);
+ port_allocator,
+ redetermine_role_on_ice_restart);
}
rtc::Thread* PeerConnectionFactory::signaling_thread() {
diff --git a/webrtc/api/peerconnectionfactory.h b/webrtc/api/peerconnectionfactory.h
index 377ad73..7684b95 100644
--- a/webrtc/api/peerconnectionfactory.h
+++ b/webrtc/api/peerconnectionfactory.h
@@ -91,7 +91,8 @@
virtual webrtc::MediaControllerInterface* CreateMediaController(
const cricket::MediaConfig& config) const;
virtual cricket::TransportController* CreateTransportController(
- cricket::PortAllocator* port_allocator);
+ cricket::PortAllocator* port_allocator,
+ bool redetermine_role_on_ice_restart);
virtual rtc::Thread* signaling_thread();
virtual rtc::Thread* worker_thread();
virtual rtc::Thread* network_thread();
diff --git a/webrtc/api/peerconnectioninterface.h b/webrtc/api/peerconnectioninterface.h
index fdf9cef..1dba14c 100644
--- a/webrtc/api/peerconnectioninterface.h
+++ b/webrtc/api/peerconnectioninterface.h
@@ -240,6 +240,18 @@
// methods for all settings which are of interest to applications,
// Chrome in particular.
+ // A configuration that is safer to use, despite it may not have the best
+ // performance.
+ static RTCConfiguration SafeConfiguration() { return RTCConfiguration(); }
+
+ // An aggressive configuration that has better performance, although it
+ // may be riskier and may need extra support in the application.
+ static RTCConfiguration AggressiveConfiguration() {
+ RTCConfiguration config;
+ config.redetermine_role_on_ice_restart = false;
+ return config;
+ }
+
bool dscp() { return media_config.enable_dscp; }
void set_dscp(bool enable) { media_config.enable_dscp = enable; }
@@ -305,6 +317,9 @@
// If set to true, this means the ICE transport should presume TURN-to-TURN
// candidate pairs will succeed, even before a binding response is received.
bool presume_writable_when_fully_relayed = false;
+ // If true, ICE role is redetermined when peerconnection sets a local
+ // transport description that indicates an ICE restart.
+ bool redetermine_role_on_ice_restart = true;
};
struct RTCOfferAnswerOptions {
diff --git a/webrtc/api/peerconnectioninterface_unittest.cc b/webrtc/api/peerconnectioninterface_unittest.cc
index 0b24fcb..d9c8af0 100644
--- a/webrtc/api/peerconnectioninterface_unittest.cc
+++ b/webrtc/api/peerconnectioninterface_unittest.cc
@@ -568,9 +568,11 @@
}
cricket::TransportController* CreateTransportController(
- cricket::PortAllocator* port_allocator) override {
+ cricket::PortAllocator* port_allocator,
+ bool redetermine_role_on_ice_restart) override {
transport_controller = new cricket::TransportController(
- rtc::Thread::Current(), rtc::Thread::Current(), port_allocator);
+ rtc::Thread::Current(), rtc::Thread::Current(), port_allocator,
+ redetermine_role_on_ice_restart);
return transport_controller;
}