From f7ddc06a43408299b2ae07f6b4a40db2b81670a6 Mon Sep 17 00:00:00 2001 From: Honghai Zhang Date: Thu, 1 Sep 2016 15:34:01 -0700 Subject: [PATCH] Use AggressiveConfiguration as the default configuration in IOS R=haysc@webrtc.org, pthatcher@webrtc.org, tkchin@webrtc.org Review URL: https://codereview.webrtc.org/2297663004 . Cr-Commit-Position: refs/heads/master@{#14030} --- webrtc/api/android/jni/peerconnection_jni.cc | 8 +++---- webrtc/api/peerconnectioninterface.h | 24 +++++++++++-------- .../Framework/Classes/RTCConfiguration.mm | 6 +++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/webrtc/api/android/jni/peerconnection_jni.cc b/webrtc/api/android/jni/peerconnection_jni.cc index 026a0c6289..684e486148 100644 --- a/webrtc/api/android/jni/peerconnection_jni.cc +++ b/webrtc/api/android/jni/peerconnection_jni.cc @@ -1644,8 +1644,8 @@ JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)( reinterpret_cast( factoryFromJava(factory))); - PeerConnectionInterface::RTCConfiguration rtc_config = - PeerConnectionInterface::RTCConfiguration::AggressiveConfiguration(); + PeerConnectionInterface::RTCConfiguration rtc_config( + PeerConnectionInterface::RTCConfigurationType::kAggressive); JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config); jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config); @@ -1786,8 +1786,8 @@ JOW(void, PeerConnection_setRemoteDescription)( JOW(jboolean, PeerConnection_setConfiguration)( JNIEnv* jni, jobject j_pc, jobject j_rtc_config) { - PeerConnectionInterface::RTCConfiguration rtc_config = - PeerConnectionInterface::RTCConfiguration::AggressiveConfiguration(); + PeerConnectionInterface::RTCConfiguration rtc_config( + PeerConnectionInterface::RTCConfigurationType::kAggressive); JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config); return ExtractNativePC(jni, j_pc)->SetConfiguration(rtc_config); } diff --git a/webrtc/api/peerconnectioninterface.h b/webrtc/api/peerconnectioninterface.h index 624c67f9cb..bcb6170c12 100644 --- a/webrtc/api/peerconnectioninterface.h +++ b/webrtc/api/peerconnectioninterface.h @@ -227,6 +227,15 @@ class PeerConnectionInterface : public rtc::RefCountInterface { GATHER_CONTINUALLY }; + enum class RTCConfigurationType { + // A configuration that is safer to use, despite not having the best + // performance. Currently this is the default configuration. + kSafe, + // An aggressive configuration that has better performance, although it + // may be riskier and may need extra support in the application. + kAggressive + }; + // TODO(hbos): Change into class with private data and public getters. // TODO(nisse): In particular, accessing fields directly from an // application is brittle, since the organization mirrors the @@ -240,16 +249,11 @@ 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; + RTCConfiguration() = default; + RTCConfiguration(RTCConfigurationType type) { + if (type == RTCConfigurationType::kAggressive) { + redetermine_role_on_ice_restart = false; + } } bool dscp() { return media_config.enable_dscp; } diff --git a/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm b/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm index be6628888b..4bd666c32e 100644 --- a/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm +++ b/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm @@ -41,7 +41,8 @@ if (self = [super init]) { _iceServers = [NSMutableArray array]; // Copy defaults. - webrtc::PeerConnectionInterface::RTCConfiguration config; + webrtc::PeerConnectionInterface::RTCConfiguration config( + webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive); _iceTransportPolicy = [[self class] transportPolicyForTransportsType:config.type]; _bundlePolicy = @@ -93,7 +94,8 @@ - (webrtc::PeerConnectionInterface::RTCConfiguration *) createNativeConfiguration { std::unique_ptr - nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration()); + nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration( + webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive)); for (RTCIceServer *iceServer in _iceServers) { nativeConfig->servers.push_back(iceServer.nativeServer);