| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 @Override | 180 @Override |
| 181 public void sendLocalIceCandidate(final IceCandidate candidate) { | 181 public void sendLocalIceCandidate(final IceCandidate candidate) { |
| 182 executor.execute(new Runnable() { | 182 executor.execute(new Runnable() { |
| 183 @Override | 183 @Override |
| 184 public void run() { | 184 public void run() { |
| 185 JSONObject json = new JSONObject(); | 185 JSONObject json = new JSONObject(); |
| 186 jsonPut(json, "type", "candidate"); | 186 jsonPut(json, "type", "candidate"); |
| 187 jsonPut(json, "label", candidate.sdpMLineIndex); | 187 jsonPut(json, "label", candidate.sdpMLineIndex); |
| 188 jsonPut(json, "id", candidate.sdpMid); | 188 jsonPut(json, "id", candidate.sdpMid); |
| 189 jsonPut(json, "candidate", candidate.sdp); | 189 jsonPut(json, "candidate", candidate.sdp); |
| 190 jsonPut(json, "url", candidate.serverUrl); | |
| 191 | 190 |
| 192 if (roomState != ConnectionState.CONNECTED) { | 191 if (roomState != ConnectionState.CONNECTED) { |
| 193 reportError("Sending ICE candidate in non connected state."); | 192 reportError("Sending ICE candidate in non connected state."); |
| 194 return; | 193 return; |
| 195 } | 194 } |
| 196 sendMessage(json.toString()); | 195 sendMessage(json.toString()); |
| 197 } | 196 } |
| 198 }); | 197 }); |
| 199 } | 198 } |
| 200 | 199 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 throw new RuntimeException(e); | 329 throw new RuntimeException(e); |
| 331 } | 330 } |
| 332 } | 331 } |
| 333 | 332 |
| 334 // Converts a Java candidate to a JSONObject. | 333 // Converts a Java candidate to a JSONObject. |
| 335 private static JSONObject toJsonCandidate(final IceCandidate candidate) { | 334 private static JSONObject toJsonCandidate(final IceCandidate candidate) { |
| 336 JSONObject json = new JSONObject(); | 335 JSONObject json = new JSONObject(); |
| 337 jsonPut(json, "label", candidate.sdpMLineIndex); | 336 jsonPut(json, "label", candidate.sdpMLineIndex); |
| 338 jsonPut(json, "id", candidate.sdpMid); | 337 jsonPut(json, "id", candidate.sdpMid); |
| 339 jsonPut(json, "candidate", candidate.sdp); | 338 jsonPut(json, "candidate", candidate.sdp); |
| 340 jsonPut(json, "url", candidate.serverUrl); | |
| 341 return json; | 339 return json; |
| 342 } | 340 } |
| 343 | 341 |
| 344 // Converts a JSON candidate to a Java object. | 342 // Converts a JSON candidate to a Java object. |
| 345 private static IceCandidate toJavaCandidate(JSONObject json) throws JSONExcept
ion { | 343 private static IceCandidate toJavaCandidate(JSONObject json) throws JSONExcept
ion { |
| 346 return new IceCandidate(json.getString("id"), json.getInt("label"), json.get
String("candidate"), | 344 return new IceCandidate( |
| 347 json.getString("url")); | 345 json.getString("id"), json.getInt("label"), json.getString("candidate"))
; |
| 348 } | 346 } |
| 349 } | 347 } |
| OLD | NEW |