henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 11 | package org.webrtc; |
| 12 | |
Artem Titarenko | 69540f4 | 2018-12-10 12:30:46 +0100 | [diff] [blame] | 13 | import android.support.annotation.Nullable; |
Magnus Jedvert | 6062f37 | 2017-11-16 16:53:12 +0100 | [diff] [blame] | 14 | import java.util.ArrayList; |
Qingsi Wang | a0d4580 | 2019-01-15 13:33:11 -0800 | [diff] [blame] | 15 | import java.util.Arrays; |
Sami Kalliomäki | 3e189a6 | 2017-11-24 11:13:39 +0100 | [diff] [blame] | 16 | import java.util.Collections; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 17 | import java.util.List; |
Patrik Höglund | bd6ffaf | 2018-11-16 14:55:16 +0100 | [diff] [blame] | 18 | import org.webrtc.DataChannel; |
| 19 | import org.webrtc.MediaStreamTrack; |
| 20 | import org.webrtc.RtpTransceiver; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Java-land version of the PeerConnection APIs; wraps the C++ API |
| 24 | * http://www.webrtc.org/reference/native-apis, which in turn is inspired by the |
| 25 | * JS APIs: http://dev.w3.org/2011/webrtc/editor/webrtc.html and |
| 26 | * http://www.w3.org/TR/mediacapture-streams/ |
| 27 | */ |
| 28 | public class PeerConnection { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 29 | /** Tracks PeerConnectionInterface::IceGatheringState */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 30 | public enum IceGatheringState { |
| 31 | NEW, |
| 32 | GATHERING, |
| 33 | COMPLETE; |
| 34 | |
| 35 | @CalledByNative("IceGatheringState") |
| 36 | static IceGatheringState fromNativeIndex(int nativeIndex) { |
| 37 | return values()[nativeIndex]; |
| 38 | } |
| 39 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 40 | |
| 41 | /** Tracks PeerConnectionInterface::IceConnectionState */ |
| 42 | public enum IceConnectionState { |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 43 | NEW, |
| 44 | CHECKING, |
| 45 | CONNECTED, |
| 46 | COMPLETED, |
| 47 | FAILED, |
| 48 | DISCONNECTED, |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 49 | CLOSED; |
| 50 | |
| 51 | @CalledByNative("IceConnectionState") |
| 52 | static IceConnectionState fromNativeIndex(int nativeIndex) { |
| 53 | return values()[nativeIndex]; |
| 54 | } |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 55 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 56 | |
Jonas Olsson | f01d8c8 | 2018-11-08 15:19:04 +0100 | [diff] [blame] | 57 | /** Tracks PeerConnectionInterface::PeerConnectionState */ |
| 58 | public enum PeerConnectionState { |
| 59 | NEW, |
| 60 | CONNECTING, |
| 61 | CONNECTED, |
| 62 | DISCONNECTED, |
| 63 | FAILED, |
| 64 | CLOSED; |
| 65 | |
| 66 | @CalledByNative("PeerConnectionState") |
| 67 | static PeerConnectionState fromNativeIndex(int nativeIndex) { |
| 68 | return values()[nativeIndex]; |
| 69 | } |
| 70 | } |
| 71 | |
hnsl | 0483362 | 2017-01-09 08:35:45 -0800 | [diff] [blame] | 72 | /** Tracks PeerConnectionInterface::TlsCertPolicy */ |
| 73 | public enum TlsCertPolicy { |
| 74 | TLS_CERT_POLICY_SECURE, |
| 75 | TLS_CERT_POLICY_INSECURE_NO_CHECK, |
| 76 | } |
| 77 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 78 | /** Tracks PeerConnectionInterface::SignalingState */ |
| 79 | public enum SignalingState { |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 80 | STABLE, |
| 81 | HAVE_LOCAL_OFFER, |
| 82 | HAVE_LOCAL_PRANSWER, |
| 83 | HAVE_REMOTE_OFFER, |
| 84 | HAVE_REMOTE_PRANSWER, |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 85 | CLOSED; |
| 86 | |
| 87 | @CalledByNative("SignalingState") |
| 88 | static SignalingState fromNativeIndex(int nativeIndex) { |
| 89 | return values()[nativeIndex]; |
| 90 | } |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 91 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 92 | |
| 93 | /** Java version of PeerConnectionObserver. */ |
| 94 | public static interface Observer { |
| 95 | /** Triggered when the SignalingState changes. */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 96 | @CalledByNative("Observer") void onSignalingChange(SignalingState newState); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 97 | |
| 98 | /** Triggered when the IceConnectionState changes. */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 99 | @CalledByNative("Observer") void onIceConnectionChange(IceConnectionState newState); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 100 | |
Qingsi Wang | 36e3147 | 2019-05-29 11:37:26 -0700 | [diff] [blame^] | 101 | /* Triggered when the standard-compliant state transition of IceConnectionState happens. */ |
| 102 | @CalledByNative("Observer") |
| 103 | default void onStandardizedIceConnectionChange(IceConnectionState newState) {} |
| 104 | |
Jonas Olsson | f01d8c8 | 2018-11-08 15:19:04 +0100 | [diff] [blame] | 105 | /** Triggered when the PeerConnectionState changes. */ |
| 106 | @CalledByNative("Observer") |
| 107 | default void onConnectionChange(PeerConnectionState newState) {} |
| 108 | |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 109 | /** Triggered when the ICE connection receiving status changes. */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 110 | @CalledByNative("Observer") void onIceConnectionReceivingChange(boolean receiving); |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 111 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 112 | /** Triggered when the IceGatheringState changes. */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 113 | @CalledByNative("Observer") void onIceGatheringChange(IceGatheringState newState); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 114 | |
| 115 | /** Triggered when a new ICE candidate has been found. */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 116 | @CalledByNative("Observer") void onIceCandidate(IceCandidate candidate); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 117 | |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 118 | /** Triggered when some ICE candidates have been removed. */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 119 | @CalledByNative("Observer") void onIceCandidatesRemoved(IceCandidate[] candidates); |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 120 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 121 | /** Triggered when media is received on a new stream from remote peer. */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 122 | @CalledByNative("Observer") void onAddStream(MediaStream stream); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 123 | |
| 124 | /** Triggered when a remote peer close a stream. */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 125 | @CalledByNative("Observer") void onRemoveStream(MediaStream stream); |
henrike@webrtc.org | 723d683 | 2013-07-12 16:04:50 +0000 | [diff] [blame] | 126 | |
| 127 | /** Triggered when a remote peer opens a DataChannel. */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 128 | @CalledByNative("Observer") void onDataChannel(DataChannel dataChannel); |
fischman@webrtc.org | d7568a0 | 2014-01-13 22:04:12 +0000 | [diff] [blame] | 129 | |
| 130 | /** Triggered when renegotiation is necessary. */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 131 | @CalledByNative("Observer") void onRenegotiationNeeded(); |
zhihuang | dcccda7 | 2016-12-21 14:08:03 -0800 | [diff] [blame] | 132 | |
| 133 | /** |
| 134 | * Triggered when a new track is signaled by the remote peer, as a result of |
| 135 | * setRemoteDescription. |
| 136 | */ |
Magnus Jedvert | ba700f6 | 2017-12-04 13:43:27 +0100 | [diff] [blame] | 137 | @CalledByNative("Observer") void onAddTrack(RtpReceiver receiver, MediaStream[] mediaStreams); |
Seth Hampson | 31dbc24 | 2018-05-07 09:28:19 -0700 | [diff] [blame] | 138 | |
| 139 | /** |
| 140 | * Triggered when the signaling from SetRemoteDescription indicates that a transceiver |
| 141 | * will be receiving media from a remote endpoint. This is only called if UNIFIED_PLAN |
| 142 | * semantics are specified. The transceiver will be disposed automatically. |
| 143 | */ |
| 144 | @CalledByNative("Observer") default void onTrack(RtpTransceiver transceiver){}; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | /** Java version of PeerConnectionInterface.IceServer. */ |
| 148 | public static class IceServer { |
Emad Omara | dab1d2d | 2017-06-16 15:43:11 -0700 | [diff] [blame] | 149 | // List of URIs associated with this server. Valid formats are described |
| 150 | // in RFC7064 and RFC7065, and more may be added in the future. The "host" |
| 151 | // part of the URI may contain either an IP address or a hostname. |
korniltsev.anatoly | 0ea0310 | 2017-09-11 06:41:38 -0700 | [diff] [blame] | 152 | @Deprecated public final String uri; |
| 153 | public final List<String> urls; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 154 | public final String username; |
| 155 | public final String password; |
Sergey Silkin | 9c147dd | 2018-09-12 10:45:38 +0000 | [diff] [blame] | 156 | public final TlsCertPolicy tlsCertPolicy; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 157 | |
Emad Omara | dab1d2d | 2017-06-16 15:43:11 -0700 | [diff] [blame] | 158 | // If the URIs in |urls| only contain IP addresses, this field can be used |
| 159 | // to indicate the hostname, which may be necessary for TLS (using the SNI |
| 160 | // extension). If |urls| itself contains the hostname, this isn't |
| 161 | // necessary. |
| 162 | public final String hostname; |
| 163 | |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 164 | // List of protocols to be used in the TLS ALPN extension. |
Sergey Silkin | 9c147dd | 2018-09-12 10:45:38 +0000 | [diff] [blame] | 165 | public final List<String> tlsAlpnProtocols; |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 166 | |
Diogo Real | 7bd1f1b | 2017-09-08 12:50:41 -0700 | [diff] [blame] | 167 | // List of elliptic curves to be used in the TLS elliptic curves extension. |
| 168 | // Only curve names supported by OpenSSL should be used (eg. "P-256","X25519"). |
Sergey Silkin | 9c147dd | 2018-09-12 10:45:38 +0000 | [diff] [blame] | 169 | public final List<String> tlsEllipticCurves; |
Diogo Real | 7bd1f1b | 2017-09-08 12:50:41 -0700 | [diff] [blame] | 170 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 171 | /** Convenience constructor for STUN servers. */ |
Diogo Real | 05ea2b3 | 2017-08-31 00:12:58 -0700 | [diff] [blame] | 172 | @Deprecated |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 173 | public IceServer(String uri) { |
| 174 | this(uri, "", ""); |
| 175 | } |
| 176 | |
Diogo Real | 05ea2b3 | 2017-08-31 00:12:58 -0700 | [diff] [blame] | 177 | @Deprecated |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 178 | public IceServer(String uri, String username, String password) { |
hnsl | 0483362 | 2017-01-09 08:35:45 -0800 | [diff] [blame] | 179 | this(uri, username, password, TlsCertPolicy.TLS_CERT_POLICY_SECURE); |
| 180 | } |
| 181 | |
Diogo Real | 05ea2b3 | 2017-08-31 00:12:58 -0700 | [diff] [blame] | 182 | @Deprecated |
hnsl | 0483362 | 2017-01-09 08:35:45 -0800 | [diff] [blame] | 183 | public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy) { |
Emad Omara | dab1d2d | 2017-06-16 15:43:11 -0700 | [diff] [blame] | 184 | this(uri, username, password, tlsCertPolicy, ""); |
| 185 | } |
| 186 | |
Diogo Real | 05ea2b3 | 2017-08-31 00:12:58 -0700 | [diff] [blame] | 187 | @Deprecated |
Emad Omara | dab1d2d | 2017-06-16 15:43:11 -0700 | [diff] [blame] | 188 | public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy, |
| 189 | String hostname) { |
korniltsev.anatoly | 0ea0310 | 2017-09-11 06:41:38 -0700 | [diff] [blame] | 190 | this(uri, Collections.singletonList(uri), username, password, tlsCertPolicy, hostname, null, |
Sergey Silkin | 9c147dd | 2018-09-12 10:45:38 +0000 | [diff] [blame] | 191 | null); |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 192 | } |
| 193 | |
korniltsev.anatoly | 0ea0310 | 2017-09-11 06:41:38 -0700 | [diff] [blame] | 194 | private IceServer(String uri, List<String> urls, String username, String password, |
| 195 | TlsCertPolicy tlsCertPolicy, String hostname, List<String> tlsAlpnProtocols, |
Sergey Silkin | 9c147dd | 2018-09-12 10:45:38 +0000 | [diff] [blame] | 196 | List<String> tlsEllipticCurves) { |
korniltsev.anatoly | 0ea0310 | 2017-09-11 06:41:38 -0700 | [diff] [blame] | 197 | if (uri == null || urls == null || urls.isEmpty()) { |
| 198 | throw new IllegalArgumentException("uri == null || urls == null || urls.isEmpty()"); |
| 199 | } |
| 200 | for (String it : urls) { |
| 201 | if (it == null) { |
| 202 | throw new IllegalArgumentException("urls element is null: " + urls); |
| 203 | } |
| 204 | } |
| 205 | if (username == null) { |
| 206 | throw new IllegalArgumentException("username == null"); |
| 207 | } |
| 208 | if (password == null) { |
| 209 | throw new IllegalArgumentException("password == null"); |
| 210 | } |
| 211 | if (hostname == null) { |
| 212 | throw new IllegalArgumentException("hostname == null"); |
| 213 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 214 | this.uri = uri; |
korniltsev.anatoly | 0ea0310 | 2017-09-11 06:41:38 -0700 | [diff] [blame] | 215 | this.urls = urls; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 216 | this.username = username; |
| 217 | this.password = password; |
hnsl | 0483362 | 2017-01-09 08:35:45 -0800 | [diff] [blame] | 218 | this.tlsCertPolicy = tlsCertPolicy; |
Emad Omara | dab1d2d | 2017-06-16 15:43:11 -0700 | [diff] [blame] | 219 | this.hostname = hostname; |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 220 | this.tlsAlpnProtocols = tlsAlpnProtocols; |
Diogo Real | 7bd1f1b | 2017-09-08 12:50:41 -0700 | [diff] [blame] | 221 | this.tlsEllipticCurves = tlsEllipticCurves; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 222 | } |
| 223 | |
Sami Kalliomäki | bde473e | 2017-10-30 13:34:41 +0100 | [diff] [blame] | 224 | @Override |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 225 | public String toString() { |
korniltsev.anatoly | 0ea0310 | 2017-09-11 06:41:38 -0700 | [diff] [blame] | 226 | return urls + " [" + username + ":" + password + "] [" + tlsCertPolicy + "] [" + hostname |
Sergey Silkin | 9c147dd | 2018-09-12 10:45:38 +0000 | [diff] [blame] | 227 | + "] [" + tlsAlpnProtocols + "] [" + tlsEllipticCurves + "]"; |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Qingsi Wang | a0d4580 | 2019-01-15 13:33:11 -0800 | [diff] [blame] | 230 | @Override |
| 231 | public boolean equals(@Nullable Object obj) { |
| 232 | if (obj == null) { |
| 233 | return false; |
| 234 | } |
| 235 | if (obj == this) { |
| 236 | return true; |
| 237 | } |
| 238 | if (!(obj instanceof IceServer)) { |
| 239 | return false; |
| 240 | } |
| 241 | IceServer other = (IceServer) obj; |
| 242 | return (uri.equals(other.uri) && urls.equals(other.urls) && username.equals(other.username) |
| 243 | && password.equals(other.password) && tlsCertPolicy.equals(other.tlsCertPolicy) |
| 244 | && hostname.equals(other.hostname) && tlsAlpnProtocols.equals(other.tlsAlpnProtocols) |
| 245 | && tlsEllipticCurves.equals(other.tlsEllipticCurves)); |
| 246 | } |
| 247 | |
| 248 | @Override |
| 249 | public int hashCode() { |
| 250 | Object[] values = {uri, urls, username, password, tlsCertPolicy, hostname, tlsAlpnProtocols, |
| 251 | tlsEllipticCurves}; |
| 252 | return Arrays.hashCode(values); |
| 253 | } |
| 254 | |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 255 | public static Builder builder(String uri) { |
korniltsev.anatoly | 0ea0310 | 2017-09-11 06:41:38 -0700 | [diff] [blame] | 256 | return new Builder(Collections.singletonList(uri)); |
| 257 | } |
| 258 | |
| 259 | public static Builder builder(List<String> urls) { |
| 260 | return new Builder(urls); |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | public static class Builder { |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 264 | @Nullable private final List<String> urls; |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 265 | private String username = ""; |
| 266 | private String password = ""; |
| 267 | private TlsCertPolicy tlsCertPolicy = TlsCertPolicy.TLS_CERT_POLICY_SECURE; |
| 268 | private String hostname = ""; |
| 269 | private List<String> tlsAlpnProtocols; |
Diogo Real | 7bd1f1b | 2017-09-08 12:50:41 -0700 | [diff] [blame] | 270 | private List<String> tlsEllipticCurves; |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 271 | |
korniltsev.anatoly | 0ea0310 | 2017-09-11 06:41:38 -0700 | [diff] [blame] | 272 | private Builder(List<String> urls) { |
| 273 | if (urls == null || urls.isEmpty()) { |
| 274 | throw new IllegalArgumentException("urls == null || urls.isEmpty(): " + urls); |
| 275 | } |
| 276 | this.urls = urls; |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | public Builder setUsername(String username) { |
| 280 | this.username = username; |
| 281 | return this; |
| 282 | } |
| 283 | |
| 284 | public Builder setPassword(String password) { |
| 285 | this.password = password; |
| 286 | return this; |
| 287 | } |
| 288 | |
| 289 | public Builder setTlsCertPolicy(TlsCertPolicy tlsCertPolicy) { |
| 290 | this.tlsCertPolicy = tlsCertPolicy; |
| 291 | return this; |
| 292 | } |
| 293 | |
| 294 | public Builder setHostname(String hostname) { |
| 295 | this.hostname = hostname; |
| 296 | return this; |
| 297 | } |
| 298 | |
| 299 | public Builder setTlsAlpnProtocols(List<String> tlsAlpnProtocols) { |
| 300 | this.tlsAlpnProtocols = tlsAlpnProtocols; |
| 301 | return this; |
| 302 | } |
| 303 | |
Diogo Real | 7bd1f1b | 2017-09-08 12:50:41 -0700 | [diff] [blame] | 304 | public Builder setTlsEllipticCurves(List<String> tlsEllipticCurves) { |
| 305 | this.tlsEllipticCurves = tlsEllipticCurves; |
| 306 | return this; |
| 307 | } |
| 308 | |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 309 | public IceServer createIceServer() { |
korniltsev.anatoly | 0ea0310 | 2017-09-11 06:41:38 -0700 | [diff] [blame] | 310 | return new IceServer(urls.get(0), urls, username, password, tlsCertPolicy, hostname, |
Sergey Silkin | 9c147dd | 2018-09-12 10:45:38 +0000 | [diff] [blame] | 311 | tlsAlpnProtocols, tlsEllipticCurves); |
Diogo Real | 1dca9d5 | 2017-08-29 12:18:32 -0700 | [diff] [blame] | 312 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 313 | } |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 314 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 315 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 316 | @CalledByNative("IceServer") |
| 317 | List<String> getUrls() { |
| 318 | return urls; |
| 319 | } |
| 320 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 321 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 322 | @CalledByNative("IceServer") |
| 323 | String getUsername() { |
| 324 | return username; |
| 325 | } |
| 326 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 327 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 328 | @CalledByNative("IceServer") |
| 329 | String getPassword() { |
| 330 | return password; |
| 331 | } |
| 332 | |
| 333 | @CalledByNative("IceServer") |
| 334 | TlsCertPolicy getTlsCertPolicy() { |
| 335 | return tlsCertPolicy; |
| 336 | } |
| 337 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 338 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 339 | @CalledByNative("IceServer") |
| 340 | String getHostname() { |
| 341 | return hostname; |
| 342 | } |
| 343 | |
| 344 | @CalledByNative("IceServer") |
| 345 | List<String> getTlsAlpnProtocols() { |
| 346 | return tlsAlpnProtocols; |
| 347 | } |
| 348 | |
| 349 | @CalledByNative("IceServer") |
| 350 | List<String> getTlsEllipticCurves() { |
| 351 | return tlsEllipticCurves; |
| 352 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 353 | } |
| 354 | |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 355 | /** Java version of PeerConnectionInterface.IceTransportsType */ |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 356 | public enum IceTransportsType { NONE, RELAY, NOHOST, ALL } |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 357 | |
| 358 | /** Java version of PeerConnectionInterface.BundlePolicy */ |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 359 | public enum BundlePolicy { BALANCED, MAXBUNDLE, MAXCOMPAT } |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 360 | |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 361 | /** Java version of PeerConnectionInterface.RtcpMuxPolicy */ |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 362 | public enum RtcpMuxPolicy { NEGOTIATE, REQUIRE } |
glaznev | 97579a4 | 2015-09-01 11:31:27 -0700 | [diff] [blame] | 363 | |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 364 | /** Java version of PeerConnectionInterface.TcpCandidatePolicy */ |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 365 | public enum TcpCandidatePolicy { ENABLED, DISABLED } |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 366 | |
honghaiz | 6034705 | 2016-05-31 18:29:12 -0700 | [diff] [blame] | 367 | /** Java version of PeerConnectionInterface.CandidateNetworkPolicy */ |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 368 | public enum CandidateNetworkPolicy { ALL, LOW_COST } |
honghaiz | 6034705 | 2016-05-31 18:29:12 -0700 | [diff] [blame] | 369 | |
Qingsi Wang | 9a5c6f8 | 2018-02-01 10:38:40 -0800 | [diff] [blame] | 370 | // Keep in sync with webrtc/rtc_base/network_constants.h. |
| 371 | public enum AdapterType { |
| 372 | UNKNOWN, |
| 373 | ETHERNET, |
| 374 | WIFI, |
| 375 | CELLULAR, |
| 376 | VPN, |
| 377 | LOOPBACK, |
| 378 | } |
| 379 | |
glaznev | 97579a4 | 2015-09-01 11:31:27 -0700 | [diff] [blame] | 380 | /** Java version of rtc::KeyType */ |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 381 | public enum KeyType { RSA, ECDSA } |
glaznev | 97579a4 | 2015-09-01 11:31:27 -0700 | [diff] [blame] | 382 | |
honghaiz | 1f429e3 | 2015-09-28 07:57:34 -0700 | [diff] [blame] | 383 | /** Java version of PeerConnectionInterface.ContinualGatheringPolicy */ |
sakal | b6760f9 | 2016-09-29 04:12:44 -0700 | [diff] [blame] | 384 | public enum ContinualGatheringPolicy { GATHER_ONCE, GATHER_CONTINUALLY } |
honghaiz | 1f429e3 | 2015-09-28 07:57:34 -0700 | [diff] [blame] | 385 | |
Steve Anton | d960a0c | 2017-07-17 12:33:07 -0700 | [diff] [blame] | 386 | /** Java version of rtc::IntervalRange */ |
| 387 | public static class IntervalRange { |
| 388 | private final int min; |
| 389 | private final int max; |
| 390 | |
| 391 | public IntervalRange(int min, int max) { |
| 392 | this.min = min; |
| 393 | this.max = max; |
| 394 | } |
| 395 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 396 | @CalledByNative("IntervalRange") |
Steve Anton | d960a0c | 2017-07-17 12:33:07 -0700 | [diff] [blame] | 397 | public int getMin() { |
| 398 | return min; |
| 399 | } |
| 400 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 401 | @CalledByNative("IntervalRange") |
Steve Anton | d960a0c | 2017-07-17 12:33:07 -0700 | [diff] [blame] | 402 | public int getMax() { |
| 403 | return max; |
| 404 | } |
| 405 | } |
| 406 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 407 | /** |
| 408 | * Java version of webrtc::SdpSemantics. |
| 409 | * |
| 410 | * Configure the SDP semantics used by this PeerConnection. Note that the |
| 411 | * WebRTC 1.0 specification requires UNIFIED_PLAN semantics. The |
| 412 | * RtpTransceiver API is only available with UNIFIED_PLAN semantics. |
| 413 | * |
| 414 | * <p>PLAN_B will cause PeerConnection to create offers and answers with at |
| 415 | * most one audio and one video m= section with multiple RtpSenders and |
| 416 | * RtpReceivers specified as multiple a=ssrc lines within the section. This |
| 417 | * will also cause PeerConnection to ignore all but the first m= section of |
| 418 | * the same media type. |
| 419 | * |
| 420 | * <p>UNIFIED_PLAN will cause PeerConnection to create offers and answers with |
| 421 | * multiple m= sections where each m= section maps to one RtpSender and one |
| 422 | * RtpReceiver (an RtpTransceiver), either both audio or both video. This |
| 423 | * will also cause PeerConnection to ignore all but the first a=ssrc lines |
| 424 | * that form a Plan B stream. |
| 425 | * |
| 426 | * <p>For users who wish to send multiple audio/video streams and need to stay |
| 427 | * interoperable with legacy WebRTC implementations, specify PLAN_B. |
| 428 | * |
| 429 | * <p>For users who wish to send multiple audio/video streams and/or wish to |
| 430 | * use the new RtpTransceiver API, specify UNIFIED_PLAN. |
| 431 | */ |
| 432 | public enum SdpSemantics { PLAN_B, UNIFIED_PLAN } |
| 433 | |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 434 | /** Java version of PeerConnectionInterface.RTCConfiguration */ |
Qingsi Wang | db53f8e | 2018-02-20 14:45:49 -0800 | [diff] [blame] | 435 | // TODO(qingsi): Resolve the naming inconsistency of fields with/without units. |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 436 | public static class RTCConfiguration { |
| 437 | public IceTransportsType iceTransportsType; |
| 438 | public List<IceServer> iceServers; |
| 439 | public BundlePolicy bundlePolicy; |
Michael Iedema | 0213786 | 2018-10-09 15:30:01 +0200 | [diff] [blame] | 440 | @Nullable public RtcCertificatePem certificate; |
Peter Thatcher | af55ccc | 2015-05-21 07:48:41 -0700 | [diff] [blame] | 441 | public RtcpMuxPolicy rtcpMuxPolicy; |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 442 | public TcpCandidatePolicy tcpCandidatePolicy; |
honghaiz | 6034705 | 2016-05-31 18:29:12 -0700 | [diff] [blame] | 443 | public CandidateNetworkPolicy candidateNetworkPolicy; |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 444 | public int audioJitterBufferMaxPackets; |
Henrik Lundin | 5263b3c | 2015-06-01 10:29:41 +0200 | [diff] [blame] | 445 | public boolean audioJitterBufferFastAccelerate; |
honghaiz | 4edc39c | 2015-09-01 09:53:56 -0700 | [diff] [blame] | 446 | public int iceConnectionReceivingTimeout; |
Honghai Zhang | 381b421 | 2015-12-04 12:24:03 -0800 | [diff] [blame] | 447 | public int iceBackupCandidatePairPingInterval; |
glaznev | 97579a4 | 2015-09-01 11:31:27 -0700 | [diff] [blame] | 448 | public KeyType keyType; |
honghaiz | 1f429e3 | 2015-09-28 07:57:34 -0700 | [diff] [blame] | 449 | public ContinualGatheringPolicy continualGatheringPolicy; |
deadbeef | be0c96f | 2016-05-18 16:20:14 -0700 | [diff] [blame] | 450 | public int iceCandidatePoolSize; |
Honghai Zhang | d78ecf7 | 2016-07-01 14:40:40 -0700 | [diff] [blame] | 451 | public boolean pruneTurnPorts; |
Taylor Brandstetter | e985111 | 2016-07-01 11:11:13 -0700 | [diff] [blame] | 452 | public boolean presumeWritableWhenFullyRelayed; |
Qingsi Wang | e6826d2 | 2018-03-08 14:55:14 -0800 | [diff] [blame] | 453 | // The following fields define intervals in milliseconds at which ICE |
| 454 | // connectivity checks are sent. |
| 455 | // |
| 456 | // We consider ICE is "strongly connected" for an agent when there is at |
| 457 | // least one candidate pair that currently succeeds in connectivity check |
| 458 | // from its direction i.e. sending a ping and receives a ping response, AND |
| 459 | // all candidate pairs have sent a minimum number of pings for connectivity |
| 460 | // (this number is implementation-specific). Otherwise, ICE is considered in |
| 461 | // "weak connectivity". |
| 462 | // |
| 463 | // Note that the above notion of strong and weak connectivity is not defined |
| 464 | // in RFC 5245, and they apply to our current ICE implementation only. |
| 465 | // |
| 466 | // 1) iceCheckIntervalStrongConnectivityMs defines the interval applied to |
| 467 | // ALL candidate pairs when ICE is strongly connected, |
| 468 | // 2) iceCheckIntervalWeakConnectivityMs defines the counterpart for ALL |
| 469 | // pairs when ICE is weakly connected, and |
| 470 | // 3) iceCheckMinInterval defines the minimal interval (equivalently the |
| 471 | // maximum rate) that overrides the above two intervals when either of them |
| 472 | // is less. |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 473 | @Nullable public Integer iceCheckIntervalStrongConnectivityMs; |
| 474 | @Nullable public Integer iceCheckIntervalWeakConnectivityMs; |
| 475 | @Nullable public Integer iceCheckMinInterval; |
Qingsi Wang | 22e623a | 2018-03-13 10:53:57 -0700 | [diff] [blame] | 476 | // The time period in milliseconds for which a candidate pair must wait for response to |
| 477 | // connectivitiy checks before it becomes unwritable. |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 478 | @Nullable public Integer iceUnwritableTimeMs; |
Qingsi Wang | 22e623a | 2018-03-13 10:53:57 -0700 | [diff] [blame] | 479 | // The minimum number of connectivity checks that a candidate pair must sent without receiving |
| 480 | // response before it becomes unwritable. |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 481 | @Nullable public Integer iceUnwritableMinChecks; |
Qingsi Wang | db53f8e | 2018-02-20 14:45:49 -0800 | [diff] [blame] | 482 | // The interval in milliseconds at which STUN candidates will resend STUN binding requests |
| 483 | // to keep NAT bindings open. |
| 484 | // The default value in the implementation is used if this field is null. |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 485 | @Nullable public Integer stunCandidateKeepaliveIntervalMs; |
zhihuang | b09b3f9 | 2017-03-07 14:40:51 -0800 | [diff] [blame] | 486 | public boolean disableIPv6OnWifi; |
deadbeef | 28e2919 | 2017-07-27 09:14:38 -0700 | [diff] [blame] | 487 | // By default, PeerConnection will use a limited number of IPv6 network |
| 488 | // interfaces, in order to avoid too many ICE candidate pairs being created |
| 489 | // and delaying ICE completion. |
| 490 | // |
| 491 | // Can be set to Integer.MAX_VALUE to effectively disable the limit. |
| 492 | public int maxIPv6Networks; |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 493 | @Nullable public IntervalRange iceRegatherIntervalRange; |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 494 | |
Sami Kalliomäki | e8b26cd | 2017-12-19 12:51:53 +0100 | [diff] [blame] | 495 | // These values will be overridden by MediaStream constraints if deprecated constraints-based |
| 496 | // create peerconnection interface is used. |
| 497 | public boolean disableIpv6; |
| 498 | public boolean enableDscp; |
| 499 | public boolean enableCpuOveruseDetection; |
| 500 | public boolean enableRtpDataChannel; |
| 501 | public boolean suspendBelowMinBitrate; |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 502 | @Nullable public Integer screencastMinBitrate; |
| 503 | @Nullable public Boolean combinedAudioVideoBwe; |
| 504 | @Nullable public Boolean enableDtlsSrtp; |
Qingsi Wang | 9a5c6f8 | 2018-02-01 10:38:40 -0800 | [diff] [blame] | 505 | // Use "Unknown" to represent no preference of adapter types, not the |
| 506 | // preference of adapters of unknown types. |
| 507 | public AdapterType networkPreference; |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 508 | public SdpSemantics sdpSemantics; |
Sami Kalliomäki | e8b26cd | 2017-12-19 12:51:53 +0100 | [diff] [blame] | 509 | |
Jonas Oreland | bdcee28 | 2017-10-10 14:01:40 +0200 | [diff] [blame] | 510 | // This is an optional wrapper for the C++ webrtc::TurnCustomizer. |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 511 | @Nullable public TurnCustomizer turnCustomizer; |
Jonas Oreland | bdcee28 | 2017-10-10 14:01:40 +0200 | [diff] [blame] | 512 | |
Zhi Huang | b57e169 | 2018-06-12 11:41:11 -0700 | [diff] [blame] | 513 | // Actively reset the SRTP parameters whenever the DTLS transports underneath are reset for |
| 514 | // every offer/answer negotiation.This is only intended to be a workaround for crbug.com/835958 |
| 515 | public boolean activeResetSrtpParams; |
| 516 | |
Piotr (Peter) Slatala | 09beff2 | 2018-10-17 07:22:40 -0700 | [diff] [blame] | 517 | /* |
| 518 | * Experimental flag that enables a use of media transport. If this is true, the media transport |
| 519 | * factory MUST be provided to the PeerConnectionFactory. |
| 520 | */ |
| 521 | public boolean useMediaTransport; |
| 522 | |
Bjorn Mellem | a9bbd86 | 2018-11-02 09:07:48 -0700 | [diff] [blame] | 523 | /* |
| 524 | * Experimental flag that enables a use of media transport for data channels. If this is true, |
| 525 | * the media transport factory MUST be provided to the PeerConnectionFactory. |
| 526 | */ |
| 527 | public boolean useMediaTransportForDataChannels; |
| 528 | |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 529 | /** |
| 530 | * Defines advanced optional cryptographic settings related to SRTP and |
| 531 | * frame encryption for native WebRTC. Setting this will overwrite any |
| 532 | * options set through the PeerConnectionFactory (which is deprecated). |
| 533 | */ |
| 534 | @Nullable public CryptoOptions cryptoOptions; |
| 535 | |
deadbeef | 28e2919 | 2017-07-27 09:14:38 -0700 | [diff] [blame] | 536 | // TODO(deadbeef): Instead of duplicating the defaults here, we should do |
| 537 | // something to pick up the defaults from C++. The Objective-C equivalent |
| 538 | // of RTCConfiguration does that. |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 539 | public RTCConfiguration(List<IceServer> iceServers) { |
| 540 | iceTransportsType = IceTransportsType.ALL; |
| 541 | bundlePolicy = BundlePolicy.BALANCED; |
zhihuang | 4dfb8ce | 2016-11-23 10:30:12 -0800 | [diff] [blame] | 542 | rtcpMuxPolicy = RtcpMuxPolicy.REQUIRE; |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 543 | tcpCandidatePolicy = TcpCandidatePolicy.ENABLED; |
Sami Kalliomäki | 9828beb | 2017-10-26 16:21:22 +0200 | [diff] [blame] | 544 | candidateNetworkPolicy = CandidateNetworkPolicy.ALL; |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 545 | this.iceServers = iceServers; |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 546 | audioJitterBufferMaxPackets = 50; |
Henrik Lundin | 5263b3c | 2015-06-01 10:29:41 +0200 | [diff] [blame] | 547 | audioJitterBufferFastAccelerate = false; |
honghaiz | 4edc39c | 2015-09-01 09:53:56 -0700 | [diff] [blame] | 548 | iceConnectionReceivingTimeout = -1; |
Honghai Zhang | 381b421 | 2015-12-04 12:24:03 -0800 | [diff] [blame] | 549 | iceBackupCandidatePairPingInterval = -1; |
glaznev | 97579a4 | 2015-09-01 11:31:27 -0700 | [diff] [blame] | 550 | keyType = KeyType.ECDSA; |
honghaiz | 1f429e3 | 2015-09-28 07:57:34 -0700 | [diff] [blame] | 551 | continualGatheringPolicy = ContinualGatheringPolicy.GATHER_ONCE; |
deadbeef | be0c96f | 2016-05-18 16:20:14 -0700 | [diff] [blame] | 552 | iceCandidatePoolSize = 0; |
Honghai Zhang | d78ecf7 | 2016-07-01 14:40:40 -0700 | [diff] [blame] | 553 | pruneTurnPorts = false; |
Taylor Brandstetter | e985111 | 2016-07-01 11:11:13 -0700 | [diff] [blame] | 554 | presumeWritableWhenFullyRelayed = false; |
Qingsi Wang | e6826d2 | 2018-03-08 14:55:14 -0800 | [diff] [blame] | 555 | iceCheckIntervalStrongConnectivityMs = null; |
| 556 | iceCheckIntervalWeakConnectivityMs = null; |
skvlad | 5107246 | 2017-02-02 11:50:14 -0800 | [diff] [blame] | 557 | iceCheckMinInterval = null; |
Qingsi Wang | 22e623a | 2018-03-13 10:53:57 -0700 | [diff] [blame] | 558 | iceUnwritableTimeMs = null; |
| 559 | iceUnwritableMinChecks = null; |
Qingsi Wang | db53f8e | 2018-02-20 14:45:49 -0800 | [diff] [blame] | 560 | stunCandidateKeepaliveIntervalMs = null; |
zhihuang | b09b3f9 | 2017-03-07 14:40:51 -0800 | [diff] [blame] | 561 | disableIPv6OnWifi = false; |
deadbeef | 28e2919 | 2017-07-27 09:14:38 -0700 | [diff] [blame] | 562 | maxIPv6Networks = 5; |
Steve Anton | d960a0c | 2017-07-17 12:33:07 -0700 | [diff] [blame] | 563 | iceRegatherIntervalRange = null; |
Sami Kalliomäki | e8b26cd | 2017-12-19 12:51:53 +0100 | [diff] [blame] | 564 | disableIpv6 = false; |
| 565 | enableDscp = false; |
| 566 | enableCpuOveruseDetection = true; |
| 567 | enableRtpDataChannel = false; |
| 568 | suspendBelowMinBitrate = false; |
| 569 | screencastMinBitrate = null; |
| 570 | combinedAudioVideoBwe = null; |
| 571 | enableDtlsSrtp = null; |
Qingsi Wang | 9a5c6f8 | 2018-02-01 10:38:40 -0800 | [diff] [blame] | 572 | networkPreference = AdapterType.UNKNOWN; |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 573 | sdpSemantics = SdpSemantics.PLAN_B; |
Zhi Huang | b57e169 | 2018-06-12 11:41:11 -0700 | [diff] [blame] | 574 | activeResetSrtpParams = false; |
Piotr (Peter) Slatala | 09beff2 | 2018-10-17 07:22:40 -0700 | [diff] [blame] | 575 | useMediaTransport = false; |
Bjorn Mellem | a9bbd86 | 2018-11-02 09:07:48 -0700 | [diff] [blame] | 576 | useMediaTransportForDataChannels = false; |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 577 | cryptoOptions = null; |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 578 | } |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 579 | |
| 580 | @CalledByNative("RTCConfiguration") |
| 581 | IceTransportsType getIceTransportsType() { |
| 582 | return iceTransportsType; |
| 583 | } |
| 584 | |
| 585 | @CalledByNative("RTCConfiguration") |
| 586 | List<IceServer> getIceServers() { |
| 587 | return iceServers; |
| 588 | } |
| 589 | |
| 590 | @CalledByNative("RTCConfiguration") |
| 591 | BundlePolicy getBundlePolicy() { |
| 592 | return bundlePolicy; |
| 593 | } |
| 594 | |
Michael Iedema | 0213786 | 2018-10-09 15:30:01 +0200 | [diff] [blame] | 595 | @Nullable |
| 596 | @CalledByNative("RTCConfiguration") |
| 597 | RtcCertificatePem getCertificate() { |
| 598 | return certificate; |
| 599 | } |
| 600 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 601 | @CalledByNative("RTCConfiguration") |
| 602 | RtcpMuxPolicy getRtcpMuxPolicy() { |
| 603 | return rtcpMuxPolicy; |
| 604 | } |
| 605 | |
| 606 | @CalledByNative("RTCConfiguration") |
| 607 | TcpCandidatePolicy getTcpCandidatePolicy() { |
| 608 | return tcpCandidatePolicy; |
| 609 | } |
| 610 | |
| 611 | @CalledByNative("RTCConfiguration") |
| 612 | CandidateNetworkPolicy getCandidateNetworkPolicy() { |
| 613 | return candidateNetworkPolicy; |
| 614 | } |
| 615 | |
| 616 | @CalledByNative("RTCConfiguration") |
| 617 | int getAudioJitterBufferMaxPackets() { |
| 618 | return audioJitterBufferMaxPackets; |
| 619 | } |
| 620 | |
| 621 | @CalledByNative("RTCConfiguration") |
| 622 | boolean getAudioJitterBufferFastAccelerate() { |
| 623 | return audioJitterBufferFastAccelerate; |
| 624 | } |
| 625 | |
| 626 | @CalledByNative("RTCConfiguration") |
| 627 | int getIceConnectionReceivingTimeout() { |
| 628 | return iceConnectionReceivingTimeout; |
| 629 | } |
| 630 | |
| 631 | @CalledByNative("RTCConfiguration") |
| 632 | int getIceBackupCandidatePairPingInterval() { |
| 633 | return iceBackupCandidatePairPingInterval; |
| 634 | } |
| 635 | |
| 636 | @CalledByNative("RTCConfiguration") |
| 637 | KeyType getKeyType() { |
| 638 | return keyType; |
| 639 | } |
| 640 | |
| 641 | @CalledByNative("RTCConfiguration") |
| 642 | ContinualGatheringPolicy getContinualGatheringPolicy() { |
| 643 | return continualGatheringPolicy; |
| 644 | } |
| 645 | |
| 646 | @CalledByNative("RTCConfiguration") |
| 647 | int getIceCandidatePoolSize() { |
| 648 | return iceCandidatePoolSize; |
| 649 | } |
| 650 | |
| 651 | @CalledByNative("RTCConfiguration") |
| 652 | boolean getPruneTurnPorts() { |
| 653 | return pruneTurnPorts; |
| 654 | } |
| 655 | |
| 656 | @CalledByNative("RTCConfiguration") |
| 657 | boolean getPresumeWritableWhenFullyRelayed() { |
| 658 | return presumeWritableWhenFullyRelayed; |
| 659 | } |
| 660 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 661 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 662 | @CalledByNative("RTCConfiguration") |
Qingsi Wang | e6826d2 | 2018-03-08 14:55:14 -0800 | [diff] [blame] | 663 | Integer getIceCheckIntervalStrongConnectivity() { |
| 664 | return iceCheckIntervalStrongConnectivityMs; |
| 665 | } |
| 666 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 667 | @Nullable |
Qingsi Wang | e6826d2 | 2018-03-08 14:55:14 -0800 | [diff] [blame] | 668 | @CalledByNative("RTCConfiguration") |
| 669 | Integer getIceCheckIntervalWeakConnectivity() { |
| 670 | return iceCheckIntervalWeakConnectivityMs; |
| 671 | } |
| 672 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 673 | @Nullable |
Qingsi Wang | e6826d2 | 2018-03-08 14:55:14 -0800 | [diff] [blame] | 674 | @CalledByNative("RTCConfiguration") |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 675 | Integer getIceCheckMinInterval() { |
| 676 | return iceCheckMinInterval; |
| 677 | } |
| 678 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 679 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 680 | @CalledByNative("RTCConfiguration") |
Qingsi Wang | 22e623a | 2018-03-13 10:53:57 -0700 | [diff] [blame] | 681 | Integer getIceUnwritableTimeout() { |
| 682 | return iceUnwritableTimeMs; |
| 683 | } |
| 684 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 685 | @Nullable |
Qingsi Wang | 22e623a | 2018-03-13 10:53:57 -0700 | [diff] [blame] | 686 | @CalledByNative("RTCConfiguration") |
| 687 | Integer getIceUnwritableMinChecks() { |
| 688 | return iceUnwritableMinChecks; |
| 689 | } |
| 690 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 691 | @Nullable |
Qingsi Wang | 22e623a | 2018-03-13 10:53:57 -0700 | [diff] [blame] | 692 | @CalledByNative("RTCConfiguration") |
Qingsi Wang | db53f8e | 2018-02-20 14:45:49 -0800 | [diff] [blame] | 693 | Integer getStunCandidateKeepaliveInterval() { |
| 694 | return stunCandidateKeepaliveIntervalMs; |
| 695 | } |
| 696 | |
| 697 | @CalledByNative("RTCConfiguration") |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 698 | boolean getDisableIPv6OnWifi() { |
| 699 | return disableIPv6OnWifi; |
| 700 | } |
| 701 | |
| 702 | @CalledByNative("RTCConfiguration") |
| 703 | int getMaxIPv6Networks() { |
| 704 | return maxIPv6Networks; |
| 705 | } |
| 706 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 707 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 708 | @CalledByNative("RTCConfiguration") |
| 709 | IntervalRange getIceRegatherIntervalRange() { |
| 710 | return iceRegatherIntervalRange; |
| 711 | } |
| 712 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 713 | @Nullable |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 714 | @CalledByNative("RTCConfiguration") |
| 715 | TurnCustomizer getTurnCustomizer() { |
| 716 | return turnCustomizer; |
| 717 | } |
Sami Kalliomäki | e8b26cd | 2017-12-19 12:51:53 +0100 | [diff] [blame] | 718 | |
| 719 | @CalledByNative("RTCConfiguration") |
| 720 | boolean getDisableIpv6() { |
| 721 | return disableIpv6; |
| 722 | } |
| 723 | |
| 724 | @CalledByNative("RTCConfiguration") |
| 725 | boolean getEnableDscp() { |
| 726 | return enableDscp; |
| 727 | } |
| 728 | |
| 729 | @CalledByNative("RTCConfiguration") |
| 730 | boolean getEnableCpuOveruseDetection() { |
| 731 | return enableCpuOveruseDetection; |
| 732 | } |
| 733 | |
| 734 | @CalledByNative("RTCConfiguration") |
| 735 | boolean getEnableRtpDataChannel() { |
| 736 | return enableRtpDataChannel; |
| 737 | } |
| 738 | |
| 739 | @CalledByNative("RTCConfiguration") |
| 740 | boolean getSuspendBelowMinBitrate() { |
| 741 | return suspendBelowMinBitrate; |
| 742 | } |
| 743 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 744 | @Nullable |
Sami Kalliomäki | e8b26cd | 2017-12-19 12:51:53 +0100 | [diff] [blame] | 745 | @CalledByNative("RTCConfiguration") |
| 746 | Integer getScreencastMinBitrate() { |
| 747 | return screencastMinBitrate; |
| 748 | } |
| 749 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 750 | @Nullable |
Sami Kalliomäki | e8b26cd | 2017-12-19 12:51:53 +0100 | [diff] [blame] | 751 | @CalledByNative("RTCConfiguration") |
| 752 | Boolean getCombinedAudioVideoBwe() { |
| 753 | return combinedAudioVideoBwe; |
| 754 | } |
| 755 | |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 756 | @Nullable |
Sami Kalliomäki | e8b26cd | 2017-12-19 12:51:53 +0100 | [diff] [blame] | 757 | @CalledByNative("RTCConfiguration") |
| 758 | Boolean getEnableDtlsSrtp() { |
| 759 | return enableDtlsSrtp; |
| 760 | } |
Qingsi Wang | 9a5c6f8 | 2018-02-01 10:38:40 -0800 | [diff] [blame] | 761 | |
| 762 | @CalledByNative("RTCConfiguration") |
| 763 | AdapterType getNetworkPreference() { |
| 764 | return networkPreference; |
| 765 | } |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 766 | |
| 767 | @CalledByNative("RTCConfiguration") |
| 768 | SdpSemantics getSdpSemantics() { |
| 769 | return sdpSemantics; |
| 770 | } |
Zhi Huang | b57e169 | 2018-06-12 11:41:11 -0700 | [diff] [blame] | 771 | |
| 772 | @CalledByNative("RTCConfiguration") |
| 773 | boolean getActiveResetSrtpParams() { |
| 774 | return activeResetSrtpParams; |
| 775 | } |
Piotr (Peter) Slatala | 09beff2 | 2018-10-17 07:22:40 -0700 | [diff] [blame] | 776 | |
| 777 | @CalledByNative("RTCConfiguration") |
| 778 | boolean getUseMediaTransport() { |
| 779 | return useMediaTransport; |
| 780 | } |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 781 | |
Bjorn Mellem | a9bbd86 | 2018-11-02 09:07:48 -0700 | [diff] [blame] | 782 | @CalledByNative("RTCConfiguration") |
| 783 | boolean getUseMediaTransportForDataChannels() { |
| 784 | return useMediaTransportForDataChannels; |
| 785 | } |
| 786 | |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 787 | @Nullable |
| 788 | @CalledByNative("RTCConfiguration") |
| 789 | CryptoOptions getCryptoOptions() { |
| 790 | return cryptoOptions; |
| 791 | } |
Jiayang Liu | cac1b38 | 2015-04-30 12:35:24 -0700 | [diff] [blame] | 792 | }; |
| 793 | |
Magnus Jedvert | 6062f37 | 2017-11-16 16:53:12 +0100 | [diff] [blame] | 794 | private final List<MediaStream> localStreams = new ArrayList<>(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 795 | private final long nativePeerConnection; |
Magnus Jedvert | 6062f37 | 2017-11-16 16:53:12 +0100 | [diff] [blame] | 796 | private List<RtpSender> senders = new ArrayList<>(); |
| 797 | private List<RtpReceiver> receivers = new ArrayList<>(); |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 798 | private List<RtpTransceiver> transceivers = new ArrayList<>(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 799 | |
Sami Kalliomäki | 1ece1ed | 2017-12-20 11:59:22 +0100 | [diff] [blame] | 800 | /** |
| 801 | * Wraps a PeerConnection created by the factory. Can be used by clients that want to implement |
| 802 | * their PeerConnection creation in JNI. |
| 803 | */ |
| 804 | public PeerConnection(NativePeerConnectionFactory factory) { |
Sami Kalliomäki | ce5c19a | 2018-01-15 09:28:34 +0100 | [diff] [blame] | 805 | this(factory.createNativePeerConnection()); |
Sami Kalliomäki | 1ece1ed | 2017-12-20 11:59:22 +0100 | [diff] [blame] | 806 | } |
| 807 | |
Sami Kalliomäki | ce5c19a | 2018-01-15 09:28:34 +0100 | [diff] [blame] | 808 | PeerConnection(long nativePeerConnection) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 809 | this.nativePeerConnection = nativePeerConnection; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 810 | } |
| 811 | |
| 812 | // JsepInterface. |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 813 | public SessionDescription getLocalDescription() { |
| 814 | return nativeGetLocalDescription(); |
| 815 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 816 | |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 817 | public SessionDescription getRemoteDescription() { |
| 818 | return nativeGetRemoteDescription(); |
| 819 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 820 | |
Michael Iedema | 0213786 | 2018-10-09 15:30:01 +0200 | [diff] [blame] | 821 | public RtcCertificatePem getCertificate() { |
| 822 | return nativeGetCertificate(); |
| 823 | } |
| 824 | |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 825 | public DataChannel createDataChannel(String label, DataChannel.Init init) { |
| 826 | return nativeCreateDataChannel(label, init); |
| 827 | } |
henrike@webrtc.org | 723d683 | 2013-07-12 16:04:50 +0000 | [diff] [blame] | 828 | |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 829 | public void createOffer(SdpObserver observer, MediaConstraints constraints) { |
| 830 | nativeCreateOffer(observer, constraints); |
| 831 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 832 | |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 833 | public void createAnswer(SdpObserver observer, MediaConstraints constraints) { |
| 834 | nativeCreateAnswer(observer, constraints); |
| 835 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 836 | |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 837 | public void setLocalDescription(SdpObserver observer, SessionDescription sdp) { |
| 838 | nativeSetLocalDescription(observer, sdp); |
| 839 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 840 | |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 841 | public void setRemoteDescription(SdpObserver observer, SessionDescription sdp) { |
| 842 | nativeSetRemoteDescription(observer, sdp); |
| 843 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 844 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 845 | /** |
| 846 | * Enables/disables playout of received audio streams. Enabled by default. |
| 847 | * |
| 848 | * Note that even if playout is enabled, streams will only be played out if |
| 849 | * the appropriate SDP is also applied. The main purpose of this API is to |
| 850 | * be able to control the exact time when audio playout starts. |
| 851 | */ |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 852 | public void setAudioPlayout(boolean playout) { |
| 853 | nativeSetAudioPlayout(playout); |
| 854 | } |
henrika | 5f6bf24 | 2017-11-01 11:06:56 +0100 | [diff] [blame] | 855 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 856 | /** |
| 857 | * Enables/disables recording of transmitted audio streams. Enabled by default. |
| 858 | * |
| 859 | * Note that even if recording is enabled, streams will only be recorded if |
| 860 | * the appropriate SDP is also applied. The main purpose of this API is to |
| 861 | * be able to control the exact time when audio recording starts. |
| 862 | */ |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 863 | public void setAudioRecording(boolean recording) { |
| 864 | nativeSetAudioRecording(recording); |
| 865 | } |
henrika | 5f6bf24 | 2017-11-01 11:06:56 +0100 | [diff] [blame] | 866 | |
deadbeef | 5d0b6d8 | 2017-01-09 16:05:28 -0800 | [diff] [blame] | 867 | public boolean setConfiguration(RTCConfiguration config) { |
Sami Kalliomäki | ce5c19a | 2018-01-15 09:28:34 +0100 | [diff] [blame] | 868 | return nativeSetConfiguration(config); |
deadbeef | 5d0b6d8 | 2017-01-09 16:05:28 -0800 | [diff] [blame] | 869 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 870 | |
| 871 | public boolean addIceCandidate(IceCandidate candidate) { |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 872 | return nativeAddIceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 873 | } |
| 874 | |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 875 | public boolean removeIceCandidates(final IceCandidate[] candidates) { |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 876 | return nativeRemoveIceCandidates(candidates); |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 877 | } |
| 878 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 879 | /** |
| 880 | * Adds a new MediaStream to be sent on this peer connection. |
| 881 | * Note: This method is not supported with SdpSemantics.UNIFIED_PLAN. Please |
| 882 | * use addTrack instead. |
| 883 | */ |
perkj@webrtc.org | c2dd5ee | 2014-11-04 11:31:29 +0000 | [diff] [blame] | 884 | public boolean addStream(MediaStream stream) { |
Sami Kalliomäki | ee05e90 | 2018-09-28 14:38:21 +0200 | [diff] [blame] | 885 | boolean ret = nativeAddLocalStream(stream.getNativeMediaStream()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 886 | if (!ret) { |
| 887 | return false; |
| 888 | } |
| 889 | localStreams.add(stream); |
| 890 | return true; |
| 891 | } |
| 892 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 893 | /** |
| 894 | * Removes the given media stream from this peer connection. |
| 895 | * This method is not supported with SdpSemantics.UNIFIED_PLAN. Please use |
| 896 | * removeTrack instead. |
| 897 | */ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 898 | public void removeStream(MediaStream stream) { |
Sami Kalliomäki | ee05e90 | 2018-09-28 14:38:21 +0200 | [diff] [blame] | 899 | nativeRemoveLocalStream(stream.getNativeMediaStream()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 900 | localStreams.remove(stream); |
| 901 | } |
| 902 | |
deadbeef | 7a24688 | 2017-08-09 08:40:10 -0700 | [diff] [blame] | 903 | /** |
| 904 | * Creates an RtpSender without a track. |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 905 | * |
| 906 | * <p>This method allows an application to cause the PeerConnection to negotiate |
deadbeef | 7a24688 | 2017-08-09 08:40:10 -0700 | [diff] [blame] | 907 | * sending/receiving a specific media type, but without having a track to |
| 908 | * send yet. |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 909 | * |
| 910 | * <p>When the application does want to begin sending a track, it can call |
deadbeef | 7a24688 | 2017-08-09 08:40:10 -0700 | [diff] [blame] | 911 | * RtpSender.setTrack, which doesn't require any additional SDP negotiation. |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 912 | * |
| 913 | * <p>Example use: |
deadbeef | 7a24688 | 2017-08-09 08:40:10 -0700 | [diff] [blame] | 914 | * <pre> |
| 915 | * {@code |
| 916 | * audioSender = pc.createSender("audio", "stream1"); |
| 917 | * videoSender = pc.createSender("video", "stream1"); |
| 918 | * // Do normal SDP offer/answer, which will kick off ICE/DTLS and negotiate |
| 919 | * // media parameters.... |
| 920 | * // Later, when the endpoint is ready to actually begin sending: |
| 921 | * audioSender.setTrack(audioTrack, false); |
| 922 | * videoSender.setTrack(videoTrack, false); |
| 923 | * } |
| 924 | * </pre> |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 925 | * <p>Note: This corresponds most closely to "addTransceiver" in the official |
deadbeef | 7a24688 | 2017-08-09 08:40:10 -0700 | [diff] [blame] | 926 | * WebRTC API, in that it creates a sender without a track. It was |
| 927 | * implemented before addTransceiver because it provides useful |
| 928 | * functionality, and properly implementing transceivers would have required |
| 929 | * a great deal more work. |
| 930 | * |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 931 | * <p>Note: This is only available with SdpSemantics.PLAN_B specified. Please use |
| 932 | * addTransceiver instead. |
| 933 | * |
deadbeef | 7a24688 | 2017-08-09 08:40:10 -0700 | [diff] [blame] | 934 | * @param kind Corresponds to MediaStreamTrack kinds (must be "audio" or |
| 935 | * "video"). |
| 936 | * @param stream_id The ID of the MediaStream that this sender's track will |
| 937 | * be associated with when SDP is applied to the remote |
| 938 | * PeerConnection. If createSender is used to create an |
| 939 | * audio and video sender that should be synchronized, they |
| 940 | * should use the same stream ID. |
| 941 | * @return A new RtpSender object if successful, or null otherwise. |
| 942 | */ |
deadbeef | bd7d8f7 | 2015-12-18 16:58:44 -0800 | [diff] [blame] | 943 | public RtpSender createSender(String kind, String stream_id) { |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 944 | RtpSender newSender = nativeCreateSender(kind, stream_id); |
| 945 | if (newSender != null) { |
| 946 | senders.add(newSender); |
deadbeef | ee524f7 | 2015-12-02 11:27:40 -0800 | [diff] [blame] | 947 | } |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 948 | return newSender; |
deadbeef | ee524f7 | 2015-12-02 11:27:40 -0800 | [diff] [blame] | 949 | } |
| 950 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 951 | /** |
| 952 | * Gets all RtpSenders associated with this peer connection. |
| 953 | * Note that calling getSenders will dispose of the senders previously |
| 954 | * returned. |
| 955 | */ |
deadbeef | 4139c0f | 2015-10-06 12:29:25 -0700 | [diff] [blame] | 956 | public List<RtpSender> getSenders() { |
| 957 | for (RtpSender sender : senders) { |
| 958 | sender.dispose(); |
| 959 | } |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 960 | senders = nativeGetSenders(); |
deadbeef | 4139c0f | 2015-10-06 12:29:25 -0700 | [diff] [blame] | 961 | return Collections.unmodifiableList(senders); |
| 962 | } |
| 963 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 964 | /** |
| 965 | * Gets all RtpReceivers associated with this peer connection. |
| 966 | * Note that calling getReceivers will dispose of the receivers previously |
| 967 | * returned. |
| 968 | */ |
deadbeef | 4139c0f | 2015-10-06 12:29:25 -0700 | [diff] [blame] | 969 | public List<RtpReceiver> getReceivers() { |
| 970 | for (RtpReceiver receiver : receivers) { |
| 971 | receiver.dispose(); |
| 972 | } |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 973 | receivers = nativeGetReceivers(); |
deadbeef | 4139c0f | 2015-10-06 12:29:25 -0700 | [diff] [blame] | 974 | return Collections.unmodifiableList(receivers); |
| 975 | } |
| 976 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 977 | /** |
| 978 | * Gets all RtpTransceivers associated with this peer connection. |
| 979 | * Note that calling getTransceivers will dispose of the transceivers previously |
| 980 | * returned. |
| 981 | * Note: This is only available with SdpSemantics.UNIFIED_PLAN specified. |
| 982 | */ |
| 983 | public List<RtpTransceiver> getTransceivers() { |
| 984 | for (RtpTransceiver transceiver : transceivers) { |
| 985 | transceiver.dispose(); |
| 986 | } |
| 987 | transceivers = nativeGetTransceivers(); |
| 988 | return Collections.unmodifiableList(transceivers); |
| 989 | } |
| 990 | |
| 991 | /** |
| 992 | * Adds a new media stream track to be sent on this peer connection, and returns |
| 993 | * the newly created RtpSender. If streamIds are specified, the RtpSender will |
| 994 | * be associated with the streams specified in the streamIds list. |
| 995 | * |
| 996 | * @throws IllegalStateException if an error accors in C++ addTrack. |
| 997 | * An error can occur if: |
| 998 | * - A sender already exists for the track. |
| 999 | * - The peer connection is closed. |
| 1000 | */ |
| 1001 | public RtpSender addTrack(MediaStreamTrack track) { |
| 1002 | return addTrack(track, Collections.emptyList()); |
| 1003 | } |
| 1004 | |
| 1005 | public RtpSender addTrack(MediaStreamTrack track, List<String> streamIds) { |
| 1006 | if (track == null || streamIds == null) { |
| 1007 | throw new NullPointerException("No MediaStreamTrack specified in addTrack."); |
| 1008 | } |
Sami Kalliomäki | ee05e90 | 2018-09-28 14:38:21 +0200 | [diff] [blame] | 1009 | RtpSender newSender = nativeAddTrack(track.getNativeMediaStreamTrack(), streamIds); |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1010 | if (newSender == null) { |
| 1011 | throw new IllegalStateException("C++ addTrack failed."); |
| 1012 | } |
| 1013 | senders.add(newSender); |
| 1014 | return newSender; |
| 1015 | } |
| 1016 | |
| 1017 | /** |
| 1018 | * Stops sending media from sender. The sender will still appear in getSenders. Future |
| 1019 | * calls to createOffer will mark the m section for the corresponding transceiver as |
| 1020 | * receive only or inactive, as defined in JSEP. Returns true on success. |
| 1021 | */ |
| 1022 | public boolean removeTrack(RtpSender sender) { |
| 1023 | if (sender == null) { |
| 1024 | throw new NullPointerException("No RtpSender specified for removeTrack."); |
| 1025 | } |
Sami Kalliomäki | ee05e90 | 2018-09-28 14:38:21 +0200 | [diff] [blame] | 1026 | return nativeRemoveTrack(sender.getNativeRtpSender()); |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1027 | } |
| 1028 | |
| 1029 | /** |
| 1030 | * Creates a new RtpTransceiver and adds it to the set of transceivers. Adding a |
| 1031 | * transceiver will cause future calls to CreateOffer to add a media description |
| 1032 | * for the corresponding transceiver. |
| 1033 | * |
| 1034 | * <p>The initial value of |mid| in the returned transceiver is null. Setting a |
| 1035 | * new session description may change it to a non-null value. |
| 1036 | * |
| 1037 | * <p>https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtransceiver |
| 1038 | * |
| 1039 | * <p>If a MediaStreamTrack is specified then a transceiver will be added with a |
| 1040 | * sender set to transmit the given track. The kind |
| 1041 | * of the transceiver (and sender/receiver) will be derived from the kind of |
| 1042 | * the track. |
| 1043 | * |
| 1044 | * <p>If MediaType is specified then a transceiver will be added based upon that type. |
| 1045 | * This can be either MEDIA_TYPE_AUDIO or MEDIA_TYPE_VIDEO. |
| 1046 | * |
| 1047 | * <p>Optionally, an RtpTransceiverInit structure can be specified to configure |
| 1048 | * the transceiver from construction. If not specified, the transceiver will |
| 1049 | * default to having a direction of kSendRecv and not be part of any streams. |
| 1050 | * |
| 1051 | * <p>Note: These methods are only available with SdpSemantics.UNIFIED_PLAN specified. |
| 1052 | * @throws IllegalStateException if an error accors in C++ addTransceiver |
| 1053 | */ |
| 1054 | public RtpTransceiver addTransceiver(MediaStreamTrack track) { |
| 1055 | return addTransceiver(track, new RtpTransceiver.RtpTransceiverInit()); |
| 1056 | } |
| 1057 | |
| 1058 | public RtpTransceiver addTransceiver( |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 1059 | MediaStreamTrack track, @Nullable RtpTransceiver.RtpTransceiverInit init) { |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1060 | if (track == null) { |
| 1061 | throw new NullPointerException("No MediaStreamTrack specified for addTransceiver."); |
| 1062 | } |
| 1063 | if (init == null) { |
| 1064 | init = new RtpTransceiver.RtpTransceiverInit(); |
| 1065 | } |
Sami Kalliomäki | ee05e90 | 2018-09-28 14:38:21 +0200 | [diff] [blame] | 1066 | RtpTransceiver newTransceiver = |
| 1067 | nativeAddTransceiverWithTrack(track.getNativeMediaStreamTrack(), init); |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1068 | if (newTransceiver == null) { |
| 1069 | throw new IllegalStateException("C++ addTransceiver failed."); |
| 1070 | } |
| 1071 | transceivers.add(newTransceiver); |
| 1072 | return newTransceiver; |
| 1073 | } |
| 1074 | |
| 1075 | public RtpTransceiver addTransceiver(MediaStreamTrack.MediaType mediaType) { |
| 1076 | return addTransceiver(mediaType, new RtpTransceiver.RtpTransceiverInit()); |
| 1077 | } |
| 1078 | |
| 1079 | public RtpTransceiver addTransceiver( |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 1080 | MediaStreamTrack.MediaType mediaType, @Nullable RtpTransceiver.RtpTransceiverInit init) { |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1081 | if (mediaType == null) { |
| 1082 | throw new NullPointerException("No MediaType specified for addTransceiver."); |
| 1083 | } |
| 1084 | if (init == null) { |
| 1085 | init = new RtpTransceiver.RtpTransceiverInit(); |
| 1086 | } |
| 1087 | RtpTransceiver newTransceiver = nativeAddTransceiverOfType(mediaType, init); |
| 1088 | if (newTransceiver == null) { |
| 1089 | throw new IllegalStateException("C++ addTransceiver failed."); |
| 1090 | } |
| 1091 | transceivers.add(newTransceiver); |
| 1092 | return newTransceiver; |
| 1093 | } |
| 1094 | |
deadbeef | 8221587 | 2017-04-18 10:27:51 -0700 | [diff] [blame] | 1095 | // Older, non-standard implementation of getStats. |
| 1096 | @Deprecated |
Sami Kalliomäki | e7592d8 | 2018-03-22 13:32:44 +0100 | [diff] [blame] | 1097 | public boolean getStats(StatsObserver observer, @Nullable MediaStreamTrack track) { |
Sami Kalliomäki | ee05e90 | 2018-09-28 14:38:21 +0200 | [diff] [blame] | 1098 | return nativeOldGetStats(observer, (track == null) ? 0 : track.getNativeMediaStreamTrack()); |
deadbeef | 8221587 | 2017-04-18 10:27:51 -0700 | [diff] [blame] | 1099 | } |
| 1100 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1101 | /** |
| 1102 | * Gets stats using the new stats collection API, see webrtc/api/stats/. These |
| 1103 | * will replace old stats collection API when the new API has matured enough. |
| 1104 | */ |
deadbeef | 8221587 | 2017-04-18 10:27:51 -0700 | [diff] [blame] | 1105 | public void getStats(RTCStatsCollectorCallback callback) { |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1106 | nativeNewGetStats(callback); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1107 | } |
| 1108 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1109 | /** |
| 1110 | * Limits the bandwidth allocated for all RTP streams sent by this |
| 1111 | * PeerConnection. Pass null to leave a value unchanged. |
| 1112 | */ |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1113 | public boolean setBitrate(Integer min, Integer current, Integer max) { |
| 1114 | return nativeSetBitrate(min, current, max); |
| 1115 | } |
zstein | d89b0bc | 2017-08-03 11:11:40 -0700 | [diff] [blame] | 1116 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1117 | /** |
| 1118 | * Starts recording an RTC event log. |
| 1119 | * |
| 1120 | * Ownership of the file is transfered to the native code. If an RTC event |
| 1121 | * log is already being recorded, it will be stopped and a new one will start |
| 1122 | * using the provided file. Logging will continue until the stopRtcEventLog |
| 1123 | * function is called. The max_size_bytes argument is ignored, it is added |
| 1124 | * for future use. |
| 1125 | */ |
ivoc | 0c6f0f6 | 2016-07-06 04:34:23 -0700 | [diff] [blame] | 1126 | public boolean startRtcEventLog(int file_descriptor, int max_size_bytes) { |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1127 | return nativeStartRtcEventLog(file_descriptor, max_size_bytes); |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 1128 | } |
| 1129 | |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1130 | /** |
| 1131 | * Stops recording an RTC event log. If no RTC event log is currently being |
| 1132 | * recorded, this call will have no effect. |
| 1133 | */ |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 1134 | public void stopRtcEventLog() { |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1135 | nativeStopRtcEventLog(); |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 1136 | } |
| 1137 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1138 | // TODO(fischman): add support for DTMF-related methods once that API |
| 1139 | // stabilizes. |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1140 | public SignalingState signalingState() { |
| 1141 | return nativeSignalingState(); |
| 1142 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1143 | |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1144 | public IceConnectionState iceConnectionState() { |
| 1145 | return nativeIceConnectionState(); |
| 1146 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1147 | |
Jonas Olsson | f01d8c8 | 2018-11-08 15:19:04 +0100 | [diff] [blame] | 1148 | public PeerConnectionState connectionState() { |
| 1149 | return nativeConnectionState(); |
| 1150 | } |
| 1151 | |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1152 | public IceGatheringState iceGatheringState() { |
| 1153 | return nativeIceGatheringState(); |
| 1154 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1155 | |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1156 | public void close() { |
| 1157 | nativeClose(); |
| 1158 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1159 | |
deadbeef | 43697f6 | 2017-09-12 10:52:14 -0700 | [diff] [blame] | 1160 | /** |
| 1161 | * Free native resources associated with this PeerConnection instance. |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1162 | * |
deadbeef | 43697f6 | 2017-09-12 10:52:14 -0700 | [diff] [blame] | 1163 | * This method removes a reference count from the C++ PeerConnection object, |
| 1164 | * which should result in it being destroyed. It also calls equivalent |
| 1165 | * "dispose" methods on the Java objects attached to this PeerConnection |
| 1166 | * (streams, senders, receivers), such that their associated C++ objects |
| 1167 | * will also be destroyed. |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1168 | * |
| 1169 | * <p>Note that this method cannot be safely called from an observer callback |
deadbeef | 43697f6 | 2017-09-12 10:52:14 -0700 | [diff] [blame] | 1170 | * (PeerConnection.Observer, DataChannel.Observer, etc.). If you want to, for |
| 1171 | * example, destroy the PeerConnection after an "ICE failed" callback, you |
| 1172 | * must do this asynchronously (in other words, unwind the stack first). See |
| 1173 | * <a href="https://bugs.chromium.org/p/webrtc/issues/detail?id=3721">bug |
| 1174 | * 3721</a> for more details. |
| 1175 | */ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1176 | public void dispose() { |
| 1177 | close(); |
| 1178 | for (MediaStream stream : localStreams) { |
Sami Kalliomäki | ee05e90 | 2018-09-28 14:38:21 +0200 | [diff] [blame] | 1179 | nativeRemoveLocalStream(stream.getNativeMediaStream()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1180 | stream.dispose(); |
| 1181 | } |
| 1182 | localStreams.clear(); |
deadbeef | 4139c0f | 2015-10-06 12:29:25 -0700 | [diff] [blame] | 1183 | for (RtpSender sender : senders) { |
| 1184 | sender.dispose(); |
| 1185 | } |
| 1186 | senders.clear(); |
| 1187 | for (RtpReceiver receiver : receivers) { |
| 1188 | receiver.dispose(); |
| 1189 | } |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1190 | for (RtpTransceiver transceiver : transceivers) { |
| 1191 | transceiver.dispose(); |
| 1192 | } |
| 1193 | transceivers.clear(); |
deadbeef | 4139c0f | 2015-10-06 12:29:25 -0700 | [diff] [blame] | 1194 | receivers.clear(); |
Sami Kalliomäki | ce5c19a | 2018-01-15 09:28:34 +0100 | [diff] [blame] | 1195 | nativeFreeOwnedPeerConnection(nativePeerConnection); |
| 1196 | } |
| 1197 | |
| 1198 | /** Returns a pointer to the native webrtc::PeerConnectionInterface. */ |
| 1199 | public long getNativePeerConnection() { |
| 1200 | return nativeGetNativePeerConnection(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1201 | } |
| 1202 | |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 1203 | @CalledByNative |
Sami Kalliomäki | ce5c19a | 2018-01-15 09:28:34 +0100 | [diff] [blame] | 1204 | long getNativeOwnedPeerConnection() { |
Magnus Jedvert | 9060eb1 | 2017-12-12 12:52:54 +0100 | [diff] [blame] | 1205 | return nativePeerConnection; |
| 1206 | } |
| 1207 | |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1208 | public static long createNativePeerConnectionObserver(Observer observer) { |
| 1209 | return nativeCreatePeerConnectionObserver(observer); |
| 1210 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1211 | |
Sami Kalliomäki | ce5c19a | 2018-01-15 09:28:34 +0100 | [diff] [blame] | 1212 | private native long nativeGetNativePeerConnection(); |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1213 | private native SessionDescription nativeGetLocalDescription(); |
| 1214 | private native SessionDescription nativeGetRemoteDescription(); |
Michael Iedema | 0213786 | 2018-10-09 15:30:01 +0200 | [diff] [blame] | 1215 | private native RtcCertificatePem nativeGetCertificate(); |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1216 | private native DataChannel nativeCreateDataChannel(String label, DataChannel.Init init); |
| 1217 | private native void nativeCreateOffer(SdpObserver observer, MediaConstraints constraints); |
| 1218 | private native void nativeCreateAnswer(SdpObserver observer, MediaConstraints constraints); |
| 1219 | private native void nativeSetLocalDescription(SdpObserver observer, SessionDescription sdp); |
| 1220 | private native void nativeSetRemoteDescription(SdpObserver observer, SessionDescription sdp); |
| 1221 | private native void nativeSetAudioPlayout(boolean playout); |
| 1222 | private native void nativeSetAudioRecording(boolean recording); |
| 1223 | private native boolean nativeSetBitrate(Integer min, Integer current, Integer max); |
| 1224 | private native SignalingState nativeSignalingState(); |
| 1225 | private native IceConnectionState nativeIceConnectionState(); |
Jonas Olsson | f01d8c8 | 2018-11-08 15:19:04 +0100 | [diff] [blame] | 1226 | private native PeerConnectionState nativeConnectionState(); |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1227 | private native IceGatheringState nativeIceGatheringState(); |
| 1228 | private native void nativeClose(); |
| 1229 | private static native long nativeCreatePeerConnectionObserver(Observer observer); |
Sami Kalliomäki | ce5c19a | 2018-01-15 09:28:34 +0100 | [diff] [blame] | 1230 | private static native void nativeFreeOwnedPeerConnection(long ownedPeerConnection); |
| 1231 | private native boolean nativeSetConfiguration(RTCConfiguration config); |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1232 | private native boolean nativeAddIceCandidate( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1233 | String sdpMid, int sdpMLineIndex, String iceCandidateSdp); |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1234 | private native boolean nativeRemoveIceCandidates(final IceCandidate[] candidates); |
| 1235 | private native boolean nativeAddLocalStream(long stream); |
| 1236 | private native void nativeRemoveLocalStream(long stream); |
| 1237 | private native boolean nativeOldGetStats(StatsObserver observer, long nativeTrack); |
| 1238 | private native void nativeNewGetStats(RTCStatsCollectorCallback callback); |
| 1239 | private native RtpSender nativeCreateSender(String kind, String stream_id); |
| 1240 | private native List<RtpSender> nativeGetSenders(); |
| 1241 | private native List<RtpReceiver> nativeGetReceivers(); |
Seth Hampson | c384e14 | 2018-03-06 15:47:10 -0800 | [diff] [blame] | 1242 | private native List<RtpTransceiver> nativeGetTransceivers(); |
| 1243 | private native RtpSender nativeAddTrack(long track, List<String> streamIds); |
| 1244 | private native boolean nativeRemoveTrack(long sender); |
| 1245 | private native RtpTransceiver nativeAddTransceiverWithTrack( |
| 1246 | long track, RtpTransceiver.RtpTransceiverInit init); |
| 1247 | private native RtpTransceiver nativeAddTransceiverOfType( |
| 1248 | MediaStreamTrack.MediaType mediaType, RtpTransceiver.RtpTransceiverInit init); |
Magnus Jedvert | 84d8ae5 | 2017-12-20 15:12:10 +0100 | [diff] [blame] | 1249 | private native boolean nativeStartRtcEventLog(int file_descriptor, int max_size_bytes); |
| 1250 | private native void nativeStopRtcEventLog(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1251 | } |