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:
parent
041035b390
commit
82415e395f
@ -74,7 +74,6 @@ public interface AppRTCClient {
|
|||||||
public final MediaConstraints pcConstraints;
|
public final MediaConstraints pcConstraints;
|
||||||
public final MediaConstraints videoConstraints;
|
public final MediaConstraints videoConstraints;
|
||||||
public final MediaConstraints audioConstraints;
|
public final MediaConstraints audioConstraints;
|
||||||
public final String roomUrl;
|
|
||||||
public final String roomId;
|
public final String roomId;
|
||||||
public final String clientId;
|
public final String clientId;
|
||||||
public final String wssUrl;
|
public final String wssUrl;
|
||||||
@ -86,7 +85,7 @@ public interface AppRTCClient {
|
|||||||
List<PeerConnection.IceServer> iceServers,
|
List<PeerConnection.IceServer> iceServers,
|
||||||
boolean initiator, MediaConstraints pcConstraints,
|
boolean initiator, MediaConstraints pcConstraints,
|
||||||
MediaConstraints videoConstraints, MediaConstraints audioConstraints,
|
MediaConstraints videoConstraints, MediaConstraints audioConstraints,
|
||||||
String roomUrl, String roomId, String clientId,
|
String roomId, String clientId,
|
||||||
String wssUrl, String wssPostUrl,
|
String wssUrl, String wssPostUrl,
|
||||||
SessionDescription offerSdp, List<IceCandidate> iceCandidates) {
|
SessionDescription offerSdp, List<IceCandidate> iceCandidates) {
|
||||||
this.iceServers = iceServers;
|
this.iceServers = iceServers;
|
||||||
@ -94,7 +93,6 @@ public interface AppRTCClient {
|
|||||||
this.pcConstraints = pcConstraints;
|
this.pcConstraints = pcConstraints;
|
||||||
this.videoConstraints = videoConstraints;
|
this.videoConstraints = videoConstraints;
|
||||||
this.audioConstraints = audioConstraints;
|
this.audioConstraints = audioConstraints;
|
||||||
this.roomUrl = roomUrl;
|
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.wssUrl = wssUrl;
|
this.wssUrl = wssUrl;
|
||||||
|
@ -254,7 +254,7 @@ public class ConnectActivity extends Activity {
|
|||||||
String url = sharedPref.getString(
|
String url = sharedPref.getString(
|
||||||
keyprefRoomServerUrl,
|
keyprefRoomServerUrl,
|
||||||
getString(R.string.pref_room_server_url_default));
|
getString(R.string.pref_room_server_url_default));
|
||||||
url = url + "/register/" + roomName;
|
url = WebSocketRTCClient.getGAEConnectionUrl(url, roomName);
|
||||||
|
|
||||||
// Check HW codec flag.
|
// Check HW codec flag.
|
||||||
boolean hwCodec = sharedPref.getBoolean(keyprefHwCodec,
|
boolean hwCodec = sharedPref.getBoolean(keyprefHwCodec,
|
||||||
|
@ -117,8 +117,6 @@ public class RoomParametersFetcher {
|
|||||||
String wssUrl = roomJson.getString("wss_url");
|
String wssUrl = roomJson.getString("wss_url");
|
||||||
String wssPostUrl = roomJson.getString("wss_post_url");
|
String wssPostUrl = roomJson.getString("wss_post_url");
|
||||||
boolean initiator = (roomJson.getBoolean("is_initiator"));
|
boolean initiator = (roomJson.getBoolean("is_initiator"));
|
||||||
String roomUrl =
|
|
||||||
registerUrl.substring(0, registerUrl.indexOf("/register"));
|
|
||||||
if (!initiator) {
|
if (!initiator) {
|
||||||
iceCandidates = new LinkedList<IceCandidate>();
|
iceCandidates = new LinkedList<IceCandidate>();
|
||||||
String messagesString = roomJson.getString("messages");
|
String messagesString = roomJson.getString("messages");
|
||||||
@ -145,7 +143,6 @@ public class RoomParametersFetcher {
|
|||||||
}
|
}
|
||||||
Log.d(TAG, "RoomId: " + roomId + ". ClientId: " + clientId);
|
Log.d(TAG, "RoomId: " + roomId + ". ClientId: " + clientId);
|
||||||
Log.d(TAG, "Initiator: " + initiator);
|
Log.d(TAG, "Initiator: " + initiator);
|
||||||
Log.d(TAG, "Room url: " + roomUrl);
|
|
||||||
Log.d(TAG, "WSS url: " + wssUrl);
|
Log.d(TAG, "WSS url: " + wssUrl);
|
||||||
Log.d(TAG, "WSS POST url: " + wssPostUrl);
|
Log.d(TAG, "WSS POST url: " + wssPostUrl);
|
||||||
|
|
||||||
@ -184,7 +181,7 @@ public class RoomParametersFetcher {
|
|||||||
SignalingParameters params = new SignalingParameters(
|
SignalingParameters params = new SignalingParameters(
|
||||||
iceServers, initiator,
|
iceServers, initiator,
|
||||||
pcConstraints, videoConstraints, audioConstraints,
|
pcConstraints, videoConstraints, audioConstraints,
|
||||||
roomUrl, roomId, clientId,
|
roomId, clientId,
|
||||||
wssUrl, wssPostUrl,
|
wssUrl, wssPostUrl,
|
||||||
offerSdp, iceCandidates);
|
offerSdp, iceCandidates);
|
||||||
events.onSignalingParametersReady(params);
|
events.onSignalingParametersReady(params);
|
||||||
|
@ -54,6 +54,9 @@ import org.webrtc.SessionDescription;
|
|||||||
public class WebSocketRTCClient implements AppRTCClient,
|
public class WebSocketRTCClient implements AppRTCClient,
|
||||||
WebSocketChannelEvents {
|
WebSocketChannelEvents {
|
||||||
private static final String TAG = "WSRTCClient";
|
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 {
|
private enum ConnectionState {
|
||||||
NEW, CONNECTED, CLOSED, ERROR
|
NEW, CONNECTED, CLOSED, ERROR
|
||||||
@ -67,6 +70,7 @@ public class WebSocketRTCClient implements AppRTCClient,
|
|||||||
private SignalingEvents events;
|
private SignalingEvents events;
|
||||||
private WebSocketChannelClient wsClient;
|
private WebSocketChannelClient wsClient;
|
||||||
private ConnectionState roomState;
|
private ConnectionState roomState;
|
||||||
|
private String roomUrl;
|
||||||
private String postMessageUrl;
|
private String postMessageUrl;
|
||||||
private String byeMessageUrl;
|
private String byeMessageUrl;
|
||||||
|
|
||||||
@ -107,6 +111,7 @@ public class WebSocketRTCClient implements AppRTCClient,
|
|||||||
Log.d(TAG, "Connect to room: " + url);
|
Log.d(TAG, "Connect to room: " + url);
|
||||||
this.loopback = loopback;
|
this.loopback = loopback;
|
||||||
roomState = ConnectionState.NEW;
|
roomState = ConnectionState.NEW;
|
||||||
|
roomUrl = url.substring(0, url.indexOf("/" + GAE_JOIN));
|
||||||
// Create WebSocket client.
|
// Create WebSocket client.
|
||||||
wsClient = new WebSocketChannelClient(executor, this);
|
wsClient = new WebSocketChannelClient(executor, this);
|
||||||
// Get room parameters.
|
// 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
|
// Callback issued when room parameters are extracted. Runs on local
|
||||||
// looper thread.
|
// looper thread.
|
||||||
private void signalingParametersReady(final SignalingParameters params) {
|
private void signalingParametersReady(final SignalingParameters params) {
|
||||||
@ -156,10 +176,10 @@ public class WebSocketRTCClient implements AppRTCClient,
|
|||||||
Log.w(TAG, "No offer SDP in room response.");
|
Log.w(TAG, "No offer SDP in room response.");
|
||||||
}
|
}
|
||||||
initiator = params.initiator;
|
initiator = params.initiator;
|
||||||
postMessageUrl = params.roomUrl + "/message/"
|
postMessageUrl = getGAEPostMessageUrl(
|
||||||
+ params.roomId + "/" + params.clientId;
|
roomUrl, params.roomId, params.clientId);
|
||||||
byeMessageUrl = params.roomUrl + "/bye/"
|
byeMessageUrl = getGAEByeMessageUrl(
|
||||||
+ params.roomId + "/" + params.clientId;
|
roomUrl, params.roomId, params.clientId);
|
||||||
roomState = ConnectionState.CONNECTED;
|
roomState = ConnectionState.CONNECTED;
|
||||||
|
|
||||||
// Fire connection and signaling parameters events.
|
// Fire connection and signaling parameters events.
|
||||||
|
@ -220,7 +220,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase
|
|||||||
SignalingParameters signalingParameters = new SignalingParameters(
|
SignalingParameters signalingParameters = new SignalingParameters(
|
||||||
iceServers, true,
|
iceServers, true,
|
||||||
pcConstraints, videoConstraints, audioConstraints,
|
pcConstraints, videoConstraints, audioConstraints,
|
||||||
null, null, null,
|
null, null,
|
||||||
null, null,
|
null, null,
|
||||||
null, null);
|
null, null);
|
||||||
return signalingParameters;
|
return signalingParameters;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user