blob: a44969d99a357290d10261b328e3b016d450432a [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
Artem Titarenko69540f42018-12-10 12:30:46 +010013import android.support.annotation.Nullable;
Magnus Jedvert6062f372017-11-16 16:53:12 +010014import java.util.ArrayList;
Qingsi Wanga0d45802019-01-15 13:33:11 -080015import java.util.Arrays;
Sami Kalliomäki3e189a62017-11-24 11:13:39 +010016import java.util.Collections;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000017import java.util.List;
Patrik Höglundbd6ffaf2018-11-16 14:55:16 +010018import org.webrtc.DataChannel;
19import org.webrtc.MediaStreamTrack;
20import org.webrtc.RtpTransceiver;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000021
22/**
23 * Java-land version of the PeerConnection APIs; wraps the C++ API
24 * http://www.webrtc.org/reference/native-apis, which in turn is inspired by the
25 * JS APIs: http://dev.w3.org/2011/webrtc/editor/webrtc.html and
26 * http://www.w3.org/TR/mediacapture-streams/
27 */
28public class PeerConnection {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000029 /** Tracks PeerConnectionInterface::IceGatheringState */
Magnus Jedvertba700f62017-12-04 13:43:27 +010030 public enum IceGatheringState {
31 NEW,
32 GATHERING,
33 COMPLETE;
34
35 @CalledByNative("IceGatheringState")
36 static IceGatheringState fromNativeIndex(int nativeIndex) {
37 return values()[nativeIndex];
38 }
39 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000040
41 /** Tracks PeerConnectionInterface::IceConnectionState */
42 public enum IceConnectionState {
sakalb6760f92016-09-29 04:12:44 -070043 NEW,
44 CHECKING,
45 CONNECTED,
46 COMPLETED,
47 FAILED,
48 DISCONNECTED,
Magnus Jedvertba700f62017-12-04 13:43:27 +010049 CLOSED;
50
51 @CalledByNative("IceConnectionState")
52 static IceConnectionState fromNativeIndex(int nativeIndex) {
53 return values()[nativeIndex];
54 }
sakalb6760f92016-09-29 04:12:44 -070055 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000056
Jonas Olssonf01d8c82018-11-08 15:19:04 +010057 /** Tracks PeerConnectionInterface::PeerConnectionState */
58 public enum PeerConnectionState {
59 NEW,
60 CONNECTING,
61 CONNECTED,
62 DISCONNECTED,
63 FAILED,
64 CLOSED;
65
66 @CalledByNative("PeerConnectionState")
67 static PeerConnectionState fromNativeIndex(int nativeIndex) {
68 return values()[nativeIndex];
69 }
70 }
71
hnsl04833622017-01-09 08:35:45 -080072 /** Tracks PeerConnectionInterface::TlsCertPolicy */
73 public enum TlsCertPolicy {
74 TLS_CERT_POLICY_SECURE,
75 TLS_CERT_POLICY_INSECURE_NO_CHECK,
76 }
77
henrike@webrtc.org28e20752013-07-10 00:45:36 +000078 /** Tracks PeerConnectionInterface::SignalingState */
79 public enum SignalingState {
sakalb6760f92016-09-29 04:12:44 -070080 STABLE,
81 HAVE_LOCAL_OFFER,
82 HAVE_LOCAL_PRANSWER,
83 HAVE_REMOTE_OFFER,
84 HAVE_REMOTE_PRANSWER,
Magnus Jedvertba700f62017-12-04 13:43:27 +010085 CLOSED;
86
87 @CalledByNative("SignalingState")
88 static SignalingState fromNativeIndex(int nativeIndex) {
89 return values()[nativeIndex];
90 }
sakalb6760f92016-09-29 04:12:44 -070091 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000092
93 /** Java version of PeerConnectionObserver. */
94 public static interface Observer {
95 /** Triggered when the SignalingState changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +010096 @CalledByNative("Observer") void onSignalingChange(SignalingState newState);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000097
98 /** Triggered when the IceConnectionState changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +010099 @CalledByNative("Observer") void onIceConnectionChange(IceConnectionState newState);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000100
Qingsi Wang36e31472019-05-29 11:37:26 -0700101 /* Triggered when the standard-compliant state transition of IceConnectionState happens. */
102 @CalledByNative("Observer")
103 default void onStandardizedIceConnectionChange(IceConnectionState newState) {}
104
Jonas Olssonf01d8c82018-11-08 15:19:04 +0100105 /** Triggered when the PeerConnectionState changes. */
106 @CalledByNative("Observer")
107 default void onConnectionChange(PeerConnectionState newState) {}
108
Peter Thatcher54360512015-07-08 11:08:35 -0700109 /** Triggered when the ICE connection receiving status changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100110 @CalledByNative("Observer") void onIceConnectionReceivingChange(boolean receiving);
Peter Thatcher54360512015-07-08 11:08:35 -0700111
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000112 /** Triggered when the IceGatheringState changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100113 @CalledByNative("Observer") void onIceGatheringChange(IceGatheringState newState);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000114
115 /** Triggered when a new ICE candidate has been found. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100116 @CalledByNative("Observer") void onIceCandidate(IceCandidate candidate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000117
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700118 /** Triggered when some ICE candidates have been removed. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100119 @CalledByNative("Observer") void onIceCandidatesRemoved(IceCandidate[] candidates);
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700120
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000121 /** Triggered when media is received on a new stream from remote peer. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100122 @CalledByNative("Observer") void onAddStream(MediaStream stream);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000123
124 /** Triggered when a remote peer close a stream. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100125 @CalledByNative("Observer") void onRemoveStream(MediaStream stream);
henrike@webrtc.org723d6832013-07-12 16:04:50 +0000126
127 /** Triggered when a remote peer opens a DataChannel. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100128 @CalledByNative("Observer") void onDataChannel(DataChannel dataChannel);
fischman@webrtc.orgd7568a02014-01-13 22:04:12 +0000129
130 /** Triggered when renegotiation is necessary. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100131 @CalledByNative("Observer") void onRenegotiationNeeded();
zhihuangdcccda72016-12-21 14:08:03 -0800132
133 /**
134 * Triggered when a new track is signaled by the remote peer, as a result of
135 * setRemoteDescription.
136 */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100137 @CalledByNative("Observer") void onAddTrack(RtpReceiver receiver, MediaStream[] mediaStreams);
Seth Hampson31dbc242018-05-07 09:28:19 -0700138
139 /**
140 * Triggered when the signaling from SetRemoteDescription indicates that a transceiver
141 * will be receiving media from a remote endpoint. This is only called if UNIFIED_PLAN
142 * semantics are specified. The transceiver will be disposed automatically.
143 */
144 @CalledByNative("Observer") default void onTrack(RtpTransceiver transceiver){};
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000145 }
146
147 /** Java version of PeerConnectionInterface.IceServer. */
148 public static class IceServer {
Emad Omaradab1d2d2017-06-16 15:43:11 -0700149 // List of URIs associated with this server. Valid formats are described
150 // in RFC7064 and RFC7065, and more may be added in the future. The "host"
151 // part of the URI may contain either an IP address or a hostname.
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700152 @Deprecated public final String uri;
153 public final List<String> urls;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000154 public final String username;
155 public final String password;
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000156 public final TlsCertPolicy tlsCertPolicy;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000157
Emad Omaradab1d2d2017-06-16 15:43:11 -0700158 // If the URIs in |urls| only contain IP addresses, this field can be used
159 // to indicate the hostname, which may be necessary for TLS (using the SNI
160 // extension). If |urls| itself contains the hostname, this isn't
161 // necessary.
162 public final String hostname;
163
Diogo Real1dca9d52017-08-29 12:18:32 -0700164 // List of protocols to be used in the TLS ALPN extension.
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000165 public final List<String> tlsAlpnProtocols;
Diogo Real1dca9d52017-08-29 12:18:32 -0700166
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700167 // List of elliptic curves to be used in the TLS elliptic curves extension.
168 // Only curve names supported by OpenSSL should be used (eg. "P-256","X25519").
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000169 public final List<String> tlsEllipticCurves;
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700170
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000171 /** Convenience constructor for STUN servers. */
Diogo Real05ea2b32017-08-31 00:12:58 -0700172 @Deprecated
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000173 public IceServer(String uri) {
174 this(uri, "", "");
175 }
176
Diogo Real05ea2b32017-08-31 00:12:58 -0700177 @Deprecated
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000178 public IceServer(String uri, String username, String password) {
hnsl04833622017-01-09 08:35:45 -0800179 this(uri, username, password, TlsCertPolicy.TLS_CERT_POLICY_SECURE);
180 }
181
Diogo Real05ea2b32017-08-31 00:12:58 -0700182 @Deprecated
hnsl04833622017-01-09 08:35:45 -0800183 public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy) {
Emad Omaradab1d2d2017-06-16 15:43:11 -0700184 this(uri, username, password, tlsCertPolicy, "");
185 }
186
Diogo Real05ea2b32017-08-31 00:12:58 -0700187 @Deprecated
Emad Omaradab1d2d2017-06-16 15:43:11 -0700188 public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy,
189 String hostname) {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700190 this(uri, Collections.singletonList(uri), username, password, tlsCertPolicy, hostname, null,
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000191 null);
Diogo Real1dca9d52017-08-29 12:18:32 -0700192 }
193
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700194 private IceServer(String uri, List<String> urls, String username, String password,
195 TlsCertPolicy tlsCertPolicy, String hostname, List<String> tlsAlpnProtocols,
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000196 List<String> tlsEllipticCurves) {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700197 if (uri == null || urls == null || urls.isEmpty()) {
198 throw new IllegalArgumentException("uri == null || urls == null || urls.isEmpty()");
199 }
200 for (String it : urls) {
201 if (it == null) {
202 throw new IllegalArgumentException("urls element is null: " + urls);
203 }
204 }
205 if (username == null) {
206 throw new IllegalArgumentException("username == null");
207 }
208 if (password == null) {
209 throw new IllegalArgumentException("password == null");
210 }
211 if (hostname == null) {
212 throw new IllegalArgumentException("hostname == null");
213 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000214 this.uri = uri;
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700215 this.urls = urls;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000216 this.username = username;
217 this.password = password;
hnsl04833622017-01-09 08:35:45 -0800218 this.tlsCertPolicy = tlsCertPolicy;
Emad Omaradab1d2d2017-06-16 15:43:11 -0700219 this.hostname = hostname;
Diogo Real1dca9d52017-08-29 12:18:32 -0700220 this.tlsAlpnProtocols = tlsAlpnProtocols;
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700221 this.tlsEllipticCurves = tlsEllipticCurves;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000222 }
223
Sami Kalliomäkibde473e2017-10-30 13:34:41 +0100224 @Override
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000225 public String toString() {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700226 return urls + " [" + username + ":" + password + "] [" + tlsCertPolicy + "] [" + hostname
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000227 + "] [" + tlsAlpnProtocols + "] [" + tlsEllipticCurves + "]";
Diogo Real1dca9d52017-08-29 12:18:32 -0700228 }
229
Qingsi Wanga0d45802019-01-15 13:33:11 -0800230 @Override
231 public boolean equals(@Nullable Object obj) {
232 if (obj == null) {
233 return false;
234 }
235 if (obj == this) {
236 return true;
237 }
238 if (!(obj instanceof IceServer)) {
239 return false;
240 }
241 IceServer other = (IceServer) obj;
242 return (uri.equals(other.uri) && urls.equals(other.urls) && username.equals(other.username)
243 && password.equals(other.password) && tlsCertPolicy.equals(other.tlsCertPolicy)
244 && hostname.equals(other.hostname) && tlsAlpnProtocols.equals(other.tlsAlpnProtocols)
245 && tlsEllipticCurves.equals(other.tlsEllipticCurves));
246 }
247
248 @Override
249 public int hashCode() {
250 Object[] values = {uri, urls, username, password, tlsCertPolicy, hostname, tlsAlpnProtocols,
251 tlsEllipticCurves};
252 return Arrays.hashCode(values);
253 }
254
Diogo Real1dca9d52017-08-29 12:18:32 -0700255 public static Builder builder(String uri) {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700256 return new Builder(Collections.singletonList(uri));
257 }
258
259 public static Builder builder(List<String> urls) {
260 return new Builder(urls);
Diogo Real1dca9d52017-08-29 12:18:32 -0700261 }
262
263 public static class Builder {
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100264 @Nullable private final List<String> urls;
Diogo Real1dca9d52017-08-29 12:18:32 -0700265 private String username = "";
266 private String password = "";
267 private TlsCertPolicy tlsCertPolicy = TlsCertPolicy.TLS_CERT_POLICY_SECURE;
268 private String hostname = "";
269 private List<String> tlsAlpnProtocols;
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700270 private List<String> tlsEllipticCurves;
Diogo Real1dca9d52017-08-29 12:18:32 -0700271
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700272 private Builder(List<String> urls) {
273 if (urls == null || urls.isEmpty()) {
274 throw new IllegalArgumentException("urls == null || urls.isEmpty(): " + urls);
275 }
276 this.urls = urls;
Diogo Real1dca9d52017-08-29 12:18:32 -0700277 }
278
279 public Builder setUsername(String username) {
280 this.username = username;
281 return this;
282 }
283
284 public Builder setPassword(String password) {
285 this.password = password;
286 return this;
287 }
288
289 public Builder setTlsCertPolicy(TlsCertPolicy tlsCertPolicy) {
290 this.tlsCertPolicy = tlsCertPolicy;
291 return this;
292 }
293
294 public Builder setHostname(String hostname) {
295 this.hostname = hostname;
296 return this;
297 }
298
299 public Builder setTlsAlpnProtocols(List<String> tlsAlpnProtocols) {
300 this.tlsAlpnProtocols = tlsAlpnProtocols;
301 return this;
302 }
303
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700304 public Builder setTlsEllipticCurves(List<String> tlsEllipticCurves) {
305 this.tlsEllipticCurves = tlsEllipticCurves;
306 return this;
307 }
308
Diogo Real1dca9d52017-08-29 12:18:32 -0700309 public IceServer createIceServer() {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700310 return new IceServer(urls.get(0), urls, username, password, tlsCertPolicy, hostname,
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000311 tlsAlpnProtocols, tlsEllipticCurves);
Diogo Real1dca9d52017-08-29 12:18:32 -0700312 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000313 }
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100314
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100315 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100316 @CalledByNative("IceServer")
317 List<String> getUrls() {
318 return urls;
319 }
320
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100321 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100322 @CalledByNative("IceServer")
323 String getUsername() {
324 return username;
325 }
326
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100327 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100328 @CalledByNative("IceServer")
329 String getPassword() {
330 return password;
331 }
332
333 @CalledByNative("IceServer")
334 TlsCertPolicy getTlsCertPolicy() {
335 return tlsCertPolicy;
336 }
337
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100338 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100339 @CalledByNative("IceServer")
340 String getHostname() {
341 return hostname;
342 }
343
344 @CalledByNative("IceServer")
345 List<String> getTlsAlpnProtocols() {
346 return tlsAlpnProtocols;
347 }
348
349 @CalledByNative("IceServer")
350 List<String> getTlsEllipticCurves() {
351 return tlsEllipticCurves;
352 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000353 }
354
Jiayang Liucac1b382015-04-30 12:35:24 -0700355 /** Java version of PeerConnectionInterface.IceTransportsType */
sakalb6760f92016-09-29 04:12:44 -0700356 public enum IceTransportsType { NONE, RELAY, NOHOST, ALL }
Jiayang Liucac1b382015-04-30 12:35:24 -0700357
358 /** Java version of PeerConnectionInterface.BundlePolicy */
sakalb6760f92016-09-29 04:12:44 -0700359 public enum BundlePolicy { BALANCED, MAXBUNDLE, MAXCOMPAT }
Jiayang Liucac1b382015-04-30 12:35:24 -0700360
Peter Thatcheraf55ccc2015-05-21 07:48:41 -0700361 /** Java version of PeerConnectionInterface.RtcpMuxPolicy */
sakalb6760f92016-09-29 04:12:44 -0700362 public enum RtcpMuxPolicy { NEGOTIATE, REQUIRE }
glaznev97579a42015-09-01 11:31:27 -0700363
Peter Thatcheraf55ccc2015-05-21 07:48:41 -0700364 /** Java version of PeerConnectionInterface.TcpCandidatePolicy */
sakalb6760f92016-09-29 04:12:44 -0700365 public enum TcpCandidatePolicy { ENABLED, DISABLED }
Jiayang Liucac1b382015-04-30 12:35:24 -0700366
honghaiz60347052016-05-31 18:29:12 -0700367 /** Java version of PeerConnectionInterface.CandidateNetworkPolicy */
sakalb6760f92016-09-29 04:12:44 -0700368 public enum CandidateNetworkPolicy { ALL, LOW_COST }
honghaiz60347052016-05-31 18:29:12 -0700369
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800370 // Keep in sync with webrtc/rtc_base/network_constants.h.
371 public enum AdapterType {
372 UNKNOWN,
373 ETHERNET,
374 WIFI,
375 CELLULAR,
376 VPN,
377 LOOPBACK,
378 }
379
glaznev97579a42015-09-01 11:31:27 -0700380 /** Java version of rtc::KeyType */
sakalb6760f92016-09-29 04:12:44 -0700381 public enum KeyType { RSA, ECDSA }
glaznev97579a42015-09-01 11:31:27 -0700382
honghaiz1f429e32015-09-28 07:57:34 -0700383 /** Java version of PeerConnectionInterface.ContinualGatheringPolicy */
sakalb6760f92016-09-29 04:12:44 -0700384 public enum ContinualGatheringPolicy { GATHER_ONCE, GATHER_CONTINUALLY }
honghaiz1f429e32015-09-28 07:57:34 -0700385
Steve Antond960a0c2017-07-17 12:33:07 -0700386 /** Java version of rtc::IntervalRange */
387 public static class IntervalRange {
388 private final int min;
389 private final int max;
390
391 public IntervalRange(int min, int max) {
392 this.min = min;
393 this.max = max;
394 }
395
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100396 @CalledByNative("IntervalRange")
Steve Antond960a0c2017-07-17 12:33:07 -0700397 public int getMin() {
398 return min;
399 }
400
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100401 @CalledByNative("IntervalRange")
Steve Antond960a0c2017-07-17 12:33:07 -0700402 public int getMax() {
403 return max;
404 }
405 }
406
Seth Hampsonc384e142018-03-06 15:47:10 -0800407 /**
408 * Java version of webrtc::SdpSemantics.
409 *
410 * Configure the SDP semantics used by this PeerConnection. Note that the
411 * WebRTC 1.0 specification requires UNIFIED_PLAN semantics. The
412 * RtpTransceiver API is only available with UNIFIED_PLAN semantics.
413 *
414 * <p>PLAN_B will cause PeerConnection to create offers and answers with at
415 * most one audio and one video m= section with multiple RtpSenders and
416 * RtpReceivers specified as multiple a=ssrc lines within the section. This
417 * will also cause PeerConnection to ignore all but the first m= section of
418 * the same media type.
419 *
420 * <p>UNIFIED_PLAN will cause PeerConnection to create offers and answers with
421 * multiple m= sections where each m= section maps to one RtpSender and one
422 * RtpReceiver (an RtpTransceiver), either both audio or both video. This
423 * will also cause PeerConnection to ignore all but the first a=ssrc lines
424 * that form a Plan B stream.
425 *
426 * <p>For users who wish to send multiple audio/video streams and need to stay
427 * interoperable with legacy WebRTC implementations, specify PLAN_B.
428 *
429 * <p>For users who wish to send multiple audio/video streams and/or wish to
430 * use the new RtpTransceiver API, specify UNIFIED_PLAN.
431 */
432 public enum SdpSemantics { PLAN_B, UNIFIED_PLAN }
433
Jiayang Liucac1b382015-04-30 12:35:24 -0700434 /** Java version of PeerConnectionInterface.RTCConfiguration */
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800435 // TODO(qingsi): Resolve the naming inconsistency of fields with/without units.
Jiayang Liucac1b382015-04-30 12:35:24 -0700436 public static class RTCConfiguration {
437 public IceTransportsType iceTransportsType;
438 public List<IceServer> iceServers;
439 public BundlePolicy bundlePolicy;
Michael Iedema02137862018-10-09 15:30:01 +0200440 @Nullable public RtcCertificatePem certificate;
Peter Thatcheraf55ccc2015-05-21 07:48:41 -0700441 public RtcpMuxPolicy rtcpMuxPolicy;
Jiayang Liucac1b382015-04-30 12:35:24 -0700442 public TcpCandidatePolicy tcpCandidatePolicy;
honghaiz60347052016-05-31 18:29:12 -0700443 public CandidateNetworkPolicy candidateNetworkPolicy;
Henrik Lundin64dad832015-05-11 12:44:23 +0200444 public int audioJitterBufferMaxPackets;
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200445 public boolean audioJitterBufferFastAccelerate;
honghaiz4edc39c2015-09-01 09:53:56 -0700446 public int iceConnectionReceivingTimeout;
Honghai Zhang381b4212015-12-04 12:24:03 -0800447 public int iceBackupCandidatePairPingInterval;
glaznev97579a42015-09-01 11:31:27 -0700448 public KeyType keyType;
honghaiz1f429e32015-09-28 07:57:34 -0700449 public ContinualGatheringPolicy continualGatheringPolicy;
deadbeefbe0c96f2016-05-18 16:20:14 -0700450 public int iceCandidatePoolSize;
Honghai Zhangd78ecf72016-07-01 14:40:40 -0700451 public boolean pruneTurnPorts;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700452 public boolean presumeWritableWhenFullyRelayed;
Qingsi Wang1fe119f2019-05-31 16:55:33 -0700453 public boolean surfaceIceCandidatesOnIceTransportTypeChanged;
Qingsi Wange6826d22018-03-08 14:55:14 -0800454 // The following fields define intervals in milliseconds at which ICE
455 // connectivity checks are sent.
456 //
457 // We consider ICE is "strongly connected" for an agent when there is at
458 // least one candidate pair that currently succeeds in connectivity check
459 // from its direction i.e. sending a ping and receives a ping response, AND
460 // all candidate pairs have sent a minimum number of pings for connectivity
461 // (this number is implementation-specific). Otherwise, ICE is considered in
462 // "weak connectivity".
463 //
464 // Note that the above notion of strong and weak connectivity is not defined
465 // in RFC 5245, and they apply to our current ICE implementation only.
466 //
467 // 1) iceCheckIntervalStrongConnectivityMs defines the interval applied to
468 // ALL candidate pairs when ICE is strongly connected,
469 // 2) iceCheckIntervalWeakConnectivityMs defines the counterpart for ALL
470 // pairs when ICE is weakly connected, and
471 // 3) iceCheckMinInterval defines the minimal interval (equivalently the
472 // maximum rate) that overrides the above two intervals when either of them
473 // is less.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100474 @Nullable public Integer iceCheckIntervalStrongConnectivityMs;
475 @Nullable public Integer iceCheckIntervalWeakConnectivityMs;
476 @Nullable public Integer iceCheckMinInterval;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700477 // The time period in milliseconds for which a candidate pair must wait for response to
478 // connectivitiy checks before it becomes unwritable.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100479 @Nullable public Integer iceUnwritableTimeMs;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700480 // The minimum number of connectivity checks that a candidate pair must sent without receiving
481 // response before it becomes unwritable.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100482 @Nullable public Integer iceUnwritableMinChecks;
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800483 // The interval in milliseconds at which STUN candidates will resend STUN binding requests
484 // to keep NAT bindings open.
485 // The default value in the implementation is used if this field is null.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100486 @Nullable public Integer stunCandidateKeepaliveIntervalMs;
zhihuangb09b3f92017-03-07 14:40:51 -0800487 public boolean disableIPv6OnWifi;
deadbeef28e29192017-07-27 09:14:38 -0700488 // By default, PeerConnection will use a limited number of IPv6 network
489 // interfaces, in order to avoid too many ICE candidate pairs being created
490 // and delaying ICE completion.
491 //
492 // Can be set to Integer.MAX_VALUE to effectively disable the limit.
493 public int maxIPv6Networks;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100494 @Nullable public IntervalRange iceRegatherIntervalRange;
Jiayang Liucac1b382015-04-30 12:35:24 -0700495
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100496 // These values will be overridden by MediaStream constraints if deprecated constraints-based
497 // create peerconnection interface is used.
498 public boolean disableIpv6;
499 public boolean enableDscp;
500 public boolean enableCpuOveruseDetection;
501 public boolean enableRtpDataChannel;
502 public boolean suspendBelowMinBitrate;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100503 @Nullable public Integer screencastMinBitrate;
504 @Nullable public Boolean combinedAudioVideoBwe;
505 @Nullable public Boolean enableDtlsSrtp;
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800506 // Use "Unknown" to represent no preference of adapter types, not the
507 // preference of adapters of unknown types.
508 public AdapterType networkPreference;
Seth Hampsonc384e142018-03-06 15:47:10 -0800509 public SdpSemantics sdpSemantics;
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100510
Jonas Orelandbdcee282017-10-10 14:01:40 +0200511 // This is an optional wrapper for the C++ webrtc::TurnCustomizer.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100512 @Nullable public TurnCustomizer turnCustomizer;
Jonas Orelandbdcee282017-10-10 14:01:40 +0200513
Zhi Huangb57e1692018-06-12 11:41:11 -0700514 // Actively reset the SRTP parameters whenever the DTLS transports underneath are reset for
515 // every offer/answer negotiation.This is only intended to be a workaround for crbug.com/835958
516 public boolean activeResetSrtpParams;
517
Piotr (Peter) Slatala09beff22018-10-17 07:22:40 -0700518 /*
519 * Experimental flag that enables a use of media transport. If this is true, the media transport
520 * factory MUST be provided to the PeerConnectionFactory.
521 */
522 public boolean useMediaTransport;
523
Bjorn Mellema9bbd862018-11-02 09:07:48 -0700524 /*
525 * Experimental flag that enables a use of media transport for data channels. If this is true,
526 * the media transport factory MUST be provided to the PeerConnectionFactory.
527 */
528 public boolean useMediaTransportForDataChannels;
529
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700530 /**
531 * Defines advanced optional cryptographic settings related to SRTP and
532 * frame encryption for native WebRTC. Setting this will overwrite any
533 * options set through the PeerConnectionFactory (which is deprecated).
534 */
535 @Nullable public CryptoOptions cryptoOptions;
536
deadbeef28e29192017-07-27 09:14:38 -0700537 // TODO(deadbeef): Instead of duplicating the defaults here, we should do
538 // something to pick up the defaults from C++. The Objective-C equivalent
539 // of RTCConfiguration does that.
Jiayang Liucac1b382015-04-30 12:35:24 -0700540 public RTCConfiguration(List<IceServer> iceServers) {
541 iceTransportsType = IceTransportsType.ALL;
542 bundlePolicy = BundlePolicy.BALANCED;
zhihuang4dfb8ce2016-11-23 10:30:12 -0800543 rtcpMuxPolicy = RtcpMuxPolicy.REQUIRE;
Jiayang Liucac1b382015-04-30 12:35:24 -0700544 tcpCandidatePolicy = TcpCandidatePolicy.ENABLED;
Sami Kalliomäki9828beb2017-10-26 16:21:22 +0200545 candidateNetworkPolicy = CandidateNetworkPolicy.ALL;
Jiayang Liucac1b382015-04-30 12:35:24 -0700546 this.iceServers = iceServers;
Henrik Lundin64dad832015-05-11 12:44:23 +0200547 audioJitterBufferMaxPackets = 50;
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200548 audioJitterBufferFastAccelerate = false;
honghaiz4edc39c2015-09-01 09:53:56 -0700549 iceConnectionReceivingTimeout = -1;
Honghai Zhang381b4212015-12-04 12:24:03 -0800550 iceBackupCandidatePairPingInterval = -1;
glaznev97579a42015-09-01 11:31:27 -0700551 keyType = KeyType.ECDSA;
honghaiz1f429e32015-09-28 07:57:34 -0700552 continualGatheringPolicy = ContinualGatheringPolicy.GATHER_ONCE;
deadbeefbe0c96f2016-05-18 16:20:14 -0700553 iceCandidatePoolSize = 0;
Honghai Zhangd78ecf72016-07-01 14:40:40 -0700554 pruneTurnPorts = false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700555 presumeWritableWhenFullyRelayed = false;
Qingsi Wang1fe119f2019-05-31 16:55:33 -0700556 surfaceIceCandidatesOnIceTransportTypeChanged = false;
Qingsi Wange6826d22018-03-08 14:55:14 -0800557 iceCheckIntervalStrongConnectivityMs = null;
558 iceCheckIntervalWeakConnectivityMs = null;
skvlad51072462017-02-02 11:50:14 -0800559 iceCheckMinInterval = null;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700560 iceUnwritableTimeMs = null;
561 iceUnwritableMinChecks = null;
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800562 stunCandidateKeepaliveIntervalMs = null;
zhihuangb09b3f92017-03-07 14:40:51 -0800563 disableIPv6OnWifi = false;
deadbeef28e29192017-07-27 09:14:38 -0700564 maxIPv6Networks = 5;
Steve Antond960a0c2017-07-17 12:33:07 -0700565 iceRegatherIntervalRange = null;
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100566 disableIpv6 = false;
567 enableDscp = false;
568 enableCpuOveruseDetection = true;
569 enableRtpDataChannel = false;
570 suspendBelowMinBitrate = false;
571 screencastMinBitrate = null;
572 combinedAudioVideoBwe = null;
573 enableDtlsSrtp = null;
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800574 networkPreference = AdapterType.UNKNOWN;
Seth Hampsonc384e142018-03-06 15:47:10 -0800575 sdpSemantics = SdpSemantics.PLAN_B;
Zhi Huangb57e1692018-06-12 11:41:11 -0700576 activeResetSrtpParams = false;
Piotr (Peter) Slatala09beff22018-10-17 07:22:40 -0700577 useMediaTransport = false;
Bjorn Mellema9bbd862018-11-02 09:07:48 -0700578 useMediaTransportForDataChannels = false;
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700579 cryptoOptions = null;
Jiayang Liucac1b382015-04-30 12:35:24 -0700580 }
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100581
582 @CalledByNative("RTCConfiguration")
583 IceTransportsType getIceTransportsType() {
584 return iceTransportsType;
585 }
586
587 @CalledByNative("RTCConfiguration")
588 List<IceServer> getIceServers() {
589 return iceServers;
590 }
591
592 @CalledByNative("RTCConfiguration")
593 BundlePolicy getBundlePolicy() {
594 return bundlePolicy;
595 }
596
Michael Iedema02137862018-10-09 15:30:01 +0200597 @Nullable
598 @CalledByNative("RTCConfiguration")
599 RtcCertificatePem getCertificate() {
600 return certificate;
601 }
602
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100603 @CalledByNative("RTCConfiguration")
604 RtcpMuxPolicy getRtcpMuxPolicy() {
605 return rtcpMuxPolicy;
606 }
607
608 @CalledByNative("RTCConfiguration")
609 TcpCandidatePolicy getTcpCandidatePolicy() {
610 return tcpCandidatePolicy;
611 }
612
613 @CalledByNative("RTCConfiguration")
614 CandidateNetworkPolicy getCandidateNetworkPolicy() {
615 return candidateNetworkPolicy;
616 }
617
618 @CalledByNative("RTCConfiguration")
619 int getAudioJitterBufferMaxPackets() {
620 return audioJitterBufferMaxPackets;
621 }
622
623 @CalledByNative("RTCConfiguration")
624 boolean getAudioJitterBufferFastAccelerate() {
625 return audioJitterBufferFastAccelerate;
626 }
627
628 @CalledByNative("RTCConfiguration")
629 int getIceConnectionReceivingTimeout() {
630 return iceConnectionReceivingTimeout;
631 }
632
633 @CalledByNative("RTCConfiguration")
634 int getIceBackupCandidatePairPingInterval() {
635 return iceBackupCandidatePairPingInterval;
636 }
637
638 @CalledByNative("RTCConfiguration")
639 KeyType getKeyType() {
640 return keyType;
641 }
642
643 @CalledByNative("RTCConfiguration")
644 ContinualGatheringPolicy getContinualGatheringPolicy() {
645 return continualGatheringPolicy;
646 }
647
648 @CalledByNative("RTCConfiguration")
649 int getIceCandidatePoolSize() {
650 return iceCandidatePoolSize;
651 }
652
653 @CalledByNative("RTCConfiguration")
654 boolean getPruneTurnPorts() {
655 return pruneTurnPorts;
656 }
657
658 @CalledByNative("RTCConfiguration")
659 boolean getPresumeWritableWhenFullyRelayed() {
660 return presumeWritableWhenFullyRelayed;
661 }
662
Qingsi Wang1fe119f2019-05-31 16:55:33 -0700663 @CalledByNative("RTCConfiguration")
664 boolean getSurfaceIceCandidatesOnIceTransportTypeChanged() {
665 return surfaceIceCandidatesOnIceTransportTypeChanged;
666 }
667
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100668 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100669 @CalledByNative("RTCConfiguration")
Qingsi Wange6826d22018-03-08 14:55:14 -0800670 Integer getIceCheckIntervalStrongConnectivity() {
671 return iceCheckIntervalStrongConnectivityMs;
672 }
673
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100674 @Nullable
Qingsi Wange6826d22018-03-08 14:55:14 -0800675 @CalledByNative("RTCConfiguration")
676 Integer getIceCheckIntervalWeakConnectivity() {
677 return iceCheckIntervalWeakConnectivityMs;
678 }
679
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100680 @Nullable
Qingsi Wange6826d22018-03-08 14:55:14 -0800681 @CalledByNative("RTCConfiguration")
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100682 Integer getIceCheckMinInterval() {
683 return iceCheckMinInterval;
684 }
685
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100686 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100687 @CalledByNative("RTCConfiguration")
Qingsi Wang22e623a2018-03-13 10:53:57 -0700688 Integer getIceUnwritableTimeout() {
689 return iceUnwritableTimeMs;
690 }
691
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100692 @Nullable
Qingsi Wang22e623a2018-03-13 10:53:57 -0700693 @CalledByNative("RTCConfiguration")
694 Integer getIceUnwritableMinChecks() {
695 return iceUnwritableMinChecks;
696 }
697
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100698 @Nullable
Qingsi Wang22e623a2018-03-13 10:53:57 -0700699 @CalledByNative("RTCConfiguration")
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800700 Integer getStunCandidateKeepaliveInterval() {
701 return stunCandidateKeepaliveIntervalMs;
702 }
703
704 @CalledByNative("RTCConfiguration")
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100705 boolean getDisableIPv6OnWifi() {
706 return disableIPv6OnWifi;
707 }
708
709 @CalledByNative("RTCConfiguration")
710 int getMaxIPv6Networks() {
711 return maxIPv6Networks;
712 }
713
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100714 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100715 @CalledByNative("RTCConfiguration")
716 IntervalRange getIceRegatherIntervalRange() {
717 return iceRegatherIntervalRange;
718 }
719
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100720 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100721 @CalledByNative("RTCConfiguration")
722 TurnCustomizer getTurnCustomizer() {
723 return turnCustomizer;
724 }
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100725
726 @CalledByNative("RTCConfiguration")
727 boolean getDisableIpv6() {
728 return disableIpv6;
729 }
730
731 @CalledByNative("RTCConfiguration")
732 boolean getEnableDscp() {
733 return enableDscp;
734 }
735
736 @CalledByNative("RTCConfiguration")
737 boolean getEnableCpuOveruseDetection() {
738 return enableCpuOveruseDetection;
739 }
740
741 @CalledByNative("RTCConfiguration")
742 boolean getEnableRtpDataChannel() {
743 return enableRtpDataChannel;
744 }
745
746 @CalledByNative("RTCConfiguration")
747 boolean getSuspendBelowMinBitrate() {
748 return suspendBelowMinBitrate;
749 }
750
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100751 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100752 @CalledByNative("RTCConfiguration")
753 Integer getScreencastMinBitrate() {
754 return screencastMinBitrate;
755 }
756
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100757 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100758 @CalledByNative("RTCConfiguration")
759 Boolean getCombinedAudioVideoBwe() {
760 return combinedAudioVideoBwe;
761 }
762
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100763 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100764 @CalledByNative("RTCConfiguration")
765 Boolean getEnableDtlsSrtp() {
766 return enableDtlsSrtp;
767 }
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800768
769 @CalledByNative("RTCConfiguration")
770 AdapterType getNetworkPreference() {
771 return networkPreference;
772 }
Seth Hampsonc384e142018-03-06 15:47:10 -0800773
774 @CalledByNative("RTCConfiguration")
775 SdpSemantics getSdpSemantics() {
776 return sdpSemantics;
777 }
Zhi Huangb57e1692018-06-12 11:41:11 -0700778
779 @CalledByNative("RTCConfiguration")
780 boolean getActiveResetSrtpParams() {
781 return activeResetSrtpParams;
782 }
Piotr (Peter) Slatala09beff22018-10-17 07:22:40 -0700783
784 @CalledByNative("RTCConfiguration")
785 boolean getUseMediaTransport() {
786 return useMediaTransport;
787 }
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700788
Bjorn Mellema9bbd862018-11-02 09:07:48 -0700789 @CalledByNative("RTCConfiguration")
790 boolean getUseMediaTransportForDataChannels() {
791 return useMediaTransportForDataChannels;
792 }
793
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700794 @Nullable
795 @CalledByNative("RTCConfiguration")
796 CryptoOptions getCryptoOptions() {
797 return cryptoOptions;
798 }
Jiayang Liucac1b382015-04-30 12:35:24 -0700799 };
800
Magnus Jedvert6062f372017-11-16 16:53:12 +0100801 private final List<MediaStream> localStreams = new ArrayList<>();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000802 private final long nativePeerConnection;
Magnus Jedvert6062f372017-11-16 16:53:12 +0100803 private List<RtpSender> senders = new ArrayList<>();
804 private List<RtpReceiver> receivers = new ArrayList<>();
Seth Hampsonc384e142018-03-06 15:47:10 -0800805 private List<RtpTransceiver> transceivers = new ArrayList<>();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000806
Sami Kalliomäki1ece1ed2017-12-20 11:59:22 +0100807 /**
808 * Wraps a PeerConnection created by the factory. Can be used by clients that want to implement
809 * their PeerConnection creation in JNI.
810 */
811 public PeerConnection(NativePeerConnectionFactory factory) {
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100812 this(factory.createNativePeerConnection());
Sami Kalliomäki1ece1ed2017-12-20 11:59:22 +0100813 }
814
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100815 PeerConnection(long nativePeerConnection) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000816 this.nativePeerConnection = nativePeerConnection;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000817 }
818
819 // JsepInterface.
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100820 public SessionDescription getLocalDescription() {
821 return nativeGetLocalDescription();
822 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000823
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100824 public SessionDescription getRemoteDescription() {
825 return nativeGetRemoteDescription();
826 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000827
Michael Iedema02137862018-10-09 15:30:01 +0200828 public RtcCertificatePem getCertificate() {
829 return nativeGetCertificate();
830 }
831
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100832 public DataChannel createDataChannel(String label, DataChannel.Init init) {
833 return nativeCreateDataChannel(label, init);
834 }
henrike@webrtc.org723d6832013-07-12 16:04:50 +0000835
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100836 public void createOffer(SdpObserver observer, MediaConstraints constraints) {
837 nativeCreateOffer(observer, constraints);
838 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000839
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100840 public void createAnswer(SdpObserver observer, MediaConstraints constraints) {
841 nativeCreateAnswer(observer, constraints);
842 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000843
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100844 public void setLocalDescription(SdpObserver observer, SessionDescription sdp) {
845 nativeSetLocalDescription(observer, sdp);
846 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000847
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100848 public void setRemoteDescription(SdpObserver observer, SessionDescription sdp) {
849 nativeSetRemoteDescription(observer, sdp);
850 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000851
Seth Hampsonc384e142018-03-06 15:47:10 -0800852 /**
853 * Enables/disables playout of received audio streams. Enabled by default.
854 *
855 * Note that even if playout is enabled, streams will only be played out if
856 * the appropriate SDP is also applied. The main purpose of this API is to
857 * be able to control the exact time when audio playout starts.
858 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100859 public void setAudioPlayout(boolean playout) {
860 nativeSetAudioPlayout(playout);
861 }
henrika5f6bf242017-11-01 11:06:56 +0100862
Seth Hampsonc384e142018-03-06 15:47:10 -0800863 /**
864 * Enables/disables recording of transmitted audio streams. Enabled by default.
865 *
866 * Note that even if recording is enabled, streams will only be recorded if
867 * the appropriate SDP is also applied. The main purpose of this API is to
868 * be able to control the exact time when audio recording starts.
869 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100870 public void setAudioRecording(boolean recording) {
871 nativeSetAudioRecording(recording);
872 }
henrika5f6bf242017-11-01 11:06:56 +0100873
deadbeef5d0b6d82017-01-09 16:05:28 -0800874 public boolean setConfiguration(RTCConfiguration config) {
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100875 return nativeSetConfiguration(config);
deadbeef5d0b6d82017-01-09 16:05:28 -0800876 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000877
878 public boolean addIceCandidate(IceCandidate candidate) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100879 return nativeAddIceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000880 }
881
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700882 public boolean removeIceCandidates(final IceCandidate[] candidates) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100883 return nativeRemoveIceCandidates(candidates);
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700884 }
885
Seth Hampsonc384e142018-03-06 15:47:10 -0800886 /**
887 * Adds a new MediaStream to be sent on this peer connection.
888 * Note: This method is not supported with SdpSemantics.UNIFIED_PLAN. Please
889 * use addTrack instead.
890 */
perkj@webrtc.orgc2dd5ee2014-11-04 11:31:29 +0000891 public boolean addStream(MediaStream stream) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +0200892 boolean ret = nativeAddLocalStream(stream.getNativeMediaStream());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000893 if (!ret) {
894 return false;
895 }
896 localStreams.add(stream);
897 return true;
898 }
899
Seth Hampsonc384e142018-03-06 15:47:10 -0800900 /**
901 * Removes the given media stream from this peer connection.
902 * This method is not supported with SdpSemantics.UNIFIED_PLAN. Please use
903 * removeTrack instead.
904 */
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000905 public void removeStream(MediaStream stream) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +0200906 nativeRemoveLocalStream(stream.getNativeMediaStream());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000907 localStreams.remove(stream);
908 }
909
deadbeef7a246882017-08-09 08:40:10 -0700910 /**
911 * Creates an RtpSender without a track.
Seth Hampsonc384e142018-03-06 15:47:10 -0800912 *
913 * <p>This method allows an application to cause the PeerConnection to negotiate
deadbeef7a246882017-08-09 08:40:10 -0700914 * sending/receiving a specific media type, but without having a track to
915 * send yet.
Seth Hampsonc384e142018-03-06 15:47:10 -0800916 *
917 * <p>When the application does want to begin sending a track, it can call
deadbeef7a246882017-08-09 08:40:10 -0700918 * RtpSender.setTrack, which doesn't require any additional SDP negotiation.
Seth Hampsonc384e142018-03-06 15:47:10 -0800919 *
920 * <p>Example use:
deadbeef7a246882017-08-09 08:40:10 -0700921 * <pre>
922 * {@code
923 * audioSender = pc.createSender("audio", "stream1");
924 * videoSender = pc.createSender("video", "stream1");
925 * // Do normal SDP offer/answer, which will kick off ICE/DTLS and negotiate
926 * // media parameters....
927 * // Later, when the endpoint is ready to actually begin sending:
928 * audioSender.setTrack(audioTrack, false);
929 * videoSender.setTrack(videoTrack, false);
930 * }
931 * </pre>
Seth Hampsonc384e142018-03-06 15:47:10 -0800932 * <p>Note: This corresponds most closely to "addTransceiver" in the official
deadbeef7a246882017-08-09 08:40:10 -0700933 * WebRTC API, in that it creates a sender without a track. It was
934 * implemented before addTransceiver because it provides useful
935 * functionality, and properly implementing transceivers would have required
936 * a great deal more work.
937 *
Seth Hampsonc384e142018-03-06 15:47:10 -0800938 * <p>Note: This is only available with SdpSemantics.PLAN_B specified. Please use
939 * addTransceiver instead.
940 *
deadbeef7a246882017-08-09 08:40:10 -0700941 * @param kind Corresponds to MediaStreamTrack kinds (must be "audio" or
942 * "video").
943 * @param stream_id The ID of the MediaStream that this sender's track will
944 * be associated with when SDP is applied to the remote
945 * PeerConnection. If createSender is used to create an
946 * audio and video sender that should be synchronized, they
947 * should use the same stream ID.
948 * @return A new RtpSender object if successful, or null otherwise.
949 */
deadbeefbd7d8f72015-12-18 16:58:44 -0800950 public RtpSender createSender(String kind, String stream_id) {
Seth Hampsonc384e142018-03-06 15:47:10 -0800951 RtpSender newSender = nativeCreateSender(kind, stream_id);
952 if (newSender != null) {
953 senders.add(newSender);
deadbeefee524f72015-12-02 11:27:40 -0800954 }
Seth Hampsonc384e142018-03-06 15:47:10 -0800955 return newSender;
deadbeefee524f72015-12-02 11:27:40 -0800956 }
957
Seth Hampsonc384e142018-03-06 15:47:10 -0800958 /**
959 * Gets all RtpSenders associated with this peer connection.
960 * Note that calling getSenders will dispose of the senders previously
961 * returned.
962 */
deadbeef4139c0f2015-10-06 12:29:25 -0700963 public List<RtpSender> getSenders() {
964 for (RtpSender sender : senders) {
965 sender.dispose();
966 }
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100967 senders = nativeGetSenders();
deadbeef4139c0f2015-10-06 12:29:25 -0700968 return Collections.unmodifiableList(senders);
969 }
970
Seth Hampsonc384e142018-03-06 15:47:10 -0800971 /**
972 * Gets all RtpReceivers associated with this peer connection.
973 * Note that calling getReceivers will dispose of the receivers previously
974 * returned.
975 */
deadbeef4139c0f2015-10-06 12:29:25 -0700976 public List<RtpReceiver> getReceivers() {
977 for (RtpReceiver receiver : receivers) {
978 receiver.dispose();
979 }
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100980 receivers = nativeGetReceivers();
deadbeef4139c0f2015-10-06 12:29:25 -0700981 return Collections.unmodifiableList(receivers);
982 }
983
Seth Hampsonc384e142018-03-06 15:47:10 -0800984 /**
985 * Gets all RtpTransceivers associated with this peer connection.
986 * Note that calling getTransceivers will dispose of the transceivers previously
987 * returned.
988 * Note: This is only available with SdpSemantics.UNIFIED_PLAN specified.
989 */
990 public List<RtpTransceiver> getTransceivers() {
991 for (RtpTransceiver transceiver : transceivers) {
992 transceiver.dispose();
993 }
994 transceivers = nativeGetTransceivers();
995 return Collections.unmodifiableList(transceivers);
996 }
997
998 /**
999 * Adds a new media stream track to be sent on this peer connection, and returns
1000 * the newly created RtpSender. If streamIds are specified, the RtpSender will
1001 * be associated with the streams specified in the streamIds list.
1002 *
1003 * @throws IllegalStateException if an error accors in C++ addTrack.
1004 * An error can occur if:
1005 * - A sender already exists for the track.
1006 * - The peer connection is closed.
1007 */
1008 public RtpSender addTrack(MediaStreamTrack track) {
1009 return addTrack(track, Collections.emptyList());
1010 }
1011
1012 public RtpSender addTrack(MediaStreamTrack track, List<String> streamIds) {
1013 if (track == null || streamIds == null) {
1014 throw new NullPointerException("No MediaStreamTrack specified in addTrack.");
1015 }
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001016 RtpSender newSender = nativeAddTrack(track.getNativeMediaStreamTrack(), streamIds);
Seth Hampsonc384e142018-03-06 15:47:10 -08001017 if (newSender == null) {
1018 throw new IllegalStateException("C++ addTrack failed.");
1019 }
1020 senders.add(newSender);
1021 return newSender;
1022 }
1023
1024 /**
1025 * Stops sending media from sender. The sender will still appear in getSenders. Future
1026 * calls to createOffer will mark the m section for the corresponding transceiver as
1027 * receive only or inactive, as defined in JSEP. Returns true on success.
1028 */
1029 public boolean removeTrack(RtpSender sender) {
1030 if (sender == null) {
1031 throw new NullPointerException("No RtpSender specified for removeTrack.");
1032 }
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001033 return nativeRemoveTrack(sender.getNativeRtpSender());
Seth Hampsonc384e142018-03-06 15:47:10 -08001034 }
1035
1036 /**
1037 * Creates a new RtpTransceiver and adds it to the set of transceivers. Adding a
1038 * transceiver will cause future calls to CreateOffer to add a media description
1039 * for the corresponding transceiver.
1040 *
1041 * <p>The initial value of |mid| in the returned transceiver is null. Setting a
1042 * new session description may change it to a non-null value.
1043 *
1044 * <p>https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtransceiver
1045 *
1046 * <p>If a MediaStreamTrack is specified then a transceiver will be added with a
1047 * sender set to transmit the given track. The kind
1048 * of the transceiver (and sender/receiver) will be derived from the kind of
1049 * the track.
1050 *
1051 * <p>If MediaType is specified then a transceiver will be added based upon that type.
1052 * This can be either MEDIA_TYPE_AUDIO or MEDIA_TYPE_VIDEO.
1053 *
1054 * <p>Optionally, an RtpTransceiverInit structure can be specified to configure
1055 * the transceiver from construction. If not specified, the transceiver will
1056 * default to having a direction of kSendRecv and not be part of any streams.
1057 *
1058 * <p>Note: These methods are only available with SdpSemantics.UNIFIED_PLAN specified.
1059 * @throws IllegalStateException if an error accors in C++ addTransceiver
1060 */
1061 public RtpTransceiver addTransceiver(MediaStreamTrack track) {
1062 return addTransceiver(track, new RtpTransceiver.RtpTransceiverInit());
1063 }
1064
1065 public RtpTransceiver addTransceiver(
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001066 MediaStreamTrack track, @Nullable RtpTransceiver.RtpTransceiverInit init) {
Seth Hampsonc384e142018-03-06 15:47:10 -08001067 if (track == null) {
1068 throw new NullPointerException("No MediaStreamTrack specified for addTransceiver.");
1069 }
1070 if (init == null) {
1071 init = new RtpTransceiver.RtpTransceiverInit();
1072 }
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001073 RtpTransceiver newTransceiver =
1074 nativeAddTransceiverWithTrack(track.getNativeMediaStreamTrack(), init);
Seth Hampsonc384e142018-03-06 15:47:10 -08001075 if (newTransceiver == null) {
1076 throw new IllegalStateException("C++ addTransceiver failed.");
1077 }
1078 transceivers.add(newTransceiver);
1079 return newTransceiver;
1080 }
1081
1082 public RtpTransceiver addTransceiver(MediaStreamTrack.MediaType mediaType) {
1083 return addTransceiver(mediaType, new RtpTransceiver.RtpTransceiverInit());
1084 }
1085
1086 public RtpTransceiver addTransceiver(
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001087 MediaStreamTrack.MediaType mediaType, @Nullable RtpTransceiver.RtpTransceiverInit init) {
Seth Hampsonc384e142018-03-06 15:47:10 -08001088 if (mediaType == null) {
1089 throw new NullPointerException("No MediaType specified for addTransceiver.");
1090 }
1091 if (init == null) {
1092 init = new RtpTransceiver.RtpTransceiverInit();
1093 }
1094 RtpTransceiver newTransceiver = nativeAddTransceiverOfType(mediaType, init);
1095 if (newTransceiver == null) {
1096 throw new IllegalStateException("C++ addTransceiver failed.");
1097 }
1098 transceivers.add(newTransceiver);
1099 return newTransceiver;
1100 }
1101
deadbeef82215872017-04-18 10:27:51 -07001102 // Older, non-standard implementation of getStats.
1103 @Deprecated
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001104 public boolean getStats(StatsObserver observer, @Nullable MediaStreamTrack track) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001105 return nativeOldGetStats(observer, (track == null) ? 0 : track.getNativeMediaStreamTrack());
deadbeef82215872017-04-18 10:27:51 -07001106 }
1107
Seth Hampsonc384e142018-03-06 15:47:10 -08001108 /**
1109 * Gets stats using the new stats collection API, see webrtc/api/stats/. These
1110 * will replace old stats collection API when the new API has matured enough.
1111 */
deadbeef82215872017-04-18 10:27:51 -07001112 public void getStats(RTCStatsCollectorCallback callback) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001113 nativeNewGetStats(callback);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001114 }
1115
Seth Hampsonc384e142018-03-06 15:47:10 -08001116 /**
1117 * Limits the bandwidth allocated for all RTP streams sent by this
1118 * PeerConnection. Pass null to leave a value unchanged.
1119 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001120 public boolean setBitrate(Integer min, Integer current, Integer max) {
1121 return nativeSetBitrate(min, current, max);
1122 }
zsteind89b0bc2017-08-03 11:11:40 -07001123
Seth Hampsonc384e142018-03-06 15:47:10 -08001124 /**
1125 * Starts recording an RTC event log.
1126 *
1127 * Ownership of the file is transfered to the native code. If an RTC event
1128 * log is already being recorded, it will be stopped and a new one will start
1129 * using the provided file. Logging will continue until the stopRtcEventLog
1130 * function is called. The max_size_bytes argument is ignored, it is added
1131 * for future use.
1132 */
ivoc0c6f0f62016-07-06 04:34:23 -07001133 public boolean startRtcEventLog(int file_descriptor, int max_size_bytes) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001134 return nativeStartRtcEventLog(file_descriptor, max_size_bytes);
ivoc14d5dbe2016-07-04 07:06:55 -07001135 }
1136
Seth Hampsonc384e142018-03-06 15:47:10 -08001137 /**
1138 * Stops recording an RTC event log. If no RTC event log is currently being
1139 * recorded, this call will have no effect.
1140 */
ivoc14d5dbe2016-07-04 07:06:55 -07001141 public void stopRtcEventLog() {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001142 nativeStopRtcEventLog();
ivoc14d5dbe2016-07-04 07:06:55 -07001143 }
1144
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001145 // TODO(fischman): add support for DTMF-related methods once that API
1146 // stabilizes.
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001147 public SignalingState signalingState() {
1148 return nativeSignalingState();
1149 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001150
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001151 public IceConnectionState iceConnectionState() {
1152 return nativeIceConnectionState();
1153 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001154
Jonas Olssonf01d8c82018-11-08 15:19:04 +01001155 public PeerConnectionState connectionState() {
1156 return nativeConnectionState();
1157 }
1158
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001159 public IceGatheringState iceGatheringState() {
1160 return nativeIceGatheringState();
1161 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001162
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001163 public void close() {
1164 nativeClose();
1165 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001166
deadbeef43697f62017-09-12 10:52:14 -07001167 /**
1168 * Free native resources associated with this PeerConnection instance.
Seth Hampsonc384e142018-03-06 15:47:10 -08001169 *
deadbeef43697f62017-09-12 10:52:14 -07001170 * This method removes a reference count from the C++ PeerConnection object,
1171 * which should result in it being destroyed. It also calls equivalent
1172 * "dispose" methods on the Java objects attached to this PeerConnection
1173 * (streams, senders, receivers), such that their associated C++ objects
1174 * will also be destroyed.
Seth Hampsonc384e142018-03-06 15:47:10 -08001175 *
1176 * <p>Note that this method cannot be safely called from an observer callback
deadbeef43697f62017-09-12 10:52:14 -07001177 * (PeerConnection.Observer, DataChannel.Observer, etc.). If you want to, for
1178 * example, destroy the PeerConnection after an "ICE failed" callback, you
1179 * must do this asynchronously (in other words, unwind the stack first). See
1180 * <a href="https://bugs.chromium.org/p/webrtc/issues/detail?id=3721">bug
1181 * 3721</a> for more details.
1182 */
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001183 public void dispose() {
1184 close();
1185 for (MediaStream stream : localStreams) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001186 nativeRemoveLocalStream(stream.getNativeMediaStream());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001187 stream.dispose();
1188 }
1189 localStreams.clear();
deadbeef4139c0f2015-10-06 12:29:25 -07001190 for (RtpSender sender : senders) {
1191 sender.dispose();
1192 }
1193 senders.clear();
1194 for (RtpReceiver receiver : receivers) {
1195 receiver.dispose();
1196 }
Seth Hampsonc384e142018-03-06 15:47:10 -08001197 for (RtpTransceiver transceiver : transceivers) {
1198 transceiver.dispose();
1199 }
1200 transceivers.clear();
deadbeef4139c0f2015-10-06 12:29:25 -07001201 receivers.clear();
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001202 nativeFreeOwnedPeerConnection(nativePeerConnection);
1203 }
1204
1205 /** Returns a pointer to the native webrtc::PeerConnectionInterface. */
1206 public long getNativePeerConnection() {
1207 return nativeGetNativePeerConnection();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001208 }
1209
Magnus Jedvert9060eb12017-12-12 12:52:54 +01001210 @CalledByNative
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001211 long getNativeOwnedPeerConnection() {
Magnus Jedvert9060eb12017-12-12 12:52:54 +01001212 return nativePeerConnection;
1213 }
1214
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001215 public static long createNativePeerConnectionObserver(Observer observer) {
1216 return nativeCreatePeerConnectionObserver(observer);
1217 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001218
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001219 private native long nativeGetNativePeerConnection();
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001220 private native SessionDescription nativeGetLocalDescription();
1221 private native SessionDescription nativeGetRemoteDescription();
Michael Iedema02137862018-10-09 15:30:01 +02001222 private native RtcCertificatePem nativeGetCertificate();
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001223 private native DataChannel nativeCreateDataChannel(String label, DataChannel.Init init);
1224 private native void nativeCreateOffer(SdpObserver observer, MediaConstraints constraints);
1225 private native void nativeCreateAnswer(SdpObserver observer, MediaConstraints constraints);
1226 private native void nativeSetLocalDescription(SdpObserver observer, SessionDescription sdp);
1227 private native void nativeSetRemoteDescription(SdpObserver observer, SessionDescription sdp);
1228 private native void nativeSetAudioPlayout(boolean playout);
1229 private native void nativeSetAudioRecording(boolean recording);
1230 private native boolean nativeSetBitrate(Integer min, Integer current, Integer max);
1231 private native SignalingState nativeSignalingState();
1232 private native IceConnectionState nativeIceConnectionState();
Jonas Olssonf01d8c82018-11-08 15:19:04 +01001233 private native PeerConnectionState nativeConnectionState();
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001234 private native IceGatheringState nativeIceGatheringState();
1235 private native void nativeClose();
1236 private static native long nativeCreatePeerConnectionObserver(Observer observer);
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001237 private static native void nativeFreeOwnedPeerConnection(long ownedPeerConnection);
1238 private native boolean nativeSetConfiguration(RTCConfiguration config);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001239 private native boolean nativeAddIceCandidate(
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001240 String sdpMid, int sdpMLineIndex, String iceCandidateSdp);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001241 private native boolean nativeRemoveIceCandidates(final IceCandidate[] candidates);
1242 private native boolean nativeAddLocalStream(long stream);
1243 private native void nativeRemoveLocalStream(long stream);
1244 private native boolean nativeOldGetStats(StatsObserver observer, long nativeTrack);
1245 private native void nativeNewGetStats(RTCStatsCollectorCallback callback);
1246 private native RtpSender nativeCreateSender(String kind, String stream_id);
1247 private native List<RtpSender> nativeGetSenders();
1248 private native List<RtpReceiver> nativeGetReceivers();
Seth Hampsonc384e142018-03-06 15:47:10 -08001249 private native List<RtpTransceiver> nativeGetTransceivers();
1250 private native RtpSender nativeAddTrack(long track, List<String> streamIds);
1251 private native boolean nativeRemoveTrack(long sender);
1252 private native RtpTransceiver nativeAddTransceiverWithTrack(
1253 long track, RtpTransceiver.RtpTransceiverInit init);
1254 private native RtpTransceiver nativeAddTransceiverOfType(
1255 MediaStreamTrack.MediaType mediaType, RtpTransceiver.RtpTransceiverInit init);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001256 private native boolean nativeStartRtcEventLog(int file_descriptor, int max_size_bytes);
1257 private native void nativeStopRtcEventLog();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001258}