Propagating Network Type in Candidate for JNI
Bug: webrtc:10419 Change-Id: I32726c9a4095c998996acdbf00f72de18ed462c4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149025 Commit-Queue: Alex Drake <alexdrake@google.com> Reviewed-by: Alex Glaznev <glaznev@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28848}
This commit is contained in:
@ -10,6 +10,8 @@
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import org.webrtc.PeerConnection;
|
||||
|
||||
/**
|
||||
* Representation of a single ICE Candidate, mirroring
|
||||
* {@code IceCandidateInterface} in the C++ API.
|
||||
@ -19,25 +21,30 @@ public class IceCandidate {
|
||||
public final int sdpMLineIndex;
|
||||
public final String sdp;
|
||||
public final String serverUrl;
|
||||
public final PeerConnection.AdapterType adapterType;
|
||||
|
||||
public IceCandidate(String sdpMid, int sdpMLineIndex, String sdp) {
|
||||
this.sdpMid = sdpMid;
|
||||
this.sdpMLineIndex = sdpMLineIndex;
|
||||
this.sdp = sdp;
|
||||
this.serverUrl = "";
|
||||
this.adapterType = PeerConnection.AdapterType.UNKNOWN;
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
IceCandidate(String sdpMid, int sdpMLineIndex, String sdp, String serverUrl) {
|
||||
IceCandidate(String sdpMid, int sdpMLineIndex, String sdp, String serverUrl,
|
||||
PeerConnection.AdapterType adapterType) {
|
||||
this.sdpMid = sdpMid;
|
||||
this.sdpMLineIndex = sdpMLineIndex;
|
||||
this.sdp = sdp;
|
||||
this.serverUrl = serverUrl;
|
||||
this.adapterType = adapterType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return sdpMid + ":" + sdpMLineIndex + ":" + sdp + ":" + serverUrl;
|
||||
return sdpMid + ":" + sdpMLineIndex + ":" + sdp + ":" + serverUrl + ":"
|
||||
+ adapterType.toString();
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
|
||||
@ -14,7 +14,9 @@ import android.support.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.webrtc.CandidatePairChangeEvent;
|
||||
import org.webrtc.DataChannel;
|
||||
import org.webrtc.MediaStreamTrack;
|
||||
@ -374,12 +376,29 @@ public class PeerConnection {
|
||||
|
||||
// Keep in sync with webrtc/rtc_base/network_constants.h.
|
||||
public enum AdapterType {
|
||||
UNKNOWN,
|
||||
ETHERNET,
|
||||
WIFI,
|
||||
CELLULAR,
|
||||
VPN,
|
||||
LOOPBACK,
|
||||
UNKNOWN(0),
|
||||
ETHERNET(1 << 0),
|
||||
WIFI(1 << 1),
|
||||
CELLULAR(1 << 2),
|
||||
VPN(1 << 3),
|
||||
LOOPBACK(1 << 4),
|
||||
ADAPTER_TYPE_ANY(1 << 5);
|
||||
|
||||
public final Integer bitMask;
|
||||
private AdapterType(Integer bitMask) {
|
||||
this.bitMask = bitMask;
|
||||
}
|
||||
private static final Map<Integer, AdapterType> BY_BITMASK = new HashMap<>();
|
||||
static {
|
||||
for (AdapterType t : values()) {
|
||||
BY_BITMASK.put(t.bitMask, t);
|
||||
}
|
||||
}
|
||||
|
||||
@CalledByNative("AdapterType")
|
||||
static AdapterType fromNativeIndex(int nativeIndex) {
|
||||
return BY_BITMASK.get(nativeIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/** Java version of rtc::KeyType */
|
||||
|
||||
Reference in New Issue
Block a user