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

Unified Diff: webrtc/examples/androidapp/src/org/appspot/apprtc/RoomParametersFetcher.java

Issue 1862423002: Update ice server provider response format in the Android AppRTCDemo app (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/examples/androidapp/src/org/appspot/apprtc/RoomParametersFetcher.java
diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/RoomParametersFetcher.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/RoomParametersFetcher.java
index a751f92e6a54de38ae7429e442a6381334aaa6e1..2c9e60d7075518296ebf507d7f9a24c0360d4c47 100644
--- a/webrtc/examples/androidapp/src/org/appspot/apprtc/RoomParametersFetcher.java
+++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/RoomParametersFetcher.java
@@ -145,7 +145,7 @@ public class RoomParametersFetcher {
// Request TURN servers.
if (!isTurnPresent) {
LinkedList<PeerConnection.IceServer> turnServers =
- requestTurnServers(roomJson.getString("turn_url"));
+ requestTurnServers(roomJson.getString("ice_server_url"));
for (PeerConnection.IceServer turnServer : turnServers) {
Log.d(TAG, "TurnServer: " + turnServer);
iceServers.add(turnServer);
@@ -172,7 +172,10 @@ public class RoomParametersFetcher {
LinkedList<PeerConnection.IceServer> turnServers =
new LinkedList<PeerConnection.IceServer>();
Log.d(TAG, "Request TURN from: " + url);
- HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
+ HttpURLConnection connection =
+ (HttpURLConnection) new URL(url).openConnection();
+ connection.setDoOutput(true);
+ connection.setRequestProperty("REFERER", "https://appr.tc");
connection.setConnectTimeout(TURN_HTTP_TIMEOUT_MS);
connection.setReadTimeout(TURN_HTTP_TIMEOUT_MS);
int responseCode = connection.getResponseCode();
@@ -185,12 +188,19 @@ public class RoomParametersFetcher {
connection.disconnect();
Log.d(TAG, "TURN response: " + response);
JSONObject responseJSON = new JSONObject(response);
- String username = responseJSON.getString("username");
- String password = responseJSON.getString("password");
- JSONArray turnUris = responseJSON.getJSONArray("uris");
- for (int i = 0; i < turnUris.length(); i++) {
- String uri = turnUris.getString(i);
- turnServers.add(new PeerConnection.IceServer(uri, username, password));
+ JSONArray iceServers = responseJSON.getJSONArray("iceServers");
+ for (int i = 0; i < iceServers.length(); ++i) {
+ JSONObject server = iceServers.getJSONObject(i);
+ JSONArray turnUrls = server.getJSONArray("urls");
+ String username =
+ server.has("username") ? server.getString("username") : "";
+ String credential =
+ server.has("credential") ? server.getString("credential") : "";
+ for (int j = 0; j < turnUrls.length(); j++) {
+ String turnUrl = turnUrls.getString(j);
+ turnServers.add(new PeerConnection.IceServer(turnUrl, username,
+ credential));
+ }
}
return turnServers;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698