Add configurable connectivity check intervals.

The connectivity check intervals for candidate pairs with strong and
weak connectivity are currently constants in the ICE implementation. A
set of suboptimal value of these constants for a given application may
result in undesirable behavior including excessive network switching
latency. This CL adds these intervals to RTCConfiguration that is
available to applications to configure, while maintaining the original
constants as their default value for compatibility with existing
applications.

Bug: webrtc:8988
Change-Id: I804b0f4cf7881be7d3c8aec2776bc9596de72482
Reviewed-on: https://webrtc-review.googlesource.com/60585
Commit-Queue: Qingsi Wang <qingsi@google.com>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22351}
diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h
index 1dfe2bd..7364aa0 100644
--- a/api/peerconnectioninterface.h
+++ b/api/peerconnectioninterface.h
@@ -489,8 +489,30 @@
     // re-determining was removed in ICEbis (ICE v2).
     bool redetermine_role_on_ice_restart = true;
 
-    // If set, the min interval (max rate) at which we will send ICE checks
-    // (STUN pings), in milliseconds.
+    // The following fields define intervals in milliseconds at which ICE
+    // connectivity checks are sent.
+    //
+    // We consider ICE is "strongly connected" for an agent when there is at
+    // least one candidate pair that currently succeeds in connectivity check
+    // from its direction i.e. sending a STUN ping and receives a STUN ping
+    // response, AND all candidate pairs have sent a minimum number of pings for
+    // connectivity (this number is implementation-specific). Otherwise, ICE is
+    // considered in "weak connectivity".
+    //
+    // Note that the above notion of strong and weak connectivity is not defined
+    // in RFC 5245, and they apply to our current ICE implementation only.
+    //
+    // 1) ice_check_interval_strong_connectivity defines the interval applied to
+    // ALL candidate pairs when ICE is strongly connected, and it overrides the
+    // default value of this interval in the ICE implementation;
+    // 2) ice_check_interval_weak_connectivity defines the counterpart for ALL
+    // pairs when ICE is weakly connected, and it overrides the default value of
+    // this interval in the ICE implementation;
+    // 3) ice_check_min_interval defines the minimal interval (equivalently the
+    // maximum rate) that overrides the above two intervals when either of them
+    // is less.
+    rtc::Optional<int> ice_check_interval_strong_connectivity;
+    rtc::Optional<int> ice_check_interval_weak_connectivity;
     rtc::Optional<int> ice_check_min_interval;
 
     // The interval in milliseconds at which STUN candidates will resend STUN