1039 lines
34 KiB
Java
1039 lines
34 KiB
Java
package org.webrtc;
|
|
|
|
import androidx.annotation.Nullable;
|
|
import c.d.b.a.a;
|
|
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 java.util.Objects;
|
|
import org.webrtc.DataChannel;
|
|
import org.webrtc.MediaStreamTrack;
|
|
import org.webrtc.RtpTransceiver;
|
|
public class PeerConnection {
|
|
private final List<MediaStream> localStreams;
|
|
private final long nativePeerConnection;
|
|
private List<RtpReceiver> receivers;
|
|
private List<RtpSender> senders;
|
|
private List<RtpTransceiver> transceivers;
|
|
|
|
public enum AdapterType {
|
|
UNKNOWN(0),
|
|
ETHERNET(1),
|
|
WIFI(2),
|
|
CELLULAR(4),
|
|
VPN(8),
|
|
LOOPBACK(16),
|
|
ADAPTER_TYPE_ANY(32),
|
|
CELLULAR_2G(64),
|
|
CELLULAR_3G(128),
|
|
CELLULAR_4G(256),
|
|
CELLULAR_5G(512);
|
|
|
|
private static final Map<Integer, AdapterType> BY_BITMASK = new HashMap();
|
|
public final Integer bitMask;
|
|
|
|
static {
|
|
AdapterType[] values = values();
|
|
for (int i = 0; i < 11; i++) {
|
|
AdapterType adapterType = values[i];
|
|
BY_BITMASK.put(adapterType.bitMask, adapterType);
|
|
}
|
|
}
|
|
|
|
private AdapterType(Integer num) {
|
|
this.bitMask = num;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("AdapterType")
|
|
public static AdapterType fromNativeIndex(int i) {
|
|
return BY_BITMASK.get(Integer.valueOf(i));
|
|
}
|
|
}
|
|
|
|
public enum BundlePolicy {
|
|
BALANCED,
|
|
MAXBUNDLE,
|
|
MAXCOMPAT
|
|
}
|
|
|
|
public enum CandidateNetworkPolicy {
|
|
ALL,
|
|
LOW_COST
|
|
}
|
|
|
|
public enum ContinualGatheringPolicy {
|
|
GATHER_ONCE,
|
|
GATHER_CONTINUALLY
|
|
}
|
|
|
|
public enum IceConnectionState {
|
|
NEW,
|
|
CHECKING,
|
|
CONNECTED,
|
|
COMPLETED,
|
|
FAILED,
|
|
DISCONNECTED,
|
|
CLOSED;
|
|
|
|
@CalledByNative("IceConnectionState")
|
|
public static IceConnectionState fromNativeIndex(int i) {
|
|
return values()[i];
|
|
}
|
|
}
|
|
|
|
public enum IceGatheringState {
|
|
NEW,
|
|
GATHERING,
|
|
COMPLETE;
|
|
|
|
@CalledByNative("IceGatheringState")
|
|
public static IceGatheringState fromNativeIndex(int i) {
|
|
return values()[i];
|
|
}
|
|
}
|
|
|
|
public static class IceServer {
|
|
public final String hostname;
|
|
public final String password;
|
|
public final List<String> tlsAlpnProtocols;
|
|
public final TlsCertPolicy tlsCertPolicy;
|
|
public final List<String> tlsEllipticCurves;
|
|
@Deprecated
|
|
public final String uri;
|
|
public final List<String> urls;
|
|
public final String username;
|
|
|
|
public static class Builder {
|
|
private String hostname;
|
|
private String password;
|
|
private List<String> tlsAlpnProtocols;
|
|
private TlsCertPolicy tlsCertPolicy;
|
|
private List<String> tlsEllipticCurves;
|
|
@Nullable
|
|
private final List<String> urls;
|
|
private String username;
|
|
|
|
private Builder(List<String> list) {
|
|
this.username = "";
|
|
this.password = "";
|
|
this.tlsCertPolicy = TlsCertPolicy.TLS_CERT_POLICY_SECURE;
|
|
this.hostname = "";
|
|
if (list == null || list.isEmpty()) {
|
|
throw new IllegalArgumentException("urls == null || urls.isEmpty(): " + list);
|
|
}
|
|
this.urls = list;
|
|
}
|
|
|
|
public IceServer createIceServer() {
|
|
return new IceServer(this.urls.get(0), this.urls, this.username, this.password, this.tlsCertPolicy, this.hostname, this.tlsAlpnProtocols, this.tlsEllipticCurves);
|
|
}
|
|
|
|
public Builder setHostname(String str) {
|
|
this.hostname = str;
|
|
return this;
|
|
}
|
|
|
|
public Builder setPassword(String str) {
|
|
this.password = str;
|
|
return this;
|
|
}
|
|
|
|
public Builder setTlsAlpnProtocols(List<String> list) {
|
|
this.tlsAlpnProtocols = list;
|
|
return this;
|
|
}
|
|
|
|
public Builder setTlsCertPolicy(TlsCertPolicy tlsCertPolicy) {
|
|
this.tlsCertPolicy = tlsCertPolicy;
|
|
return this;
|
|
}
|
|
|
|
public Builder setTlsEllipticCurves(List<String> list) {
|
|
this.tlsEllipticCurves = list;
|
|
return this;
|
|
}
|
|
|
|
public Builder setUsername(String str) {
|
|
this.username = str;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
@Deprecated
|
|
public IceServer(String str) {
|
|
this(str, "", "");
|
|
}
|
|
|
|
@Deprecated
|
|
public IceServer(String str, String str2, String str3) {
|
|
this(str, str2, str3, TlsCertPolicy.TLS_CERT_POLICY_SECURE);
|
|
}
|
|
|
|
@Deprecated
|
|
public IceServer(String str, String str2, String str3, TlsCertPolicy tlsCertPolicy) {
|
|
this(str, str2, str3, tlsCertPolicy, "");
|
|
}
|
|
|
|
@Deprecated
|
|
public IceServer(String str, String str2, String str3, TlsCertPolicy tlsCertPolicy, String str4) {
|
|
this(str, Collections.singletonList(str), str2, str3, tlsCertPolicy, str4, null, null);
|
|
}
|
|
|
|
private IceServer(String str, List<String> list, String str2, String str3, TlsCertPolicy tlsCertPolicy, String str4, List<String> list2, List<String> list3) {
|
|
if (str == null || list == null || list.isEmpty()) {
|
|
throw new IllegalArgumentException("uri == null || urls == null || urls.isEmpty()");
|
|
}
|
|
for (String str5 : list) {
|
|
if (str5 == null) {
|
|
throw new IllegalArgumentException("urls element is null: " + list);
|
|
}
|
|
}
|
|
if (str2 == null) {
|
|
throw new IllegalArgumentException("username == null");
|
|
} else if (str3 == null) {
|
|
throw new IllegalArgumentException("password == null");
|
|
} else if (str4 != null) {
|
|
this.uri = str;
|
|
this.urls = list;
|
|
this.username = str2;
|
|
this.password = str3;
|
|
this.tlsCertPolicy = tlsCertPolicy;
|
|
this.hostname = str4;
|
|
this.tlsAlpnProtocols = list2;
|
|
this.tlsEllipticCurves = list3;
|
|
} else {
|
|
throw new IllegalArgumentException("hostname == null");
|
|
}
|
|
}
|
|
|
|
public static Builder builder(String str) {
|
|
return new Builder(Collections.singletonList(str));
|
|
}
|
|
|
|
public static Builder builder(List<String> list) {
|
|
return new Builder(list);
|
|
}
|
|
|
|
public boolean equals(@Nullable Object obj) {
|
|
if (obj == null) {
|
|
return false;
|
|
}
|
|
if (obj == this) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof IceServer)) {
|
|
return false;
|
|
}
|
|
IceServer iceServer = (IceServer) obj;
|
|
return this.uri.equals(iceServer.uri) && this.urls.equals(iceServer.urls) && this.username.equals(iceServer.username) && this.password.equals(iceServer.password) && this.tlsCertPolicy.equals(iceServer.tlsCertPolicy) && this.hostname.equals(iceServer.hostname) && this.tlsAlpnProtocols.equals(iceServer.tlsAlpnProtocols) && this.tlsEllipticCurves.equals(iceServer.tlsEllipticCurves);
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("IceServer")
|
|
public String getHostname() {
|
|
return this.hostname;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("IceServer")
|
|
public String getPassword() {
|
|
return this.password;
|
|
}
|
|
|
|
@CalledByNative("IceServer")
|
|
public List<String> getTlsAlpnProtocols() {
|
|
return this.tlsAlpnProtocols;
|
|
}
|
|
|
|
@CalledByNative("IceServer")
|
|
public TlsCertPolicy getTlsCertPolicy() {
|
|
return this.tlsCertPolicy;
|
|
}
|
|
|
|
@CalledByNative("IceServer")
|
|
public List<String> getTlsEllipticCurves() {
|
|
return this.tlsEllipticCurves;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("IceServer")
|
|
public List<String> getUrls() {
|
|
return this.urls;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("IceServer")
|
|
public String getUsername() {
|
|
return this.username;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return Arrays.hashCode(new Object[]{this.uri, this.urls, this.username, this.password, this.tlsCertPolicy, this.hostname, this.tlsAlpnProtocols, this.tlsEllipticCurves});
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(this.urls);
|
|
sb.append(" [");
|
|
sb.append(this.username);
|
|
sb.append(":");
|
|
sb.append(this.password);
|
|
sb.append("] [");
|
|
sb.append(this.tlsCertPolicy);
|
|
sb.append("] [");
|
|
sb.append(this.hostname);
|
|
sb.append("] [");
|
|
sb.append(this.tlsAlpnProtocols);
|
|
sb.append("] [");
|
|
return a.E(sb, this.tlsEllipticCurves, "]");
|
|
}
|
|
}
|
|
|
|
public enum IceTransportsType {
|
|
NONE,
|
|
RELAY,
|
|
NOHOST,
|
|
ALL
|
|
}
|
|
|
|
public enum KeyType {
|
|
RSA,
|
|
ECDSA
|
|
}
|
|
|
|
public interface Observer {
|
|
@CalledByNative("Observer")
|
|
void onAddStream(MediaStream mediaStream);
|
|
|
|
@CalledByNative("Observer")
|
|
void onAddTrack(RtpReceiver rtpReceiver, MediaStream[] mediaStreamArr);
|
|
|
|
@CalledByNative("Observer")
|
|
void onConnectionChange(PeerConnectionState peerConnectionState);
|
|
|
|
@CalledByNative("Observer")
|
|
void onDataChannel(DataChannel dataChannel);
|
|
|
|
@CalledByNative("Observer")
|
|
void onIceCandidate(IceCandidate iceCandidate);
|
|
|
|
@CalledByNative("Observer")
|
|
void onIceCandidatesRemoved(IceCandidate[] iceCandidateArr);
|
|
|
|
@CalledByNative("Observer")
|
|
void onIceConnectionChange(IceConnectionState iceConnectionState);
|
|
|
|
@CalledByNative("Observer")
|
|
void onIceConnectionReceivingChange(boolean z2);
|
|
|
|
@CalledByNative("Observer")
|
|
void onIceGatheringChange(IceGatheringState iceGatheringState);
|
|
|
|
@CalledByNative("Observer")
|
|
void onRemoveStream(MediaStream mediaStream);
|
|
|
|
@CalledByNative("Observer")
|
|
void onRenegotiationNeeded();
|
|
|
|
@CalledByNative("Observer")
|
|
void onSelectedCandidatePairChanged(CandidatePairChangeEvent candidatePairChangeEvent);
|
|
|
|
@CalledByNative("Observer")
|
|
void onSignalingChange(SignalingState signalingState);
|
|
|
|
@CalledByNative("Observer")
|
|
void onStandardizedIceConnectionChange(IceConnectionState iceConnectionState);
|
|
|
|
@CalledByNative("Observer")
|
|
void onTrack(RtpTransceiver rtpTransceiver);
|
|
}
|
|
|
|
public enum PeerConnectionState {
|
|
NEW,
|
|
CONNECTING,
|
|
CONNECTED,
|
|
DISCONNECTED,
|
|
FAILED,
|
|
CLOSED;
|
|
|
|
@CalledByNative("PeerConnectionState")
|
|
public static PeerConnectionState fromNativeIndex(int i) {
|
|
return values()[i];
|
|
}
|
|
}
|
|
|
|
public enum PortPrunePolicy {
|
|
NO_PRUNE,
|
|
PRUNE_BASED_ON_PRIORITY,
|
|
KEEP_FIRST_READY
|
|
}
|
|
|
|
public static class RTCConfiguration {
|
|
public boolean activeResetSrtpParams;
|
|
@Nullable
|
|
public Boolean allowCodecSwitching;
|
|
public boolean audioJitterBufferFastAccelerate;
|
|
public int audioJitterBufferMaxPackets;
|
|
public BundlePolicy bundlePolicy = BundlePolicy.BALANCED;
|
|
public CandidateNetworkPolicy candidateNetworkPolicy = CandidateNetworkPolicy.ALL;
|
|
@Nullable
|
|
public RtcCertificatePem certificate;
|
|
@Nullable
|
|
public Boolean combinedAudioVideoBwe;
|
|
public ContinualGatheringPolicy continualGatheringPolicy;
|
|
@Nullable
|
|
public CryptoOptions cryptoOptions;
|
|
public boolean disableIPv6OnWifi;
|
|
public boolean disableIpv6;
|
|
public boolean enableCpuOveruseDetection;
|
|
public boolean enableDscp;
|
|
@Nullable
|
|
public Boolean enableDtlsSrtp;
|
|
public boolean enableRtpDataChannel;
|
|
public int iceBackupCandidatePairPingInterval;
|
|
public int iceCandidatePoolSize;
|
|
@Nullable
|
|
public Integer iceCheckIntervalStrongConnectivityMs;
|
|
@Nullable
|
|
public Integer iceCheckIntervalWeakConnectivityMs;
|
|
@Nullable
|
|
public Integer iceCheckMinInterval;
|
|
public int iceConnectionReceivingTimeout;
|
|
public List<IceServer> iceServers;
|
|
public IceTransportsType iceTransportsType = IceTransportsType.ALL;
|
|
@Nullable
|
|
public Integer iceUnwritableMinChecks;
|
|
@Nullable
|
|
public Integer iceUnwritableTimeMs;
|
|
public KeyType keyType;
|
|
public int maxIPv6Networks;
|
|
public AdapterType networkPreference;
|
|
public boolean presumeWritableWhenFullyRelayed;
|
|
@Deprecated
|
|
public boolean pruneTurnPorts;
|
|
public RtcpMuxPolicy rtcpMuxPolicy = RtcpMuxPolicy.REQUIRE;
|
|
@Nullable
|
|
public Integer screencastMinBitrate;
|
|
public SdpSemantics sdpSemantics;
|
|
@Nullable
|
|
public Integer stunCandidateKeepaliveIntervalMs;
|
|
public boolean surfaceIceCandidatesOnIceTransportTypeChanged;
|
|
public boolean suspendBelowMinBitrate;
|
|
public TcpCandidatePolicy tcpCandidatePolicy = TcpCandidatePolicy.ENABLED;
|
|
@Nullable
|
|
public TurnCustomizer turnCustomizer;
|
|
@Nullable
|
|
public String turnLoggingId;
|
|
public PortPrunePolicy turnPortPrunePolicy;
|
|
|
|
public RTCConfiguration(List<IceServer> list) {
|
|
this.iceServers = list;
|
|
this.audioJitterBufferMaxPackets = 50;
|
|
this.audioJitterBufferFastAccelerate = false;
|
|
this.iceConnectionReceivingTimeout = -1;
|
|
this.iceBackupCandidatePairPingInterval = -1;
|
|
this.keyType = KeyType.ECDSA;
|
|
this.continualGatheringPolicy = ContinualGatheringPolicy.GATHER_ONCE;
|
|
this.iceCandidatePoolSize = 0;
|
|
this.pruneTurnPorts = false;
|
|
this.turnPortPrunePolicy = PortPrunePolicy.NO_PRUNE;
|
|
this.presumeWritableWhenFullyRelayed = false;
|
|
this.surfaceIceCandidatesOnIceTransportTypeChanged = false;
|
|
this.iceCheckIntervalStrongConnectivityMs = null;
|
|
this.iceCheckIntervalWeakConnectivityMs = null;
|
|
this.iceCheckMinInterval = null;
|
|
this.iceUnwritableTimeMs = null;
|
|
this.iceUnwritableMinChecks = null;
|
|
this.stunCandidateKeepaliveIntervalMs = null;
|
|
this.disableIPv6OnWifi = false;
|
|
this.maxIPv6Networks = 5;
|
|
this.disableIpv6 = false;
|
|
this.enableDscp = false;
|
|
this.enableCpuOveruseDetection = true;
|
|
this.enableRtpDataChannel = false;
|
|
this.suspendBelowMinBitrate = false;
|
|
this.screencastMinBitrate = null;
|
|
this.combinedAudioVideoBwe = null;
|
|
this.enableDtlsSrtp = null;
|
|
this.networkPreference = AdapterType.UNKNOWN;
|
|
this.sdpSemantics = SdpSemantics.PLAN_B;
|
|
this.activeResetSrtpParams = false;
|
|
this.cryptoOptions = null;
|
|
this.turnLoggingId = null;
|
|
this.allowCodecSwitching = null;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public boolean getActiveResetSrtpParams() {
|
|
return this.activeResetSrtpParams;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public Boolean getAllowCodecSwitching() {
|
|
return this.allowCodecSwitching;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public boolean getAudioJitterBufferFastAccelerate() {
|
|
return this.audioJitterBufferFastAccelerate;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public int getAudioJitterBufferMaxPackets() {
|
|
return this.audioJitterBufferMaxPackets;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public BundlePolicy getBundlePolicy() {
|
|
return this.bundlePolicy;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public CandidateNetworkPolicy getCandidateNetworkPolicy() {
|
|
return this.candidateNetworkPolicy;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public RtcCertificatePem getCertificate() {
|
|
return this.certificate;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public Boolean getCombinedAudioVideoBwe() {
|
|
return this.combinedAudioVideoBwe;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public ContinualGatheringPolicy getContinualGatheringPolicy() {
|
|
return this.continualGatheringPolicy;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public CryptoOptions getCryptoOptions() {
|
|
return this.cryptoOptions;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public boolean getDisableIPv6OnWifi() {
|
|
return this.disableIPv6OnWifi;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public boolean getDisableIpv6() {
|
|
return this.disableIpv6;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public boolean getEnableCpuOveruseDetection() {
|
|
return this.enableCpuOveruseDetection;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public boolean getEnableDscp() {
|
|
return this.enableDscp;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public Boolean getEnableDtlsSrtp() {
|
|
return this.enableDtlsSrtp;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public boolean getEnableRtpDataChannel() {
|
|
return this.enableRtpDataChannel;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public int getIceBackupCandidatePairPingInterval() {
|
|
return this.iceBackupCandidatePairPingInterval;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public int getIceCandidatePoolSize() {
|
|
return this.iceCandidatePoolSize;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public Integer getIceCheckIntervalStrongConnectivity() {
|
|
return this.iceCheckIntervalStrongConnectivityMs;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public Integer getIceCheckIntervalWeakConnectivity() {
|
|
return this.iceCheckIntervalWeakConnectivityMs;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public Integer getIceCheckMinInterval() {
|
|
return this.iceCheckMinInterval;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public int getIceConnectionReceivingTimeout() {
|
|
return this.iceConnectionReceivingTimeout;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public List<IceServer> getIceServers() {
|
|
return this.iceServers;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public IceTransportsType getIceTransportsType() {
|
|
return this.iceTransportsType;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public Integer getIceUnwritableMinChecks() {
|
|
return this.iceUnwritableMinChecks;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public Integer getIceUnwritableTimeout() {
|
|
return this.iceUnwritableTimeMs;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public KeyType getKeyType() {
|
|
return this.keyType;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public int getMaxIPv6Networks() {
|
|
return this.maxIPv6Networks;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public AdapterType getNetworkPreference() {
|
|
return this.networkPreference;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public boolean getPresumeWritableWhenFullyRelayed() {
|
|
return this.presumeWritableWhenFullyRelayed;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public boolean getPruneTurnPorts() {
|
|
return this.pruneTurnPorts;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public RtcpMuxPolicy getRtcpMuxPolicy() {
|
|
return this.rtcpMuxPolicy;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public Integer getScreencastMinBitrate() {
|
|
return this.screencastMinBitrate;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public SdpSemantics getSdpSemantics() {
|
|
return this.sdpSemantics;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public Integer getStunCandidateKeepaliveInterval() {
|
|
return this.stunCandidateKeepaliveIntervalMs;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public boolean getSurfaceIceCandidatesOnIceTransportTypeChanged() {
|
|
return this.surfaceIceCandidatesOnIceTransportTypeChanged;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public boolean getSuspendBelowMinBitrate() {
|
|
return this.suspendBelowMinBitrate;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public TcpCandidatePolicy getTcpCandidatePolicy() {
|
|
return this.tcpCandidatePolicy;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public TurnCustomizer getTurnCustomizer() {
|
|
return this.turnCustomizer;
|
|
}
|
|
|
|
@Nullable
|
|
@CalledByNative("RTCConfiguration")
|
|
public String getTurnLoggingId() {
|
|
return this.turnLoggingId;
|
|
}
|
|
|
|
@CalledByNative("RTCConfiguration")
|
|
public PortPrunePolicy getTurnPortPrunePolicy() {
|
|
return this.turnPortPrunePolicy;
|
|
}
|
|
}
|
|
|
|
public enum RtcpMuxPolicy {
|
|
NEGOTIATE,
|
|
REQUIRE
|
|
}
|
|
|
|
public enum SdpSemantics {
|
|
PLAN_B,
|
|
UNIFIED_PLAN
|
|
}
|
|
|
|
public enum SignalingState {
|
|
STABLE,
|
|
HAVE_LOCAL_OFFER,
|
|
HAVE_LOCAL_PRANSWER,
|
|
HAVE_REMOTE_OFFER,
|
|
HAVE_REMOTE_PRANSWER,
|
|
CLOSED;
|
|
|
|
@CalledByNative("SignalingState")
|
|
public static SignalingState fromNativeIndex(int i) {
|
|
return values()[i];
|
|
}
|
|
}
|
|
|
|
public enum TcpCandidatePolicy {
|
|
ENABLED,
|
|
DISABLED
|
|
}
|
|
|
|
public enum TlsCertPolicy {
|
|
TLS_CERT_POLICY_SECURE,
|
|
TLS_CERT_POLICY_INSECURE_NO_CHECK
|
|
}
|
|
|
|
public PeerConnection(long j) {
|
|
this.localStreams = new ArrayList();
|
|
this.senders = new ArrayList();
|
|
this.receivers = new ArrayList();
|
|
this.transceivers = new ArrayList();
|
|
this.nativePeerConnection = j;
|
|
}
|
|
|
|
public PeerConnection(NativePeerConnectionFactory nativePeerConnectionFactory) {
|
|
this(nativePeerConnectionFactory.createNativePeerConnection());
|
|
}
|
|
|
|
public static long createNativePeerConnectionObserver(Observer observer) {
|
|
return nativeCreatePeerConnectionObserver(observer);
|
|
}
|
|
|
|
private native boolean nativeAddIceCandidate(String str, int i, String str2);
|
|
|
|
private native boolean nativeAddLocalStream(long j);
|
|
|
|
private native RtpSender nativeAddTrack(long j, List<String> list);
|
|
|
|
private native RtpTransceiver nativeAddTransceiverOfType(MediaStreamTrack.MediaType mediaType, RtpTransceiver.RtpTransceiverInit rtpTransceiverInit);
|
|
|
|
private native RtpTransceiver nativeAddTransceiverWithTrack(long j, RtpTransceiver.RtpTransceiverInit rtpTransceiverInit);
|
|
|
|
private native void nativeClose();
|
|
|
|
private native PeerConnectionState nativeConnectionState();
|
|
|
|
private native void nativeCreateAnswer(SdpObserver sdpObserver, MediaConstraints mediaConstraints);
|
|
|
|
private native DataChannel nativeCreateDataChannel(String str, DataChannel.Init init);
|
|
|
|
private native void nativeCreateOffer(SdpObserver sdpObserver, MediaConstraints mediaConstraints);
|
|
|
|
private static native long nativeCreatePeerConnectionObserver(Observer observer);
|
|
|
|
private native RtpSender nativeCreateSender(String str, String str2);
|
|
|
|
private static native void nativeFreeOwnedPeerConnection(long j);
|
|
|
|
private native RtcCertificatePem nativeGetCertificate();
|
|
|
|
private native SessionDescription nativeGetLocalDescription();
|
|
|
|
private native long nativeGetNativePeerConnection();
|
|
|
|
private native List<RtpReceiver> nativeGetReceivers();
|
|
|
|
private native SessionDescription nativeGetRemoteDescription();
|
|
|
|
private native List<RtpSender> nativeGetSenders();
|
|
|
|
private native List<RtpTransceiver> nativeGetTransceivers();
|
|
|
|
private native IceConnectionState nativeIceConnectionState();
|
|
|
|
private native IceGatheringState nativeIceGatheringState();
|
|
|
|
private native void nativeNewGetStats(RTCStatsCollectorCallback rTCStatsCollectorCallback);
|
|
|
|
private native boolean nativeOldGetStats(StatsObserver statsObserver, long j);
|
|
|
|
private native boolean nativeRemoveIceCandidates(IceCandidate[] iceCandidateArr);
|
|
|
|
private native void nativeRemoveLocalStream(long j);
|
|
|
|
private native boolean nativeRemoveTrack(long j);
|
|
|
|
private native void nativeSetAudioPlayout(boolean z2);
|
|
|
|
private native void nativeSetAudioRecording(boolean z2);
|
|
|
|
private native boolean nativeSetBitrate(Integer num, Integer num2, Integer num3);
|
|
|
|
private native boolean nativeSetConfiguration(RTCConfiguration rTCConfiguration);
|
|
|
|
private native void nativeSetLocalDescription(SdpObserver sdpObserver, SessionDescription sessionDescription);
|
|
|
|
private native void nativeSetRemoteDescription(SdpObserver sdpObserver, SessionDescription sessionDescription);
|
|
|
|
private native SignalingState nativeSignalingState();
|
|
|
|
private native boolean nativeStartRtcEventLog(int i, int i2);
|
|
|
|
private native void nativeStopRtcEventLog();
|
|
|
|
public boolean addIceCandidate(IceCandidate iceCandidate) {
|
|
return nativeAddIceCandidate(iceCandidate.sdpMid, iceCandidate.sdpMLineIndex, iceCandidate.sdp);
|
|
}
|
|
|
|
public boolean addStream(MediaStream mediaStream) {
|
|
if (!nativeAddLocalStream(mediaStream.getNativeMediaStream())) {
|
|
return false;
|
|
}
|
|
this.localStreams.add(mediaStream);
|
|
return true;
|
|
}
|
|
|
|
public RtpSender addTrack(MediaStreamTrack mediaStreamTrack) {
|
|
return addTrack(mediaStreamTrack, Collections.emptyList());
|
|
}
|
|
|
|
public RtpSender addTrack(MediaStreamTrack mediaStreamTrack, List<String> list) {
|
|
if (mediaStreamTrack == null || list == null) {
|
|
throw new NullPointerException("No MediaStreamTrack specified in addTrack.");
|
|
}
|
|
RtpSender nativeAddTrack = nativeAddTrack(mediaStreamTrack.getNativeMediaStreamTrack(), list);
|
|
if (nativeAddTrack != null) {
|
|
this.senders.add(nativeAddTrack);
|
|
return nativeAddTrack;
|
|
}
|
|
throw new IllegalStateException("C++ addTrack failed.");
|
|
}
|
|
|
|
public RtpTransceiver addTransceiver(MediaStreamTrack.MediaType mediaType) {
|
|
return addTransceiver(mediaType, new RtpTransceiver.RtpTransceiverInit());
|
|
}
|
|
|
|
public RtpTransceiver addTransceiver(MediaStreamTrack.MediaType mediaType, @Nullable RtpTransceiver.RtpTransceiverInit rtpTransceiverInit) {
|
|
Objects.requireNonNull(mediaType, "No MediaType specified for addTransceiver.");
|
|
if (rtpTransceiverInit == null) {
|
|
rtpTransceiverInit = new RtpTransceiver.RtpTransceiverInit();
|
|
}
|
|
RtpTransceiver nativeAddTransceiverOfType = nativeAddTransceiverOfType(mediaType, rtpTransceiverInit);
|
|
if (nativeAddTransceiverOfType != null) {
|
|
this.transceivers.add(nativeAddTransceiverOfType);
|
|
return nativeAddTransceiverOfType;
|
|
}
|
|
throw new IllegalStateException("C++ addTransceiver failed.");
|
|
}
|
|
|
|
public RtpTransceiver addTransceiver(MediaStreamTrack mediaStreamTrack) {
|
|
return addTransceiver(mediaStreamTrack, new RtpTransceiver.RtpTransceiverInit());
|
|
}
|
|
|
|
public RtpTransceiver addTransceiver(MediaStreamTrack mediaStreamTrack, @Nullable RtpTransceiver.RtpTransceiverInit rtpTransceiverInit) {
|
|
Objects.requireNonNull(mediaStreamTrack, "No MediaStreamTrack specified for addTransceiver.");
|
|
if (rtpTransceiverInit == null) {
|
|
rtpTransceiverInit = new RtpTransceiver.RtpTransceiverInit();
|
|
}
|
|
RtpTransceiver nativeAddTransceiverWithTrack = nativeAddTransceiverWithTrack(mediaStreamTrack.getNativeMediaStreamTrack(), rtpTransceiverInit);
|
|
if (nativeAddTransceiverWithTrack != null) {
|
|
this.transceivers.add(nativeAddTransceiverWithTrack);
|
|
return nativeAddTransceiverWithTrack;
|
|
}
|
|
throw new IllegalStateException("C++ addTransceiver failed.");
|
|
}
|
|
|
|
public void close() {
|
|
nativeClose();
|
|
}
|
|
|
|
public PeerConnectionState connectionState() {
|
|
return nativeConnectionState();
|
|
}
|
|
|
|
public void createAnswer(SdpObserver sdpObserver, MediaConstraints mediaConstraints) {
|
|
nativeCreateAnswer(sdpObserver, mediaConstraints);
|
|
}
|
|
|
|
public DataChannel createDataChannel(String str, DataChannel.Init init) {
|
|
return nativeCreateDataChannel(str, init);
|
|
}
|
|
|
|
public void createOffer(SdpObserver sdpObserver, MediaConstraints mediaConstraints) {
|
|
nativeCreateOffer(sdpObserver, mediaConstraints);
|
|
}
|
|
|
|
public RtpSender createSender(String str, String str2) {
|
|
RtpSender nativeCreateSender = nativeCreateSender(str, str2);
|
|
if (nativeCreateSender != null) {
|
|
this.senders.add(nativeCreateSender);
|
|
}
|
|
return nativeCreateSender;
|
|
}
|
|
|
|
public void dispose() {
|
|
close();
|
|
for (MediaStream mediaStream : this.localStreams) {
|
|
nativeRemoveLocalStream(mediaStream.getNativeMediaStream());
|
|
mediaStream.dispose();
|
|
}
|
|
this.localStreams.clear();
|
|
for (RtpSender rtpSender : this.senders) {
|
|
rtpSender.dispose();
|
|
}
|
|
this.senders.clear();
|
|
for (RtpReceiver rtpReceiver : this.receivers) {
|
|
rtpReceiver.dispose();
|
|
}
|
|
for (RtpTransceiver rtpTransceiver : this.transceivers) {
|
|
rtpTransceiver.dispose();
|
|
}
|
|
this.transceivers.clear();
|
|
this.receivers.clear();
|
|
nativeFreeOwnedPeerConnection(this.nativePeerConnection);
|
|
}
|
|
|
|
public RtcCertificatePem getCertificate() {
|
|
return nativeGetCertificate();
|
|
}
|
|
|
|
public SessionDescription getLocalDescription() {
|
|
return nativeGetLocalDescription();
|
|
}
|
|
|
|
@CalledByNative
|
|
public long getNativeOwnedPeerConnection() {
|
|
return this.nativePeerConnection;
|
|
}
|
|
|
|
public long getNativePeerConnection() {
|
|
return nativeGetNativePeerConnection();
|
|
}
|
|
|
|
public List<RtpReceiver> getReceivers() {
|
|
for (RtpReceiver rtpReceiver : this.receivers) {
|
|
rtpReceiver.dispose();
|
|
}
|
|
List<RtpReceiver> nativeGetReceivers = nativeGetReceivers();
|
|
this.receivers = nativeGetReceivers;
|
|
return Collections.unmodifiableList(nativeGetReceivers);
|
|
}
|
|
|
|
public SessionDescription getRemoteDescription() {
|
|
return nativeGetRemoteDescription();
|
|
}
|
|
|
|
public List<RtpSender> getSenders() {
|
|
for (RtpSender rtpSender : this.senders) {
|
|
rtpSender.dispose();
|
|
}
|
|
List<RtpSender> nativeGetSenders = nativeGetSenders();
|
|
this.senders = nativeGetSenders;
|
|
return Collections.unmodifiableList(nativeGetSenders);
|
|
}
|
|
|
|
public void getStats(RTCStatsCollectorCallback rTCStatsCollectorCallback) {
|
|
nativeNewGetStats(rTCStatsCollectorCallback);
|
|
}
|
|
|
|
@Deprecated
|
|
public boolean getStats(StatsObserver statsObserver, @Nullable MediaStreamTrack mediaStreamTrack) {
|
|
return nativeOldGetStats(statsObserver, mediaStreamTrack == null ? 0 : mediaStreamTrack.getNativeMediaStreamTrack());
|
|
}
|
|
|
|
public List<RtpTransceiver> getTransceivers() {
|
|
for (RtpTransceiver rtpTransceiver : this.transceivers) {
|
|
rtpTransceiver.dispose();
|
|
}
|
|
List<RtpTransceiver> nativeGetTransceivers = nativeGetTransceivers();
|
|
this.transceivers = nativeGetTransceivers;
|
|
return Collections.unmodifiableList(nativeGetTransceivers);
|
|
}
|
|
|
|
public IceConnectionState iceConnectionState() {
|
|
return nativeIceConnectionState();
|
|
}
|
|
|
|
public IceGatheringState iceGatheringState() {
|
|
return nativeIceGatheringState();
|
|
}
|
|
|
|
public boolean removeIceCandidates(IceCandidate[] iceCandidateArr) {
|
|
return nativeRemoveIceCandidates(iceCandidateArr);
|
|
}
|
|
|
|
public void removeStream(MediaStream mediaStream) {
|
|
nativeRemoveLocalStream(mediaStream.getNativeMediaStream());
|
|
this.localStreams.remove(mediaStream);
|
|
}
|
|
|
|
public boolean removeTrack(RtpSender rtpSender) {
|
|
Objects.requireNonNull(rtpSender, "No RtpSender specified for removeTrack.");
|
|
return nativeRemoveTrack(rtpSender.getNativeRtpSender());
|
|
}
|
|
|
|
public void setAudioPlayout(boolean z2) {
|
|
nativeSetAudioPlayout(z2);
|
|
}
|
|
|
|
public void setAudioRecording(boolean z2) {
|
|
nativeSetAudioRecording(z2);
|
|
}
|
|
|
|
public boolean setBitrate(Integer num, Integer num2, Integer num3) {
|
|
return nativeSetBitrate(num, num2, num3);
|
|
}
|
|
|
|
public boolean setConfiguration(RTCConfiguration rTCConfiguration) {
|
|
return nativeSetConfiguration(rTCConfiguration);
|
|
}
|
|
|
|
public void setLocalDescription(SdpObserver sdpObserver, SessionDescription sessionDescription) {
|
|
nativeSetLocalDescription(sdpObserver, sessionDescription);
|
|
}
|
|
|
|
public void setRemoteDescription(SdpObserver sdpObserver, SessionDescription sessionDescription) {
|
|
nativeSetRemoteDescription(sdpObserver, sessionDescription);
|
|
}
|
|
|
|
public SignalingState signalingState() {
|
|
return nativeSignalingState();
|
|
}
|
|
|
|
public boolean startRtcEventLog(int i, int i2) {
|
|
return nativeStartRtcEventLog(i, i2);
|
|
}
|
|
|
|
public void stopRtcEventLog() {
|
|
nativeStopRtcEventLog();
|
|
}
|
|
}
|