| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2014 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 |
| 11 package org.appspot.apprtc; | 11 package org.appspot.apprtc; |
| 12 | 12 |
| 13 import org.appspot.apprtc.RoomParametersFetcher.RoomParametersFetcherEvents; | 13 import org.appspot.apprtc.RoomParametersFetcher.RoomParametersFetcherEvents; |
| 14 import org.appspot.apprtc.WebSocketChannelClient.WebSocketChannelEvents; | 14 import org.appspot.apprtc.WebSocketChannelClient.WebSocketChannelEvents; |
| 15 import org.appspot.apprtc.WebSocketChannelClient.WebSocketConnectionState; | 15 import org.appspot.apprtc.WebSocketChannelClient.WebSocketConnectionState; |
| 16 import org.appspot.apprtc.util.AsyncHttpURLConnection; | 16 import org.appspot.apprtc.util.AsyncHttpURLConnection; |
| 17 import org.appspot.apprtc.util.AsyncHttpURLConnection.AsyncHttpEvents; | 17 import org.appspot.apprtc.util.AsyncHttpURLConnection.AsyncHttpEvents; |
| 18 import org.appspot.apprtc.util.LooperExecutor; | 18 import org.appspot.apprtc.util.LooperExecutor; |
| 19 | 19 |
| 20 import android.util.Log; | 20 import android.util.Log; |
| 21 | 21 |
| 22 import org.json.JSONArray; | 22 import org.json.JSONArray; |
| 23 import org.json.JSONException; | 23 import org.json.JSONException; |
| 24 import org.json.JSONObject; | 24 import org.json.JSONObject; |
| 25 import org.webrtc.IceCandidate; | 25 import org.webrtc.IceCandidate; |
| 26 import org.webrtc.SessionDescription; | 26 import org.webrtc.SessionDescription; |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Negotiates signaling for chatting with apprtc.appspot.com "rooms". | 29 * Negotiates signaling for chatting with https://appr.tc "rooms". |
| 30 * Uses the client<->server specifics of the apprtc AppEngine webapp. | 30 * Uses the client<->server specifics of the apprtc AppEngine webapp. |
| 31 * | 31 * |
| 32 * <p>To use: create an instance of this object (registering a message handler)
and | 32 * <p>To use: create an instance of this object (registering a message handler)
and |
| 33 * call connectToRoom(). Once room connection is established | 33 * call connectToRoom(). Once room connection is established |
| 34 * onConnectedToRoom() callback with room parameters is invoked. | 34 * onConnectedToRoom() callback with room parameters is invoked. |
| 35 * Messages to other party (with local Ice candidates and answer SDP) can | 35 * Messages to other party (with local Ice candidates and answer SDP) can |
| 36 * be sent after WebSocket connection is established. | 36 * be sent after WebSocket connection is established. |
| 37 */ | 37 */ |
| 38 public class WebSocketRTCClient implements AppRTCClient, | 38 public class WebSocketRTCClient implements AppRTCClient, |
| 39 WebSocketChannelEvents { | 39 WebSocketChannelEvents { |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 return json; | 421 return json; |
| 422 } | 422 } |
| 423 | 423 |
| 424 // Converts a JSON candidate to a Java object. | 424 // Converts a JSON candidate to a Java object. |
| 425 IceCandidate toJavaCandidate(JSONObject json) throws JSONException { | 425 IceCandidate toJavaCandidate(JSONObject json) throws JSONException { |
| 426 return new IceCandidate(json.getString("id"), | 426 return new IceCandidate(json.getString("id"), |
| 427 json.getInt("label"), | 427 json.getInt("label"), |
| 428 json.getString("candidate")); | 428 json.getString("candidate")); |
| 429 } | 429 } |
| 430 } | 430 } |
| OLD | NEW |