Update AppRTCDemo to use renamed GAE messages.

BUG=4221
R=wzh@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/33089004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@8158 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
glaznev@webrtc.org 2015-01-26 22:22:50 +00:00
parent 041035b390
commit 82415e395f
5 changed files with 28 additions and 13 deletions

View File

@ -74,7 +74,6 @@ public interface AppRTCClient {
public final MediaConstraints pcConstraints;
public final MediaConstraints videoConstraints;
public final MediaConstraints audioConstraints;
public final String roomUrl;
public final String roomId;
public final String clientId;
public final String wssUrl;
@ -86,7 +85,7 @@ public interface AppRTCClient {
List<PeerConnection.IceServer> iceServers,
boolean initiator, MediaConstraints pcConstraints,
MediaConstraints videoConstraints, MediaConstraints audioConstraints,
String roomUrl, String roomId, String clientId,
String roomId, String clientId,
String wssUrl, String wssPostUrl,
SessionDescription offerSdp, List<IceCandidate> iceCandidates) {
this.iceServers = iceServers;
@ -94,7 +93,6 @@ public interface AppRTCClient {
this.pcConstraints = pcConstraints;
this.videoConstraints = videoConstraints;
this.audioConstraints = audioConstraints;
this.roomUrl = roomUrl;
this.roomId = roomId;
this.clientId = clientId;
this.wssUrl = wssUrl;

View File

@ -254,7 +254,7 @@ public class ConnectActivity extends Activity {
String url = sharedPref.getString(
keyprefRoomServerUrl,
getString(R.string.pref_room_server_url_default));
url = url + "/register/" + roomName;
url = WebSocketRTCClient.getGAEConnectionUrl(url, roomName);
// Check HW codec flag.
boolean hwCodec = sharedPref.getBoolean(keyprefHwCodec,

View File

@ -117,8 +117,6 @@ public class RoomParametersFetcher {
String wssUrl = roomJson.getString("wss_url");
String wssPostUrl = roomJson.getString("wss_post_url");
boolean initiator = (roomJson.getBoolean("is_initiator"));
String roomUrl =
registerUrl.substring(0, registerUrl.indexOf("/register"));
if (!initiator) {
iceCandidates = new LinkedList<IceCandidate>();
String messagesString = roomJson.getString("messages");
@ -145,7 +143,6 @@ public class RoomParametersFetcher {
}
Log.d(TAG, "RoomId: " + roomId + ". ClientId: " + clientId);
Log.d(TAG, "Initiator: " + initiator);
Log.d(TAG, "Room url: " + roomUrl);
Log.d(TAG, "WSS url: " + wssUrl);
Log.d(TAG, "WSS POST url: " + wssPostUrl);
@ -184,7 +181,7 @@ public class RoomParametersFetcher {
SignalingParameters params = new SignalingParameters(
iceServers, initiator,
pcConstraints, videoConstraints, audioConstraints,
roomUrl, roomId, clientId,
roomId, clientId,
wssUrl, wssPostUrl,
offerSdp, iceCandidates);
events.onSignalingParametersReady(params);

View File

@ -54,6 +54,9 @@ import org.webrtc.SessionDescription;
public class WebSocketRTCClient implements AppRTCClient,
WebSocketChannelEvents {
private static final String TAG = "WSRTCClient";
public static final String GAE_JOIN = "join";
private static final String GAE_MESSAGE = "message";
private static final String GAE_LEAVE = "leave";
private enum ConnectionState {
NEW, CONNECTED, CLOSED, ERROR
@ -67,6 +70,7 @@ public class WebSocketRTCClient implements AppRTCClient,
private SignalingEvents events;
private WebSocketChannelClient wsClient;
private ConnectionState roomState;
private String roomUrl;
private String postMessageUrl;
private String byeMessageUrl;
@ -107,6 +111,7 @@ public class WebSocketRTCClient implements AppRTCClient,
Log.d(TAG, "Connect to room: " + url);
this.loopback = loopback;
roomState = ConnectionState.NEW;
roomUrl = url.substring(0, url.indexOf("/" + GAE_JOIN));
// Create WebSocket client.
wsClient = new WebSocketChannelClient(executor, this);
// Get room parameters.
@ -144,6 +149,21 @@ public class WebSocketRTCClient implements AppRTCClient,
}
}
// Helper functions to get connection, post message and leave message URLs
public static String getGAEConnectionUrl(String roomUrl, String roomId) {
return roomUrl + "/" + GAE_JOIN + "/" + roomId;
}
private String getGAEPostMessageUrl(String roomUrl, String roomId,
String clientId) {
return roomUrl + "/" + GAE_MESSAGE + "/" + roomId + "/" + clientId;
}
private String getGAEByeMessageUrl(String roomUrl, String roomId,
String clientId) {
return roomUrl + "/" + GAE_LEAVE + "/" + roomId + "/" + clientId;
}
// Callback issued when room parameters are extracted. Runs on local
// looper thread.
private void signalingParametersReady(final SignalingParameters params) {
@ -156,10 +176,10 @@ public class WebSocketRTCClient implements AppRTCClient,
Log.w(TAG, "No offer SDP in room response.");
}
initiator = params.initiator;
postMessageUrl = params.roomUrl + "/message/"
+ params.roomId + "/" + params.clientId;
byeMessageUrl = params.roomUrl + "/bye/"
+ params.roomId + "/" + params.clientId;
postMessageUrl = getGAEPostMessageUrl(
roomUrl, params.roomId, params.clientId);
byeMessageUrl = getGAEByeMessageUrl(
roomUrl, params.roomId, params.clientId);
roomState = ConnectionState.CONNECTED;
// Fire connection and signaling parameters events.

View File

@ -220,7 +220,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase
SignalingParameters signalingParameters = new SignalingParameters(
iceServers, true,
pcConstraints, videoConstraints, audioConstraints,
null, null, null,
null, null,
null, null,
null, null);
return signalingParameters;