Add flag in ios to support disabling high-cost networks.

This depends on CL:
https://codereview.webrtc.org/1987833002/

BUG=
R=tkchin@webrtc.org

Review URL: https://codereview.webrtc.org/2030443002 .

Cr-Commit-Position: refs/heads/master@{#13046}
This commit is contained in:
Honghai Zhang
2016-06-03 16:31:32 -07:00
parent f83a94a41e
commit 46007ae1eb
4 changed files with 55 additions and 1 deletions

View File

@ -48,6 +48,14 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy; + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy;
+ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)
nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy;
+ (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy:
(webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy;
+ (NSString *)stringForCandidateNetworkPolicy:(RTCCandidateNetworkPolicy)policy;
/** /**
* RTCConfiguration struct representation of this RTCConfiguration. This is * RTCConfiguration struct representation of this RTCConfiguration. This is
* needed to pass to the underlying C++ APIs. * needed to pass to the underlying C++ APIs.

View File

@ -25,6 +25,7 @@
@synthesize bundlePolicy = _bundlePolicy; @synthesize bundlePolicy = _bundlePolicy;
@synthesize rtcpMuxPolicy = _rtcpMuxPolicy; @synthesize rtcpMuxPolicy = _rtcpMuxPolicy;
@synthesize tcpCandidatePolicy = _tcpCandidatePolicy; @synthesize tcpCandidatePolicy = _tcpCandidatePolicy;
@synthesize candidateNetworkPolicy = _candidateNetworkPolicy;
@synthesize continualGatheringPolicy = _continualGatheringPolicy; @synthesize continualGatheringPolicy = _continualGatheringPolicy;
@synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets;
@synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout;
@ -46,6 +47,8 @@
[[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy]; [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy];
_tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy: _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
config.tcp_candidate_policy]; config.tcp_candidate_policy];
_candidateNetworkPolicy = [[self class]
candidateNetworkPolicyForNativePolicy:config.candidate_network_policy];
webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy = webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy =
config.continual_gathering_policy; config.continual_gathering_policy;
_continualGatheringPolicy = _continualGatheringPolicy =
@ -62,12 +65,13 @@
- (NSString *)description { - (NSString *)description {
return [NSString stringWithFormat: return [NSString stringWithFormat:
@"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n}\n", @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n}\n",
_iceServers, _iceServers,
[[self class] stringForTransportPolicy:_iceTransportPolicy], [[self class] stringForTransportPolicy:_iceTransportPolicy],
[[self class] stringForBundlePolicy:_bundlePolicy], [[self class] stringForBundlePolicy:_bundlePolicy],
[[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy],
[[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy],
[[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy],
[[self class] [[self class]
stringForContinualGatheringPolicy:_continualGatheringPolicy], stringForContinualGatheringPolicy:_continualGatheringPolicy],
_audioJitterBufferMaxPackets, _audioJitterBufferMaxPackets,
@ -94,6 +98,8 @@
[[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy];
nativeConfig->tcp_candidate_policy = nativeConfig->tcp_candidate_policy =
[[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy];
nativeConfig->candidate_network_policy = [[self class]
nativeCandidateNetworkPolicyForPolicy:_candidateNetworkPolicy];
nativeConfig->continual_gathering_policy = [[self class] nativeConfig->continual_gathering_policy = [[self class]
nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy];
nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
@ -234,6 +240,16 @@
} }
} }
+ (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)
nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy {
switch (policy) {
case RTCCandidateNetworkPolicyAll:
return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll;
case RTCCandidateNetworkPolicyLowCost:
return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
}
}
+ (rtc::KeyType)nativeEncryptionKeyTypeForKeyType: + (rtc::KeyType)nativeEncryptionKeyTypeForKeyType:
(RTCEncryptionKeyType)keyType { (RTCEncryptionKeyType)keyType {
switch (keyType) { switch (keyType) {
@ -263,6 +279,26 @@
} }
} }
+ (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy:
(webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy {
switch (nativePolicy) {
case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll:
return RTCCandidateNetworkPolicyAll;
case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost:
return RTCCandidateNetworkPolicyLowCost;
}
}
+ (NSString *)stringForCandidateNetworkPolicy:
(RTCCandidateNetworkPolicy)policy {
switch (policy) {
case RTCCandidateNetworkPolicyAll:
return @"CANDIDATE_ALL_NETWORKS";
case RTCCandidateNetworkPolicyLowCost:
return @"CANDIDATE_LOW_COST_NETWORKS";
}
}
+ (webrtc::PeerConnectionInterface::ContinualGatheringPolicy) + (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)
nativeContinualGatheringPolicyForPolicy: nativeContinualGatheringPolicyForPolicy:
(RTCContinualGatheringPolicy)policy { (RTCContinualGatheringPolicy)policy {

View File

@ -44,6 +44,12 @@ typedef NS_ENUM(NSInteger, RTCTcpCandidatePolicy) {
RTCTcpCandidatePolicyDisabled RTCTcpCandidatePolicyDisabled
}; };
/** Represents the candidate network policy. */
typedef NS_ENUM(NSInteger, RTCCandidateNetworkPolicy) {
RTCCandidateNetworkPolicyAll,
RTCCandidateNetworkPolicyLowCost
};
/** Represents the continual gathering policy. */ /** Represents the continual gathering policy. */
typedef NS_ENUM(NSInteger, RTCContinualGatheringPolicy) { typedef NS_ENUM(NSInteger, RTCContinualGatheringPolicy) {
RTCContinualGatheringPolicyGatherOnce, RTCContinualGatheringPolicyGatherOnce,
@ -74,6 +80,7 @@ RTC_EXPORT
/** The rtcp-mux policy to use when gathering ICE candidates. */ /** The rtcp-mux policy to use when gathering ICE candidates. */
@property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy; @property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy;
@property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy; @property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy;
@property(nonatomic, assign) RTCCandidateNetworkPolicy candidateNetworkPolicy;
@property(nonatomic, assign) @property(nonatomic, assign)
RTCContinualGatheringPolicy continualGatheringPolicy; RTCContinualGatheringPolicy continualGatheringPolicy;
@property(nonatomic, assign) int audioJitterBufferMaxPackets; @property(nonatomic, assign) int audioJitterBufferMaxPackets;

View File

@ -35,6 +35,7 @@
config.bundlePolicy = RTCBundlePolicyMaxBundle; config.bundlePolicy = RTCBundlePolicyMaxBundle;
config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate; config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate;
config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled; config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled;
config.candidateNetworkPolicy = RTCCandidateNetworkPolicyLowCost;
const int maxPackets = 60; const int maxPackets = 60;
const int timeout = 1; const int timeout = 1;
const int interval = 2; const int interval = 2;
@ -60,6 +61,8 @@
nativeConfig->rtcp_mux_policy); nativeConfig->rtcp_mux_policy);
EXPECT_EQ(webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled, EXPECT_EQ(webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled,
nativeConfig->tcp_candidate_policy); nativeConfig->tcp_candidate_policy);
EXPECT_EQ(webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost,
nativeConfig->candidate_network_policy);
EXPECT_EQ(maxPackets, nativeConfig->audio_jitter_buffer_max_packets); EXPECT_EQ(maxPackets, nativeConfig->audio_jitter_buffer_max_packets);
EXPECT_EQ(timeout, nativeConfig->ice_connection_receiving_timeout); EXPECT_EQ(timeout, nativeConfig->ice_connection_receiving_timeout);
EXPECT_EQ(interval, nativeConfig->ice_backup_candidate_pair_ping_interval); EXPECT_EQ(interval, nativeConfig->ice_backup_candidate_pair_ping_interval);