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}
This commit is contained in:
Honghai Zhang 2016-08-30 22:07:42 -07:00
parent 6a60e70266
commit bfd398ccda
6 changed files with 32 additions and 8 deletions

View File

@ -1668,7 +1668,8 @@ JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)(
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(void, PeerConnection_setRemoteDescription)(
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);
}

View File

@ -627,7 +627,9 @@ bool PeerConnection::Initialize(
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));

View File

@ -309,10 +309,12 @@ webrtc::MediaControllerInterface* PeerConnectionFactory::CreateMediaController(
}
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() {

View File

@ -91,7 +91,8 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
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();

View File

@ -240,6 +240,18 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
// 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 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
// 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 {

View File

@ -568,9 +568,11 @@ class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory {
}
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;
}