blob: a5eeb58c634ebc0c5bee7c50867e9330edb6e750 [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;
Alex Drake43faee02019-08-12 16:27:34 -070018import org.webrtc.CandidatePairChangeEvent;
Patrik Höglundbd6ffaf2018-11-16 14:55:16 +010019import org.webrtc.DataChannel;
20import org.webrtc.MediaStreamTrack;
21import org.webrtc.RtpTransceiver;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000022
23/**
24 * Java-land version of the PeerConnection APIs; wraps the C++ API
25 * http://www.webrtc.org/reference/native-apis, which in turn is inspired by the
26 * JS APIs: http://dev.w3.org/2011/webrtc/editor/webrtc.html and
27 * http://www.w3.org/TR/mediacapture-streams/
28 */
29public class PeerConnection {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000030 /** Tracks PeerConnectionInterface::IceGatheringState */
Magnus Jedvertba700f62017-12-04 13:43:27 +010031 public enum IceGatheringState {
32 NEW,
33 GATHERING,
34 COMPLETE;
35
36 @CalledByNative("IceGatheringState")
37 static IceGatheringState fromNativeIndex(int nativeIndex) {
38 return values()[nativeIndex];
39 }
40 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000041
42 /** Tracks PeerConnectionInterface::IceConnectionState */
43 public enum IceConnectionState {
sakalb6760f92016-09-29 04:12:44 -070044 NEW,
45 CHECKING,
46 CONNECTED,
47 COMPLETED,
48 FAILED,
49 DISCONNECTED,
Magnus Jedvertba700f62017-12-04 13:43:27 +010050 CLOSED;
51
52 @CalledByNative("IceConnectionState")
53 static IceConnectionState fromNativeIndex(int nativeIndex) {
54 return values()[nativeIndex];
55 }
sakalb6760f92016-09-29 04:12:44 -070056 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000057
Jonas Olssonf01d8c82018-11-08 15:19:04 +010058 /** Tracks PeerConnectionInterface::PeerConnectionState */
59 public enum PeerConnectionState {
60 NEW,
61 CONNECTING,
62 CONNECTED,
63 DISCONNECTED,
64 FAILED,
65 CLOSED;
66
67 @CalledByNative("PeerConnectionState")
68 static PeerConnectionState fromNativeIndex(int nativeIndex) {
69 return values()[nativeIndex];
70 }
71 }
72
hnsl04833622017-01-09 08:35:45 -080073 /** Tracks PeerConnectionInterface::TlsCertPolicy */
74 public enum TlsCertPolicy {
75 TLS_CERT_POLICY_SECURE,
76 TLS_CERT_POLICY_INSECURE_NO_CHECK,
77 }
78
henrike@webrtc.org28e20752013-07-10 00:45:36 +000079 /** Tracks PeerConnectionInterface::SignalingState */
80 public enum SignalingState {
sakalb6760f92016-09-29 04:12:44 -070081 STABLE,
82 HAVE_LOCAL_OFFER,
83 HAVE_LOCAL_PRANSWER,
84 HAVE_REMOTE_OFFER,
85 HAVE_REMOTE_PRANSWER,
Magnus Jedvertba700f62017-12-04 13:43:27 +010086 CLOSED;
87
88 @CalledByNative("SignalingState")
89 static SignalingState fromNativeIndex(int nativeIndex) {
90 return values()[nativeIndex];
91 }
sakalb6760f92016-09-29 04:12:44 -070092 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +000093
94 /** Java version of PeerConnectionObserver. */
95 public static interface Observer {
96 /** Triggered when the SignalingState changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +010097 @CalledByNative("Observer") void onSignalingChange(SignalingState newState);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000098
99 /** Triggered when the IceConnectionState changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100100 @CalledByNative("Observer") void onIceConnectionChange(IceConnectionState newState);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000101
Qingsi Wang36e31472019-05-29 11:37:26 -0700102 /* Triggered when the standard-compliant state transition of IceConnectionState happens. */
103 @CalledByNative("Observer")
104 default void onStandardizedIceConnectionChange(IceConnectionState newState) {}
105
Jonas Olssonf01d8c82018-11-08 15:19:04 +0100106 /** Triggered when the PeerConnectionState changes. */
107 @CalledByNative("Observer")
108 default void onConnectionChange(PeerConnectionState newState) {}
109
Peter Thatcher54360512015-07-08 11:08:35 -0700110 /** Triggered when the ICE connection receiving status changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100111 @CalledByNative("Observer") void onIceConnectionReceivingChange(boolean receiving);
Peter Thatcher54360512015-07-08 11:08:35 -0700112
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000113 /** Triggered when the IceGatheringState changes. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100114 @CalledByNative("Observer") void onIceGatheringChange(IceGatheringState newState);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000115
116 /** Triggered when a new ICE candidate has been found. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100117 @CalledByNative("Observer") void onIceCandidate(IceCandidate candidate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000118
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700119 /** Triggered when some ICE candidates have been removed. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100120 @CalledByNative("Observer") void onIceCandidatesRemoved(IceCandidate[] candidates);
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700121
Alex Drake43faee02019-08-12 16:27:34 -0700122 /** Triggered when the ICE candidate pair is changed. */
123 @CalledByNative("Observer")
124 default void onSelectedCandidatePairChanged(CandidatePairChangeEvent event) {}
125
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000126 /** Triggered when media is received on a new stream from remote peer. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100127 @CalledByNative("Observer") void onAddStream(MediaStream stream);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000128
129 /** Triggered when a remote peer close a stream. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100130 @CalledByNative("Observer") void onRemoveStream(MediaStream stream);
henrike@webrtc.org723d6832013-07-12 16:04:50 +0000131
132 /** Triggered when a remote peer opens a DataChannel. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100133 @CalledByNative("Observer") void onDataChannel(DataChannel dataChannel);
fischman@webrtc.orgd7568a02014-01-13 22:04:12 +0000134
135 /** Triggered when renegotiation is necessary. */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100136 @CalledByNative("Observer") void onRenegotiationNeeded();
zhihuangdcccda72016-12-21 14:08:03 -0800137
138 /**
139 * Triggered when a new track is signaled by the remote peer, as a result of
140 * setRemoteDescription.
141 */
Magnus Jedvertba700f62017-12-04 13:43:27 +0100142 @CalledByNative("Observer") void onAddTrack(RtpReceiver receiver, MediaStream[] mediaStreams);
Seth Hampson31dbc242018-05-07 09:28:19 -0700143
144 /**
145 * Triggered when the signaling from SetRemoteDescription indicates that a transceiver
146 * will be receiving media from a remote endpoint. This is only called if UNIFIED_PLAN
147 * semantics are specified. The transceiver will be disposed automatically.
148 */
149 @CalledByNative("Observer") default void onTrack(RtpTransceiver transceiver){};
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000150 }
151
152 /** Java version of PeerConnectionInterface.IceServer. */
153 public static class IceServer {
Emad Omaradab1d2d2017-06-16 15:43:11 -0700154 // List of URIs associated with this server. Valid formats are described
155 // in RFC7064 and RFC7065, and more may be added in the future. The "host"
156 // part of the URI may contain either an IP address or a hostname.
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700157 @Deprecated public final String uri;
158 public final List<String> urls;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000159 public final String username;
160 public final String password;
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000161 public final TlsCertPolicy tlsCertPolicy;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000162
Emad Omaradab1d2d2017-06-16 15:43:11 -0700163 // If the URIs in |urls| only contain IP addresses, this field can be used
164 // to indicate the hostname, which may be necessary for TLS (using the SNI
165 // extension). If |urls| itself contains the hostname, this isn't
166 // necessary.
167 public final String hostname;
168
Diogo Real1dca9d52017-08-29 12:18:32 -0700169 // List of protocols to be used in the TLS ALPN extension.
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000170 public final List<String> tlsAlpnProtocols;
Diogo Real1dca9d52017-08-29 12:18:32 -0700171
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700172 // List of elliptic curves to be used in the TLS elliptic curves extension.
173 // Only curve names supported by OpenSSL should be used (eg. "P-256","X25519").
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000174 public final List<String> tlsEllipticCurves;
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700175
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000176 /** Convenience constructor for STUN servers. */
Diogo Real05ea2b32017-08-31 00:12:58 -0700177 @Deprecated
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000178 public IceServer(String uri) {
179 this(uri, "", "");
180 }
181
Diogo Real05ea2b32017-08-31 00:12:58 -0700182 @Deprecated
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000183 public IceServer(String uri, String username, String password) {
hnsl04833622017-01-09 08:35:45 -0800184 this(uri, username, password, TlsCertPolicy.TLS_CERT_POLICY_SECURE);
185 }
186
Diogo Real05ea2b32017-08-31 00:12:58 -0700187 @Deprecated
hnsl04833622017-01-09 08:35:45 -0800188 public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy) {
Emad Omaradab1d2d2017-06-16 15:43:11 -0700189 this(uri, username, password, tlsCertPolicy, "");
190 }
191
Diogo Real05ea2b32017-08-31 00:12:58 -0700192 @Deprecated
Emad Omaradab1d2d2017-06-16 15:43:11 -0700193 public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy,
194 String hostname) {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700195 this(uri, Collections.singletonList(uri), username, password, tlsCertPolicy, hostname, null,
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000196 null);
Diogo Real1dca9d52017-08-29 12:18:32 -0700197 }
198
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700199 private IceServer(String uri, List<String> urls, String username, String password,
200 TlsCertPolicy tlsCertPolicy, String hostname, List<String> tlsAlpnProtocols,
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000201 List<String> tlsEllipticCurves) {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700202 if (uri == null || urls == null || urls.isEmpty()) {
203 throw new IllegalArgumentException("uri == null || urls == null || urls.isEmpty()");
204 }
205 for (String it : urls) {
206 if (it == null) {
207 throw new IllegalArgumentException("urls element is null: " + urls);
208 }
209 }
210 if (username == null) {
211 throw new IllegalArgumentException("username == null");
212 }
213 if (password == null) {
214 throw new IllegalArgumentException("password == null");
215 }
216 if (hostname == null) {
217 throw new IllegalArgumentException("hostname == null");
218 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000219 this.uri = uri;
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700220 this.urls = urls;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000221 this.username = username;
222 this.password = password;
hnsl04833622017-01-09 08:35:45 -0800223 this.tlsCertPolicy = tlsCertPolicy;
Emad Omaradab1d2d2017-06-16 15:43:11 -0700224 this.hostname = hostname;
Diogo Real1dca9d52017-08-29 12:18:32 -0700225 this.tlsAlpnProtocols = tlsAlpnProtocols;
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700226 this.tlsEllipticCurves = tlsEllipticCurves;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000227 }
228
Sami Kalliomäkibde473e2017-10-30 13:34:41 +0100229 @Override
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000230 public String toString() {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700231 return urls + " [" + username + ":" + password + "] [" + tlsCertPolicy + "] [" + hostname
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000232 + "] [" + tlsAlpnProtocols + "] [" + tlsEllipticCurves + "]";
Diogo Real1dca9d52017-08-29 12:18:32 -0700233 }
234
Qingsi Wanga0d45802019-01-15 13:33:11 -0800235 @Override
236 public boolean equals(@Nullable Object obj) {
237 if (obj == null) {
238 return false;
239 }
240 if (obj == this) {
241 return true;
242 }
243 if (!(obj instanceof IceServer)) {
244 return false;
245 }
246 IceServer other = (IceServer) obj;
247 return (uri.equals(other.uri) && urls.equals(other.urls) && username.equals(other.username)
248 && password.equals(other.password) && tlsCertPolicy.equals(other.tlsCertPolicy)
249 && hostname.equals(other.hostname) && tlsAlpnProtocols.equals(other.tlsAlpnProtocols)
250 && tlsEllipticCurves.equals(other.tlsEllipticCurves));
251 }
252
253 @Override
254 public int hashCode() {
255 Object[] values = {uri, urls, username, password, tlsCertPolicy, hostname, tlsAlpnProtocols,
256 tlsEllipticCurves};
257 return Arrays.hashCode(values);
258 }
259
Diogo Real1dca9d52017-08-29 12:18:32 -0700260 public static Builder builder(String uri) {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700261 return new Builder(Collections.singletonList(uri));
262 }
263
264 public static Builder builder(List<String> urls) {
265 return new Builder(urls);
Diogo Real1dca9d52017-08-29 12:18:32 -0700266 }
267
268 public static class Builder {
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100269 @Nullable private final List<String> urls;
Diogo Real1dca9d52017-08-29 12:18:32 -0700270 private String username = "";
271 private String password = "";
272 private TlsCertPolicy tlsCertPolicy = TlsCertPolicy.TLS_CERT_POLICY_SECURE;
273 private String hostname = "";
274 private List<String> tlsAlpnProtocols;
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700275 private List<String> tlsEllipticCurves;
Diogo Real1dca9d52017-08-29 12:18:32 -0700276
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700277 private Builder(List<String> urls) {
278 if (urls == null || urls.isEmpty()) {
279 throw new IllegalArgumentException("urls == null || urls.isEmpty(): " + urls);
280 }
281 this.urls = urls;
Diogo Real1dca9d52017-08-29 12:18:32 -0700282 }
283
284 public Builder setUsername(String username) {
285 this.username = username;
286 return this;
287 }
288
289 public Builder setPassword(String password) {
290 this.password = password;
291 return this;
292 }
293
294 public Builder setTlsCertPolicy(TlsCertPolicy tlsCertPolicy) {
295 this.tlsCertPolicy = tlsCertPolicy;
296 return this;
297 }
298
299 public Builder setHostname(String hostname) {
300 this.hostname = hostname;
301 return this;
302 }
303
304 public Builder setTlsAlpnProtocols(List<String> tlsAlpnProtocols) {
305 this.tlsAlpnProtocols = tlsAlpnProtocols;
306 return this;
307 }
308
Diogo Real7bd1f1b2017-09-08 12:50:41 -0700309 public Builder setTlsEllipticCurves(List<String> tlsEllipticCurves) {
310 this.tlsEllipticCurves = tlsEllipticCurves;
311 return this;
312 }
313
Diogo Real1dca9d52017-08-29 12:18:32 -0700314 public IceServer createIceServer() {
korniltsev.anatoly0ea03102017-09-11 06:41:38 -0700315 return new IceServer(urls.get(0), urls, username, password, tlsCertPolicy, hostname,
Sergey Silkin9c147dd2018-09-12 10:45:38 +0000316 tlsAlpnProtocols, tlsEllipticCurves);
Diogo Real1dca9d52017-08-29 12:18:32 -0700317 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000318 }
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100319
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100320 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100321 @CalledByNative("IceServer")
322 List<String> getUrls() {
323 return urls;
324 }
325
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100326 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100327 @CalledByNative("IceServer")
328 String getUsername() {
329 return username;
330 }
331
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100332 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100333 @CalledByNative("IceServer")
334 String getPassword() {
335 return password;
336 }
337
338 @CalledByNative("IceServer")
339 TlsCertPolicy getTlsCertPolicy() {
340 return tlsCertPolicy;
341 }
342
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100343 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100344 @CalledByNative("IceServer")
345 String getHostname() {
346 return hostname;
347 }
348
349 @CalledByNative("IceServer")
350 List<String> getTlsAlpnProtocols() {
351 return tlsAlpnProtocols;
352 }
353
354 @CalledByNative("IceServer")
355 List<String> getTlsEllipticCurves() {
356 return tlsEllipticCurves;
357 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000358 }
359
Jiayang Liucac1b382015-04-30 12:35:24 -0700360 /** Java version of PeerConnectionInterface.IceTransportsType */
sakalb6760f92016-09-29 04:12:44 -0700361 public enum IceTransportsType { NONE, RELAY, NOHOST, ALL }
Jiayang Liucac1b382015-04-30 12:35:24 -0700362
363 /** Java version of PeerConnectionInterface.BundlePolicy */
sakalb6760f92016-09-29 04:12:44 -0700364 public enum BundlePolicy { BALANCED, MAXBUNDLE, MAXCOMPAT }
Jiayang Liucac1b382015-04-30 12:35:24 -0700365
Peter Thatcheraf55ccc2015-05-21 07:48:41 -0700366 /** Java version of PeerConnectionInterface.RtcpMuxPolicy */
sakalb6760f92016-09-29 04:12:44 -0700367 public enum RtcpMuxPolicy { NEGOTIATE, REQUIRE }
glaznev97579a42015-09-01 11:31:27 -0700368
Peter Thatcheraf55ccc2015-05-21 07:48:41 -0700369 /** Java version of PeerConnectionInterface.TcpCandidatePolicy */
sakalb6760f92016-09-29 04:12:44 -0700370 public enum TcpCandidatePolicy { ENABLED, DISABLED }
Jiayang Liucac1b382015-04-30 12:35:24 -0700371
honghaiz60347052016-05-31 18:29:12 -0700372 /** Java version of PeerConnectionInterface.CandidateNetworkPolicy */
sakalb6760f92016-09-29 04:12:44 -0700373 public enum CandidateNetworkPolicy { ALL, LOW_COST }
honghaiz60347052016-05-31 18:29:12 -0700374
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800375 // Keep in sync with webrtc/rtc_base/network_constants.h.
376 public enum AdapterType {
377 UNKNOWN,
378 ETHERNET,
379 WIFI,
380 CELLULAR,
381 VPN,
382 LOOPBACK,
383 }
384
glaznev97579a42015-09-01 11:31:27 -0700385 /** Java version of rtc::KeyType */
sakalb6760f92016-09-29 04:12:44 -0700386 public enum KeyType { RSA, ECDSA }
glaznev97579a42015-09-01 11:31:27 -0700387
honghaiz1f429e32015-09-28 07:57:34 -0700388 /** Java version of PeerConnectionInterface.ContinualGatheringPolicy */
sakalb6760f92016-09-29 04:12:44 -0700389 public enum ContinualGatheringPolicy { GATHER_ONCE, GATHER_CONTINUALLY }
honghaiz1f429e32015-09-28 07:57:34 -0700390
Steve Antond960a0c2017-07-17 12:33:07 -0700391 /** Java version of rtc::IntervalRange */
392 public static class IntervalRange {
393 private final int min;
394 private final int max;
395
396 public IntervalRange(int min, int max) {
397 this.min = min;
398 this.max = max;
399 }
400
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100401 @CalledByNative("IntervalRange")
Steve Antond960a0c2017-07-17 12:33:07 -0700402 public int getMin() {
403 return min;
404 }
405
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100406 @CalledByNative("IntervalRange")
Steve Antond960a0c2017-07-17 12:33:07 -0700407 public int getMax() {
408 return max;
409 }
410 }
411
Seth Hampsonc384e142018-03-06 15:47:10 -0800412 /**
413 * Java version of webrtc::SdpSemantics.
414 *
415 * Configure the SDP semantics used by this PeerConnection. Note that the
416 * WebRTC 1.0 specification requires UNIFIED_PLAN semantics. The
417 * RtpTransceiver API is only available with UNIFIED_PLAN semantics.
418 *
419 * <p>PLAN_B will cause PeerConnection to create offers and answers with at
420 * most one audio and one video m= section with multiple RtpSenders and
421 * RtpReceivers specified as multiple a=ssrc lines within the section. This
422 * will also cause PeerConnection to ignore all but the first m= section of
423 * the same media type.
424 *
425 * <p>UNIFIED_PLAN will cause PeerConnection to create offers and answers with
426 * multiple m= sections where each m= section maps to one RtpSender and one
427 * RtpReceiver (an RtpTransceiver), either both audio or both video. This
428 * will also cause PeerConnection to ignore all but the first a=ssrc lines
429 * that form a Plan B stream.
430 *
431 * <p>For users who wish to send multiple audio/video streams and need to stay
432 * interoperable with legacy WebRTC implementations, specify PLAN_B.
433 *
434 * <p>For users who wish to send multiple audio/video streams and/or wish to
435 * use the new RtpTransceiver API, specify UNIFIED_PLAN.
436 */
437 public enum SdpSemantics { PLAN_B, UNIFIED_PLAN }
438
Jiayang Liucac1b382015-04-30 12:35:24 -0700439 /** Java version of PeerConnectionInterface.RTCConfiguration */
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800440 // TODO(qingsi): Resolve the naming inconsistency of fields with/without units.
Jiayang Liucac1b382015-04-30 12:35:24 -0700441 public static class RTCConfiguration {
442 public IceTransportsType iceTransportsType;
443 public List<IceServer> iceServers;
444 public BundlePolicy bundlePolicy;
Michael Iedema02137862018-10-09 15:30:01 +0200445 @Nullable public RtcCertificatePem certificate;
Peter Thatcheraf55ccc2015-05-21 07:48:41 -0700446 public RtcpMuxPolicy rtcpMuxPolicy;
Jiayang Liucac1b382015-04-30 12:35:24 -0700447 public TcpCandidatePolicy tcpCandidatePolicy;
honghaiz60347052016-05-31 18:29:12 -0700448 public CandidateNetworkPolicy candidateNetworkPolicy;
Henrik Lundin64dad832015-05-11 12:44:23 +0200449 public int audioJitterBufferMaxPackets;
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200450 public boolean audioJitterBufferFastAccelerate;
honghaiz4edc39c2015-09-01 09:53:56 -0700451 public int iceConnectionReceivingTimeout;
Honghai Zhang381b4212015-12-04 12:24:03 -0800452 public int iceBackupCandidatePairPingInterval;
glaznev97579a42015-09-01 11:31:27 -0700453 public KeyType keyType;
honghaiz1f429e32015-09-28 07:57:34 -0700454 public ContinualGatheringPolicy continualGatheringPolicy;
deadbeefbe0c96f2016-05-18 16:20:14 -0700455 public int iceCandidatePoolSize;
Honghai Zhangd78ecf72016-07-01 14:40:40 -0700456 public boolean pruneTurnPorts;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700457 public boolean presumeWritableWhenFullyRelayed;
Qingsi Wang1fe119f2019-05-31 16:55:33 -0700458 public boolean surfaceIceCandidatesOnIceTransportTypeChanged;
Qingsi Wange6826d22018-03-08 14:55:14 -0800459 // The following fields define intervals in milliseconds at which ICE
460 // connectivity checks are sent.
461 //
462 // We consider ICE is "strongly connected" for an agent when there is at
463 // least one candidate pair that currently succeeds in connectivity check
464 // from its direction i.e. sending a ping and receives a ping response, AND
465 // all candidate pairs have sent a minimum number of pings for connectivity
466 // (this number is implementation-specific). Otherwise, ICE is considered in
467 // "weak connectivity".
468 //
469 // Note that the above notion of strong and weak connectivity is not defined
470 // in RFC 5245, and they apply to our current ICE implementation only.
471 //
472 // 1) iceCheckIntervalStrongConnectivityMs defines the interval applied to
473 // ALL candidate pairs when ICE is strongly connected,
474 // 2) iceCheckIntervalWeakConnectivityMs defines the counterpart for ALL
475 // pairs when ICE is weakly connected, and
476 // 3) iceCheckMinInterval defines the minimal interval (equivalently the
477 // maximum rate) that overrides the above two intervals when either of them
478 // is less.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100479 @Nullable public Integer iceCheckIntervalStrongConnectivityMs;
480 @Nullable public Integer iceCheckIntervalWeakConnectivityMs;
481 @Nullable public Integer iceCheckMinInterval;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700482 // The time period in milliseconds for which a candidate pair must wait for response to
483 // connectivitiy checks before it becomes unwritable.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100484 @Nullable public Integer iceUnwritableTimeMs;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700485 // The minimum number of connectivity checks that a candidate pair must sent without receiving
486 // response before it becomes unwritable.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100487 @Nullable public Integer iceUnwritableMinChecks;
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800488 // The interval in milliseconds at which STUN candidates will resend STUN binding requests
489 // to keep NAT bindings open.
490 // The default value in the implementation is used if this field is null.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100491 @Nullable public Integer stunCandidateKeepaliveIntervalMs;
zhihuangb09b3f92017-03-07 14:40:51 -0800492 public boolean disableIPv6OnWifi;
deadbeef28e29192017-07-27 09:14:38 -0700493 // By default, PeerConnection will use a limited number of IPv6 network
494 // interfaces, in order to avoid too many ICE candidate pairs being created
495 // and delaying ICE completion.
496 //
497 // Can be set to Integer.MAX_VALUE to effectively disable the limit.
498 public int maxIPv6Networks;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100499 @Nullable public IntervalRange iceRegatherIntervalRange;
Jiayang Liucac1b382015-04-30 12:35:24 -0700500
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100501 // These values will be overridden by MediaStream constraints if deprecated constraints-based
502 // create peerconnection interface is used.
503 public boolean disableIpv6;
504 public boolean enableDscp;
505 public boolean enableCpuOveruseDetection;
506 public boolean enableRtpDataChannel;
507 public boolean suspendBelowMinBitrate;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100508 @Nullable public Integer screencastMinBitrate;
509 @Nullable public Boolean combinedAudioVideoBwe;
510 @Nullable public Boolean enableDtlsSrtp;
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800511 // Use "Unknown" to represent no preference of adapter types, not the
512 // preference of adapters of unknown types.
513 public AdapterType networkPreference;
Seth Hampsonc384e142018-03-06 15:47:10 -0800514 public SdpSemantics sdpSemantics;
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100515
Jonas Orelandbdcee282017-10-10 14:01:40 +0200516 // This is an optional wrapper for the C++ webrtc::TurnCustomizer.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100517 @Nullable public TurnCustomizer turnCustomizer;
Jonas Orelandbdcee282017-10-10 14:01:40 +0200518
Zhi Huangb57e1692018-06-12 11:41:11 -0700519 // Actively reset the SRTP parameters whenever the DTLS transports underneath are reset for
520 // every offer/answer negotiation.This is only intended to be a workaround for crbug.com/835958
521 public boolean activeResetSrtpParams;
522
Piotr (Peter) Slatala09beff22018-10-17 07:22:40 -0700523 /*
524 * Experimental flag that enables a use of media transport. If this is true, the media transport
525 * factory MUST be provided to the PeerConnectionFactory.
526 */
527 public boolean useMediaTransport;
528
Bjorn Mellema9bbd862018-11-02 09:07:48 -0700529 /*
530 * Experimental flag that enables a use of media transport for data channels. If this is true,
531 * the media transport factory MUST be provided to the PeerConnectionFactory.
532 */
533 public boolean useMediaTransportForDataChannels;
534
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700535 /**
536 * Defines advanced optional cryptographic settings related to SRTP and
537 * frame encryption for native WebRTC. Setting this will overwrite any
538 * options set through the PeerConnectionFactory (which is deprecated).
539 */
540 @Nullable public CryptoOptions cryptoOptions;
541
deadbeef28e29192017-07-27 09:14:38 -0700542 // TODO(deadbeef): Instead of duplicating the defaults here, we should do
543 // something to pick up the defaults from C++. The Objective-C equivalent
544 // of RTCConfiguration does that.
Jiayang Liucac1b382015-04-30 12:35:24 -0700545 public RTCConfiguration(List<IceServer> iceServers) {
546 iceTransportsType = IceTransportsType.ALL;
547 bundlePolicy = BundlePolicy.BALANCED;
zhihuang4dfb8ce2016-11-23 10:30:12 -0800548 rtcpMuxPolicy = RtcpMuxPolicy.REQUIRE;
Jiayang Liucac1b382015-04-30 12:35:24 -0700549 tcpCandidatePolicy = TcpCandidatePolicy.ENABLED;
Sami Kalliomäki9828beb2017-10-26 16:21:22 +0200550 candidateNetworkPolicy = CandidateNetworkPolicy.ALL;
Jiayang Liucac1b382015-04-30 12:35:24 -0700551 this.iceServers = iceServers;
Henrik Lundin64dad832015-05-11 12:44:23 +0200552 audioJitterBufferMaxPackets = 50;
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200553 audioJitterBufferFastAccelerate = false;
honghaiz4edc39c2015-09-01 09:53:56 -0700554 iceConnectionReceivingTimeout = -1;
Honghai Zhang381b4212015-12-04 12:24:03 -0800555 iceBackupCandidatePairPingInterval = -1;
glaznev97579a42015-09-01 11:31:27 -0700556 keyType = KeyType.ECDSA;
honghaiz1f429e32015-09-28 07:57:34 -0700557 continualGatheringPolicy = ContinualGatheringPolicy.GATHER_ONCE;
deadbeefbe0c96f2016-05-18 16:20:14 -0700558 iceCandidatePoolSize = 0;
Honghai Zhangd78ecf72016-07-01 14:40:40 -0700559 pruneTurnPorts = false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700560 presumeWritableWhenFullyRelayed = false;
Qingsi Wang1fe119f2019-05-31 16:55:33 -0700561 surfaceIceCandidatesOnIceTransportTypeChanged = false;
Qingsi Wange6826d22018-03-08 14:55:14 -0800562 iceCheckIntervalStrongConnectivityMs = null;
563 iceCheckIntervalWeakConnectivityMs = null;
skvlad51072462017-02-02 11:50:14 -0800564 iceCheckMinInterval = null;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700565 iceUnwritableTimeMs = null;
566 iceUnwritableMinChecks = null;
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800567 stunCandidateKeepaliveIntervalMs = null;
zhihuangb09b3f92017-03-07 14:40:51 -0800568 disableIPv6OnWifi = false;
deadbeef28e29192017-07-27 09:14:38 -0700569 maxIPv6Networks = 5;
Steve Antond960a0c2017-07-17 12:33:07 -0700570 iceRegatherIntervalRange = null;
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100571 disableIpv6 = false;
572 enableDscp = false;
573 enableCpuOveruseDetection = true;
574 enableRtpDataChannel = false;
575 suspendBelowMinBitrate = false;
576 screencastMinBitrate = null;
577 combinedAudioVideoBwe = null;
578 enableDtlsSrtp = null;
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800579 networkPreference = AdapterType.UNKNOWN;
Seth Hampsonc384e142018-03-06 15:47:10 -0800580 sdpSemantics = SdpSemantics.PLAN_B;
Zhi Huangb57e1692018-06-12 11:41:11 -0700581 activeResetSrtpParams = false;
Piotr (Peter) Slatala09beff22018-10-17 07:22:40 -0700582 useMediaTransport = false;
Bjorn Mellema9bbd862018-11-02 09:07:48 -0700583 useMediaTransportForDataChannels = false;
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700584 cryptoOptions = null;
Jiayang Liucac1b382015-04-30 12:35:24 -0700585 }
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100586
587 @CalledByNative("RTCConfiguration")
588 IceTransportsType getIceTransportsType() {
589 return iceTransportsType;
590 }
591
592 @CalledByNative("RTCConfiguration")
593 List<IceServer> getIceServers() {
594 return iceServers;
595 }
596
597 @CalledByNative("RTCConfiguration")
598 BundlePolicy getBundlePolicy() {
599 return bundlePolicy;
600 }
601
Michael Iedema02137862018-10-09 15:30:01 +0200602 @Nullable
603 @CalledByNative("RTCConfiguration")
604 RtcCertificatePem getCertificate() {
605 return certificate;
606 }
607
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100608 @CalledByNative("RTCConfiguration")
609 RtcpMuxPolicy getRtcpMuxPolicy() {
610 return rtcpMuxPolicy;
611 }
612
613 @CalledByNative("RTCConfiguration")
614 TcpCandidatePolicy getTcpCandidatePolicy() {
615 return tcpCandidatePolicy;
616 }
617
618 @CalledByNative("RTCConfiguration")
619 CandidateNetworkPolicy getCandidateNetworkPolicy() {
620 return candidateNetworkPolicy;
621 }
622
623 @CalledByNative("RTCConfiguration")
624 int getAudioJitterBufferMaxPackets() {
625 return audioJitterBufferMaxPackets;
626 }
627
628 @CalledByNative("RTCConfiguration")
629 boolean getAudioJitterBufferFastAccelerate() {
630 return audioJitterBufferFastAccelerate;
631 }
632
633 @CalledByNative("RTCConfiguration")
634 int getIceConnectionReceivingTimeout() {
635 return iceConnectionReceivingTimeout;
636 }
637
638 @CalledByNative("RTCConfiguration")
639 int getIceBackupCandidatePairPingInterval() {
640 return iceBackupCandidatePairPingInterval;
641 }
642
643 @CalledByNative("RTCConfiguration")
644 KeyType getKeyType() {
645 return keyType;
646 }
647
648 @CalledByNative("RTCConfiguration")
649 ContinualGatheringPolicy getContinualGatheringPolicy() {
650 return continualGatheringPolicy;
651 }
652
653 @CalledByNative("RTCConfiguration")
654 int getIceCandidatePoolSize() {
655 return iceCandidatePoolSize;
656 }
657
658 @CalledByNative("RTCConfiguration")
659 boolean getPruneTurnPorts() {
660 return pruneTurnPorts;
661 }
662
663 @CalledByNative("RTCConfiguration")
664 boolean getPresumeWritableWhenFullyRelayed() {
665 return presumeWritableWhenFullyRelayed;
666 }
667
Qingsi Wang1fe119f2019-05-31 16:55:33 -0700668 @CalledByNative("RTCConfiguration")
669 boolean getSurfaceIceCandidatesOnIceTransportTypeChanged() {
670 return surfaceIceCandidatesOnIceTransportTypeChanged;
671 }
672
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100673 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100674 @CalledByNative("RTCConfiguration")
Qingsi Wange6826d22018-03-08 14:55:14 -0800675 Integer getIceCheckIntervalStrongConnectivity() {
676 return iceCheckIntervalStrongConnectivityMs;
677 }
678
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100679 @Nullable
Qingsi Wange6826d22018-03-08 14:55:14 -0800680 @CalledByNative("RTCConfiguration")
681 Integer getIceCheckIntervalWeakConnectivity() {
682 return iceCheckIntervalWeakConnectivityMs;
683 }
684
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100685 @Nullable
Qingsi Wange6826d22018-03-08 14:55:14 -0800686 @CalledByNative("RTCConfiguration")
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100687 Integer getIceCheckMinInterval() {
688 return iceCheckMinInterval;
689 }
690
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100691 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100692 @CalledByNative("RTCConfiguration")
Qingsi Wang22e623a2018-03-13 10:53:57 -0700693 Integer getIceUnwritableTimeout() {
694 return iceUnwritableTimeMs;
695 }
696
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100697 @Nullable
Qingsi Wang22e623a2018-03-13 10:53:57 -0700698 @CalledByNative("RTCConfiguration")
699 Integer getIceUnwritableMinChecks() {
700 return iceUnwritableMinChecks;
701 }
702
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100703 @Nullable
Qingsi Wang22e623a2018-03-13 10:53:57 -0700704 @CalledByNative("RTCConfiguration")
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800705 Integer getStunCandidateKeepaliveInterval() {
706 return stunCandidateKeepaliveIntervalMs;
707 }
708
709 @CalledByNative("RTCConfiguration")
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100710 boolean getDisableIPv6OnWifi() {
711 return disableIPv6OnWifi;
712 }
713
714 @CalledByNative("RTCConfiguration")
715 int getMaxIPv6Networks() {
716 return maxIPv6Networks;
717 }
718
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100719 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100720 @CalledByNative("RTCConfiguration")
721 IntervalRange getIceRegatherIntervalRange() {
722 return iceRegatherIntervalRange;
723 }
724
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100725 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100726 @CalledByNative("RTCConfiguration")
727 TurnCustomizer getTurnCustomizer() {
728 return turnCustomizer;
729 }
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100730
731 @CalledByNative("RTCConfiguration")
732 boolean getDisableIpv6() {
733 return disableIpv6;
734 }
735
736 @CalledByNative("RTCConfiguration")
737 boolean getEnableDscp() {
738 return enableDscp;
739 }
740
741 @CalledByNative("RTCConfiguration")
742 boolean getEnableCpuOveruseDetection() {
743 return enableCpuOveruseDetection;
744 }
745
746 @CalledByNative("RTCConfiguration")
747 boolean getEnableRtpDataChannel() {
748 return enableRtpDataChannel;
749 }
750
751 @CalledByNative("RTCConfiguration")
752 boolean getSuspendBelowMinBitrate() {
753 return suspendBelowMinBitrate;
754 }
755
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100756 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100757 @CalledByNative("RTCConfiguration")
758 Integer getScreencastMinBitrate() {
759 return screencastMinBitrate;
760 }
761
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100762 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100763 @CalledByNative("RTCConfiguration")
764 Boolean getCombinedAudioVideoBwe() {
765 return combinedAudioVideoBwe;
766 }
767
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100768 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100769 @CalledByNative("RTCConfiguration")
770 Boolean getEnableDtlsSrtp() {
771 return enableDtlsSrtp;
772 }
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800773
774 @CalledByNative("RTCConfiguration")
775 AdapterType getNetworkPreference() {
776 return networkPreference;
777 }
Seth Hampsonc384e142018-03-06 15:47:10 -0800778
779 @CalledByNative("RTCConfiguration")
780 SdpSemantics getSdpSemantics() {
781 return sdpSemantics;
782 }
Zhi Huangb57e1692018-06-12 11:41:11 -0700783
784 @CalledByNative("RTCConfiguration")
785 boolean getActiveResetSrtpParams() {
786 return activeResetSrtpParams;
787 }
Piotr (Peter) Slatala09beff22018-10-17 07:22:40 -0700788
789 @CalledByNative("RTCConfiguration")
790 boolean getUseMediaTransport() {
791 return useMediaTransport;
792 }
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700793
Bjorn Mellema9bbd862018-11-02 09:07:48 -0700794 @CalledByNative("RTCConfiguration")
795 boolean getUseMediaTransportForDataChannels() {
796 return useMediaTransportForDataChannels;
797 }
798
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700799 @Nullable
800 @CalledByNative("RTCConfiguration")
801 CryptoOptions getCryptoOptions() {
802 return cryptoOptions;
803 }
Jiayang Liucac1b382015-04-30 12:35:24 -0700804 };
805
Magnus Jedvert6062f372017-11-16 16:53:12 +0100806 private final List<MediaStream> localStreams = new ArrayList<>();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000807 private final long nativePeerConnection;
Magnus Jedvert6062f372017-11-16 16:53:12 +0100808 private List<RtpSender> senders = new ArrayList<>();
809 private List<RtpReceiver> receivers = new ArrayList<>();
Seth Hampsonc384e142018-03-06 15:47:10 -0800810 private List<RtpTransceiver> transceivers = new ArrayList<>();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000811
Sami Kalliomäki1ece1ed2017-12-20 11:59:22 +0100812 /**
813 * Wraps a PeerConnection created by the factory. Can be used by clients that want to implement
814 * their PeerConnection creation in JNI.
815 */
816 public PeerConnection(NativePeerConnectionFactory factory) {
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100817 this(factory.createNativePeerConnection());
Sami Kalliomäki1ece1ed2017-12-20 11:59:22 +0100818 }
819
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100820 PeerConnection(long nativePeerConnection) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000821 this.nativePeerConnection = nativePeerConnection;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000822 }
823
824 // JsepInterface.
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100825 public SessionDescription getLocalDescription() {
826 return nativeGetLocalDescription();
827 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000828
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100829 public SessionDescription getRemoteDescription() {
830 return nativeGetRemoteDescription();
831 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000832
Michael Iedema02137862018-10-09 15:30:01 +0200833 public RtcCertificatePem getCertificate() {
834 return nativeGetCertificate();
835 }
836
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100837 public DataChannel createDataChannel(String label, DataChannel.Init init) {
838 return nativeCreateDataChannel(label, init);
839 }
henrike@webrtc.org723d6832013-07-12 16:04:50 +0000840
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100841 public void createOffer(SdpObserver observer, MediaConstraints constraints) {
842 nativeCreateOffer(observer, constraints);
843 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000844
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100845 public void createAnswer(SdpObserver observer, MediaConstraints constraints) {
846 nativeCreateAnswer(observer, constraints);
847 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000848
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100849 public void setLocalDescription(SdpObserver observer, SessionDescription sdp) {
850 nativeSetLocalDescription(observer, sdp);
851 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000852
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100853 public void setRemoteDescription(SdpObserver observer, SessionDescription sdp) {
854 nativeSetRemoteDescription(observer, sdp);
855 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000856
Seth Hampsonc384e142018-03-06 15:47:10 -0800857 /**
858 * Enables/disables playout of received audio streams. Enabled by default.
859 *
860 * Note that even if playout is enabled, streams will only be played out if
861 * the appropriate SDP is also applied. The main purpose of this API is to
862 * be able to control the exact time when audio playout starts.
863 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100864 public void setAudioPlayout(boolean playout) {
865 nativeSetAudioPlayout(playout);
866 }
henrika5f6bf242017-11-01 11:06:56 +0100867
Seth Hampsonc384e142018-03-06 15:47:10 -0800868 /**
869 * Enables/disables recording of transmitted audio streams. Enabled by default.
870 *
871 * Note that even if recording is enabled, streams will only be recorded if
872 * the appropriate SDP is also applied. The main purpose of this API is to
873 * be able to control the exact time when audio recording starts.
874 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100875 public void setAudioRecording(boolean recording) {
876 nativeSetAudioRecording(recording);
877 }
henrika5f6bf242017-11-01 11:06:56 +0100878
deadbeef5d0b6d82017-01-09 16:05:28 -0800879 public boolean setConfiguration(RTCConfiguration config) {
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100880 return nativeSetConfiguration(config);
deadbeef5d0b6d82017-01-09 16:05:28 -0800881 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000882
883 public boolean addIceCandidate(IceCandidate candidate) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100884 return nativeAddIceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000885 }
886
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700887 public boolean removeIceCandidates(final IceCandidate[] candidates) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100888 return nativeRemoveIceCandidates(candidates);
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700889 }
890
Seth Hampsonc384e142018-03-06 15:47:10 -0800891 /**
892 * Adds a new MediaStream to be sent on this peer connection.
893 * Note: This method is not supported with SdpSemantics.UNIFIED_PLAN. Please
894 * use addTrack instead.
895 */
perkj@webrtc.orgc2dd5ee2014-11-04 11:31:29 +0000896 public boolean addStream(MediaStream stream) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +0200897 boolean ret = nativeAddLocalStream(stream.getNativeMediaStream());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000898 if (!ret) {
899 return false;
900 }
901 localStreams.add(stream);
902 return true;
903 }
904
Seth Hampsonc384e142018-03-06 15:47:10 -0800905 /**
906 * Removes the given media stream from this peer connection.
907 * This method is not supported with SdpSemantics.UNIFIED_PLAN. Please use
908 * removeTrack instead.
909 */
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000910 public void removeStream(MediaStream stream) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +0200911 nativeRemoveLocalStream(stream.getNativeMediaStream());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000912 localStreams.remove(stream);
913 }
914
deadbeef7a246882017-08-09 08:40:10 -0700915 /**
916 * Creates an RtpSender without a track.
Seth Hampsonc384e142018-03-06 15:47:10 -0800917 *
918 * <p>This method allows an application to cause the PeerConnection to negotiate
deadbeef7a246882017-08-09 08:40:10 -0700919 * sending/receiving a specific media type, but without having a track to
920 * send yet.
Seth Hampsonc384e142018-03-06 15:47:10 -0800921 *
922 * <p>When the application does want to begin sending a track, it can call
deadbeef7a246882017-08-09 08:40:10 -0700923 * RtpSender.setTrack, which doesn't require any additional SDP negotiation.
Seth Hampsonc384e142018-03-06 15:47:10 -0800924 *
925 * <p>Example use:
deadbeef7a246882017-08-09 08:40:10 -0700926 * <pre>
927 * {@code
928 * audioSender = pc.createSender("audio", "stream1");
929 * videoSender = pc.createSender("video", "stream1");
930 * // Do normal SDP offer/answer, which will kick off ICE/DTLS and negotiate
931 * // media parameters....
932 * // Later, when the endpoint is ready to actually begin sending:
933 * audioSender.setTrack(audioTrack, false);
934 * videoSender.setTrack(videoTrack, false);
935 * }
936 * </pre>
Seth Hampsonc384e142018-03-06 15:47:10 -0800937 * <p>Note: This corresponds most closely to "addTransceiver" in the official
deadbeef7a246882017-08-09 08:40:10 -0700938 * WebRTC API, in that it creates a sender without a track. It was
939 * implemented before addTransceiver because it provides useful
940 * functionality, and properly implementing transceivers would have required
941 * a great deal more work.
942 *
Seth Hampsonc384e142018-03-06 15:47:10 -0800943 * <p>Note: This is only available with SdpSemantics.PLAN_B specified. Please use
944 * addTransceiver instead.
945 *
deadbeef7a246882017-08-09 08:40:10 -0700946 * @param kind Corresponds to MediaStreamTrack kinds (must be "audio" or
947 * "video").
948 * @param stream_id The ID of the MediaStream that this sender's track will
949 * be associated with when SDP is applied to the remote
950 * PeerConnection. If createSender is used to create an
951 * audio and video sender that should be synchronized, they
952 * should use the same stream ID.
953 * @return A new RtpSender object if successful, or null otherwise.
954 */
deadbeefbd7d8f72015-12-18 16:58:44 -0800955 public RtpSender createSender(String kind, String stream_id) {
Seth Hampsonc384e142018-03-06 15:47:10 -0800956 RtpSender newSender = nativeCreateSender(kind, stream_id);
957 if (newSender != null) {
958 senders.add(newSender);
deadbeefee524f72015-12-02 11:27:40 -0800959 }
Seth Hampsonc384e142018-03-06 15:47:10 -0800960 return newSender;
deadbeefee524f72015-12-02 11:27:40 -0800961 }
962
Seth Hampsonc384e142018-03-06 15:47:10 -0800963 /**
964 * Gets all RtpSenders associated with this peer connection.
965 * Note that calling getSenders will dispose of the senders previously
966 * returned.
967 */
deadbeef4139c0f2015-10-06 12:29:25 -0700968 public List<RtpSender> getSenders() {
969 for (RtpSender sender : senders) {
970 sender.dispose();
971 }
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100972 senders = nativeGetSenders();
deadbeef4139c0f2015-10-06 12:29:25 -0700973 return Collections.unmodifiableList(senders);
974 }
975
Seth Hampsonc384e142018-03-06 15:47:10 -0800976 /**
977 * Gets all RtpReceivers associated with this peer connection.
978 * Note that calling getReceivers will dispose of the receivers previously
979 * returned.
980 */
deadbeef4139c0f2015-10-06 12:29:25 -0700981 public List<RtpReceiver> getReceivers() {
982 for (RtpReceiver receiver : receivers) {
983 receiver.dispose();
984 }
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100985 receivers = nativeGetReceivers();
deadbeef4139c0f2015-10-06 12:29:25 -0700986 return Collections.unmodifiableList(receivers);
987 }
988
Seth Hampsonc384e142018-03-06 15:47:10 -0800989 /**
990 * Gets all RtpTransceivers associated with this peer connection.
991 * Note that calling getTransceivers will dispose of the transceivers previously
992 * returned.
993 * Note: This is only available with SdpSemantics.UNIFIED_PLAN specified.
994 */
995 public List<RtpTransceiver> getTransceivers() {
996 for (RtpTransceiver transceiver : transceivers) {
997 transceiver.dispose();
998 }
999 transceivers = nativeGetTransceivers();
1000 return Collections.unmodifiableList(transceivers);
1001 }
1002
1003 /**
1004 * Adds a new media stream track to be sent on this peer connection, and returns
1005 * the newly created RtpSender. If streamIds are specified, the RtpSender will
1006 * be associated with the streams specified in the streamIds list.
1007 *
1008 * @throws IllegalStateException if an error accors in C++ addTrack.
1009 * An error can occur if:
1010 * - A sender already exists for the track.
1011 * - The peer connection is closed.
1012 */
1013 public RtpSender addTrack(MediaStreamTrack track) {
1014 return addTrack(track, Collections.emptyList());
1015 }
1016
1017 public RtpSender addTrack(MediaStreamTrack track, List<String> streamIds) {
1018 if (track == null || streamIds == null) {
1019 throw new NullPointerException("No MediaStreamTrack specified in addTrack.");
1020 }
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001021 RtpSender newSender = nativeAddTrack(track.getNativeMediaStreamTrack(), streamIds);
Seth Hampsonc384e142018-03-06 15:47:10 -08001022 if (newSender == null) {
1023 throw new IllegalStateException("C++ addTrack failed.");
1024 }
1025 senders.add(newSender);
1026 return newSender;
1027 }
1028
1029 /**
1030 * Stops sending media from sender. The sender will still appear in getSenders. Future
1031 * calls to createOffer will mark the m section for the corresponding transceiver as
1032 * receive only or inactive, as defined in JSEP. Returns true on success.
1033 */
1034 public boolean removeTrack(RtpSender sender) {
1035 if (sender == null) {
1036 throw new NullPointerException("No RtpSender specified for removeTrack.");
1037 }
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001038 return nativeRemoveTrack(sender.getNativeRtpSender());
Seth Hampsonc384e142018-03-06 15:47:10 -08001039 }
1040
1041 /**
1042 * Creates a new RtpTransceiver and adds it to the set of transceivers. Adding a
1043 * transceiver will cause future calls to CreateOffer to add a media description
1044 * for the corresponding transceiver.
1045 *
1046 * <p>The initial value of |mid| in the returned transceiver is null. Setting a
1047 * new session description may change it to a non-null value.
1048 *
1049 * <p>https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtransceiver
1050 *
1051 * <p>If a MediaStreamTrack is specified then a transceiver will be added with a
1052 * sender set to transmit the given track. The kind
1053 * of the transceiver (and sender/receiver) will be derived from the kind of
1054 * the track.
1055 *
1056 * <p>If MediaType is specified then a transceiver will be added based upon that type.
1057 * This can be either MEDIA_TYPE_AUDIO or MEDIA_TYPE_VIDEO.
1058 *
1059 * <p>Optionally, an RtpTransceiverInit structure can be specified to configure
1060 * the transceiver from construction. If not specified, the transceiver will
1061 * default to having a direction of kSendRecv and not be part of any streams.
1062 *
1063 * <p>Note: These methods are only available with SdpSemantics.UNIFIED_PLAN specified.
1064 * @throws IllegalStateException if an error accors in C++ addTransceiver
1065 */
1066 public RtpTransceiver addTransceiver(MediaStreamTrack track) {
1067 return addTransceiver(track, new RtpTransceiver.RtpTransceiverInit());
1068 }
1069
1070 public RtpTransceiver addTransceiver(
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001071 MediaStreamTrack track, @Nullable RtpTransceiver.RtpTransceiverInit init) {
Seth Hampsonc384e142018-03-06 15:47:10 -08001072 if (track == null) {
1073 throw new NullPointerException("No MediaStreamTrack specified for addTransceiver.");
1074 }
1075 if (init == null) {
1076 init = new RtpTransceiver.RtpTransceiverInit();
1077 }
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001078 RtpTransceiver newTransceiver =
1079 nativeAddTransceiverWithTrack(track.getNativeMediaStreamTrack(), init);
Seth Hampsonc384e142018-03-06 15:47:10 -08001080 if (newTransceiver == null) {
1081 throw new IllegalStateException("C++ addTransceiver failed.");
1082 }
1083 transceivers.add(newTransceiver);
1084 return newTransceiver;
1085 }
1086
1087 public RtpTransceiver addTransceiver(MediaStreamTrack.MediaType mediaType) {
1088 return addTransceiver(mediaType, new RtpTransceiver.RtpTransceiverInit());
1089 }
1090
1091 public RtpTransceiver addTransceiver(
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001092 MediaStreamTrack.MediaType mediaType, @Nullable RtpTransceiver.RtpTransceiverInit init) {
Seth Hampsonc384e142018-03-06 15:47:10 -08001093 if (mediaType == null) {
1094 throw new NullPointerException("No MediaType specified for addTransceiver.");
1095 }
1096 if (init == null) {
1097 init = new RtpTransceiver.RtpTransceiverInit();
1098 }
1099 RtpTransceiver newTransceiver = nativeAddTransceiverOfType(mediaType, init);
1100 if (newTransceiver == null) {
1101 throw new IllegalStateException("C++ addTransceiver failed.");
1102 }
1103 transceivers.add(newTransceiver);
1104 return newTransceiver;
1105 }
1106
deadbeef82215872017-04-18 10:27:51 -07001107 // Older, non-standard implementation of getStats.
1108 @Deprecated
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001109 public boolean getStats(StatsObserver observer, @Nullable MediaStreamTrack track) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001110 return nativeOldGetStats(observer, (track == null) ? 0 : track.getNativeMediaStreamTrack());
deadbeef82215872017-04-18 10:27:51 -07001111 }
1112
Seth Hampsonc384e142018-03-06 15:47:10 -08001113 /**
1114 * Gets stats using the new stats collection API, see webrtc/api/stats/. These
1115 * will replace old stats collection API when the new API has matured enough.
1116 */
deadbeef82215872017-04-18 10:27:51 -07001117 public void getStats(RTCStatsCollectorCallback callback) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001118 nativeNewGetStats(callback);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001119 }
1120
Seth Hampsonc384e142018-03-06 15:47:10 -08001121 /**
1122 * Limits the bandwidth allocated for all RTP streams sent by this
1123 * PeerConnection. Pass null to leave a value unchanged.
1124 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001125 public boolean setBitrate(Integer min, Integer current, Integer max) {
1126 return nativeSetBitrate(min, current, max);
1127 }
zsteind89b0bc2017-08-03 11:11:40 -07001128
Seth Hampsonc384e142018-03-06 15:47:10 -08001129 /**
1130 * Starts recording an RTC event log.
1131 *
1132 * Ownership of the file is transfered to the native code. If an RTC event
1133 * log is already being recorded, it will be stopped and a new one will start
1134 * using the provided file. Logging will continue until the stopRtcEventLog
1135 * function is called. The max_size_bytes argument is ignored, it is added
1136 * for future use.
1137 */
ivoc0c6f0f62016-07-06 04:34:23 -07001138 public boolean startRtcEventLog(int file_descriptor, int max_size_bytes) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001139 return nativeStartRtcEventLog(file_descriptor, max_size_bytes);
ivoc14d5dbe2016-07-04 07:06:55 -07001140 }
1141
Seth Hampsonc384e142018-03-06 15:47:10 -08001142 /**
1143 * Stops recording an RTC event log. If no RTC event log is currently being
1144 * recorded, this call will have no effect.
1145 */
ivoc14d5dbe2016-07-04 07:06:55 -07001146 public void stopRtcEventLog() {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001147 nativeStopRtcEventLog();
ivoc14d5dbe2016-07-04 07:06:55 -07001148 }
1149
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001150 // TODO(fischman): add support for DTMF-related methods once that API
1151 // stabilizes.
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001152 public SignalingState signalingState() {
1153 return nativeSignalingState();
1154 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001155
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001156 public IceConnectionState iceConnectionState() {
1157 return nativeIceConnectionState();
1158 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001159
Jonas Olssonf01d8c82018-11-08 15:19:04 +01001160 public PeerConnectionState connectionState() {
1161 return nativeConnectionState();
1162 }
1163
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001164 public IceGatheringState iceGatheringState() {
1165 return nativeIceGatheringState();
1166 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001167
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001168 public void close() {
1169 nativeClose();
1170 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001171
deadbeef43697f62017-09-12 10:52:14 -07001172 /**
1173 * Free native resources associated with this PeerConnection instance.
Seth Hampsonc384e142018-03-06 15:47:10 -08001174 *
deadbeef43697f62017-09-12 10:52:14 -07001175 * This method removes a reference count from the C++ PeerConnection object,
1176 * which should result in it being destroyed. It also calls equivalent
1177 * "dispose" methods on the Java objects attached to this PeerConnection
1178 * (streams, senders, receivers), such that their associated C++ objects
1179 * will also be destroyed.
Seth Hampsonc384e142018-03-06 15:47:10 -08001180 *
1181 * <p>Note that this method cannot be safely called from an observer callback
deadbeef43697f62017-09-12 10:52:14 -07001182 * (PeerConnection.Observer, DataChannel.Observer, etc.). If you want to, for
1183 * example, destroy the PeerConnection after an "ICE failed" callback, you
1184 * must do this asynchronously (in other words, unwind the stack first). See
1185 * <a href="https://bugs.chromium.org/p/webrtc/issues/detail?id=3721">bug
1186 * 3721</a> for more details.
1187 */
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001188 public void dispose() {
1189 close();
1190 for (MediaStream stream : localStreams) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001191 nativeRemoveLocalStream(stream.getNativeMediaStream());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001192 stream.dispose();
1193 }
1194 localStreams.clear();
deadbeef4139c0f2015-10-06 12:29:25 -07001195 for (RtpSender sender : senders) {
1196 sender.dispose();
1197 }
1198 senders.clear();
1199 for (RtpReceiver receiver : receivers) {
1200 receiver.dispose();
1201 }
Seth Hampsonc384e142018-03-06 15:47:10 -08001202 for (RtpTransceiver transceiver : transceivers) {
1203 transceiver.dispose();
1204 }
1205 transceivers.clear();
deadbeef4139c0f2015-10-06 12:29:25 -07001206 receivers.clear();
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001207 nativeFreeOwnedPeerConnection(nativePeerConnection);
1208 }
1209
1210 /** Returns a pointer to the native webrtc::PeerConnectionInterface. */
1211 public long getNativePeerConnection() {
1212 return nativeGetNativePeerConnection();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001213 }
1214
Magnus Jedvert9060eb12017-12-12 12:52:54 +01001215 @CalledByNative
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001216 long getNativeOwnedPeerConnection() {
Magnus Jedvert9060eb12017-12-12 12:52:54 +01001217 return nativePeerConnection;
1218 }
1219
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001220 public static long createNativePeerConnectionObserver(Observer observer) {
1221 return nativeCreatePeerConnectionObserver(observer);
1222 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001223
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001224 private native long nativeGetNativePeerConnection();
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001225 private native SessionDescription nativeGetLocalDescription();
1226 private native SessionDescription nativeGetRemoteDescription();
Michael Iedema02137862018-10-09 15:30:01 +02001227 private native RtcCertificatePem nativeGetCertificate();
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001228 private native DataChannel nativeCreateDataChannel(String label, DataChannel.Init init);
1229 private native void nativeCreateOffer(SdpObserver observer, MediaConstraints constraints);
1230 private native void nativeCreateAnswer(SdpObserver observer, MediaConstraints constraints);
1231 private native void nativeSetLocalDescription(SdpObserver observer, SessionDescription sdp);
1232 private native void nativeSetRemoteDescription(SdpObserver observer, SessionDescription sdp);
1233 private native void nativeSetAudioPlayout(boolean playout);
1234 private native void nativeSetAudioRecording(boolean recording);
1235 private native boolean nativeSetBitrate(Integer min, Integer current, Integer max);
1236 private native SignalingState nativeSignalingState();
1237 private native IceConnectionState nativeIceConnectionState();
Jonas Olssonf01d8c82018-11-08 15:19:04 +01001238 private native PeerConnectionState nativeConnectionState();
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001239 private native IceGatheringState nativeIceGatheringState();
1240 private native void nativeClose();
1241 private static native long nativeCreatePeerConnectionObserver(Observer observer);
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001242 private static native void nativeFreeOwnedPeerConnection(long ownedPeerConnection);
1243 private native boolean nativeSetConfiguration(RTCConfiguration config);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001244 private native boolean nativeAddIceCandidate(
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001245 String sdpMid, int sdpMLineIndex, String iceCandidateSdp);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001246 private native boolean nativeRemoveIceCandidates(final IceCandidate[] candidates);
1247 private native boolean nativeAddLocalStream(long stream);
1248 private native void nativeRemoveLocalStream(long stream);
1249 private native boolean nativeOldGetStats(StatsObserver observer, long nativeTrack);
1250 private native void nativeNewGetStats(RTCStatsCollectorCallback callback);
1251 private native RtpSender nativeCreateSender(String kind, String stream_id);
1252 private native List<RtpSender> nativeGetSenders();
1253 private native List<RtpReceiver> nativeGetReceivers();
Seth Hampsonc384e142018-03-06 15:47:10 -08001254 private native List<RtpTransceiver> nativeGetTransceivers();
1255 private native RtpSender nativeAddTrack(long track, List<String> streamIds);
1256 private native boolean nativeRemoveTrack(long sender);
1257 private native RtpTransceiver nativeAddTransceiverWithTrack(
1258 long track, RtpTransceiver.RtpTransceiverInit init);
1259 private native RtpTransceiver nativeAddTransceiverOfType(
1260 MediaStreamTrack.MediaType mediaType, RtpTransceiver.RtpTransceiverInit init);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001261 private native boolean nativeStartRtcEventLog(int file_descriptor, int max_size_bytes);
1262 private native void nativeStopRtcEventLog();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001263}