From 3108fc933b7dfacf3b724e4b956b99f6575696bc Mon Sep 17 00:00:00 2001 From: Honghai Zhang Date: Wed, 11 May 2016 10:10:39 -0700 Subject: [PATCH] Add config continualGatheringPolicy to the IOS RTCConfiguration. BUG= R=tkchin@webrtc.org Review URL: https://codereview.webrtc.org/1971563002 . Cr-Commit-Position: refs/heads/master@{#12689} --- .../Framework/Classes/RTCConfiguration.mm | 42 ++++++++++++++++++- .../Headers/WebRTC/RTCConfiguration.h | 8 ++++ .../UnitTests/RTCConfigurationTest.mm | 4 ++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm b/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm index b006319cae..0bb85a29b6 100644 --- a/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm +++ b/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm @@ -24,6 +24,7 @@ @synthesize bundlePolicy = _bundlePolicy; @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; +@synthesize continualGatheringPolicy = _continualGatheringPolicy; @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; @synthesize iceBackupCandidatePairPingInterval = @@ -43,6 +44,10 @@ [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy]; _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy: config.tcp_candidate_policy]; + webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy = + config.continual_gathering_policy; + _continualGatheringPolicy = + [[self class] continualGatheringPolicyForNativePolicy:nativePolicy]; _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout; _iceBackupCandidatePairPingInterval = @@ -54,12 +59,14 @@ - (NSString *)description { return [NSString stringWithFormat: - @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n}\n", + @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n}\n", _iceServers, [[self class] stringForTransportPolicy:_iceTransportPolicy], [[self class] stringForBundlePolicy:_bundlePolicy], [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], + [[self class] + stringForContinualGatheringPolicy:_continualGatheringPolicy], _audioJitterBufferMaxPackets, _iceConnectionReceivingTimeout, _iceBackupCandidatePairPingInterval]; @@ -81,6 +88,8 @@ [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; nativeConfig.tcp_candidate_policy = [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; + nativeConfig.continual_gathering_policy = [[self class] + nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; nativeConfig.ice_connection_receiving_timeout = _iceConnectionReceivingTimeout; @@ -234,4 +243,35 @@ } } ++ (webrtc::PeerConnectionInterface::ContinualGatheringPolicy) + nativeContinualGatheringPolicyForPolicy: + (RTCContinualGatheringPolicy)policy { + switch (policy) { + case RTCContinualGatheringPolicyGatherOnce: + return webrtc::PeerConnectionInterface::GATHER_ONCE; + case RTCContinualGatheringPolicyGatherContinually: + return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY; + } +} + ++ (RTCContinualGatheringPolicy)continualGatheringPolicyForNativePolicy: + (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy { + switch (nativePolicy) { + case webrtc::PeerConnectionInterface::GATHER_ONCE: + return RTCContinualGatheringPolicyGatherOnce; + case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY: + return RTCContinualGatheringPolicyGatherContinually; + } +} + ++ (NSString *)stringForContinualGatheringPolicy: + (RTCContinualGatheringPolicy)policy { + switch (policy) { + case RTCContinualGatheringPolicyGatherOnce: + return @"GATHER_ONCE"; + case RTCContinualGatheringPolicyGatherContinually: + return @"GATHER_CONTINUALLY"; + } +} + @end diff --git a/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCConfiguration.h b/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCConfiguration.h index 4d512311e1..74e7801ac0 100644 --- a/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCConfiguration.h +++ b/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCConfiguration.h @@ -44,6 +44,12 @@ typedef NS_ENUM(NSInteger, RTCTcpCandidatePolicy) { RTCTcpCandidatePolicyDisabled }; +/** Represents the continual gathering policy. */ +typedef NS_ENUM(NSInteger, RTCContinualGatheringPolicy) { + RTCContinualGatheringPolicyGatherOnce, + RTCContinualGatheringPolicyGatherContinually +}; + /** Represents the encryption key type. */ typedef NS_ENUM(NSInteger, RTCEncryptionKeyType) { RTCEncryptionKeyTypeRSA, @@ -68,6 +74,8 @@ RTC_EXPORT /** The rtcp-mux policy to use when gathering ICE candidates. */ @property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy; @property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy; +@property(nonatomic, assign) + RTCContinualGatheringPolicy continualGatheringPolicy; @property(nonatomic, assign) int audioJitterBufferMaxPackets; @property(nonatomic, assign) int iceConnectionReceivingTimeout; @property(nonatomic, assign) int iceBackupCandidatePairPingInterval; diff --git a/webrtc/sdk/objc/Framework/UnitTests/RTCConfigurationTest.mm b/webrtc/sdk/objc/Framework/UnitTests/RTCConfigurationTest.mm index ff35696d6e..eba9ded728 100644 --- a/webrtc/sdk/objc/Framework/UnitTests/RTCConfigurationTest.mm +++ b/webrtc/sdk/objc/Framework/UnitTests/RTCConfigurationTest.mm @@ -41,6 +41,8 @@ config.audioJitterBufferMaxPackets = maxPackets; config.iceConnectionReceivingTimeout = timeout; config.iceBackupCandidatePairPingInterval = interval; + config.continualGatheringPolicy = + RTCContinualGatheringPolicyGatherContinually; webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig = config.nativeConfiguration; @@ -60,6 +62,8 @@ EXPECT_EQ(maxPackets, nativeConfig.audio_jitter_buffer_max_packets); EXPECT_EQ(timeout, nativeConfig.ice_connection_receiving_timeout); EXPECT_EQ(interval, nativeConfig.ice_backup_candidate_pair_ping_interval); + EXPECT_EQ(webrtc::PeerConnectionInterface::GATHER_CONTINUALLY, + nativeConfig.continual_gathering_policy); } @end