blob: 5f802fb7ca6073735c08bc0860d68cf938f86655 [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 Wange6826d22018-03-08 14:55:14 -0800453 // The following fields define intervals in milliseconds at which ICE
454 // connectivity checks are sent.
455 //
456 // We consider ICE is "strongly connected" for an agent when there is at
457 // least one candidate pair that currently succeeds in connectivity check
458 // from its direction i.e. sending a ping and receives a ping response, AND
459 // all candidate pairs have sent a minimum number of pings for connectivity
460 // (this number is implementation-specific). Otherwise, ICE is considered in
461 // "weak connectivity".
462 //
463 // Note that the above notion of strong and weak connectivity is not defined
464 // in RFC 5245, and they apply to our current ICE implementation only.
465 //
466 // 1) iceCheckIntervalStrongConnectivityMs defines the interval applied to
467 // ALL candidate pairs when ICE is strongly connected,
468 // 2) iceCheckIntervalWeakConnectivityMs defines the counterpart for ALL
469 // pairs when ICE is weakly connected, and
470 // 3) iceCheckMinInterval defines the minimal interval (equivalently the
471 // maximum rate) that overrides the above two intervals when either of them
472 // is less.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100473 @Nullable public Integer iceCheckIntervalStrongConnectivityMs;
474 @Nullable public Integer iceCheckIntervalWeakConnectivityMs;
475 @Nullable public Integer iceCheckMinInterval;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700476 // The time period in milliseconds for which a candidate pair must wait for response to
477 // connectivitiy checks before it becomes unwritable.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100478 @Nullable public Integer iceUnwritableTimeMs;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700479 // The minimum number of connectivity checks that a candidate pair must sent without receiving
480 // response before it becomes unwritable.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100481 @Nullable public Integer iceUnwritableMinChecks;
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800482 // The interval in milliseconds at which STUN candidates will resend STUN binding requests
483 // to keep NAT bindings open.
484 // The default value in the implementation is used if this field is null.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100485 @Nullable public Integer stunCandidateKeepaliveIntervalMs;
zhihuangb09b3f92017-03-07 14:40:51 -0800486 public boolean disableIPv6OnWifi;
deadbeef28e29192017-07-27 09:14:38 -0700487 // By default, PeerConnection will use a limited number of IPv6 network
488 // interfaces, in order to avoid too many ICE candidate pairs being created
489 // and delaying ICE completion.
490 //
491 // Can be set to Integer.MAX_VALUE to effectively disable the limit.
492 public int maxIPv6Networks;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100493 @Nullable public IntervalRange iceRegatherIntervalRange;
Jiayang Liucac1b382015-04-30 12:35:24 -0700494
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100495 // These values will be overridden by MediaStream constraints if deprecated constraints-based
496 // create peerconnection interface is used.
497 public boolean disableIpv6;
498 public boolean enableDscp;
499 public boolean enableCpuOveruseDetection;
500 public boolean enableRtpDataChannel;
501 public boolean suspendBelowMinBitrate;
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100502 @Nullable public Integer screencastMinBitrate;
503 @Nullable public Boolean combinedAudioVideoBwe;
504 @Nullable public Boolean enableDtlsSrtp;
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800505 // Use "Unknown" to represent no preference of adapter types, not the
506 // preference of adapters of unknown types.
507 public AdapterType networkPreference;
Seth Hampsonc384e142018-03-06 15:47:10 -0800508 public SdpSemantics sdpSemantics;
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100509
Jonas Orelandbdcee282017-10-10 14:01:40 +0200510 // This is an optional wrapper for the C++ webrtc::TurnCustomizer.
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100511 @Nullable public TurnCustomizer turnCustomizer;
Jonas Orelandbdcee282017-10-10 14:01:40 +0200512
Zhi Huangb57e1692018-06-12 11:41:11 -0700513 // Actively reset the SRTP parameters whenever the DTLS transports underneath are reset for
514 // every offer/answer negotiation.This is only intended to be a workaround for crbug.com/835958
515 public boolean activeResetSrtpParams;
516
Piotr (Peter) Slatala09beff22018-10-17 07:22:40 -0700517 /*
518 * Experimental flag that enables a use of media transport. If this is true, the media transport
519 * factory MUST be provided to the PeerConnectionFactory.
520 */
521 public boolean useMediaTransport;
522
Bjorn Mellema9bbd862018-11-02 09:07:48 -0700523 /*
524 * Experimental flag that enables a use of media transport for data channels. If this is true,
525 * the media transport factory MUST be provided to the PeerConnectionFactory.
526 */
527 public boolean useMediaTransportForDataChannels;
528
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700529 /**
530 * Defines advanced optional cryptographic settings related to SRTP and
531 * frame encryption for native WebRTC. Setting this will overwrite any
532 * options set through the PeerConnectionFactory (which is deprecated).
533 */
534 @Nullable public CryptoOptions cryptoOptions;
535
deadbeef28e29192017-07-27 09:14:38 -0700536 // TODO(deadbeef): Instead of duplicating the defaults here, we should do
537 // something to pick up the defaults from C++. The Objective-C equivalent
538 // of RTCConfiguration does that.
Jiayang Liucac1b382015-04-30 12:35:24 -0700539 public RTCConfiguration(List<IceServer> iceServers) {
540 iceTransportsType = IceTransportsType.ALL;
541 bundlePolicy = BundlePolicy.BALANCED;
zhihuang4dfb8ce2016-11-23 10:30:12 -0800542 rtcpMuxPolicy = RtcpMuxPolicy.REQUIRE;
Jiayang Liucac1b382015-04-30 12:35:24 -0700543 tcpCandidatePolicy = TcpCandidatePolicy.ENABLED;
Sami Kalliomäki9828beb2017-10-26 16:21:22 +0200544 candidateNetworkPolicy = CandidateNetworkPolicy.ALL;
Jiayang Liucac1b382015-04-30 12:35:24 -0700545 this.iceServers = iceServers;
Henrik Lundin64dad832015-05-11 12:44:23 +0200546 audioJitterBufferMaxPackets = 50;
Henrik Lundin5263b3c2015-06-01 10:29:41 +0200547 audioJitterBufferFastAccelerate = false;
honghaiz4edc39c2015-09-01 09:53:56 -0700548 iceConnectionReceivingTimeout = -1;
Honghai Zhang381b4212015-12-04 12:24:03 -0800549 iceBackupCandidatePairPingInterval = -1;
glaznev97579a42015-09-01 11:31:27 -0700550 keyType = KeyType.ECDSA;
honghaiz1f429e32015-09-28 07:57:34 -0700551 continualGatheringPolicy = ContinualGatheringPolicy.GATHER_ONCE;
deadbeefbe0c96f2016-05-18 16:20:14 -0700552 iceCandidatePoolSize = 0;
Honghai Zhangd78ecf72016-07-01 14:40:40 -0700553 pruneTurnPorts = false;
Taylor Brandstettere9851112016-07-01 11:11:13 -0700554 presumeWritableWhenFullyRelayed = false;
Qingsi Wange6826d22018-03-08 14:55:14 -0800555 iceCheckIntervalStrongConnectivityMs = null;
556 iceCheckIntervalWeakConnectivityMs = null;
skvlad51072462017-02-02 11:50:14 -0800557 iceCheckMinInterval = null;
Qingsi Wang22e623a2018-03-13 10:53:57 -0700558 iceUnwritableTimeMs = null;
559 iceUnwritableMinChecks = null;
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800560 stunCandidateKeepaliveIntervalMs = null;
zhihuangb09b3f92017-03-07 14:40:51 -0800561 disableIPv6OnWifi = false;
deadbeef28e29192017-07-27 09:14:38 -0700562 maxIPv6Networks = 5;
Steve Antond960a0c2017-07-17 12:33:07 -0700563 iceRegatherIntervalRange = null;
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100564 disableIpv6 = false;
565 enableDscp = false;
566 enableCpuOveruseDetection = true;
567 enableRtpDataChannel = false;
568 suspendBelowMinBitrate = false;
569 screencastMinBitrate = null;
570 combinedAudioVideoBwe = null;
571 enableDtlsSrtp = null;
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800572 networkPreference = AdapterType.UNKNOWN;
Seth Hampsonc384e142018-03-06 15:47:10 -0800573 sdpSemantics = SdpSemantics.PLAN_B;
Zhi Huangb57e1692018-06-12 11:41:11 -0700574 activeResetSrtpParams = false;
Piotr (Peter) Slatala09beff22018-10-17 07:22:40 -0700575 useMediaTransport = false;
Bjorn Mellema9bbd862018-11-02 09:07:48 -0700576 useMediaTransportForDataChannels = false;
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700577 cryptoOptions = null;
Jiayang Liucac1b382015-04-30 12:35:24 -0700578 }
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100579
580 @CalledByNative("RTCConfiguration")
581 IceTransportsType getIceTransportsType() {
582 return iceTransportsType;
583 }
584
585 @CalledByNative("RTCConfiguration")
586 List<IceServer> getIceServers() {
587 return iceServers;
588 }
589
590 @CalledByNative("RTCConfiguration")
591 BundlePolicy getBundlePolicy() {
592 return bundlePolicy;
593 }
594
Michael Iedema02137862018-10-09 15:30:01 +0200595 @Nullable
596 @CalledByNative("RTCConfiguration")
597 RtcCertificatePem getCertificate() {
598 return certificate;
599 }
600
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100601 @CalledByNative("RTCConfiguration")
602 RtcpMuxPolicy getRtcpMuxPolicy() {
603 return rtcpMuxPolicy;
604 }
605
606 @CalledByNative("RTCConfiguration")
607 TcpCandidatePolicy getTcpCandidatePolicy() {
608 return tcpCandidatePolicy;
609 }
610
611 @CalledByNative("RTCConfiguration")
612 CandidateNetworkPolicy getCandidateNetworkPolicy() {
613 return candidateNetworkPolicy;
614 }
615
616 @CalledByNative("RTCConfiguration")
617 int getAudioJitterBufferMaxPackets() {
618 return audioJitterBufferMaxPackets;
619 }
620
621 @CalledByNative("RTCConfiguration")
622 boolean getAudioJitterBufferFastAccelerate() {
623 return audioJitterBufferFastAccelerate;
624 }
625
626 @CalledByNative("RTCConfiguration")
627 int getIceConnectionReceivingTimeout() {
628 return iceConnectionReceivingTimeout;
629 }
630
631 @CalledByNative("RTCConfiguration")
632 int getIceBackupCandidatePairPingInterval() {
633 return iceBackupCandidatePairPingInterval;
634 }
635
636 @CalledByNative("RTCConfiguration")
637 KeyType getKeyType() {
638 return keyType;
639 }
640
641 @CalledByNative("RTCConfiguration")
642 ContinualGatheringPolicy getContinualGatheringPolicy() {
643 return continualGatheringPolicy;
644 }
645
646 @CalledByNative("RTCConfiguration")
647 int getIceCandidatePoolSize() {
648 return iceCandidatePoolSize;
649 }
650
651 @CalledByNative("RTCConfiguration")
652 boolean getPruneTurnPorts() {
653 return pruneTurnPorts;
654 }
655
656 @CalledByNative("RTCConfiguration")
657 boolean getPresumeWritableWhenFullyRelayed() {
658 return presumeWritableWhenFullyRelayed;
659 }
660
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100661 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100662 @CalledByNative("RTCConfiguration")
Qingsi Wange6826d22018-03-08 14:55:14 -0800663 Integer getIceCheckIntervalStrongConnectivity() {
664 return iceCheckIntervalStrongConnectivityMs;
665 }
666
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100667 @Nullable
Qingsi Wange6826d22018-03-08 14:55:14 -0800668 @CalledByNative("RTCConfiguration")
669 Integer getIceCheckIntervalWeakConnectivity() {
670 return iceCheckIntervalWeakConnectivityMs;
671 }
672
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100673 @Nullable
Qingsi Wange6826d22018-03-08 14:55:14 -0800674 @CalledByNative("RTCConfiguration")
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100675 Integer getIceCheckMinInterval() {
676 return iceCheckMinInterval;
677 }
678
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100679 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100680 @CalledByNative("RTCConfiguration")
Qingsi Wang22e623a2018-03-13 10:53:57 -0700681 Integer getIceUnwritableTimeout() {
682 return iceUnwritableTimeMs;
683 }
684
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100685 @Nullable
Qingsi Wang22e623a2018-03-13 10:53:57 -0700686 @CalledByNative("RTCConfiguration")
687 Integer getIceUnwritableMinChecks() {
688 return iceUnwritableMinChecks;
689 }
690
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100691 @Nullable
Qingsi Wang22e623a2018-03-13 10:53:57 -0700692 @CalledByNative("RTCConfiguration")
Qingsi Wangdb53f8e2018-02-20 14:45:49 -0800693 Integer getStunCandidateKeepaliveInterval() {
694 return stunCandidateKeepaliveIntervalMs;
695 }
696
697 @CalledByNative("RTCConfiguration")
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100698 boolean getDisableIPv6OnWifi() {
699 return disableIPv6OnWifi;
700 }
701
702 @CalledByNative("RTCConfiguration")
703 int getMaxIPv6Networks() {
704 return maxIPv6Networks;
705 }
706
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100707 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100708 @CalledByNative("RTCConfiguration")
709 IntervalRange getIceRegatherIntervalRange() {
710 return iceRegatherIntervalRange;
711 }
712
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100713 @Nullable
Magnus Jedvert9060eb12017-12-12 12:52:54 +0100714 @CalledByNative("RTCConfiguration")
715 TurnCustomizer getTurnCustomizer() {
716 return turnCustomizer;
717 }
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100718
719 @CalledByNative("RTCConfiguration")
720 boolean getDisableIpv6() {
721 return disableIpv6;
722 }
723
724 @CalledByNative("RTCConfiguration")
725 boolean getEnableDscp() {
726 return enableDscp;
727 }
728
729 @CalledByNative("RTCConfiguration")
730 boolean getEnableCpuOveruseDetection() {
731 return enableCpuOveruseDetection;
732 }
733
734 @CalledByNative("RTCConfiguration")
735 boolean getEnableRtpDataChannel() {
736 return enableRtpDataChannel;
737 }
738
739 @CalledByNative("RTCConfiguration")
740 boolean getSuspendBelowMinBitrate() {
741 return suspendBelowMinBitrate;
742 }
743
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100744 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100745 @CalledByNative("RTCConfiguration")
746 Integer getScreencastMinBitrate() {
747 return screencastMinBitrate;
748 }
749
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100750 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100751 @CalledByNative("RTCConfiguration")
752 Boolean getCombinedAudioVideoBwe() {
753 return combinedAudioVideoBwe;
754 }
755
Sami Kalliomäkie7592d82018-03-22 13:32:44 +0100756 @Nullable
Sami Kalliomäkie8b26cd2017-12-19 12:51:53 +0100757 @CalledByNative("RTCConfiguration")
758 Boolean getEnableDtlsSrtp() {
759 return enableDtlsSrtp;
760 }
Qingsi Wang9a5c6f82018-02-01 10:38:40 -0800761
762 @CalledByNative("RTCConfiguration")
763 AdapterType getNetworkPreference() {
764 return networkPreference;
765 }
Seth Hampsonc384e142018-03-06 15:47:10 -0800766
767 @CalledByNative("RTCConfiguration")
768 SdpSemantics getSdpSemantics() {
769 return sdpSemantics;
770 }
Zhi Huangb57e1692018-06-12 11:41:11 -0700771
772 @CalledByNative("RTCConfiguration")
773 boolean getActiveResetSrtpParams() {
774 return activeResetSrtpParams;
775 }
Piotr (Peter) Slatala09beff22018-10-17 07:22:40 -0700776
777 @CalledByNative("RTCConfiguration")
778 boolean getUseMediaTransport() {
779 return useMediaTransport;
780 }
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700781
Bjorn Mellema9bbd862018-11-02 09:07:48 -0700782 @CalledByNative("RTCConfiguration")
783 boolean getUseMediaTransportForDataChannels() {
784 return useMediaTransportForDataChannels;
785 }
786
Benjamin Wright8c27cca2018-10-25 10:16:44 -0700787 @Nullable
788 @CalledByNative("RTCConfiguration")
789 CryptoOptions getCryptoOptions() {
790 return cryptoOptions;
791 }
Jiayang Liucac1b382015-04-30 12:35:24 -0700792 };
793
Magnus Jedvert6062f372017-11-16 16:53:12 +0100794 private final List<MediaStream> localStreams = new ArrayList<>();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000795 private final long nativePeerConnection;
Magnus Jedvert6062f372017-11-16 16:53:12 +0100796 private List<RtpSender> senders = new ArrayList<>();
797 private List<RtpReceiver> receivers = new ArrayList<>();
Seth Hampsonc384e142018-03-06 15:47:10 -0800798 private List<RtpTransceiver> transceivers = new ArrayList<>();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000799
Sami Kalliomäki1ece1ed2017-12-20 11:59:22 +0100800 /**
801 * Wraps a PeerConnection created by the factory. Can be used by clients that want to implement
802 * their PeerConnection creation in JNI.
803 */
804 public PeerConnection(NativePeerConnectionFactory factory) {
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100805 this(factory.createNativePeerConnection());
Sami Kalliomäki1ece1ed2017-12-20 11:59:22 +0100806 }
807
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100808 PeerConnection(long nativePeerConnection) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000809 this.nativePeerConnection = nativePeerConnection;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000810 }
811
812 // JsepInterface.
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100813 public SessionDescription getLocalDescription() {
814 return nativeGetLocalDescription();
815 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000816
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100817 public SessionDescription getRemoteDescription() {
818 return nativeGetRemoteDescription();
819 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000820
Michael Iedema02137862018-10-09 15:30:01 +0200821 public RtcCertificatePem getCertificate() {
822 return nativeGetCertificate();
823 }
824
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100825 public DataChannel createDataChannel(String label, DataChannel.Init init) {
826 return nativeCreateDataChannel(label, init);
827 }
henrike@webrtc.org723d6832013-07-12 16:04:50 +0000828
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100829 public void createOffer(SdpObserver observer, MediaConstraints constraints) {
830 nativeCreateOffer(observer, constraints);
831 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000832
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100833 public void createAnswer(SdpObserver observer, MediaConstraints constraints) {
834 nativeCreateAnswer(observer, constraints);
835 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000836
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100837 public void setLocalDescription(SdpObserver observer, SessionDescription sdp) {
838 nativeSetLocalDescription(observer, sdp);
839 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000840
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100841 public void setRemoteDescription(SdpObserver observer, SessionDescription sdp) {
842 nativeSetRemoteDescription(observer, sdp);
843 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000844
Seth Hampsonc384e142018-03-06 15:47:10 -0800845 /**
846 * Enables/disables playout of received audio streams. Enabled by default.
847 *
848 * Note that even if playout is enabled, streams will only be played out if
849 * the appropriate SDP is also applied. The main purpose of this API is to
850 * be able to control the exact time when audio playout starts.
851 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100852 public void setAudioPlayout(boolean playout) {
853 nativeSetAudioPlayout(playout);
854 }
henrika5f6bf242017-11-01 11:06:56 +0100855
Seth Hampsonc384e142018-03-06 15:47:10 -0800856 /**
857 * Enables/disables recording of transmitted audio streams. Enabled by default.
858 *
859 * Note that even if recording is enabled, streams will only be recorded if
860 * the appropriate SDP is also applied. The main purpose of this API is to
861 * be able to control the exact time when audio recording starts.
862 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100863 public void setAudioRecording(boolean recording) {
864 nativeSetAudioRecording(recording);
865 }
henrika5f6bf242017-11-01 11:06:56 +0100866
deadbeef5d0b6d82017-01-09 16:05:28 -0800867 public boolean setConfiguration(RTCConfiguration config) {
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +0100868 return nativeSetConfiguration(config);
deadbeef5d0b6d82017-01-09 16:05:28 -0800869 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000870
871 public boolean addIceCandidate(IceCandidate candidate) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100872 return nativeAddIceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000873 }
874
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700875 public boolean removeIceCandidates(final IceCandidate[] candidates) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100876 return nativeRemoveIceCandidates(candidates);
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700877 }
878
Seth Hampsonc384e142018-03-06 15:47:10 -0800879 /**
880 * Adds a new MediaStream to be sent on this peer connection.
881 * Note: This method is not supported with SdpSemantics.UNIFIED_PLAN. Please
882 * use addTrack instead.
883 */
perkj@webrtc.orgc2dd5ee2014-11-04 11:31:29 +0000884 public boolean addStream(MediaStream stream) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +0200885 boolean ret = nativeAddLocalStream(stream.getNativeMediaStream());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000886 if (!ret) {
887 return false;
888 }
889 localStreams.add(stream);
890 return true;
891 }
892
Seth Hampsonc384e142018-03-06 15:47:10 -0800893 /**
894 * Removes the given media stream from this peer connection.
895 * This method is not supported with SdpSemantics.UNIFIED_PLAN. Please use
896 * removeTrack instead.
897 */
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000898 public void removeStream(MediaStream stream) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +0200899 nativeRemoveLocalStream(stream.getNativeMediaStream());
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000900 localStreams.remove(stream);
901 }
902
deadbeef7a246882017-08-09 08:40:10 -0700903 /**
904 * Creates an RtpSender without a track.
Seth Hampsonc384e142018-03-06 15:47:10 -0800905 *
906 * <p>This method allows an application to cause the PeerConnection to negotiate
deadbeef7a246882017-08-09 08:40:10 -0700907 * sending/receiving a specific media type, but without having a track to
908 * send yet.
Seth Hampsonc384e142018-03-06 15:47:10 -0800909 *
910 * <p>When the application does want to begin sending a track, it can call
deadbeef7a246882017-08-09 08:40:10 -0700911 * RtpSender.setTrack, which doesn't require any additional SDP negotiation.
Seth Hampsonc384e142018-03-06 15:47:10 -0800912 *
913 * <p>Example use:
deadbeef7a246882017-08-09 08:40:10 -0700914 * <pre>
915 * {@code
916 * audioSender = pc.createSender("audio", "stream1");
917 * videoSender = pc.createSender("video", "stream1");
918 * // Do normal SDP offer/answer, which will kick off ICE/DTLS and negotiate
919 * // media parameters....
920 * // Later, when the endpoint is ready to actually begin sending:
921 * audioSender.setTrack(audioTrack, false);
922 * videoSender.setTrack(videoTrack, false);
923 * }
924 * </pre>
Seth Hampsonc384e142018-03-06 15:47:10 -0800925 * <p>Note: This corresponds most closely to "addTransceiver" in the official
deadbeef7a246882017-08-09 08:40:10 -0700926 * WebRTC API, in that it creates a sender without a track. It was
927 * implemented before addTransceiver because it provides useful
928 * functionality, and properly implementing transceivers would have required
929 * a great deal more work.
930 *
Seth Hampsonc384e142018-03-06 15:47:10 -0800931 * <p>Note: This is only available with SdpSemantics.PLAN_B specified. Please use
932 * addTransceiver instead.
933 *
deadbeef7a246882017-08-09 08:40:10 -0700934 * @param kind Corresponds to MediaStreamTrack kinds (must be "audio" or
935 * "video").
936 * @param stream_id The ID of the MediaStream that this sender's track will
937 * be associated with when SDP is applied to the remote
938 * PeerConnection. If createSender is used to create an
939 * audio and video sender that should be synchronized, they
940 * should use the same stream ID.
941 * @return A new RtpSender object if successful, or null otherwise.
942 */
deadbeefbd7d8f72015-12-18 16:58:44 -0800943 public RtpSender createSender(String kind, String stream_id) {
Seth Hampsonc384e142018-03-06 15:47:10 -0800944 RtpSender newSender = nativeCreateSender(kind, stream_id);
945 if (newSender != null) {
946 senders.add(newSender);
deadbeefee524f72015-12-02 11:27:40 -0800947 }
Seth Hampsonc384e142018-03-06 15:47:10 -0800948 return newSender;
deadbeefee524f72015-12-02 11:27:40 -0800949 }
950
Seth Hampsonc384e142018-03-06 15:47:10 -0800951 /**
952 * Gets all RtpSenders associated with this peer connection.
953 * Note that calling getSenders will dispose of the senders previously
954 * returned.
955 */
deadbeef4139c0f2015-10-06 12:29:25 -0700956 public List<RtpSender> getSenders() {
957 for (RtpSender sender : senders) {
958 sender.dispose();
959 }
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100960 senders = nativeGetSenders();
deadbeef4139c0f2015-10-06 12:29:25 -0700961 return Collections.unmodifiableList(senders);
962 }
963
Seth Hampsonc384e142018-03-06 15:47:10 -0800964 /**
965 * Gets all RtpReceivers associated with this peer connection.
966 * Note that calling getReceivers will dispose of the receivers previously
967 * returned.
968 */
deadbeef4139c0f2015-10-06 12:29:25 -0700969 public List<RtpReceiver> getReceivers() {
970 for (RtpReceiver receiver : receivers) {
971 receiver.dispose();
972 }
Magnus Jedvert84d8ae52017-12-20 15:12:10 +0100973 receivers = nativeGetReceivers();
deadbeef4139c0f2015-10-06 12:29:25 -0700974 return Collections.unmodifiableList(receivers);
975 }
976
Seth Hampsonc384e142018-03-06 15:47:10 -0800977 /**
978 * Gets all RtpTransceivers associated with this peer connection.
979 * Note that calling getTransceivers will dispose of the transceivers previously
980 * returned.
981 * Note: This is only available with SdpSemantics.UNIFIED_PLAN specified.
982 */
983 public List<RtpTransceiver> getTransceivers() {
984 for (RtpTransceiver transceiver : transceivers) {
985 transceiver.dispose();
986 }
987 transceivers = nativeGetTransceivers();
988 return Collections.unmodifiableList(transceivers);
989 }
990
991 /**
992 * Adds a new media stream track to be sent on this peer connection, and returns
993 * the newly created RtpSender. If streamIds are specified, the RtpSender will
994 * be associated with the streams specified in the streamIds list.
995 *
996 * @throws IllegalStateException if an error accors in C++ addTrack.
997 * An error can occur if:
998 * - A sender already exists for the track.
999 * - The peer connection is closed.
1000 */
1001 public RtpSender addTrack(MediaStreamTrack track) {
1002 return addTrack(track, Collections.emptyList());
1003 }
1004
1005 public RtpSender addTrack(MediaStreamTrack track, List<String> streamIds) {
1006 if (track == null || streamIds == null) {
1007 throw new NullPointerException("No MediaStreamTrack specified in addTrack.");
1008 }
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001009 RtpSender newSender = nativeAddTrack(track.getNativeMediaStreamTrack(), streamIds);
Seth Hampsonc384e142018-03-06 15:47:10 -08001010 if (newSender == null) {
1011 throw new IllegalStateException("C++ addTrack failed.");
1012 }
1013 senders.add(newSender);
1014 return newSender;
1015 }
1016
1017 /**
1018 * Stops sending media from sender. The sender will still appear in getSenders. Future
1019 * calls to createOffer will mark the m section for the corresponding transceiver as
1020 * receive only or inactive, as defined in JSEP. Returns true on success.
1021 */
1022 public boolean removeTrack(RtpSender sender) {
1023 if (sender == null) {
1024 throw new NullPointerException("No RtpSender specified for removeTrack.");
1025 }
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001026 return nativeRemoveTrack(sender.getNativeRtpSender());
Seth Hampsonc384e142018-03-06 15:47:10 -08001027 }
1028
1029 /**
1030 * Creates a new RtpTransceiver and adds it to the set of transceivers. Adding a
1031 * transceiver will cause future calls to CreateOffer to add a media description
1032 * for the corresponding transceiver.
1033 *
1034 * <p>The initial value of |mid| in the returned transceiver is null. Setting a
1035 * new session description may change it to a non-null value.
1036 *
1037 * <p>https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtransceiver
1038 *
1039 * <p>If a MediaStreamTrack is specified then a transceiver will be added with a
1040 * sender set to transmit the given track. The kind
1041 * of the transceiver (and sender/receiver) will be derived from the kind of
1042 * the track.
1043 *
1044 * <p>If MediaType is specified then a transceiver will be added based upon that type.
1045 * This can be either MEDIA_TYPE_AUDIO or MEDIA_TYPE_VIDEO.
1046 *
1047 * <p>Optionally, an RtpTransceiverInit structure can be specified to configure
1048 * the transceiver from construction. If not specified, the transceiver will
1049 * default to having a direction of kSendRecv and not be part of any streams.
1050 *
1051 * <p>Note: These methods are only available with SdpSemantics.UNIFIED_PLAN specified.
1052 * @throws IllegalStateException if an error accors in C++ addTransceiver
1053 */
1054 public RtpTransceiver addTransceiver(MediaStreamTrack track) {
1055 return addTransceiver(track, new RtpTransceiver.RtpTransceiverInit());
1056 }
1057
1058 public RtpTransceiver addTransceiver(
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001059 MediaStreamTrack track, @Nullable RtpTransceiver.RtpTransceiverInit init) {
Seth Hampsonc384e142018-03-06 15:47:10 -08001060 if (track == null) {
1061 throw new NullPointerException("No MediaStreamTrack specified for addTransceiver.");
1062 }
1063 if (init == null) {
1064 init = new RtpTransceiver.RtpTransceiverInit();
1065 }
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001066 RtpTransceiver newTransceiver =
1067 nativeAddTransceiverWithTrack(track.getNativeMediaStreamTrack(), init);
Seth Hampsonc384e142018-03-06 15:47:10 -08001068 if (newTransceiver == null) {
1069 throw new IllegalStateException("C++ addTransceiver failed.");
1070 }
1071 transceivers.add(newTransceiver);
1072 return newTransceiver;
1073 }
1074
1075 public RtpTransceiver addTransceiver(MediaStreamTrack.MediaType mediaType) {
1076 return addTransceiver(mediaType, new RtpTransceiver.RtpTransceiverInit());
1077 }
1078
1079 public RtpTransceiver addTransceiver(
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001080 MediaStreamTrack.MediaType mediaType, @Nullable RtpTransceiver.RtpTransceiverInit init) {
Seth Hampsonc384e142018-03-06 15:47:10 -08001081 if (mediaType == null) {
1082 throw new NullPointerException("No MediaType specified for addTransceiver.");
1083 }
1084 if (init == null) {
1085 init = new RtpTransceiver.RtpTransceiverInit();
1086 }
1087 RtpTransceiver newTransceiver = nativeAddTransceiverOfType(mediaType, init);
1088 if (newTransceiver == null) {
1089 throw new IllegalStateException("C++ addTransceiver failed.");
1090 }
1091 transceivers.add(newTransceiver);
1092 return newTransceiver;
1093 }
1094
deadbeef82215872017-04-18 10:27:51 -07001095 // Older, non-standard implementation of getStats.
1096 @Deprecated
Sami Kalliomäkie7592d82018-03-22 13:32:44 +01001097 public boolean getStats(StatsObserver observer, @Nullable MediaStreamTrack track) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001098 return nativeOldGetStats(observer, (track == null) ? 0 : track.getNativeMediaStreamTrack());
deadbeef82215872017-04-18 10:27:51 -07001099 }
1100
Seth Hampsonc384e142018-03-06 15:47:10 -08001101 /**
1102 * Gets stats using the new stats collection API, see webrtc/api/stats/. These
1103 * will replace old stats collection API when the new API has matured enough.
1104 */
deadbeef82215872017-04-18 10:27:51 -07001105 public void getStats(RTCStatsCollectorCallback callback) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001106 nativeNewGetStats(callback);
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001107 }
1108
Seth Hampsonc384e142018-03-06 15:47:10 -08001109 /**
1110 * Limits the bandwidth allocated for all RTP streams sent by this
1111 * PeerConnection. Pass null to leave a value unchanged.
1112 */
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001113 public boolean setBitrate(Integer min, Integer current, Integer max) {
1114 return nativeSetBitrate(min, current, max);
1115 }
zsteind89b0bc2017-08-03 11:11:40 -07001116
Seth Hampsonc384e142018-03-06 15:47:10 -08001117 /**
1118 * Starts recording an RTC event log.
1119 *
1120 * Ownership of the file is transfered to the native code. If an RTC event
1121 * log is already being recorded, it will be stopped and a new one will start
1122 * using the provided file. Logging will continue until the stopRtcEventLog
1123 * function is called. The max_size_bytes argument is ignored, it is added
1124 * for future use.
1125 */
ivoc0c6f0f62016-07-06 04:34:23 -07001126 public boolean startRtcEventLog(int file_descriptor, int max_size_bytes) {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001127 return nativeStartRtcEventLog(file_descriptor, max_size_bytes);
ivoc14d5dbe2016-07-04 07:06:55 -07001128 }
1129
Seth Hampsonc384e142018-03-06 15:47:10 -08001130 /**
1131 * Stops recording an RTC event log. If no RTC event log is currently being
1132 * recorded, this call will have no effect.
1133 */
ivoc14d5dbe2016-07-04 07:06:55 -07001134 public void stopRtcEventLog() {
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001135 nativeStopRtcEventLog();
ivoc14d5dbe2016-07-04 07:06:55 -07001136 }
1137
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001138 // TODO(fischman): add support for DTMF-related methods once that API
1139 // stabilizes.
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001140 public SignalingState signalingState() {
1141 return nativeSignalingState();
1142 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001143
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001144 public IceConnectionState iceConnectionState() {
1145 return nativeIceConnectionState();
1146 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001147
Jonas Olssonf01d8c82018-11-08 15:19:04 +01001148 public PeerConnectionState connectionState() {
1149 return nativeConnectionState();
1150 }
1151
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001152 public IceGatheringState iceGatheringState() {
1153 return nativeIceGatheringState();
1154 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001155
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001156 public void close() {
1157 nativeClose();
1158 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001159
deadbeef43697f62017-09-12 10:52:14 -07001160 /**
1161 * Free native resources associated with this PeerConnection instance.
Seth Hampsonc384e142018-03-06 15:47:10 -08001162 *
deadbeef43697f62017-09-12 10:52:14 -07001163 * This method removes a reference count from the C++ PeerConnection object,
1164 * which should result in it being destroyed. It also calls equivalent
1165 * "dispose" methods on the Java objects attached to this PeerConnection
1166 * (streams, senders, receivers), such that their associated C++ objects
1167 * will also be destroyed.
Seth Hampsonc384e142018-03-06 15:47:10 -08001168 *
1169 * <p>Note that this method cannot be safely called from an observer callback
deadbeef43697f62017-09-12 10:52:14 -07001170 * (PeerConnection.Observer, DataChannel.Observer, etc.). If you want to, for
1171 * example, destroy the PeerConnection after an "ICE failed" callback, you
1172 * must do this asynchronously (in other words, unwind the stack first). See
1173 * <a href="https://bugs.chromium.org/p/webrtc/issues/detail?id=3721">bug
1174 * 3721</a> for more details.
1175 */
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001176 public void dispose() {
1177 close();
1178 for (MediaStream stream : localStreams) {
Sami Kalliomäkiee05e902018-09-28 14:38:21 +02001179 nativeRemoveLocalStream(stream.getNativeMediaStream());
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001180 stream.dispose();
1181 }
1182 localStreams.clear();
deadbeef4139c0f2015-10-06 12:29:25 -07001183 for (RtpSender sender : senders) {
1184 sender.dispose();
1185 }
1186 senders.clear();
1187 for (RtpReceiver receiver : receivers) {
1188 receiver.dispose();
1189 }
Seth Hampsonc384e142018-03-06 15:47:10 -08001190 for (RtpTransceiver transceiver : transceivers) {
1191 transceiver.dispose();
1192 }
1193 transceivers.clear();
deadbeef4139c0f2015-10-06 12:29:25 -07001194 receivers.clear();
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001195 nativeFreeOwnedPeerConnection(nativePeerConnection);
1196 }
1197
1198 /** Returns a pointer to the native webrtc::PeerConnectionInterface. */
1199 public long getNativePeerConnection() {
1200 return nativeGetNativePeerConnection();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001201 }
1202
Magnus Jedvert9060eb12017-12-12 12:52:54 +01001203 @CalledByNative
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001204 long getNativeOwnedPeerConnection() {
Magnus Jedvert9060eb12017-12-12 12:52:54 +01001205 return nativePeerConnection;
1206 }
1207
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001208 public static long createNativePeerConnectionObserver(Observer observer) {
1209 return nativeCreatePeerConnectionObserver(observer);
1210 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001211
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001212 private native long nativeGetNativePeerConnection();
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001213 private native SessionDescription nativeGetLocalDescription();
1214 private native SessionDescription nativeGetRemoteDescription();
Michael Iedema02137862018-10-09 15:30:01 +02001215 private native RtcCertificatePem nativeGetCertificate();
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001216 private native DataChannel nativeCreateDataChannel(String label, DataChannel.Init init);
1217 private native void nativeCreateOffer(SdpObserver observer, MediaConstraints constraints);
1218 private native void nativeCreateAnswer(SdpObserver observer, MediaConstraints constraints);
1219 private native void nativeSetLocalDescription(SdpObserver observer, SessionDescription sdp);
1220 private native void nativeSetRemoteDescription(SdpObserver observer, SessionDescription sdp);
1221 private native void nativeSetAudioPlayout(boolean playout);
1222 private native void nativeSetAudioRecording(boolean recording);
1223 private native boolean nativeSetBitrate(Integer min, Integer current, Integer max);
1224 private native SignalingState nativeSignalingState();
1225 private native IceConnectionState nativeIceConnectionState();
Jonas Olssonf01d8c82018-11-08 15:19:04 +01001226 private native PeerConnectionState nativeConnectionState();
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001227 private native IceGatheringState nativeIceGatheringState();
1228 private native void nativeClose();
1229 private static native long nativeCreatePeerConnectionObserver(Observer observer);
Sami Kalliomäkice5c19a2018-01-15 09:28:34 +01001230 private static native void nativeFreeOwnedPeerConnection(long ownedPeerConnection);
1231 private native boolean nativeSetConfiguration(RTCConfiguration config);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001232 private native boolean nativeAddIceCandidate(
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001233 String sdpMid, int sdpMLineIndex, String iceCandidateSdp);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001234 private native boolean nativeRemoveIceCandidates(final IceCandidate[] candidates);
1235 private native boolean nativeAddLocalStream(long stream);
1236 private native void nativeRemoveLocalStream(long stream);
1237 private native boolean nativeOldGetStats(StatsObserver observer, long nativeTrack);
1238 private native void nativeNewGetStats(RTCStatsCollectorCallback callback);
1239 private native RtpSender nativeCreateSender(String kind, String stream_id);
1240 private native List<RtpSender> nativeGetSenders();
1241 private native List<RtpReceiver> nativeGetReceivers();
Seth Hampsonc384e142018-03-06 15:47:10 -08001242 private native List<RtpTransceiver> nativeGetTransceivers();
1243 private native RtpSender nativeAddTrack(long track, List<String> streamIds);
1244 private native boolean nativeRemoveTrack(long sender);
1245 private native RtpTransceiver nativeAddTransceiverWithTrack(
1246 long track, RtpTransceiver.RtpTransceiverInit init);
1247 private native RtpTransceiver nativeAddTransceiverOfType(
1248 MediaStreamTrack.MediaType mediaType, RtpTransceiver.RtpTransceiverInit init);
Magnus Jedvert84d8ae52017-12-20 15:12:10 +01001249 private native boolean nativeStartRtcEventLog(int file_descriptor, int max_size_bytes);
1250 private native void nativeStopRtcEventLog();
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001251}