Added auto-call feature to WebRTCDemo.
This (compile-time switchable) option automatically starts & stops calls in series to stress-test the setup/teardown codepaths. When startCPULoad() is removed (https://webrtc-codereview.appspot.com/972008/) this showed no hangs/crashes after completing 200 start/stop pairs. Also fixed a tiny shutdown-order bug (onDestroy() calling super.onDestroy() before performing self-shutdown) and changed default video frame resolution to 640x480 to more effectively stress the device (and be a more compelling demo). BUG=1162 Review URL: https://webrtc-codereview.appspot.com/939032 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3238 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -28,6 +28,7 @@ import android.media.MediaPlayer;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.PowerManager.WakeLock;
|
import android.os.PowerManager.WakeLock;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -94,6 +95,15 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
private static final int SEND_CODEC_FRAMERATE = 15;
|
private static final int SEND_CODEC_FRAMERATE = 15;
|
||||||
private static final int INIT_BITRATE = 500;
|
private static final int INIT_BITRATE = 500;
|
||||||
private static final String LOOPBACK_IP = "127.0.0.1";
|
private static final String LOOPBACK_IP = "127.0.0.1";
|
||||||
|
// Zero means don't automatically start/stop calls.
|
||||||
|
private static final long AUTO_CALL_RESTART_DELAY_MS = 0;
|
||||||
|
|
||||||
|
private Handler handler = new Handler();
|
||||||
|
private Runnable startOrStopCallback = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
startOrStop();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private int volumeLevel = 204;
|
private int volumeLevel = 204;
|
||||||
|
|
||||||
@ -167,6 +177,7 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
private int packetLoss;
|
private int packetLoss;
|
||||||
private int frameRateO;
|
private int frameRateO;
|
||||||
private int bitRateO;
|
private int bitRateO;
|
||||||
|
private int numCalls = 0;
|
||||||
|
|
||||||
// Variable for storing variables
|
// Variable for storing variables
|
||||||
private String webrtcName = "/webrtc";
|
private String webrtcName = "/webrtc";
|
||||||
@ -310,15 +321,18 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
startMain();
|
startMain();
|
||||||
return;
|
|
||||||
|
if (AUTO_CALL_RESTART_DELAY_MS > 0)
|
||||||
|
startOrStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called before the activity is destroyed.
|
// Called before the activity is destroyed.
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Log.d(TAG, "onDestroy");
|
Log.d(TAG, "onDestroy");
|
||||||
super.onDestroy();
|
handler.removeCallbacks(startOrStopCallback);
|
||||||
unregisterReceiver(receiver);
|
unregisterReceiver(receiver);
|
||||||
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class StatsView extends View{
|
private class StatsView extends View{
|
||||||
@ -329,16 +343,18 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
@Override protected void onDraw(Canvas canvas) {
|
@Override protected void onDraw(Canvas canvas) {
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
|
|
||||||
Paint mLoadPaint = new Paint();
|
Paint loadPaint = new Paint();
|
||||||
mLoadPaint.setAntiAlias(true);
|
loadPaint.setAntiAlias(true);
|
||||||
mLoadPaint.setTextSize(16);
|
loadPaint.setTextSize(16);
|
||||||
mLoadPaint.setARGB(255, 255, 255, 255);
|
loadPaint.setARGB(255, 255, 255, 255);
|
||||||
|
|
||||||
String mLoadText;
|
canvas.drawText("#calls " + numCalls, 4, 152, loadPaint);
|
||||||
mLoadText = "> " + frameRateI + " fps/" + bitRateI + "k bps/ " + packetLoss;
|
|
||||||
canvas.drawText(mLoadText, 4, 172, mLoadPaint);
|
String loadText;
|
||||||
mLoadText = "< " + frameRateO + " fps/ " + bitRateO + "k bps";
|
loadText = "> " + frameRateI + " fps/" + bitRateI + "k bps/ " + packetLoss;
|
||||||
canvas.drawText(mLoadText, 4, 192, mLoadPaint);
|
canvas.drawText(loadText, 4, 172, loadPaint);
|
||||||
|
loadText = "< " + frameRateO + " fps/ " + bitRateO + "k bps";
|
||||||
|
canvas.drawText(loadText, 4, 192, loadPaint);
|
||||||
|
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
@ -484,7 +500,7 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
spCodecSize.setAdapter(new SpinnerAdapter(this,
|
spCodecSize.setAdapter(new SpinnerAdapter(this,
|
||||||
R.layout.row,
|
R.layout.row,
|
||||||
mVideoCodecsSizeStrings));
|
mVideoCodecsSizeStrings));
|
||||||
spCodecSize.setSelection(0);
|
spCodecSize.setSelection(mVideoCodecsSizeStrings.length - 1);
|
||||||
|
|
||||||
// Voice codec
|
// Voice codec
|
||||||
mVoiceCodecsStrings = vieAndroidAPI.VoE_GetCodecs();
|
mVoiceCodecsStrings = vieAndroidAPI.VoE_GetCodecs();
|
||||||
@ -793,6 +809,24 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startOrStop() {
|
||||||
|
readSettings();
|
||||||
|
if (viERunning || voERunning) {
|
||||||
|
stopAll();
|
||||||
|
startMain();
|
||||||
|
wakeLock.release(); // release the wake lock
|
||||||
|
btStartStopCall.setText(R.string.startCall);
|
||||||
|
} else if (enableVoice || enableVideo){
|
||||||
|
++numCalls;
|
||||||
|
startCall();
|
||||||
|
wakeLock.acquire(); // screen stay on during the call
|
||||||
|
btStartStopCall.setText(R.string.stopCall);
|
||||||
|
}
|
||||||
|
if (AUTO_CALL_RESTART_DELAY_MS > 0) {
|
||||||
|
handler.postDelayed(startOrStopCallback, AUTO_CALL_RESTART_DELAY_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onClick(View arg0) {
|
public void onClick(View arg0) {
|
||||||
switch (arg0.getId()) {
|
switch (arg0.getId()) {
|
||||||
case R.id.btSwitchCamera:
|
case R.id.btSwitchCamera:
|
||||||
@ -816,18 +850,8 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.btStartStopCall:
|
case R.id.btStartStopCall:
|
||||||
readSettings();
|
startOrStop();
|
||||||
if (viERunning || voERunning) {
|
break;
|
||||||
stopAll();
|
|
||||||
startMain();
|
|
||||||
wakeLock.release(); // release the wake lock
|
|
||||||
btStartStopCall.setText(R.string.startCall);
|
|
||||||
} else if (enableVoice || enableVideo){
|
|
||||||
startCall();
|
|
||||||
wakeLock.acquire(); // screen stay on during the call
|
|
||||||
btStartStopCall.setText(R.string.stopCall);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.btExit:
|
case R.id.btExit:
|
||||||
stopAll();
|
stopAll();
|
||||||
finish();
|
finish();
|
||||||
|
Reference in New Issue
Block a user