Android bindings for ice_regather_interval_range RTCConfiguration option

Bug: webrtc:7969
Change-Id: I3fbb723d35fa6cc4c7b92aa1e155b974e9fb0b55
Reviewed-on: https://chromium-review.googlesource.com/567698
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Alex Glaznev <glaznev@chromium.org>
Reviewed-by: Peter Thatcher <pthatcher@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19062}
This commit is contained in:
Steve Anton
2017-07-17 12:33:07 -07:00
committed by Commit Bot
parent 3f003a5e3d
commit d960a0c7d1
3 changed files with 61 additions and 0 deletions

View File

@ -159,6 +159,25 @@ public class PeerConnection {
/** Java version of PeerConnectionInterface.ContinualGatheringPolicy */ /** Java version of PeerConnectionInterface.ContinualGatheringPolicy */
public enum ContinualGatheringPolicy { GATHER_ONCE, GATHER_CONTINUALLY } public enum ContinualGatheringPolicy { GATHER_ONCE, GATHER_CONTINUALLY }
/** Java version of rtc::IntervalRange */
public static class IntervalRange {
private final int min;
private final int max;
public IntervalRange(int min, int max) {
this.min = min;
this.max = max;
}
public int getMin() {
return min;
}
public int getMax() {
return max;
}
}
/** Java version of PeerConnectionInterface.RTCConfiguration */ /** Java version of PeerConnectionInterface.RTCConfiguration */
public static class RTCConfiguration { public static class RTCConfiguration {
public IceTransportsType iceTransportsType; public IceTransportsType iceTransportsType;
@ -178,6 +197,7 @@ public class PeerConnection {
public boolean presumeWritableWhenFullyRelayed; public boolean presumeWritableWhenFullyRelayed;
public Integer iceCheckMinInterval; public Integer iceCheckMinInterval;
public boolean disableIPv6OnWifi; public boolean disableIPv6OnWifi;
public IntervalRange iceRegatherIntervalRange;
public RTCConfiguration(List<IceServer> iceServers) { public RTCConfiguration(List<IceServer> iceServers) {
iceTransportsType = IceTransportsType.ALL; iceTransportsType = IceTransportsType.ALL;
@ -197,6 +217,7 @@ public class PeerConnection {
presumeWritableWhenFullyRelayed = false; presumeWritableWhenFullyRelayed = false;
iceCheckMinInterval = null; iceCheckMinInterval = null;
disableIPv6OnWifi = false; disableIPv6OnWifi = false;
iceRegatherIntervalRange = null;
} }
}; };

View File

@ -18,6 +18,7 @@ import static org.junit.Assert.assertTrue;
import android.support.test.InstrumentationRegistry; import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest; import android.support.test.filters.MediumTest;
import android.support.test.filters.SmallTest;
import java.io.File; import java.io.File;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -565,6 +566,28 @@ public class PeerConnectionTest {
// in JNI-style programming; make sure no typos! // in JNI-style programming; make sure no typos!
// - Test that shutdown mid-interaction is crash-free. // - Test that shutdown mid-interaction is crash-free.
// Tests that the JNI glue between Java and C++ does not crash when creating a PeerConnection.
@Test
@SmallTest
public void testCreationWithConfig() throws Exception {
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
PeerConnectionFactory factory = new PeerConnectionFactory(options);
List<PeerConnection.IceServer> iceServers =
Arrays.asList(new PeerConnection.IceServer("stun:stun.l.google.com:19302"),
new PeerConnection.IceServer("turn:fake.example.com", "fakeUsername", "fakePassword"));
PeerConnection.RTCConfiguration config = new PeerConnection.RTCConfiguration(iceServers);
// Test configuration options.
config.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY;
config.iceRegatherIntervalRange = new PeerConnection.IntervalRange(1000, 2000);
MediaConstraints constraints = new MediaConstraints();
ObserverExpectations offeringExpectations = new ObserverExpectations("PCTest:offerer");
PeerConnection offeringPC =
factory.createPeerConnection(config, constraints, offeringExpectations);
assertNotNull(offeringPC);
}
@Test @Test
@MediumTest @MediumTest
public void testCompleteSession() throws Exception { public void testCompleteSession() throws Exception {

View File

@ -1537,6 +1537,16 @@ static void JavaRTCConfigurationToJsepRTCConfiguration(
jfieldID j_disable_ipv6_on_wifi_id = jfieldID j_disable_ipv6_on_wifi_id =
GetFieldID(jni, j_rtc_config_class, "disableIPv6OnWifi", "Z"); GetFieldID(jni, j_rtc_config_class, "disableIPv6OnWifi", "Z");
jfieldID j_ice_regather_interval_range_id =
GetFieldID(jni, j_rtc_config_class, "iceRegatherIntervalRange",
"Lorg/webrtc/PeerConnection$IntervalRange;");
jclass j_interval_range_class =
jni->FindClass("org/webrtc/PeerConnection$IntervalRange");
jmethodID get_min_id =
GetMethodID(jni, j_interval_range_class, "getMin", "()I");
jmethodID get_max_id =
GetMethodID(jni, j_interval_range_class, "getMax", "()I");
rtc_config->type = rtc_config->type =
JavaIceTransportsTypeToNativeType(jni, j_ice_transports_type); JavaIceTransportsTypeToNativeType(jni, j_ice_transports_type);
rtc_config->bundle_policy = rtc_config->bundle_policy =
@ -1575,6 +1585,13 @@ static void JavaRTCConfigurationToJsepRTCConfiguration(
} }
rtc_config->disable_ipv6_on_wifi = rtc_config->disable_ipv6_on_wifi =
GetBooleanField(jni, j_rtc_config, j_disable_ipv6_on_wifi_id); GetBooleanField(jni, j_rtc_config, j_disable_ipv6_on_wifi_id);
jobject j_ice_regather_interval_range = GetNullableObjectField(
jni, j_rtc_config, j_ice_regather_interval_range_id);
if (!IsNull(jni, j_ice_regather_interval_range)) {
int min = jni->CallIntMethod(j_ice_regather_interval_range, get_min_id);
int max = jni->CallIntMethod(j_ice_regather_interval_range, get_max_id);
rtc_config->ice_regather_interval_range.emplace(min, max);
}
} }
JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)( JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)(