blob: d2a61e078020be9d348a05b2cf8e1edd509eb46a [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2013 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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.org28e20752013-07-10 00:45:36 +00009 */
10
henrike@webrtc.org28e20752013-07-10 00:45:36 +000011package org.webrtc;
12
Magnus Jedvert6062f372017-11-16 16:53:12 +010013import java.util.ArrayList;
Sami Kalliomäki3e189a62017-11-24 11:13:39 +010014import java.util.Collections;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000015import java.util.List;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +010016import javax.annotation.Nullable;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000017
18/**
19 * Java-land version of the PeerConnection APIs; wraps the C++ API
20 * http://www.webrtc.org/reference/native-apis, which in turn is inspired by the
21 * JS APIs: http://dev.w3.org/2011/webrtc/editor/webrtc.html and
22 * http://www.w3.org/TR/mediacapture-streams/
23 */
24public class PeerConnection {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000025 /** Tracks PeerConnectionInterface::IceGatheringState */
Magnus Jedvertba700f62017-12-04 13:43:27 +010026 public enum IceGatheringState {
27 NEW,
28 GATHERING,
29 COMPLETE;
30
31 @CalledByNative("IceGatheringState")
32 static IceGatheringState fromNativeIndex(int nativeIndex) {
33 return values()[nativeIndex];
34 }
35 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000036
37 /** Tracks PeerConnectionInterface::IceConnectionState */
38 public enum IceConnectionState {
sakalb6760f92016-09-29 04:12:44 -070039 NEW,
40 CHECKING,
41 CONNECTED,
42 COMPLETED,
43 FAILED,
44 DISCONNECTED,
Magnus Jedvertba700f62017-12-04 13:43:27 +010045 CLOSED;
46
47 @CalledByNative("IceConnectionState")
48 static IceConnectionState fromNativeIndex(int nativeIndex) {
49 return values()[nativeIndex];
50 }
sakalb6760f92016-09-29 04:12:44 -070051 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000052
hnsl04833622017-01-09 08:35:45 -080053 /** Tracks PeerConnectionInterface::TlsCertPolicy */
54 public enum TlsCertPolicy {
55 TLS_CERT_POLICY_SECURE,
56 TLS_CERT_POLICY_INSECURE_NO_CHECK,
57 }
58
henrike@webrtc.org28e20752013-07-10 00:45:36 +000059 /** Tracks PeerConnectionInterface::SignalingState */
60 public enum SignalingState {
sakalb6760f92016-09-29 04:12:44 -070061 STABLE,
62 HAVE_LOCAL_OFFER,
63 HAVE_LOCAL_PRANSWER,
64 HAVE_REMOTE_OFFER,
65 HAVE_REMOTE_PRANSWER,
Magnus Jedvertba700f62017-12-04 13:43:27 +010066 CLOSED;
67
68 @CalledByNative("SignalingState")
69 static SignalingState fromNativeIndex(int nativeIndex) {
70 return values()[nativeIndex];
71 }
sakalb6760f92016-09-29 04:12:44 -070072 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000073
Diogo Real7f1ffcc2018-09-04 14:42:03 -070074 /**
75 * Java version of PeerConnectionInterface::SSLConfig.
76 *
77 * Contains the configuration of any SSL/TLS connections that are initiated by
78 * our client.
79 */
80 public static class SslConfig {
81 /** Indicates whether to enable OCSP stapling in TLS. */
82 public final boolean enableOcspStapling;
83 /** Indicates whether to enable the signed certificate timestamp extension in TLS. */
84 public final boolean enableSignedCertTimestamp;
85 /** Indicates whether to enable the TLS Channel ID extension. */
86 public final boolean enableTlsChannelId;
87 /** Indicates whether to enable the TLS GREASE extension. */
88 public final boolean enableGrease;
89
90 /** Indicates how to process TURN server certificates */
91 public final TlsCertPolicy tlsCertPolicy;
92
93 /**
94 * Highest supported SSL version, as defined in the supported_versions TLS extension.
95 * If null, the default OpenSSL/BoringSSL max version will be used.
96 */
97 @Nullable public final Integer maxSslVersion;
98
99 /**
100 * List of protocols to be used in the TLS ALPN extension.
101 * If null, the default list of OpenSSL/BoringSSL ALPN protocols will be used.
102 */
103 @Nullable public final List<String> tlsAlpnProtocols;
104
105 /**
106 * List of elliptic curves to be used in the TLS elliptic curves extension.
107 * Only curve names supported by OpenSSL should be used (eg. "P-256","X25519").
108 * If null, the default list of OpenSSL/BoringSSL curves will be used.
109 */
110 @Nullable public final List<String> tlsEllipticCurves;
111
112 private SslConfig(boolean enableOcspStapling, boolean enableSignedCertTimestamp,
113 boolean enableTlsChannelId, boolean enableGrease, TlsCertPolicy tlsCertPolicy,
114 Integer maxSslVersion, List<String> tlsAlpnProtocols, List<String> tlsEllipticCurves) {
115 this.enableOcspStapling = enableOcspStapling;
116 this.enableSignedCertTimestamp = enableSignedCertTimestamp;
117 this.enableTlsChannelId = enableTlsChannelId;
118 this.enableGrease = enableGrease;
119 this.tlsCertPolicy = tlsCertPolicy;
120 this.maxSslVersion = maxSslVersion;
121 if (tlsAlpnProtocols != null) {
122 this.tlsAlpnProtocols = Collections.unmodifiableList(tlsAlpnProtocols);
123 } else {
124 this.tlsAlpnProtocols = null;
125 }
126 if (tlsEllipticCurves != null) {
127 this.tlsEllipticCurves = Collections.unmodifiableList(tlsEllipticCurves);
128 } else {
129 this.tlsEllipticCurves = null;
130 }
131 }
132
133 @Override
134 public String toString() {
135 return "[enableOcspStapling=" + enableOcspStapling + "] [enableSignedCertTimestamp="
136 + enableSignedCertTimestamp + "] [enableTlsChannelId=" + enableTlsChannelId
137 + "] [enableGrease=" + enableGrease + "] [tlsCertPolicy=" + tlsCertPolicy
138 + "] [maxSslVersion=" + maxSslVersion + "] [tlsAlpnProtocols=" + tlsAlpnProtocols
139 + "] [tlsEllipticCurves=" + tlsEllipticCurves + "]";
140 }
141
142 public static Builder builder() {
143 return new Builder();
144 }
145
146 public static class Builder {
147 private boolean enableOcspStapling = true;
148 private boolean enableSignedCertTimestamp = true;
149 private boolean enableTlsChannelId = false;
150 private boolean enableGrease = false;
151 private TlsCertPolicy tlsCertPolicy = TlsCertPolicy.TLS_CERT_POLICY_SECURE;
152 @Nullable private Integer maxSslVersion = null;
153 @Nullable private List<String> tlsAlpnProtocols = null;
154 @Nullable private List<String> tlsEllipticCurves = null;
155
156 private Builder() {}
157
158 public Builder setEnableOcspStapling(boolean enableOcspStapling) {
159 this.enableOcspStapling = enableOcspStapling;
160 return this;
161 }
162
163 public Builder setEnableSignedCertTimestamp(boolean enableSignedCertTimestamp) {
164 this.enableSignedCertTimestamp = enableSignedCertTimestamp;
165 return this;
166 }
167
168 public Builder setEnableTlsChannelId(boolean enableTlsChannelId) {
169 this.enableTlsChannelId = enableTlsChannelId;
170 return this;
171 }
172
173 public Builder setEnableGrease(boolean enableGrease) {
174 this.enableGrease = enableGrease;
175 return this;
176 }
177
178 public Builder setTlsCertPolicy(TlsCertPolicy tlsCertPolicy) {
179 this.tlsCertPolicy = tlsCertPolicy;
180 return this;
181 }
182
183 public Builder setMaxSslVersion(int maxSslVersion) {
184 this.maxSslVersion = maxSslVersion;
185 return this;
186 }
187
188 public Builder setTlsAlpnProtocols(List<String> tlsAlpnProtocols) {
189 this.tlsAlpnProtocols = tlsAlpnProtocols;
190 return this;
191 }
192
193 public Builder setTlsEllipticCurves(List<String> tlsEllipticCurves) {
194 this.tlsEllipticCurves = tlsEllipticCurves;
195 return this;
196 }
197
198 public SslConfig createSslConfig() {
199 return new SslConfig(enableOcspStapling, enableSignedCertTimestamp, enableTlsChannelId,
200 enableGrease, tlsCertPolicy, maxSslVersion, tlsAlpnProtocols, tlsEllipticCurves);
201 }
202 }
203
204 @CalledByNative("SslConfig")
205 boolean getEnableOcspStapling() {
206 return enableOcspStapling;
207 }
208
209 @CalledByNative("SslConfig")
210 boolean getEnableSignedCertTimestamp() {
211 return enableSignedCertTimestamp;
212 }
213
214 @CalledByNative("SslConfig")
215 boolean getEnableTlsChannelId() {
216 return enableTlsChannelId;
217 }
218
219 @CalledByNative("SslConfig")
220 boolean getEnableGrease() {
221 return enableGrease;
222 }
223
224 @CalledByNative("SslConfig")
225 TlsCertPolicy getTlsCertPolicy() {
226 return tlsCertPolicy;
227 }
228
229 @Nullable
230 @CalledByNative("SslConfig")
231 Integer getMaxSslVersion() {
232 return maxSslVersion;
233 }
234
235 @Nullable
236 @CalledByNative("SslConfig")
237 List<String> getTlsAlpnProtocols() {
238 return tlsAlpnProtocols;
239 }
240
241 @Nullable
242 @CalledByNative("SslConfig")
243 List<String> getTlsEllipticCurves() {
244 return tlsEllipticCurves;
245 }
246 }
247
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000248 /** Java version of PeerConnectionObserver. */
249 public static interface Observer {
250 /** Triggered when the SignalingState changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100251 @CalledByNative("Observer") void onSignalingChange(SignalingState newState);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000252
253 /** Triggered when the IceConnectionState changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100254 @CalledByNative("Observer") void onIceConnectionChange(IceConnectionState newState);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000255
Peter Thatcher54360512015-07-08 11:08:35 -0700256 /** Triggered when the ICE connection receiving status changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100257 @CalledByNative("Observer") void onIceConnectionReceivingChange(boolean receiving);
Peter Thatcher54360512015-07-08 11:08:35 -0700258
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000259 /** Triggered when the IceGatheringState changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100260 @CalledByNative("Observer") void onIceGatheringChange(IceGatheringState newState);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000261
262 /** Triggered when a new ICE candidate has been found. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100263 @CalledByNative("Observer") void onIceCandidate(IceCandidate candidate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000264
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700265 /** Triggered when some ICE candidates have been removed. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100266 @CalledByNative("Observer") void onIceCandidatesRemoved(IceCandidate[] candidates);
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700267
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000268 /** Triggered when media is received on a new stream from remote peer. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100269 @CalledByNative("Observer") void onAddStream(MediaStream stream);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000270
271 /** Triggered when a remote peer close a stream. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100272 @CalledByNative("Observer") void onRemoveStream(MediaStream stream);
henrike@webrtc.org723d6832013-07-12 16:04:50 +0000273
274 /** Triggered when a remote peer opens a DataChannel. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100275 @CalledByNative("Observer") void onDataChannel(DataChannel dataChannel);
fischman@webrtc.orgd7568a02014-01-13 22:04:12 +0000276
277 /** Triggered when renegotiation is necessary. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100278 @CalledByNative("Observer") void onRenegotiationNeeded();
zhihuangdcccda72016-12-21 14:08:03 -0800279
280 /**
281 * Triggered when a new track is signaled by the remote peer, as a result of
282 * setRemoteDescription.
283 */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100284 @CalledByNative("Observer") void onAddTrack(RtpReceiver receiver, MediaStream[] mediaStreams);
Seth Hampson31dbc242018-05-07 09:28:19 -0700285
286 /**
287 * Triggered when the signaling from SetRemoteDescription indicates that a transceiver
288 * will be receiving media from a remote endpoint. This is only called if UNIFIED_PLAN
289 * semantics are specified. The transceiver will be disposed automatically.
290 */
291 @CalledByNative("Observer") default void onTrack(RtpTransceiver transceiver){};
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000292 }
293
294 /** Java version of PeerConnectionInterface.IceServer. */
295 public static class IceServer {
Emad Omaradab1d2d2017-06-16 15:43:11 -0700296 // List of URIs associated with this server. Valid formats are described
297 // in RFC7064 and RFC7065, and more may be added in the future. The "host"
298 // part of the URI may contain either an IP address or a hostname.
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700299 @Deprecated public final String uri;
300 public final List<String> urls;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000301 public final String username;
302 public final String password;
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700303 // TODO(diogor, webrtc:9673): Remove tlsCertPolicy from this API.
304 // This field will be ignored if tlsCertPolicy is also set in SslConfig.
305 @Deprecated public final TlsCertPolicy tlsCertPolicy;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000306
Emad Omaradab1d2d2017-06-16 15:43:11 -0700307 // If the URIs in |urls| only contain IP addresses, this field can be used
308 // to indicate the hostname, which may be necessary for TLS (using the SNI
309 // extension). If |urls| itself contains the hostname, this isn't
310 // necessary.
311 public final String hostname;
312
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700313 // TODO(diogor, webrtc:9673): Remove tlsAlpnProtocols from this API.
Diogo Real1dca9d52017-08-29 12:18:32 -0700314 // List of protocols to be used in the TLS ALPN extension.
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700315 @Deprecated public final List<String> tlsAlpnProtocols;
Diogo Real1dca9d52017-08-29 12:18:32 -0700316
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700317 // TODO(diogor, webrtc:9673): Remove tlsEllipticCurves from this API.
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700318 // List of elliptic curves to be used in the TLS elliptic curves extension.
319 // Only curve names supported by OpenSSL should be used (eg. "P-256","X25519").
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700320 // This field will be ignored if tlsEllipticCurves is also set in SslConfig.
321 @Deprecated public final List<String> tlsEllipticCurves;
322
323 // SSL configuration options for any SSL/TLS connections to this IceServer.
324 public final SslConfig sslConfig;
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700325
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000326 /** Convenience constructor for STUN servers. */
Diogo Real05ea2b32017-08-31 00:12:58 -0700327 @Deprecated
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000328 public IceServer(String uri) {
329 this(uri, "", "");
330 }
331
Diogo Real05ea2b32017-08-31 00:12:58 -0700332 @Deprecated
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000333 public IceServer(String uri, String username, String password) {
hnsl04833622017-01-09 08:35:45 -0800334 this(uri, username, password, TlsCertPolicy.TLS_CERT_POLICY_SECURE);
335 }
336
Diogo Real05ea2b32017-08-31 00:12:58 -0700337 @Deprecated
hnsl04833622017-01-09 08:35:45 -0800338 public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy) {
Emad Omaradab1d2d2017-06-16 15:43:11 -0700339 this(uri, username, password, tlsCertPolicy, "");
340 }
341
Diogo Real05ea2b32017-08-31 00:12:58 -0700342 @Deprecated
Emad Omaradab1d2d2017-06-16 15:43:11 -0700343 public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy,
344 String hostname) {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700345 this(uri, Collections.singletonList(uri), username, password, tlsCertPolicy, hostname, null,
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700346 null, SslConfig.builder().createSslConfig());
Diogo Real1dca9d52017-08-29 12:18:32 -0700347 }
348
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700349 private IceServer(String uri, List<String> urls, String username, String password,
350 TlsCertPolicy tlsCertPolicy, String hostname, List<String> tlsAlpnProtocols,
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700351 List<String> tlsEllipticCurves, SslConfig sslConfig) {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700352 if (uri == null || urls == null || urls.isEmpty()) {
353 throw new IllegalArgumentException("uri == null || urls == null || urls.isEmpty()");
354 }
355 for (String it : urls) {
356 if (it == null) {
357 throw new IllegalArgumentException("urls element is null: " + urls);
358 }
359 }
360 if (username == null) {
361 throw new IllegalArgumentException("username == null");
362 }
363 if (password == null) {
364 throw new IllegalArgumentException("password == null");
365 }
366 if (hostname == null) {
367 throw new IllegalArgumentException("hostname == null");
368 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000369 this.uri = uri;
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700370 this.urls = urls;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000371 this.username = username;
372 this.password = password;
hnsl04833622017-01-09 08:35:45 -0800373 this.tlsCertPolicy = tlsCertPolicy;
Emad Omaradab1d2d2017-06-16 15:43:11 -0700374 this.hostname = hostname;
Diogo Real1dca9d52017-08-29 12:18:32 -0700375 this.tlsAlpnProtocols = tlsAlpnProtocols;
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700376 this.tlsEllipticCurves = tlsEllipticCurves;
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700377 this.sslConfig = sslConfig;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000378 }
379
Sami Kalliomäkibde473e2017-10-30 13:34:41 +0100380 @Override
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000381 public String toString() {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700382 return urls + " [" + username + ":" + password + "] [" + tlsCertPolicy + "] [" + hostname
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700383 + "] [" + tlsAlpnProtocols + "] [" + tlsEllipticCurves + "] [" + sslConfig + "]";
Diogo Real1dca9d52017-08-29 12:18:32 -0700384 }
385
386 public static Builder builder(String uri) {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700387 return new Builder(Collections.singletonList(uri));
388 }
389
390 public static Builder builder(List<String> urls) {
391 return new Builder(urls);
Diogo Real1dca9d52017-08-29 12:18:32 -0700392 }
393
394 public static class Builder {
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100395 @Nullable private final List<String> urls;
Diogo Real1dca9d52017-08-29 12:18:32 -0700396 private String username = "";
397 private String password = "";
398 private TlsCertPolicy tlsCertPolicy = TlsCertPolicy.TLS_CERT_POLICY_SECURE;
399 private String hostname = "";
400 private List<String> tlsAlpnProtocols;
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700401 private List<String> tlsEllipticCurves;
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700402 private SslConfig sslConfig = SslConfig.builder().createSslConfig();
Diogo Real1dca9d52017-08-29 12:18:32 -0700403
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700404 private Builder(List<String> urls) {
405 if (urls == null || urls.isEmpty()) {
406 throw new IllegalArgumentException("urls == null || urls.isEmpty(): " + urls);
407 }
408 this.urls = urls;
Diogo Real1dca9d52017-08-29 12:18:32 -0700409 }
410
411 public Builder setUsername(String username) {
412 this.username = username;
413 return this;
414 }
415
416 public Builder setPassword(String password) {
417 this.password = password;
418 return this;
419 }
420
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700421 @Deprecated
Diogo Real1dca9d52017-08-29 12:18:32 -0700422 public Builder setTlsCertPolicy(TlsCertPolicy tlsCertPolicy) {
423 this.tlsCertPolicy = tlsCertPolicy;
424 return this;
425 }
426
427 public Builder setHostname(String hostname) {
428 this.hostname = hostname;
429 return this;
430 }
431
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700432 @Deprecated
Diogo Real1dca9d52017-08-29 12:18:32 -0700433 public Builder setTlsAlpnProtocols(List<String> tlsAlpnProtocols) {
434 this.tlsAlpnProtocols = tlsAlpnProtocols;
435 return this;
436 }
437
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700438 @Deprecated
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700439 public Builder setTlsEllipticCurves(List<String> tlsEllipticCurves) {
440 this.tlsEllipticCurves = tlsEllipticCurves;
441 return this;
442 }
443
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700444 public Builder setSslConfig(SslConfig sslConfig) {
445 this.sslConfig = sslConfig;
446 return this;
447 }
448
Diogo Real1dca9d52017-08-29 12:18:32 -0700449 public IceServer createIceServer() {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700450 return new IceServer(urls.get(0), urls, username, password, tlsCertPolicy, hostname,
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700451 tlsAlpnProtocols, tlsEllipticCurves, sslConfig);
Diogo Real1dca9d52017-08-29 12:18:32 -0700452 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000453 }
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100454
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100455 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100456 @CalledByNative("IceServer")
457 List<String> getUrls() {
458 return urls;
459 }
460
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100461 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100462 @CalledByNative("IceServer")
463 String getUsername() {
464 return username;
465 }
466
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100467 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100468 @CalledByNative("IceServer")
469 String getPassword() {
470 return password;
471 }
472
473 @CalledByNative("IceServer")
474 TlsCertPolicy getTlsCertPolicy() {
475 return tlsCertPolicy;
476 }
477
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100478 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100479 @CalledByNative("IceServer")
480 String getHostname() {
481 return hostname;
482 }
483
484 @CalledByNative("IceServer")
485 List<String> getTlsAlpnProtocols() {
486 return tlsAlpnProtocols;
487 }
488
489 @CalledByNative("IceServer")
490 List<String> getTlsEllipticCurves() {
491 return tlsEllipticCurves;
492 }
Diogo Real7f1ffcc2018-09-04 14:42:03 -0700493
494 @CalledByNative("IceServer")
495 SslConfig getSslConfig() {
496 return sslConfig;
497 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000498 }
499
Jiayang Liucac1b382015-04-30 12:35:24 -0700500 /** Java version of PeerConnectionInterface.IceTransportsType */
sakalb6760f92016-09-29 04:12:44 -0700501 public enum IceTransportsType { NONE, RELAY, NOHOST, ALL }
Jiayang Liucac1b382015-04-30 12:35:24 -0700502
503 /** Java version of PeerConnectionInterface.BundlePolicy */
sakalb6760f92016-09-29 04:12:44 -0700504 public enum BundlePolicy { BALANCED, MAXBUNDLE, MAXCOMPAT }
Jiayang Liucac1b382015-04-30 12:35:24 -0700505
Peter Thatcheraf55ccc2015-05-21 07:48:41 -0700506 /** Java version of PeerConnectionInterface.RtcpMuxPolicy */
sakalb6760f92016-09-29 04:12:44 -0700507 public enum RtcpMuxPolicy { NEGOTIATE, REQUIRE }
glaznev97579a42015-09-01 11:31:27 -0700508
Peter Thatcheraf55ccc2015-05-21 07:48:41 -0700509 /** Java version of PeerConnectionInterface.TcpCandidatePolicy */
sakalb6760f92016-09-29 04:12:44 -0700510 public enum TcpCandidatePolicy { ENABLED, DISABLED }
Jiayang Liucac1b382015-04-30 12:35:24 -0700511
honghaiz60347052016-05-31 18:29:12 -0700512 /** Java version of PeerConnectionInterface.CandidateNetworkPolicy */
sakalb6760f92016-09-29 04:12:44 -0700513 public enum CandidateNetworkPolicy { ALL, LOW_COST }
honghaiz60347052016-05-31 18:29:12 -0700514
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800515 // Keep in sync with webrtc/rtc_base/network_constants.h.
516 public enum AdapterType {
517 UNKNOWN,
518 ETHERNET,
519 WIFI,
520 CELLULAR,
521 VPN,
522 LOOPBACK,
523 }
524
glaznev97579a42015-09-01 11:31:27 -0700525 /** Java version of rtc::KeyType */
sakalb6760f92016-09-29 04:12:44 -0700526 public enum KeyType { RSA, ECDSA }
glaznev97579a42015-09-01 11:31:27 -0700527
honghaiz1f429e32015-09-28 07:57:34 -0700528 /** Java version of PeerConnectionInterface.ContinualGatheringPolicy */
sakalb6760f92016-09-29 04:12:44 -0700529 public enum ContinualGatheringPolicy { GATHER_ONCE, GATHER_CONTINUALLY }
honghaiz1f429e32015-09-28 07:57:34 -0700530
Steve Antond960a0c2017-07-17 12:33:07 -0700531 /** Java version of rtc::IntervalRange */
532 public static class IntervalRange {
533 private final int min;
534 private final int max;
535
536 public IntervalRange(int min, int max) {
537 this.min = min;
538 this.max = max;
539 }
540
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100541 @CalledByNative("IntervalRange")
Steve Antond960a0c2017-07-17 12:33:07 -0700542 public int getMin() {
543 return min;
544 }
545
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100546 @CalledByNative("IntervalRange")
Steve Antond960a0c2017-07-17 12:33:07 -0700547 public int getMax() {
548 return max;
549 }
550 }
551
Seth Hampsonc384e142018-03-06 15:47:10 -0800552 /**
553 * Java version of webrtc::SdpSemantics.
554 *
555 * Configure the SDP semantics used by this PeerConnection. Note that the
556 * WebRTC 1.0 specification requires UNIFIED_PLAN semantics. The
557 * RtpTransceiver API is only available with UNIFIED_PLAN semantics.
558 *
559 * <p>PLAN_B will cause PeerConnection to create offers and answers with at
560 * most one audio and one video m= section with multiple RtpSenders and
561 * RtpReceivers specified as multiple a=ssrc lines within the section. This
562 * will also cause PeerConnection to ignore all but the first m= section of
563 * the same media type.
564 *
565 * <p>UNIFIED_PLAN will cause PeerConnection to create offers and answers with
566 * multiple m= sections where each m= section maps to one RtpSender and one
567 * RtpReceiver (an RtpTransceiver), either both audio or both video. This
568 * will also cause PeerConnection to ignore all but the first a=ssrc lines
569 * that form a Plan B stream.
570 *
571 * <p>For users who wish to send multiple audio/video streams and need to stay
572 * interoperable with legacy WebRTC implementations, specify PLAN_B.
573 *
574 * <p>For users who wish to send multiple audio/video streams and/or wish to
575 * use the new RtpTransceiver API, specify UNIFIED_PLAN.
576 */
577 public enum SdpSemantics { PLAN_B, UNIFIED_PLAN }
578
Jiayang Liucac1b382015-04-30 12:35:24 -0700579 /** Java version of PeerConnectionInterface.RTCConfiguration */
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800580 // TODO(qingsi): Resolve the naming inconsistency of fields with/without units.
Jiayang Liucac1b382015-04-30 12:35:24 -0700581 public static class RTCConfiguration {
582 public IceTransportsType iceTransportsType;
583 public List<IceServer> iceServers;
584 public BundlePolicy bundlePolicy;
Peter Thatcheraf55ccc2015-05-21 07:48:41 -0700585 public RtcpMuxPolicy rtcpMuxPolicy;
Jiayang Liucac1b382015-04-30 12:35:24 -0700586 public TcpCandidatePolicy tcpCandidatePolicy;
honghaiz60347052016-05-31 18:29:12 -0700587 public CandidateNetworkPolicy candidateNetworkPolicy;
Henrik Lundin64dad832015-05-11 12:44:23 +0200588 public int audioJitterBufferMaxPackets;
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200589 public boolean audioJitterBufferFastAccelerate;
honghaiz4edc39c2015-09-01 09:53:56 -0700590 public int iceConnectionReceivingTimeout;
Honghai Zhang381b4212015-12-04 12:24:03 -0800591 public int iceBackupCandidatePairPingInterval;
glaznev97579a42015-09-01 11:31:27 -0700592 public KeyType keyType;
honghaiz1f429e32015-09-28 07:57:34 -0700593 public ContinualGatheringPolicy continualGatheringPolicy;
deadbeefbe0c96f2016-05-18 16:20:14 -0700594 public int iceCandidatePoolSize;
Honghai Zhangd78ecf72016-07-01 14:40:40 -0700595 public boolean pruneTurnPorts;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700596 public boolean presumeWritableWhenFullyRelayed;
Qingsi Wange6826d22018-03-08 14:55:14 -0800597 // The following fields define intervals in milliseconds at which ICE
598 // connectivity checks are sent.
599 //
600 // We consider ICE is "strongly connected" for an agent when there is at
601 // least one candidate pair that currently succeeds in connectivity check
602 // from its direction i.e. sending a ping and receives a ping response, AND
603 // all candidate pairs have sent a minimum number of pings for connectivity
604 // (this number is implementation-specific). Otherwise, ICE is considered in
605 // "weak connectivity".
606 //
607 // Note that the above notion of strong and weak connectivity is not defined
608 // in RFC 5245, and they apply to our current ICE implementation only.
609 //
610 // 1) iceCheckIntervalStrongConnectivityMs defines the interval applied to
611 // ALL candidate pairs when ICE is strongly connected,
612 // 2) iceCheckIntervalWeakConnectivityMs defines the counterpart for ALL
613 // pairs when ICE is weakly connected, and
614 // 3) iceCheckMinInterval defines the minimal interval (equivalently the
615 // maximum rate) that overrides the above two intervals when either of them
616 // is less.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100617 @Nullable public Integer iceCheckIntervalStrongConnectivityMs;
618 @Nullable public Integer iceCheckIntervalWeakConnectivityMs;
619 @Nullable public Integer iceCheckMinInterval;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700620 // The time period in milliseconds for which a candidate pair must wait for response to
621 // connectivitiy checks before it becomes unwritable.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100622 @Nullable public Integer iceUnwritableTimeMs;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700623 // The minimum number of connectivity checks that a candidate pair must sent without receiving
624 // response before it becomes unwritable.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100625 @Nullable public Integer iceUnwritableMinChecks;
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800626 // The interval in milliseconds at which STUN candidates will resend STUN binding requests
627 // to keep NAT bindings open.
628 // The default value in the implementation is used if this field is null.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100629 @Nullable public Integer stunCandidateKeepaliveIntervalMs;
zhihuangb09b3f92017-03-07 14:40:51 -0800630 public boolean disableIPv6OnWifi;
deadbeef28e29192017-07-27 09:14:38 -0700631 // By default, PeerConnection will use a limited number of IPv6 network
632 // interfaces, in order to avoid too many ICE candidate pairs being created
633 // and delaying ICE completion.
634 //
635 // Can be set to Integer.MAX_VALUE to effectively disable the limit.
636 public int maxIPv6Networks;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100637 @Nullable public IntervalRange iceRegatherIntervalRange;
Jiayang Liucac1b382015-04-30 12:35:24 -0700638
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100639 // These values will be overridden by MediaStream constraints if deprecated constraints-based
640 // create peerconnection interface is used.
641 public boolean disableIpv6;
642 public boolean enableDscp;
643 public boolean enableCpuOveruseDetection;
644 public boolean enableRtpDataChannel;
645 public boolean suspendBelowMinBitrate;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100646 @Nullable public Integer screencastMinBitrate;
647 @Nullable public Boolean combinedAudioVideoBwe;
648 @Nullable public Boolean enableDtlsSrtp;
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800649 // Use "Unknown" to represent no preference of adapter types, not the
650 // preference of adapters of unknown types.
651 public AdapterType networkPreference;
Seth Hampsonc384e142018-03-06 15:47:10 -0800652 public SdpSemantics sdpSemantics;
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100653
Jonas Orelandbdcee282017-10-10 14:01:40 +0200654 // This is an optional wrapper for the C++ webrtc::TurnCustomizer.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100655 @Nullable public TurnCustomizer turnCustomizer;
Jonas Orelandbdcee282017-10-10 14:01:40 +0200656
Zhi Huangb57e1692018-06-12 11:41:11 -0700657 // Actively reset the SRTP parameters whenever the DTLS transports underneath are reset for
658 // every offer/answer negotiation.This is only intended to be a workaround for crbug.com/835958
659 public boolean activeResetSrtpParams;
660
deadbeef28e29192017-07-27 09:14:38 -0700661 // TODO(deadbeef): Instead of duplicating the defaults here, we should do
662 // something to pick up the defaults from C++. The Objective-C equivalent
663 // of RTCConfiguration does that.
Jiayang Liucac1b382015-04-30 12:35:24 -0700664 public RTCConfiguration(List<IceServer> iceServers) {
665 iceTransportsType = IceTransportsType.ALL;
666 bundlePolicy = BundlePolicy.BALANCED;
zhihuang4dfb8ce2016-11-23 10:30:12 -0800667 rtcpMuxPolicy = RtcpMuxPolicy.REQUIRE;
Jiayang Liucac1b382015-04-30 12:35:24 -0700668 tcpCandidatePolicy = TcpCandidatePolicy.ENABLED;
Sami Kalliomäki9828beb2017-10-26 16:21:22 +0200669 candidateNetworkPolicy = CandidateNetworkPolicy.ALL;
Jiayang Liucac1b382015-04-30 12:35:24 -0700670 this.iceServers = iceServers;
Henrik Lundin64dad832015-05-11 12:44:23 +0200671 audioJitterBufferMaxPackets = 50;
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200672 audioJitterBufferFastAccelerate = false;
honghaiz4edc39c2015-09-01 09:53:56 -0700673 iceConnectionReceivingTimeout = -1;
Honghai Zhang381b4212015-12-04 12:24:03 -0800674 iceBackupCandidatePairPingInterval = -1;
glaznev97579a42015-09-01 11:31:27 -0700675 keyType = KeyType.ECDSA;
honghaiz1f429e32015-09-28 07:57:34 -0700676 continualGatheringPolicy = ContinualGatheringPolicy.GATHER_ONCE;
deadbeefbe0c96f2016-05-18 16:20:14 -0700677 iceCandidatePoolSize = 0;
Honghai Zhangd78ecf72016-07-01 14:40:40 -0700678 pruneTurnPorts = false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700679 presumeWritableWhenFullyRelayed = false;
Qingsi Wange6826d22018-03-08 14:55:14 -0800680 iceCheckIntervalStrongConnectivityMs = null;
681 iceCheckIntervalWeakConnectivityMs = null;
skvlad51072462017-02-02 11:50:14 -0800682 iceCheckMinInterval = null;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700683 iceUnwritableTimeMs = null;
684 iceUnwritableMinChecks = null;
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800685 stunCandidateKeepaliveIntervalMs = null;
zhihuangb09b3f92017-03-07 14:40:51 -0800686 disableIPv6OnWifi = false;
deadbeef28e29192017-07-27 09:14:38 -0700687 maxIPv6Networks = 5;
Steve Antond960a0c2017-07-17 12:33:07 -0700688 iceRegatherIntervalRange = null;
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100689 disableIpv6 = false;
690 enableDscp = false;
691 enableCpuOveruseDetection = true;
692 enableRtpDataChannel = false;
693 suspendBelowMinBitrate = false;
694 screencastMinBitrate = null;
695 combinedAudioVideoBwe = null;
696 enableDtlsSrtp = null;
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800697 networkPreference = AdapterType.UNKNOWN;
Seth Hampsonc384e142018-03-06 15:47:10 -0800698 sdpSemantics = SdpSemantics.PLAN_B;
Zhi Huangb57e1692018-06-12 11:41:11 -0700699 activeResetSrtpParams = false;
Jiayang Liucac1b382015-04-30 12:35:24 -0700700 }
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100701
702 @CalledByNative("RTCConfiguration")
703 IceTransportsType getIceTransportsType() {
704 return iceTransportsType;
705 }
706
707 @CalledByNative("RTCConfiguration")
708 List<IceServer> getIceServers() {
709 return iceServers;
710 }
711
712 @CalledByNative("RTCConfiguration")
713 BundlePolicy getBundlePolicy() {
714 return bundlePolicy;
715 }
716
717 @CalledByNative("RTCConfiguration")
718 RtcpMuxPolicy getRtcpMuxPolicy() {
719 return rtcpMuxPolicy;
720 }
721
722 @CalledByNative("RTCConfiguration")
723 TcpCandidatePolicy getTcpCandidatePolicy() {
724 return tcpCandidatePolicy;
725 }
726
727 @CalledByNative("RTCConfiguration")
728 CandidateNetworkPolicy getCandidateNetworkPolicy() {
729 return candidateNetworkPolicy;
730 }
731
732 @CalledByNative("RTCConfiguration")
733 int getAudioJitterBufferMaxPackets() {
734 return audioJitterBufferMaxPackets;
735 }
736
737 @CalledByNative("RTCConfiguration")
738 boolean getAudioJitterBufferFastAccelerate() {
739 return audioJitterBufferFastAccelerate;
740 }
741
742 @CalledByNative("RTCConfiguration")
743 int getIceConnectionReceivingTimeout() {
744 return iceConnectionReceivingTimeout;
745 }
746
747 @CalledByNative("RTCConfiguration")
748 int getIceBackupCandidatePairPingInterval() {
749 return iceBackupCandidatePairPingInterval;
750 }
751
752 @CalledByNative("RTCConfiguration")
753 KeyType getKeyType() {
754 return keyType;
755 }
756
757 @CalledByNative("RTCConfiguration")
758 ContinualGatheringPolicy getContinualGatheringPolicy() {
759 return continualGatheringPolicy;
760 }
761
762 @CalledByNative("RTCConfiguration")
763 int getIceCandidatePoolSize() {
764 return iceCandidatePoolSize;
765 }
766
767 @CalledByNative("RTCConfiguration")
768 boolean getPruneTurnPorts() {
769 return pruneTurnPorts;
770 }
771
772 @CalledByNative("RTCConfiguration")
773 boolean getPresumeWritableWhenFullyRelayed() {
774 return presumeWritableWhenFullyRelayed;
775 }
776
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100777 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100778 @CalledByNative("RTCConfiguration")
Qingsi Wange6826d22018-03-08 14:55:14 -0800779 Integer getIceCheckIntervalStrongConnectivity() {
780 return iceCheckIntervalStrongConnectivityMs;
781 }
782
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100783 @Nullable
Qingsi Wange6826d22018-03-08 14:55:14 -0800784 @CalledByNative("RTCConfiguration")
785 Integer getIceCheckIntervalWeakConnectivity() {
786 return iceCheckIntervalWeakConnectivityMs;
787 }
788
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100789 @Nullable
Qingsi Wange6826d22018-03-08 14:55:14 -0800790 @CalledByNative("RTCConfiguration")
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100791 Integer getIceCheckMinInterval() {
792 return iceCheckMinInterval;
793 }
794
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100795 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100796 @CalledByNative("RTCConfiguration")
Qingsi Wang22e623a2018-03-13 10:53:57 -0700797 Integer getIceUnwritableTimeout() {
798 return iceUnwritableTimeMs;
799 }
800
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100801 @Nullable
Qingsi Wang22e623a2018-03-13 10:53:57 -0700802 @CalledByNative("RTCConfiguration")
803 Integer getIceUnwritableMinChecks() {
804 return iceUnwritableMinChecks;
805 }
806
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100807 @Nullable
Qingsi Wang22e623a2018-03-13 10:53:57 -0700808 @CalledByNative("RTCConfiguration")
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800809 Integer getStunCandidateKeepaliveInterval() {
810 return stunCandidateKeepaliveIntervalMs;
811 }
812
813 @CalledByNative("RTCConfiguration")
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100814 boolean getDisableIPv6OnWifi() {
815 return disableIPv6OnWifi;
816 }
817
818 @CalledByNative("RTCConfiguration")
819 int getMaxIPv6Networks() {
820 return maxIPv6Networks;
821 }
822
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100823 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100824 @CalledByNative("RTCConfiguration")
825 IntervalRange getIceRegatherIntervalRange() {
826 return iceRegatherIntervalRange;
827 }
828
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100829 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100830 @CalledByNative("RTCConfiguration")
831 TurnCustomizer getTurnCustomizer() {
832 return turnCustomizer;
833 }
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100834
835 @CalledByNative("RTCConfiguration")
836 boolean getDisableIpv6() {
837 return disableIpv6;
838 }
839
840 @CalledByNative("RTCConfiguration")
841 boolean getEnableDscp() {
842 return enableDscp;
843 }
844
845 @CalledByNative("RTCConfiguration")
846 boolean getEnableCpuOveruseDetection() {
847 return enableCpuOveruseDetection;
848 }
849
850 @CalledByNative("RTCConfiguration")
851 boolean getEnableRtpDataChannel() {
852 return enableRtpDataChannel;
853 }
854
855 @CalledByNative("RTCConfiguration")
856 boolean getSuspendBelowMinBitrate() {
857 return suspendBelowMinBitrate;
858 }
859
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100860 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100861 @CalledByNative("RTCConfiguration")
862 Integer getScreencastMinBitrate() {
863 return screencastMinBitrate;
864 }
865
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100866 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100867 @CalledByNative("RTCConfiguration")
868 Boolean getCombinedAudioVideoBwe() {
869 return combinedAudioVideoBwe;
870 }
871
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100872 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100873 @CalledByNative("RTCConfiguration")
874 Boolean getEnableDtlsSrtp() {
875 return enableDtlsSrtp;
876 }
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800877
878 @CalledByNative("RTCConfiguration")
879 AdapterType getNetworkPreference() {
880 return networkPreference;
881 }
Seth Hampsonc384e142018-03-06 15:47:10 -0800882
883 @CalledByNative("RTCConfiguration")
884 SdpSemantics getSdpSemantics() {
885 return sdpSemantics;
886 }
Zhi Huangb57e1692018-06-12 11:41:11 -0700887
888 @CalledByNative("RTCConfiguration")
889 boolean getActiveResetSrtpParams() {
890 return activeResetSrtpParams;
891 }
Jiayang Liucac1b382015-04-30 12:35:24 -0700892 };
893
Magnus Jedvert6062f372017-11-16 16:53:12 +0100894 private final List<MediaStream> localStreams = new ArrayList<>();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000895 private final long nativePeerConnection;
Magnus Jedvert6062f372017-11-16 16:53:12 +0100896 private List<RtpSender> senders = new ArrayList<>();
897 private List<RtpReceiver> receivers = new ArrayList<>();
Seth Hampsonc384e142018-03-06 15:47:10 -0800898 private List<RtpTransceiver> transceivers = new ArrayList<>();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000899
Sami Kalliomäki1ece1ed2017-12-20 11:59:22 +0100900 /**
901 * Wraps a PeerConnection created by the factory. Can be used by clients that want to implement
902 * their PeerConnection creation in JNI.
903 */
904 public PeerConnection(NativePeerConnectionFactory factory) {
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100905 this(factory.createNativePeerConnection());
Sami Kalliomäki1ece1ed2017-12-20 11:59:22 +0100906 }
907
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100908 PeerConnection(long nativePeerConnection) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000909 this.nativePeerConnection = nativePeerConnection;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000910 }
911
912 // JsepInterface.
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100913 public SessionDescription getLocalDescription() {
914 return nativeGetLocalDescription();
915 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000916
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100917 public SessionDescription getRemoteDescription() {
918 return nativeGetRemoteDescription();
919 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000920
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100921 public DataChannel createDataChannel(String label, DataChannel.Init init) {
922 return nativeCreateDataChannel(label, init);
923 }
henrike@webrtc.org723d6832013-07-12 16:04:50 +0000924
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100925 public void createOffer(SdpObserver observer, MediaConstraints constraints) {
926 nativeCreateOffer(observer, constraints);
927 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000928
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100929 public void createAnswer(SdpObserver observer, MediaConstraints constraints) {
930 nativeCreateAnswer(observer, constraints);
931 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000932
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100933 public void setLocalDescription(SdpObserver observer, SessionDescription sdp) {
934 nativeSetLocalDescription(observer, sdp);
935 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000936
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100937 public void setRemoteDescription(SdpObserver observer, SessionDescription sdp) {
938 nativeSetRemoteDescription(observer, sdp);
939 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000940
Seth Hampsonc384e142018-03-06 15:47:10 -0800941 /**
942 * Enables/disables playout of received audio streams. Enabled by default.
943 *
944 * Note that even if playout is enabled, streams will only be played out if
945 * the appropriate SDP is also applied. The main purpose of this API is to
946 * be able to control the exact time when audio playout starts.
947 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100948 public void setAudioPlayout(boolean playout) {
949 nativeSetAudioPlayout(playout);
950 }
henrika5f6bf242017-11-01 11:06:56 +0100951
Seth Hampsonc384e142018-03-06 15:47:10 -0800952 /**
953 * Enables/disables recording of transmitted audio streams. Enabled by default.
954 *
955 * Note that even if recording is enabled, streams will only be recorded if
956 * the appropriate SDP is also applied. The main purpose of this API is to
957 * be able to control the exact time when audio recording starts.
958 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100959 public void setAudioRecording(boolean recording) {
960 nativeSetAudioRecording(recording);
961 }
henrika5f6bf242017-11-01 11:06:56 +0100962
deadbeef5d0b6d82017-01-09 16:05:28 -0800963 public boolean setConfiguration(RTCConfiguration config) {
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100964 return nativeSetConfiguration(config);
deadbeef5d0b6d82017-01-09 16:05:28 -0800965 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000966
967 public boolean addIceCandidate(IceCandidate candidate) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100968 return nativeAddIceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000969 }
970
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700971 public boolean removeIceCandidates(final IceCandidate[] candidates) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100972 return nativeRemoveIceCandidates(candidates);
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700973 }
974
Seth Hampsonc384e142018-03-06 15:47:10 -0800975 /**
976 * Adds a new MediaStream to be sent on this peer connection.
977 * Note: This method is not supported with SdpSemantics.UNIFIED_PLAN. Please
978 * use addTrack instead.
979 */
perkj@webrtc.orgc2dd5ee2014-11-04 11:31:29 +0000980 public boolean addStream(MediaStream stream) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100981 boolean ret = nativeAddLocalStream(stream.nativeStream);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000982 if (!ret) {
983 return false;
984 }
985 localStreams.add(stream);
986 return true;
987 }
988
Seth Hampsonc384e142018-03-06 15:47:10 -0800989 /**
990 * Removes the given media stream from this peer connection.
991 * This method is not supported with SdpSemantics.UNIFIED_PLAN. Please use
992 * removeTrack instead.
993 */
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000994 public void removeStream(MediaStream stream) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100995 nativeRemoveLocalStream(stream.nativeStream);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000996 localStreams.remove(stream);
997 }
998
deadbeef7a246882017-08-09 08:40:10 -0700999 /**
1000 * Creates an RtpSender without a track.
Seth Hampsonc384e142018-03-06 15:47:10 -08001001 *
1002 * <p>This method allows an application to cause the PeerConnection to negotiate
deadbeef7a246882017-08-09 08:40:10 -07001003 * sending/receiving a specific media type, but without having a track to
1004 * send yet.
Seth Hampsonc384e142018-03-06 15:47:10 -08001005 *
1006 * <p>When the application does want to begin sending a track, it can call
deadbeef7a246882017-08-09 08:40:10 -07001007 * RtpSender.setTrack, which doesn't require any additional SDP negotiation.
Seth Hampsonc384e142018-03-06 15:47:10 -08001008 *
1009 * <p>Example use:
deadbeef7a246882017-08-09 08:40:10 -07001010 * <pre>
1011 * {@code
1012 * audioSender = pc.createSender("audio", "stream1");
1013 * videoSender = pc.createSender("video", "stream1");
1014 * // Do normal SDP offer/answer, which will kick off ICE/DTLS and negotiate
1015 * // media parameters....
1016 * // Later, when the endpoint is ready to actually begin sending:
1017 * audioSender.setTrack(audioTrack, false);
1018 * videoSender.setTrack(videoTrack, false);
1019 * }
1020 * </pre>
Seth Hampsonc384e142018-03-06 15:47:10 -08001021 * <p>Note: This corresponds most closely to "addTransceiver" in the official
deadbeef7a246882017-08-09 08:40:10 -07001022 * WebRTC API, in that it creates a sender without a track. It was
1023 * implemented before addTransceiver because it provides useful
1024 * functionality, and properly implementing transceivers would have required
1025 * a great deal more work.
1026 *
Seth Hampsonc384e142018-03-06 15:47:10 -08001027 * <p>Note: This is only available with SdpSemantics.PLAN_B specified. Please use
1028 * addTransceiver instead.
1029 *
deadbeef7a246882017-08-09 08:40:10 -07001030 * @param kind Corresponds to MediaStreamTrack kinds (must be "audio" or
1031 * "video").
1032 * @param stream_id The ID of the MediaStream that this sender's track will
1033 * be associated with when SDP is applied to the remote
1034 * PeerConnection. If createSender is used to create an
1035 * audio and video sender that should be synchronized, they
1036 * should use the same stream ID.
1037 * @return A new RtpSender object if successful, or null otherwise.
1038 */
deadbeefbd7d8f72015-12-18 16:58:44 -08001039 public RtpSender createSender(String kind, String stream_id) {
Seth Hampsonc384e142018-03-06 15:47:10 -08001040 RtpSender newSender = nativeCreateSender(kind, stream_id);
1041 if (newSender != null) {
1042 senders.add(newSender);
deadbeefee524f72015-12-02 11:27:40 -08001043 }
Seth Hampsonc384e142018-03-06 15:47:10 -08001044 return newSender;
deadbeefee524f72015-12-02 11:27:40 -08001045 }
1046
Seth Hampsonc384e142018-03-06 15:47:10 -08001047 /**
1048 * Gets all RtpSenders associated with this peer connection.
1049 * Note that calling getSenders will dispose of the senders previously
1050 * returned.
1051 */
deadbeef4139c0f2015-10-06 12:29:25 -07001052 public List<RtpSender> getSenders() {
1053 for (RtpSender sender : senders) {
1054 sender.dispose();
1055 }
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001056 senders = nativeGetSenders();
deadbeef4139c0f2015-10-06 12:29:25 -07001057 return Collections.unmodifiableList(senders);
1058 }
1059
Seth Hampsonc384e142018-03-06 15:47:10 -08001060 /**
1061 * Gets all RtpReceivers associated with this peer connection.
1062 * Note that calling getReceivers will dispose of the receivers previously
1063 * returned.
1064 */
deadbeef4139c0f2015-10-06 12:29:25 -07001065 public List<RtpReceiver> getReceivers() {
1066 for (RtpReceiver receiver : receivers) {
1067 receiver.dispose();
1068 }
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001069 receivers = nativeGetReceivers();
deadbeef4139c0f2015-10-06 12:29:25 -07001070 return Collections.unmodifiableList(receivers);
1071 }
1072
Seth Hampsonc384e142018-03-06 15:47:10 -08001073 /**
1074 * Gets all RtpTransceivers associated with this peer connection.
1075 * Note that calling getTransceivers will dispose of the transceivers previously
1076 * returned.
1077 * Note: This is only available with SdpSemantics.UNIFIED_PLAN specified.
1078 */
1079 public List<RtpTransceiver> getTransceivers() {
1080 for (RtpTransceiver transceiver : transceivers) {
1081 transceiver.dispose();
1082 }
1083 transceivers = nativeGetTransceivers();
1084 return Collections.unmodifiableList(transceivers);
1085 }
1086
1087 /**
1088 * Adds a new media stream track to be sent on this peer connection, and returns
1089 * the newly created RtpSender. If streamIds are specified, the RtpSender will
1090 * be associated with the streams specified in the streamIds list.
1091 *
1092 * @throws IllegalStateException if an error accors in C++ addTrack.
1093 * An error can occur if:
1094 * - A sender already exists for the track.
1095 * - The peer connection is closed.
1096 */
1097 public RtpSender addTrack(MediaStreamTrack track) {
1098 return addTrack(track, Collections.emptyList());
1099 }
1100
1101 public RtpSender addTrack(MediaStreamTrack track, List<String> streamIds) {
1102 if (track == null || streamIds == null) {
1103 throw new NullPointerException("No MediaStreamTrack specified in addTrack.");
1104 }
1105 RtpSender newSender = nativeAddTrack(track.nativeTrack, streamIds);
1106 if (newSender == null) {
1107 throw new IllegalStateException("C++ addTrack failed.");
1108 }
1109 senders.add(newSender);
1110 return newSender;
1111 }
1112
1113 /**
1114 * Stops sending media from sender. The sender will still appear in getSenders. Future
1115 * calls to createOffer will mark the m section for the corresponding transceiver as
1116 * receive only or inactive, as defined in JSEP. Returns true on success.
1117 */
1118 public boolean removeTrack(RtpSender sender) {
1119 if (sender == null) {
1120 throw new NullPointerException("No RtpSender specified for removeTrack.");
1121 }
1122 return nativeRemoveTrack(sender.nativeRtpSender);
1123 }
1124
1125 /**
1126 * Creates a new RtpTransceiver and adds it to the set of transceivers. Adding a
1127 * transceiver will cause future calls to CreateOffer to add a media description
1128 * for the corresponding transceiver.
1129 *
1130 * <p>The initial value of |mid| in the returned transceiver is null. Setting a
1131 * new session description may change it to a non-null value.
1132 *
1133 * <p>https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtransceiver
1134 *
1135 * <p>If a MediaStreamTrack is specified then a transceiver will be added with a
1136 * sender set to transmit the given track. The kind
1137 * of the transceiver (and sender/receiver) will be derived from the kind of
1138 * the track.
1139 *
1140 * <p>If MediaType is specified then a transceiver will be added based upon that type.
1141 * This can be either MEDIA_TYPE_AUDIO or MEDIA_TYPE_VIDEO.
1142 *
1143 * <p>Optionally, an RtpTransceiverInit structure can be specified to configure
1144 * the transceiver from construction. If not specified, the transceiver will
1145 * default to having a direction of kSendRecv and not be part of any streams.
1146 *
1147 * <p>Note: These methods are only available with SdpSemantics.UNIFIED_PLAN specified.
1148 * @throws IllegalStateException if an error accors in C++ addTransceiver
1149 */
1150 public RtpTransceiver addTransceiver(MediaStreamTrack track) {
1151 return addTransceiver(track, new RtpTransceiver.RtpTransceiverInit());
1152 }
1153
1154 public RtpTransceiver addTransceiver(
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001155 MediaStreamTrack track, @Nullable RtpTransceiver.RtpTransceiverInit init) {
Seth Hampsonc384e142018-03-06 15:47:10 -08001156 if (track == null) {
1157 throw new NullPointerException("No MediaStreamTrack specified for addTransceiver.");
1158 }
1159 if (init == null) {
1160 init = new RtpTransceiver.RtpTransceiverInit();
1161 }
1162 RtpTransceiver newTransceiver = nativeAddTransceiverWithTrack(track.nativeTrack, init);
1163 if (newTransceiver == null) {
1164 throw new IllegalStateException("C++ addTransceiver failed.");
1165 }
1166 transceivers.add(newTransceiver);
1167 return newTransceiver;
1168 }
1169
1170 public RtpTransceiver addTransceiver(MediaStreamTrack.MediaType mediaType) {
1171 return addTransceiver(mediaType, new RtpTransceiver.RtpTransceiverInit());
1172 }
1173
1174 public RtpTransceiver addTransceiver(
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001175 MediaStreamTrack.MediaType mediaType, @Nullable RtpTransceiver.RtpTransceiverInit init) {
Seth Hampsonc384e142018-03-06 15:47:10 -08001176 if (mediaType == null) {
1177 throw new NullPointerException("No MediaType specified for addTransceiver.");
1178 }
1179 if (init == null) {
1180 init = new RtpTransceiver.RtpTransceiverInit();
1181 }
1182 RtpTransceiver newTransceiver = nativeAddTransceiverOfType(mediaType, init);
1183 if (newTransceiver == null) {
1184 throw new IllegalStateException("C++ addTransceiver failed.");
1185 }
1186 transceivers.add(newTransceiver);
1187 return newTransceiver;
1188 }
1189
deadbeef82215872017-04-18 10:27:51 -07001190 // Older, non-standard implementation of getStats.
1191 @Deprecated
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001192 public boolean getStats(StatsObserver observer, @Nullable MediaStreamTrack track) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001193 return nativeOldGetStats(observer, (track == null) ? 0 : track.nativeTrack);
deadbeef82215872017-04-18 10:27:51 -07001194 }
1195
Seth Hampsonc384e142018-03-06 15:47:10 -08001196 /**
1197 * Gets stats using the new stats collection API, see webrtc/api/stats/. These
1198 * will replace old stats collection API when the new API has matured enough.
1199 */
deadbeef82215872017-04-18 10:27:51 -07001200 public void getStats(RTCStatsCollectorCallback callback) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001201 nativeNewGetStats(callback);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001202 }
1203
Seth Hampsonc384e142018-03-06 15:47:10 -08001204 /**
1205 * Limits the bandwidth allocated for all RTP streams sent by this
1206 * PeerConnection. Pass null to leave a value unchanged.
1207 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001208 public boolean setBitrate(Integer min, Integer current, Integer max) {
1209 return nativeSetBitrate(min, current, max);
1210 }
zsteind89b0bc2017-08-03 11:11:40 -07001211
Seth Hampsonc384e142018-03-06 15:47:10 -08001212 /**
1213 * Starts recording an RTC event log.
1214 *
1215 * Ownership of the file is transfered to the native code. If an RTC event
1216 * log is already being recorded, it will be stopped and a new one will start
1217 * using the provided file. Logging will continue until the stopRtcEventLog
1218 * function is called. The max_size_bytes argument is ignored, it is added
1219 * for future use.
1220 */
ivoc0c6f0f62016-07-06 04:34:23 -07001221 public boolean startRtcEventLog(int file_descriptor, int max_size_bytes) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001222 return nativeStartRtcEventLog(file_descriptor, max_size_bytes);
ivoc14d5dbe2016-07-04 07:06:55 -07001223 }
1224
Seth Hampsonc384e142018-03-06 15:47:10 -08001225 /**
1226 * Stops recording an RTC event log. If no RTC event log is currently being
1227 * recorded, this call will have no effect.
1228 */
ivoc14d5dbe2016-07-04 07:06:55 -07001229 public void stopRtcEventLog() {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001230 nativeStopRtcEventLog();
ivoc14d5dbe2016-07-04 07:06:55 -07001231 }
1232
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001233 // TODO(fischman): add support for DTMF-related methods once that API
1234 // stabilizes.
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001235 public SignalingState signalingState() {
1236 return nativeSignalingState();
1237 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001238
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001239 public IceConnectionState iceConnectionState() {
1240 return nativeIceConnectionState();
1241 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001242
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001243 public IceGatheringState iceGatheringState() {
1244 return nativeIceGatheringState();
1245 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001246
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001247 public void close() {
1248 nativeClose();
1249 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001250
deadbeef43697f62017-09-12 10:52:14 -07001251 /**
1252 * Free native resources associated with this PeerConnection instance.
Seth Hampsonc384e142018-03-06 15:47:10 -08001253 *
deadbeef43697f62017-09-12 10:52:14 -07001254 * This method removes a reference count from the C++ PeerConnection object,
1255 * which should result in it being destroyed. It also calls equivalent
1256 * "dispose" methods on the Java objects attached to this PeerConnection
1257 * (streams, senders, receivers), such that their associated C++ objects
1258 * will also be destroyed.
Seth Hampsonc384e142018-03-06 15:47:10 -08001259 *
1260 * <p>Note that this method cannot be safely called from an observer callback
deadbeef43697f62017-09-12 10:52:14 -07001261 * (PeerConnection.Observer, DataChannel.Observer, etc.). If you want to, for
1262 * example, destroy the PeerConnection after an "ICE failed" callback, you
1263 * must do this asynchronously (in other words, unwind the stack first). See
1264 * <a href="https://bugs.chromium.org/p/webrtc/issues/detail?id=3721">bug
1265 * 3721</a> for more details.
1266 */
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001267 public void dispose() {
1268 close();
1269 for (MediaStream stream : localStreams) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001270 nativeRemoveLocalStream(stream.nativeStream);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001271 stream.dispose();
1272 }
1273 localStreams.clear();
deadbeef4139c0f2015-10-06 12:29:25 -07001274 for (RtpSender sender : senders) {
1275 sender.dispose();
1276 }
1277 senders.clear();
1278 for (RtpReceiver receiver : receivers) {
1279 receiver.dispose();
1280 }
Seth Hampsonc384e142018-03-06 15:47:10 -08001281 for (RtpTransceiver transceiver : transceivers) {
1282 transceiver.dispose();
1283 }
1284 transceivers.clear();
deadbeef4139c0f2015-10-06 12:29:25 -07001285 receivers.clear();
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001286 nativeFreeOwnedPeerConnection(nativePeerConnection);
1287 }
1288
1289 /** Returns a pointer to the native webrtc::PeerConnectionInterface. */
1290 public long getNativePeerConnection() {
1291 return nativeGetNativePeerConnection();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001292 }
1293
Magnus Jedvert9060eb12017-12-12 12:52:54 +01001294 @CalledByNative
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001295 long getNativeOwnedPeerConnection() {
Magnus Jedvert9060eb12017-12-12 12:52:54 +01001296 return nativePeerConnection;
1297 }
1298
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001299 public static long createNativePeerConnectionObserver(Observer observer) {
1300 return nativeCreatePeerConnectionObserver(observer);
1301 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001302
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001303 private native long nativeGetNativePeerConnection();
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001304 private native SessionDescription nativeGetLocalDescription();
1305 private native SessionDescription nativeGetRemoteDescription();
1306 private native DataChannel nativeCreateDataChannel(String label, DataChannel.Init init);
1307 private native void nativeCreateOffer(SdpObserver observer, MediaConstraints constraints);
1308 private native void nativeCreateAnswer(SdpObserver observer, MediaConstraints constraints);
1309 private native void nativeSetLocalDescription(SdpObserver observer, SessionDescription sdp);
1310 private native void nativeSetRemoteDescription(SdpObserver observer, SessionDescription sdp);
1311 private native void nativeSetAudioPlayout(boolean playout);
1312 private native void nativeSetAudioRecording(boolean recording);
1313 private native boolean nativeSetBitrate(Integer min, Integer current, Integer max);
1314 private native SignalingState nativeSignalingState();
1315 private native IceConnectionState nativeIceConnectionState();
1316 private native IceGatheringState nativeIceGatheringState();
1317 private native void nativeClose();
1318 private static native long nativeCreatePeerConnectionObserver(Observer observer);
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001319 private static native void nativeFreeOwnedPeerConnection(long ownedPeerConnection);
1320 private native boolean nativeSetConfiguration(RTCConfiguration config);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001321 private native boolean nativeAddIceCandidate(
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001322 String sdpMid, int sdpMLineIndex, String iceCandidateSdp);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001323 private native boolean nativeRemoveIceCandidates(final IceCandidate[] candidates);
1324 private native boolean nativeAddLocalStream(long stream);
1325 private native void nativeRemoveLocalStream(long stream);
1326 private native boolean nativeOldGetStats(StatsObserver observer, long nativeTrack);
1327 private native void nativeNewGetStats(RTCStatsCollectorCallback callback);
1328 private native RtpSender nativeCreateSender(String kind, String stream_id);
1329 private native List<RtpSender> nativeGetSenders();
1330 private native List<RtpReceiver> nativeGetReceivers();
Seth Hampsonc384e142018-03-06 15:47:10 -08001331 private native List<RtpTransceiver> nativeGetTransceivers();
1332 private native RtpSender nativeAddTrack(long track, List<String> streamIds);
1333 private native boolean nativeRemoveTrack(long sender);
1334 private native RtpTransceiver nativeAddTransceiverWithTrack(
1335 long track, RtpTransceiver.RtpTransceiverInit init);
1336 private native RtpTransceiver nativeAddTransceiverOfType(
1337 MediaStreamTrack.MediaType mediaType, RtpTransceiver.RtpTransceiverInit init);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001338 private native boolean nativeStartRtcEventLog(int file_descriptor, int max_size_bytes);
1339 private native void nativeStopRtcEventLog();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001340}