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