Android AppRTCDemo improvements:
- Add a room list to ConnectActivity with buttons to add/remove rooms. - Add loopback call button. - Add option to toggle full screen / letterbox video. - Add camera fps settings. - Fix device to landscape orientation for HD video until issue 3936 will be fixed. - Fix a few crashes by avoiding calling peer connection and GAE signaling function while connection is closing. - Better handling GAE channel error - catch channel exceptions and display dialog with error messages. BUG=3939, 3935 R=kjellander@webrtc.org, pthatcher@webrtc.org, tkchin@webrtc.org Review URL: https://webrtc-codereview.appspot.com/26979004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7601 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -51,15 +51,12 @@ public class GAEChannelClient {
|
||||
|
||||
/**
|
||||
* Callback interface for messages delivered on the Google AppEngine channel.
|
||||
*
|
||||
* Methods are guaranteed to be invoked on the UI thread of |activity| passed
|
||||
* to GAEChannelClient's constructor.
|
||||
*/
|
||||
public interface GAEMessageHandler {
|
||||
public void onOpen();
|
||||
public void onMessage(String data);
|
||||
public void onMessage(final String data);
|
||||
public void onClose();
|
||||
public void onError(int code, String description);
|
||||
public void onError(final int code, final String description);
|
||||
}
|
||||
|
||||
/** Asynchronously open an AppEngine channel. */
|
||||
@@ -83,8 +80,7 @@ public class GAEChannelClient {
|
||||
", desc: " + description);
|
||||
}
|
||||
});
|
||||
proxyingMessageHandler =
|
||||
new ProxyingMessageHandler(activity, handler, token);
|
||||
proxyingMessageHandler = new ProxyingMessageHandler(handler, token);
|
||||
webView.addJavascriptInterface(
|
||||
proxyingMessageHandler, "androidMessageHandler");
|
||||
webView.loadUrl("file:///android_asset/channel.html");
|
||||
@@ -102,72 +98,52 @@ public class GAEChannelClient {
|
||||
}
|
||||
|
||||
// Helper class for proxying callbacks from the Java<->JS interaction
|
||||
// (private, background) thread to the Activity's UI thread.
|
||||
// (private, background) thread.
|
||||
private static class ProxyingMessageHandler {
|
||||
private final Activity activity;
|
||||
private final GAEMessageHandler handler;
|
||||
private final boolean[] disconnected = { false };
|
||||
private boolean disconnected = false;
|
||||
private final String token;
|
||||
|
||||
public
|
||||
ProxyingMessageHandler(Activity activity, GAEMessageHandler handler,
|
||||
String token) {
|
||||
this.activity = activity;
|
||||
public ProxyingMessageHandler(GAEMessageHandler handler, String token) {
|
||||
this.handler = handler;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
disconnected[0] = true;
|
||||
disconnected = true;
|
||||
}
|
||||
|
||||
private boolean disconnected() {
|
||||
return disconnected[0];
|
||||
}
|
||||
|
||||
@JavascriptInterface public String getToken() {
|
||||
@JavascriptInterface
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
@JavascriptInterface public void onOpen() {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (!disconnected()) {
|
||||
handler.onOpen();
|
||||
}
|
||||
}
|
||||
});
|
||||
@JavascriptInterface
|
||||
public void onOpen() {
|
||||
if (!disconnected) {
|
||||
handler.onOpen();
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface public void onMessage(final String data) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (!disconnected()) {
|
||||
handler.onMessage(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
@JavascriptInterface
|
||||
public void onMessage(final String data) {
|
||||
if (!disconnected) {
|
||||
handler.onMessage(data);
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface public void onClose() {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (!disconnected()) {
|
||||
handler.onClose();
|
||||
}
|
||||
}
|
||||
});
|
||||
@JavascriptInterface
|
||||
public void onClose() {
|
||||
if (!disconnected) {
|
||||
handler.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface public void onError(
|
||||
final int code, final String description) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (!disconnected()) {
|
||||
handler.onError(code, description);
|
||||
}
|
||||
}
|
||||
});
|
||||
@JavascriptInterface
|
||||
public void onError(final int code, final String description) {
|
||||
if (!disconnected) {
|
||||
handler.onError(code, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user