Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: webrtc/sdk/android/api/org/webrtc/PeerConnection.java

Issue 3012843002: android: add IceServer.urls field (Closed)
Patch Set: urls.isEmpty check inside builder's constructor Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 * setRemoteDescription. 92 * setRemoteDescription.
93 */ 93 */
94 public void onAddTrack(RtpReceiver receiver, MediaStream[] mediaStreams); 94 public void onAddTrack(RtpReceiver receiver, MediaStream[] mediaStreams);
95 } 95 }
96 96
97 /** Java version of PeerConnectionInterface.IceServer. */ 97 /** Java version of PeerConnectionInterface.IceServer. */
98 public static class IceServer { 98 public static class IceServer {
99 // List of URIs associated with this server. Valid formats are described 99 // List of URIs associated with this server. Valid formats are described
100 // in RFC7064 and RFC7065, and more may be added in the future. The "host" 100 // in RFC7064 and RFC7065, and more may be added in the future. The "host"
101 // part of the URI may contain either an IP address or a hostname. 101 // part of the URI may contain either an IP address or a hostname.
102 public final String uri; 102 @Deprecated public final String uri;
103 public final List<String> urls;
103 public final String username; 104 public final String username;
104 public final String password; 105 public final String password;
105 public final TlsCertPolicy tlsCertPolicy; 106 public final TlsCertPolicy tlsCertPolicy;
106 107
107 // If the URIs in |urls| only contain IP addresses, this field can be used 108 // If the URIs in |urls| only contain IP addresses, this field can be used
108 // to indicate the hostname, which may be necessary for TLS (using the SNI 109 // to indicate the hostname, which may be necessary for TLS (using the SNI
109 // extension). If |urls| itself contains the hostname, this isn't 110 // extension). If |urls| itself contains the hostname, this isn't
110 // necessary. 111 // necessary.
111 public final String hostname; 112 public final String hostname;
112 113
(...skipping 12 matching lines...) Expand all
125 } 126 }
126 127
127 @Deprecated 128 @Deprecated
128 public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy) { 129 public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy) {
129 this(uri, username, password, tlsCertPolicy, ""); 130 this(uri, username, password, tlsCertPolicy, "");
130 } 131 }
131 132
132 @Deprecated 133 @Deprecated
133 public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy, 134 public IceServer(String uri, String username, String password, TlsCertPolicy tlsCertPolicy,
134 String hostname) { 135 String hostname) {
135 this(uri, username, password, tlsCertPolicy, hostname, null); 136 this(uri, Collections.singletonList(uri), username, password, tlsCertPolic y, hostname, null);
136 } 137 }
137 138
138 private IceServer(String uri, String username, String password, TlsCertPolic y tlsCertPolicy, 139 private IceServer(String uri, List<String> urls, String username, String pas sword,
139 String hostname, List<String> tlsAlpnProtocols) { 140 TlsCertPolicy tlsCertPolicy, String hostname, List<String> tlsAlpnProtoc ols) {
141 if (uri == null || urls == null || urls.isEmpty()) {
142 throw new IllegalArgumentException("uri == null || urls == null || urls. isEmpty()");
143 }
144 for (String it : urls) {
145 if (it == null) {
146 throw new IllegalArgumentException("urls element is null: " + urls);
147 }
148 }
149 if (username == null) {
150 throw new IllegalArgumentException("username == null");
151 }
152 if (password == null) {
153 throw new IllegalArgumentException("password == null");
154 }
155 if (hostname == null) {
156 throw new IllegalArgumentException("hostname == null");
157 }
140 this.uri = uri; 158 this.uri = uri;
159 this.urls = urls;
141 this.username = username; 160 this.username = username;
142 this.password = password; 161 this.password = password;
143 this.tlsCertPolicy = tlsCertPolicy; 162 this.tlsCertPolicy = tlsCertPolicy;
144 this.hostname = hostname; 163 this.hostname = hostname;
145 this.tlsAlpnProtocols = tlsAlpnProtocols; 164 this.tlsAlpnProtocols = tlsAlpnProtocols;
146 } 165 }
147 166
148 public String toString() { 167 public String toString() {
149 return uri + " [" + username + ":" + password + "] [" + tlsCertPolicy + "] [" + hostname 168 return urls + " [" + username + ":" + password + "] [" + tlsCertPolicy + " ] [" + hostname
150 + "] [" + tlsAlpnProtocols + "]"; 169 + "] [" + tlsAlpnProtocols + "]";
151 } 170 }
152 171
153 public static Builder builder(String uri) { 172 public static Builder builder(String uri) {
154 return new Builder(uri); 173 return new Builder(Collections.singletonList(uri));
174 }
175
176 public static Builder builder(List<String> urls) {
177 return new Builder(urls);
155 } 178 }
156 179
157 public static class Builder { 180 public static class Builder {
158 private String uri; 181 private final List<String> urls;
159 private String username = ""; 182 private String username = "";
160 private String password = ""; 183 private String password = "";
161 private TlsCertPolicy tlsCertPolicy = TlsCertPolicy.TLS_CERT_POLICY_SECURE ; 184 private TlsCertPolicy tlsCertPolicy = TlsCertPolicy.TLS_CERT_POLICY_SECURE ;
162 private String hostname = ""; 185 private String hostname = "";
163 private List<String> tlsAlpnProtocols; 186 private List<String> tlsAlpnProtocols;
164 187
165 private Builder(String uri) { 188 private Builder(List<String> urls) {
166 this.uri = uri; 189 if (urls.isEmpty()) {
190 throw new IllegalArgumentException("urls.isEmpty()");
191 }
192 this.urls = urls;
167 } 193 }
168 194
169 public Builder setUsername(String username) { 195 public Builder setUsername(String username) {
170 this.username = username; 196 this.username = username;
171 return this; 197 return this;
172 } 198 }
173 199
174 public Builder setPassword(String password) { 200 public Builder setPassword(String password) {
175 this.password = password; 201 this.password = password;
176 return this; 202 return this;
177 } 203 }
178 204
179 public Builder setTlsCertPolicy(TlsCertPolicy tlsCertPolicy) { 205 public Builder setTlsCertPolicy(TlsCertPolicy tlsCertPolicy) {
180 this.tlsCertPolicy = tlsCertPolicy; 206 this.tlsCertPolicy = tlsCertPolicy;
181 return this; 207 return this;
182 } 208 }
183 209
184 public Builder setHostname(String hostname) { 210 public Builder setHostname(String hostname) {
185 this.hostname = hostname; 211 this.hostname = hostname;
186 return this; 212 return this;
187 } 213 }
188 214
189 public Builder setTlsAlpnProtocols(List<String> tlsAlpnProtocols) { 215 public Builder setTlsAlpnProtocols(List<String> tlsAlpnProtocols) {
190 this.tlsAlpnProtocols = tlsAlpnProtocols; 216 this.tlsAlpnProtocols = tlsAlpnProtocols;
191 return this; 217 return this;
192 } 218 }
193 219
194 public IceServer createIceServer() { 220 public IceServer createIceServer() {
195 return new IceServer(uri, username, password, tlsCertPolicy, hostname, t lsAlpnProtocols); 221 return new IceServer(
222 urls.get(0), urls, username, password, tlsCertPolicy, hostname, tlsA lpnProtocols);
196 } 223 }
197 } 224 }
198 } 225 }
199 226
200 /** Java version of PeerConnectionInterface.IceTransportsType */ 227 /** Java version of PeerConnectionInterface.IceTransportsType */
201 public enum IceTransportsType { NONE, RELAY, NOHOST, ALL } 228 public enum IceTransportsType { NONE, RELAY, NOHOST, ALL }
202 229
203 /** Java version of PeerConnectionInterface.BundlePolicy */ 230 /** Java version of PeerConnectionInterface.BundlePolicy */
204 public enum BundlePolicy { BALANCED, MAXBUNDLE, MAXCOMPAT } 231 public enum BundlePolicy { BALANCED, MAXBUNDLE, MAXCOMPAT }
205 232
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 private native RtpSender nativeCreateSender(String kind, String stream_id); 515 private native RtpSender nativeCreateSender(String kind, String stream_id);
489 516
490 private native List<RtpSender> nativeGetSenders(); 517 private native List<RtpSender> nativeGetSenders();
491 518
492 private native List<RtpReceiver> nativeGetReceivers(); 519 private native List<RtpReceiver> nativeGetReceivers();
493 520
494 private native boolean nativeStartRtcEventLog(int file_descriptor, int max_siz e_bytes); 521 private native boolean nativeStartRtcEventLog(int file_descriptor, int max_siz e_bytes);
495 522
496 private native void nativeStopRtcEventLog(); 523 private native void nativeStopRtcEventLog();
497 } 524 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698