Refactor WebRTCDemo.java to follow google code style
BUG=None TEST=bots Review URL: https://webrtc-codereview.appspot.com/882005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2925 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -215,7 +215,7 @@ public:
|
|||||||
_frameRateO(0), _bitRateO(0) {
|
_frameRateO(0), _bitRateO(0) {
|
||||||
_callbackCls = _env->GetObjectClass(_callbackObj);
|
_callbackCls = _env->GetObjectClass(_callbackObj);
|
||||||
_callbackId
|
_callbackId
|
||||||
= _env->GetMethodID(_callbackCls, "UpdateStats", "(IIIII)I");
|
= _env->GetMethodID(_callbackCls, "updateStats", "(IIIII)I");
|
||||||
if (_callbackId == NULL) {
|
if (_callbackId == NULL) {
|
||||||
__android_log_print(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG,
|
__android_log_print(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG,
|
||||||
"Failed to get jid");
|
"Failed to get jid");
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
package org.webrtc.videoengineapp;
|
package org.webrtc.videoengineapp;
|
||||||
|
|
||||||
public interface IViEAndroidCallback {
|
public interface IViEAndroidCallback {
|
||||||
public int UpdateStats(int frameRateI, int bitRateI,
|
public int updateStats(int frameRateI, int bitRateI,
|
||||||
int packetLoss, int frameRateO,
|
int packetLoss, int frameRateO,
|
||||||
int bitRateO);
|
int bitRateO);
|
||||||
}
|
}
|
||||||
|
@ -10,32 +10,18 @@
|
|||||||
|
|
||||||
package org.webrtc.videoengineapp;
|
package org.webrtc.videoengineapp;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.NetworkInterface;
|
|
||||||
import java.net.SocketException;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
|
|
||||||
import org.webrtc.videoengine.ViERenderer;
|
|
||||||
|
|
||||||
import android.app.TabActivity;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.TabActivity;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.DashPathEffect;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.hardware.SensorManager;
|
import android.hardware.SensorManager;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
@ -45,19 +31,19 @@ import android.os.Environment;
|
|||||||
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;
|
||||||
|
import android.view.Display;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.OrientationEventListener;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Display;
|
|
||||||
import android.view.OrientationEventListener;
|
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.WindowManager.LayoutParams;
|
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
@ -66,14 +52,23 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
|
||||||
import android.widget.TabHost.TabSpec;
|
import android.widget.TabHost.TabSpec;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.webrtc.videoengine.ViERenderer;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
|
import java.net.SocketException;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
|
||||||
|
/** {@} */
|
||||||
public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
||||||
View.OnClickListener,
|
View.OnClickListener,
|
||||||
OnItemSelectedListener {
|
OnItemSelectedListener {
|
||||||
private ViEAndroidJavaAPI ViEAndroidAPI = null;
|
private ViEAndroidJavaAPI vieAndroidAPI = null;
|
||||||
|
|
||||||
// remote renderer
|
// remote renderer
|
||||||
private SurfaceView remoteSurfaceView = null;
|
private SurfaceView remoteSurfaceView = null;
|
||||||
@ -195,7 +190,7 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
|
|
||||||
private BroadcastReceiver receiver;
|
private BroadcastReceiver receiver;
|
||||||
|
|
||||||
public int GetCameraOrientation(int cameraOrientation) {
|
public int getCameraOrientation(int cameraOrientation) {
|
||||||
Display display = this.getWindowManager().getDefaultDisplay();
|
Display display = this.getWindowManager().getDefaultDisplay();
|
||||||
int displatyRotation = display.getRotation();
|
int displatyRotation = display.getRotation();
|
||||||
int degrees = 0;
|
int degrees = 0;
|
||||||
@ -205,21 +200,20 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
case Surface.ROTATION_180: degrees = 180; break;
|
case Surface.ROTATION_180: degrees = 180; break;
|
||||||
case Surface.ROTATION_270: degrees = 270; break;
|
case Surface.ROTATION_270: degrees = 270; break;
|
||||||
}
|
}
|
||||||
int result=0;
|
int result = 0;
|
||||||
if(cameraOrientation>180) {
|
if (cameraOrientation > 180) {
|
||||||
result=(cameraOrientation + degrees) % 360;
|
result = (cameraOrientation + degrees) % 360;
|
||||||
}
|
} else {
|
||||||
else {
|
result = (cameraOrientation - degrees + 360) % 360;
|
||||||
result=(cameraOrientation - degrees+360) % 360;
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
int newRotation = GetCameraOrientation(currentCameraOrientation);
|
int newRotation = getCameraOrientation(currentCameraOrientation);
|
||||||
if (viERunning){
|
if (viERunning) {
|
||||||
ViEAndroidAPI.SetRotation(cameraId,newRotation);
|
vieAndroidAPI.SetRotation(cameraId, newRotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +229,7 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
// Set screen orientation
|
// Set screen orientation
|
||||||
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
|
||||||
PowerManager pm = (PowerManager)this.getSystemService(
|
PowerManager pm = (PowerManager) this.getSystemService(
|
||||||
Context.POWER_SERVICE);
|
Context.POWER_SERVICE);
|
||||||
wakeLock = pm.newWakeLock(
|
wakeLock = pm.newWakeLock(
|
||||||
PowerManager.SCREEN_DIM_WAKE_LOCK, TAG);
|
PowerManager.SCREEN_DIM_WAKE_LOCK, TAG);
|
||||||
@ -255,16 +249,15 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
if (voERunning) {
|
if (voERunning) {
|
||||||
if (state == 1) {
|
if (state == 1) {
|
||||||
enableSpeaker = true;
|
enableSpeaker = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
enableSpeaker = false;
|
enableSpeaker = false;
|
||||||
}
|
}
|
||||||
RouteAudio(enableSpeaker);
|
routeAudio(enableSpeaker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
registerReceiver(receiver, receiverFilter );
|
registerReceiver(receiver, receiverFilter);
|
||||||
|
|
||||||
mTabHost = getTabHost();
|
mTabHost = getTabHost();
|
||||||
|
|
||||||
@ -293,11 +286,11 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
mTabHost.addTab(mTaba);
|
mTabHost.addTab(mTaba);
|
||||||
|
|
||||||
int childCount = mTabHost.getTabWidget().getChildCount();
|
int childCount = mTabHost.getTabWidget().getChildCount();
|
||||||
for (int i=0; i<childCount; i++)
|
for (int i = 0; i < childCount; i++) {
|
||||||
mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 50;
|
mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 50;
|
||||||
|
}
|
||||||
orientationListener =
|
orientationListener =
|
||||||
new OrientationEventListener(this,SensorManager.SENSOR_DELAY_UI) {
|
new OrientationEventListener(this, SensorManager.SENSOR_DELAY_UI) {
|
||||||
public void onOrientationChanged (int orientation) {
|
public void onOrientationChanged (int orientation) {
|
||||||
if (orientation != ORIENTATION_UNKNOWN) {
|
if (orientation != ORIENTATION_UNKNOWN) {
|
||||||
currentOrientation = orientation;
|
currentOrientation = orientation;
|
||||||
@ -312,13 +305,12 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
File webrtcDir = new File(webrtcDebugDir);
|
File webrtcDir = new File(webrtcDebugDir);
|
||||||
if (!webrtcDir.exists() && webrtcDir.mkdir() == false) {
|
if (!webrtcDir.exists() && webrtcDir.mkdir() == false) {
|
||||||
Log.v(TAG, "Failed to create " + webrtcDebugDir);
|
Log.v(TAG, "Failed to create " + webrtcDebugDir);
|
||||||
}
|
} else if (!webrtcDir.isDirectory()) {
|
||||||
else if (!webrtcDir.isDirectory()) {
|
|
||||||
Log.v(TAG, webrtcDebugDir + " exists but not a folder");
|
Log.v(TAG, webrtcDebugDir + " exists but not a folder");
|
||||||
webrtcDebugDir = null;
|
webrtcDebugDir = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
StartMain();
|
startMain();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +349,7 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String GetLocalIpAddress() {
|
private String getLocalIpAddress() {
|
||||||
String localIPs = "";
|
String localIPs = "";
|
||||||
try {
|
try {
|
||||||
for (Enumeration<NetworkInterface> en = NetworkInterface
|
for (Enumeration<NetworkInterface> en = NetworkInterface
|
||||||
@ -386,8 +378,8 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
if (viERunning) {
|
if (viERunning) {
|
||||||
StopAll();
|
stopAll();
|
||||||
StartMain();
|
startMain();
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
@ -395,26 +387,26 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StopAll() {
|
private void stopAll() {
|
||||||
Log.d(TAG, "StopAll");
|
Log.d(TAG, "stopAll");
|
||||||
|
|
||||||
if (ViEAndroidAPI != null) {
|
if (vieAndroidAPI != null) {
|
||||||
|
|
||||||
StopCPULoad();
|
stopCPULoad();
|
||||||
|
|
||||||
if (voERunning) {
|
if (voERunning) {
|
||||||
voERunning = false;
|
voERunning = false;
|
||||||
StopVoiceEngine();
|
stopVoiceEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viERunning) {
|
if (viERunning) {
|
||||||
viERunning = false;
|
viERunning = false;
|
||||||
ViEAndroidAPI.StopRender(channel);
|
vieAndroidAPI.StopRender(channel);
|
||||||
ViEAndroidAPI.StopReceive(channel);
|
vieAndroidAPI.StopReceive(channel);
|
||||||
ViEAndroidAPI.StopSend(channel);
|
vieAndroidAPI.StopSend(channel);
|
||||||
ViEAndroidAPI.RemoveRemoteRenderer(channel);
|
vieAndroidAPI.RemoveRemoteRenderer(channel);
|
||||||
ViEAndroidAPI.StopCamera(cameraId);
|
vieAndroidAPI.StopCamera(cameraId);
|
||||||
ViEAndroidAPI.Terminate();
|
vieAndroidAPI.Terminate();
|
||||||
mLlRemoteSurface.removeView(remoteSurfaceView);
|
mLlRemoteSurface.removeView(remoteSurfaceView);
|
||||||
mLlLocalSurface.removeView(svLocal);
|
mLlLocalSurface.removeView(svLocal);
|
||||||
remoteSurfaceView = null;
|
remoteSurfaceView = null;
|
||||||
@ -423,6 +415,7 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** {@ArrayAdapter} */
|
||||||
public class SpinnerAdapter extends ArrayAdapter<String> {
|
public class SpinnerAdapter extends ArrayAdapter<String> {
|
||||||
private String[] mCodecString = null;
|
private String[] mCodecString = null;
|
||||||
public SpinnerAdapter(Context context, int textViewResourceId, String[] objects) {
|
public SpinnerAdapter(Context context, int textViewResourceId, String[] objects) {
|
||||||
@ -441,23 +434,23 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
public View getCustomView(int position, View convertView, ViewGroup parent) {
|
public View getCustomView(int position, View convertView, ViewGroup parent) {
|
||||||
LayoutInflater inflater = getLayoutInflater();
|
LayoutInflater inflater = getLayoutInflater();
|
||||||
View row = inflater.inflate(R.layout.row, parent, false);
|
View row = inflater.inflate(R.layout.row, parent, false);
|
||||||
TextView label = (TextView)row.findViewById(R.id.spinner_row);
|
TextView label = (TextView) row.findViewById(R.id.spinner_row);
|
||||||
label.setText(mCodecString[position]);
|
label.setText(mCodecString[position]);
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartMain() {
|
private void startMain() {
|
||||||
mTabHost.setCurrentTab(0);
|
mTabHost.setCurrentTab(0);
|
||||||
|
|
||||||
mLlRemoteSurface = (LinearLayout) findViewById(R.id.llRemoteView);
|
mLlRemoteSurface = (LinearLayout) findViewById(R.id.llRemoteView);
|
||||||
mLlLocalSurface = (LinearLayout) findViewById(R.id.llLocalView);
|
mLlLocalSurface = (LinearLayout) findViewById(R.id.llLocalView);
|
||||||
|
|
||||||
if (null == ViEAndroidAPI)
|
if (null == vieAndroidAPI) {
|
||||||
ViEAndroidAPI = new ViEAndroidJavaAPI(this);
|
vieAndroidAPI = new ViEAndroidJavaAPI(this);
|
||||||
|
}
|
||||||
if (0 > SetupVoE() || 0 > ViEAndroidAPI.GetVideoEngine() ||
|
if (0 > setupVoE() || 0 > vieAndroidAPI.GetVideoEngine() ||
|
||||||
0 > ViEAndroidAPI.Init(enableTrace) ) {
|
0 > vieAndroidAPI.Init(enableTrace)) {
|
||||||
// Show dialog
|
// Show dialog
|
||||||
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
|
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
|
||||||
alertDialog.setTitle("WebRTC Error");
|
alertDialog.setTitle("WebRTC Error");
|
||||||
@ -469,9 +462,9 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
btSwitchCamera = (Button)findViewById(R.id.btSwitchCamera);
|
btSwitchCamera = (Button) findViewById(R.id.btSwitchCamera);
|
||||||
btSwitchCamera.setOnClickListener(this);
|
btSwitchCamera.setOnClickListener(this);
|
||||||
btStartStopCall = (Button)findViewById(R.id.btStartStopCall);
|
btStartStopCall = (Button) findViewById(R.id.btStartStopCall);
|
||||||
btStartStopCall.setOnClickListener(this);
|
btStartStopCall.setOnClickListener(this);
|
||||||
findViewById(R.id.btExit).setOnClickListener(this);
|
findViewById(R.id.btExit).setOnClickListener(this);
|
||||||
|
|
||||||
@ -480,8 +473,8 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
svLocal = null;
|
svLocal = null;
|
||||||
|
|
||||||
// Video codec
|
// Video codec
|
||||||
mVideoCodecsStrings = ViEAndroidAPI.GetCodecs();
|
mVideoCodecsStrings = vieAndroidAPI.GetCodecs();
|
||||||
spCodecType = (Spinner)findViewById(R.id.spCodecType);
|
spCodecType = (Spinner) findViewById(R.id.spCodecType);
|
||||||
spCodecType.setOnItemSelectedListener(this);
|
spCodecType.setOnItemSelectedListener(this);
|
||||||
spCodecType.setAdapter(new SpinnerAdapter(this,
|
spCodecType.setAdapter(new SpinnerAdapter(this,
|
||||||
R.layout.row,
|
R.layout.row,
|
||||||
@ -497,8 +490,8 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
spCodecSize.setSelection(0);
|
spCodecSize.setSelection(0);
|
||||||
|
|
||||||
// Voice codec
|
// Voice codec
|
||||||
mVoiceCodecsStrings = ViEAndroidAPI.VoE_GetCodecs();
|
mVoiceCodecsStrings = vieAndroidAPI.VoE_GetCodecs();
|
||||||
spVoiceCodecType = (Spinner)findViewById(R.id.spVoiceCodecType);
|
spVoiceCodecType = (Spinner) findViewById(R.id.spVoiceCodecType);
|
||||||
spVoiceCodecType.setOnItemSelectedListener(this);
|
spVoiceCodecType.setOnItemSelectedListener(this);
|
||||||
spVoiceCodecType.setAdapter(new SpinnerAdapter(this,
|
spVoiceCodecType.setAdapter(new SpinnerAdapter(this,
|
||||||
R.layout.row,
|
R.layout.row,
|
||||||
@ -512,12 +505,11 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioGroup radioGroup = (RadioGroup)findViewById(R.id.radio_group1);
|
RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radio_group1);
|
||||||
radioGroup.clearCheck();
|
radioGroup.clearCheck();
|
||||||
if (useOpenGLRender == true) {
|
if (useOpenGLRender == true) {
|
||||||
radioGroup.check(R.id.radio_opengl);
|
radioGroup.check(R.id.radio_opengl);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
radioGroup.check(R.id.radio_surface);
|
radioGroup.check(R.id.radio_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -590,21 +582,20 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
if (loopbackMode) {
|
if (loopbackMode) {
|
||||||
remoteIp = LOOPBACK_IP;
|
remoteIp = LOOPBACK_IP;
|
||||||
etRemoteIp.setText(remoteIp);
|
etRemoteIp.setText(remoteIp);
|
||||||
}
|
} else {
|
||||||
else {
|
getLocalIpAddress();
|
||||||
GetLocalIpAddress();
|
|
||||||
etRemoteIp.setText(remoteIp);
|
etRemoteIp.setText(remoteIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read settings to refresh each configuration
|
// Read settings to refresh each configuration
|
||||||
ReadSettings();
|
readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String GetRemoteIPString() {
|
private String getRemoteIPString() {
|
||||||
return etRemoteIp.getText().toString();
|
return etRemoteIp.getText().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartPlayingRingtone() {
|
private void startPlayingRingtone() {
|
||||||
MediaPlayer mMediaPlayer = new MediaPlayer();
|
MediaPlayer mMediaPlayer = new MediaPlayer();
|
||||||
try {
|
try {
|
||||||
mMediaPlayer.setDataSource(this, Uri.parse(RINGTONE_URL));
|
mMediaPlayer.setDataSource(this, Uri.parse(RINGTONE_URL));
|
||||||
@ -616,13 +607,13 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartCall() {
|
private void startCall() {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
StartPlayingRingtone();
|
startPlayingRingtone();
|
||||||
|
|
||||||
if (enableVoice) {
|
if (enableVoice) {
|
||||||
StartVoiceEngine();
|
startVoiceEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableVideo) {
|
if (enableVideo) {
|
||||||
@ -631,61 +622,60 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
svLocal = ViERenderer.CreateLocalRenderer(this);
|
svLocal = ViERenderer.CreateLocalRenderer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
channel = ViEAndroidAPI.CreateChannel(voiceChannel);
|
channel = vieAndroidAPI.CreateChannel(voiceChannel);
|
||||||
ret = ViEAndroidAPI.SetLocalReceiver(channel,
|
ret = vieAndroidAPI.SetLocalReceiver(channel,
|
||||||
receivePortVideo);
|
receivePortVideo);
|
||||||
ret = ViEAndroidAPI.SetSendDestination(channel,
|
ret = vieAndroidAPI.SetSendDestination(channel,
|
||||||
destinationPortVideo,
|
destinationPortVideo,
|
||||||
GetRemoteIPString());
|
getRemoteIPString());
|
||||||
|
|
||||||
if (enableVideoReceive) {
|
if (enableVideoReceive) {
|
||||||
if(useOpenGLRender) {
|
if (useOpenGLRender) {
|
||||||
Log.v(TAG, "Create OpenGL Render");
|
Log.v(TAG, "Create OpenGL Render");
|
||||||
remoteSurfaceView = ViERenderer.CreateRenderer(this, true);
|
remoteSurfaceView = ViERenderer.CreateRenderer(this, true);
|
||||||
ret = ViEAndroidAPI.AddRemoteRenderer(channel, remoteSurfaceView);
|
ret = vieAndroidAPI.AddRemoteRenderer(channel, remoteSurfaceView);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Log.v(TAG, "Create SurfaceView Render");
|
Log.v(TAG, "Create SurfaceView Render");
|
||||||
remoteSurfaceView = ViERenderer.CreateRenderer(this, false);
|
remoteSurfaceView = ViERenderer.CreateRenderer(this, false);
|
||||||
ret = ViEAndroidAPI.AddRemoteRenderer(channel, remoteSurfaceView);
|
ret = vieAndroidAPI.AddRemoteRenderer(channel, remoteSurfaceView);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ViEAndroidAPI.SetReceiveCodec(channel,
|
ret = vieAndroidAPI.SetReceiveCodec(channel,
|
||||||
codecType,
|
codecType,
|
||||||
INIT_BITRATE,
|
INIT_BITRATE,
|
||||||
codecSizeWidth,
|
codecSizeWidth,
|
||||||
codecSizeHeight,
|
codecSizeHeight,
|
||||||
RECEIVE_CODEC_FRAMERATE);
|
RECEIVE_CODEC_FRAMERATE);
|
||||||
ret = ViEAndroidAPI.StartRender(channel);
|
ret = vieAndroidAPI.StartRender(channel);
|
||||||
ret = ViEAndroidAPI.StartReceive(channel);
|
ret = vieAndroidAPI.StartReceive(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableVideoSend) {
|
if (enableVideoSend) {
|
||||||
currentCameraOrientation =
|
currentCameraOrientation =
|
||||||
ViEAndroidAPI.GetCameraOrientation(usingFrontCamera ? 1 : 0);
|
vieAndroidAPI.GetCameraOrientation(usingFrontCamera ? 1 : 0);
|
||||||
ret = ViEAndroidAPI.SetSendCodec(channel, codecType, INIT_BITRATE,
|
ret = vieAndroidAPI.SetSendCodec(channel, codecType, INIT_BITRATE,
|
||||||
codecSizeWidth, codecSizeHeight, SEND_CODEC_FRAMERATE);
|
codecSizeWidth, codecSizeHeight, SEND_CODEC_FRAMERATE);
|
||||||
int camId = ViEAndroidAPI.StartCamera(channel, usingFrontCamera ? 1 : 0);
|
int camId = vieAndroidAPI.StartCamera(channel, usingFrontCamera ? 1 : 0);
|
||||||
|
|
||||||
if(camId > 0) {
|
if (camId > 0) {
|
||||||
cameraId = camId;
|
cameraId = camId;
|
||||||
int neededRotation = GetCameraOrientation(currentCameraOrientation);
|
int neededRotation = getCameraOrientation(currentCameraOrientation);
|
||||||
ViEAndroidAPI.SetRotation(cameraId, neededRotation);
|
vieAndroidAPI.SetRotation(cameraId, neededRotation);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ret = camId;
|
ret = camId;
|
||||||
}
|
}
|
||||||
ret = ViEAndroidAPI.StartSend(channel);
|
ret = vieAndroidAPI.StartSend(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(leozwang): Add more options besides PLI, currently use pli
|
// TODO(leozwang): Add more options besides PLI, currently use pli
|
||||||
// as the default. Also check return value.
|
// as the default. Also check return value.
|
||||||
ret = ViEAndroidAPI.EnablePLI(channel, true);
|
ret = vieAndroidAPI.EnablePLI(channel, true);
|
||||||
ret = ViEAndroidAPI.SetCallback(channel, this);
|
ret = vieAndroidAPI.SetCallback(channel, this);
|
||||||
|
|
||||||
if (enableVideoSend) {
|
if (enableVideoSend) {
|
||||||
if (mLlLocalSurface != null)
|
if (mLlLocalSurface != null) {
|
||||||
mLlLocalSurface.addView(svLocal);
|
mLlLocalSurface.addView(svLocal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableVideoReceive) {
|
if (enableVideoReceive) {
|
||||||
@ -696,64 +686,62 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
|
|
||||||
isStatsOn = cbStats.isChecked();
|
isStatsOn = cbStats.isChecked();
|
||||||
if (isStatsOn) {
|
if (isStatsOn) {
|
||||||
AddStatsView();
|
addStatusView();
|
||||||
}
|
} else {
|
||||||
else {
|
removeStatusView();
|
||||||
RemoveSatsView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isCPULoadOn = cbCPULoad.isChecked();
|
isCPULoadOn = cbCPULoad.isChecked();
|
||||||
if (isCPULoadOn) {
|
if (isCPULoadOn) {
|
||||||
StartCPULoad();
|
startCPULoad();
|
||||||
}
|
} else {
|
||||||
else {
|
stopCPULoad();
|
||||||
StopCPULoad();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
viERunning = true;
|
viERunning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StopVoiceEngine() {
|
private void stopVoiceEngine() {
|
||||||
// Stop send
|
// Stop send
|
||||||
if (0 != ViEAndroidAPI.VoE_StopSend(voiceChannel)) {
|
if (0 != vieAndroidAPI.VoE_StopSend(voiceChannel)) {
|
||||||
Log.d(TAG, "VoE stop send failed");
|
Log.d(TAG, "VoE stop send failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop listen
|
// Stop listen
|
||||||
if (0 != ViEAndroidAPI.VoE_StopListen(voiceChannel)) {
|
if (0 != vieAndroidAPI.VoE_StopListen(voiceChannel)) {
|
||||||
Log.d(TAG, "VoE stop listen failed");
|
Log.d(TAG, "VoE stop listen failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop playout
|
// Stop playout
|
||||||
if (0 != ViEAndroidAPI.VoE_StopPlayout(voiceChannel)) {
|
if (0 != vieAndroidAPI.VoE_StopPlayout(voiceChannel)) {
|
||||||
Log.d(TAG, "VoE stop playout failed");
|
Log.d(TAG, "VoE stop playout failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ViEAndroidAPI.VoE_DeleteChannel(voiceChannel)) {
|
if (0 != vieAndroidAPI.VoE_DeleteChannel(voiceChannel)) {
|
||||||
Log.d(TAG, "VoE delete channel failed");
|
Log.d(TAG, "VoE delete channel failed");
|
||||||
}
|
}
|
||||||
voiceChannel=-1;
|
voiceChannel = -1;
|
||||||
|
|
||||||
// Terminate
|
// Terminate
|
||||||
if (0 != ViEAndroidAPI.VoE_Terminate()) {
|
if (0 != vieAndroidAPI.VoE_Terminate()) {
|
||||||
Log.d(TAG, "VoE terminate failed");
|
Log.d(TAG, "VoE terminate failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int SetupVoE() {
|
private int setupVoE() {
|
||||||
// Create VoiceEngine
|
// Create VoiceEngine
|
||||||
// Error logging is done in native API wrapper
|
// Error logging is done in native API wrapper
|
||||||
ViEAndroidAPI.VoE_Create(getApplicationContext());
|
vieAndroidAPI.VoE_Create(getApplicationContext());
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
if (0 != ViEAndroidAPI.VoE_Init(enableTrace)) {
|
if (0 != vieAndroidAPI.VoE_Init(enableTrace)) {
|
||||||
Log.d(TAG, "VoE init failed");
|
Log.d(TAG, "VoE init failed");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create channel
|
// Create channel
|
||||||
voiceChannel = ViEAndroidAPI.VoE_CreateChannel();
|
voiceChannel = vieAndroidAPI.VoE_CreateChannel();
|
||||||
if (0 != voiceChannel) {
|
if (0 != voiceChannel) {
|
||||||
Log.d(TAG, "VoE create channel failed");
|
Log.d(TAG, "VoE create channel failed");
|
||||||
return -1;
|
return -1;
|
||||||
@ -764,53 +752,53 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int StartVoiceEngine() {
|
private int startVoiceEngine() {
|
||||||
// Set local receiver
|
// Set local receiver
|
||||||
if (0 != ViEAndroidAPI.VoE_SetLocalReceiver(voiceChannel,
|
if (0 != vieAndroidAPI.VoE_SetLocalReceiver(voiceChannel,
|
||||||
receivePortVoice)) {
|
receivePortVoice)) {
|
||||||
Log.d(TAG, "VoE set local receiver failed");
|
Log.d(TAG, "VoE set local receiver failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ViEAndroidAPI.VoE_StartListen(voiceChannel)) {
|
if (0 != vieAndroidAPI.VoE_StartListen(voiceChannel)) {
|
||||||
Log.d(TAG, "VoE start listen failed");
|
Log.d(TAG, "VoE start listen failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route audio
|
// Route audio
|
||||||
RouteAudio(enableSpeaker);
|
routeAudio(enableSpeaker);
|
||||||
|
|
||||||
// set volume to default value
|
// set volume to default value
|
||||||
if (0 != ViEAndroidAPI.VoE_SetSpeakerVolume(volumeLevel)) {
|
if (0 != vieAndroidAPI.VoE_SetSpeakerVolume(volumeLevel)) {
|
||||||
Log.d(TAG, "VoE set speaker volume failed");
|
Log.d(TAG, "VoE set speaker volume failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start playout
|
// Start playout
|
||||||
if (0 != ViEAndroidAPI.VoE_StartPlayout(voiceChannel)) {
|
if (0 != vieAndroidAPI.VoE_StartPlayout(voiceChannel)) {
|
||||||
Log.d(TAG, "VoE start playout failed");
|
Log.d(TAG, "VoE start playout failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ViEAndroidAPI.VoE_SetSendDestination(voiceChannel,
|
if (0 != vieAndroidAPI.VoE_SetSendDestination(voiceChannel,
|
||||||
destinationPortVoice,
|
destinationPortVoice,
|
||||||
GetRemoteIPString())) {
|
getRemoteIPString())) {
|
||||||
Log.d(TAG, "VoE set send destination failed");
|
Log.d(TAG, "VoE set send destination failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ViEAndroidAPI.VoE_SetSendCodec(voiceChannel, voiceCodecType)) {
|
if (0 != vieAndroidAPI.VoE_SetSendCodec(voiceChannel, voiceCodecType)) {
|
||||||
Log.d(TAG, "VoE set send codec failed");
|
Log.d(TAG, "VoE set send codec failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ViEAndroidAPI.VoE_SetECStatus(enableAECM)) {
|
if (0 != vieAndroidAPI.VoE_SetECStatus(enableAECM)) {
|
||||||
Log.d(TAG, "VoE set EC Status failed");
|
Log.d(TAG, "VoE set EC Status failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ViEAndroidAPI.VoE_SetAGCStatus(enableAGC)) {
|
if (0 != vieAndroidAPI.VoE_SetAGCStatus(enableAGC)) {
|
||||||
Log.d(TAG, "VoE set AGC Status failed");
|
Log.d(TAG, "VoE set AGC Status failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ViEAndroidAPI.VoE_SetNSStatus(enableNS)) {
|
if (0 != vieAndroidAPI.VoE_SetNSStatus(enableNS)) {
|
||||||
Log.d(TAG, "VoE set NS Status failed");
|
Log.d(TAG, "VoE set NS Status failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ViEAndroidAPI.VoE_StartSend(voiceChannel)) {
|
if (0 != vieAndroidAPI.VoE_StartSend(voiceChannel)) {
|
||||||
Log.d(TAG, "VoE start send failed");
|
Log.d(TAG, "VoE start send failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,8 +806,8 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RouteAudio(boolean enableSpeaker) {
|
private void routeAudio(boolean enableSpeaker) {
|
||||||
if (0 != ViEAndroidAPI.VoE_SetLoudspeakerStatus(enableSpeaker)) {
|
if (0 != vieAndroidAPI.VoE_SetLoudspeakerStatus(enableSpeaker)) {
|
||||||
Log.d(TAG, "VoE set louspeaker status failed");
|
Log.d(TAG, "VoE set louspeaker status failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -827,41 +815,39 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
public void onClick(View arg0) {
|
public void onClick(View arg0) {
|
||||||
switch (arg0.getId()) {
|
switch (arg0.getId()) {
|
||||||
case R.id.btSwitchCamera:
|
case R.id.btSwitchCamera:
|
||||||
if (usingFrontCamera ){
|
if (usingFrontCamera) {
|
||||||
btSwitchCamera.setText(R.string.frontCamera);
|
btSwitchCamera.setText(R.string.frontCamera);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
btSwitchCamera.setText(R.string.backCamera);
|
btSwitchCamera.setText(R.string.backCamera);
|
||||||
}
|
}
|
||||||
usingFrontCamera = !usingFrontCamera;
|
usingFrontCamera = !usingFrontCamera;
|
||||||
|
|
||||||
if (viERunning) {
|
if (viERunning) {
|
||||||
currentCameraOrientation =
|
currentCameraOrientation =
|
||||||
ViEAndroidAPI.GetCameraOrientation(usingFrontCamera?1:0);
|
vieAndroidAPI.GetCameraOrientation(usingFrontCamera ? 1 : 0);
|
||||||
ViEAndroidAPI.StopCamera(cameraId);
|
vieAndroidAPI.StopCamera(cameraId);
|
||||||
mLlLocalSurface.removeView(svLocal);
|
mLlLocalSurface.removeView(svLocal);
|
||||||
|
|
||||||
ViEAndroidAPI.StartCamera(channel,usingFrontCamera?1:0);
|
vieAndroidAPI.StartCamera(channel, usingFrontCamera ? 1 : 0);
|
||||||
mLlLocalSurface.addView(svLocal);
|
mLlLocalSurface.addView(svLocal);
|
||||||
int neededRotation = GetCameraOrientation(currentCameraOrientation);
|
int neededRotation = getCameraOrientation(currentCameraOrientation);
|
||||||
ViEAndroidAPI.SetRotation(cameraId, neededRotation);
|
vieAndroidAPI.SetRotation(cameraId, neededRotation);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.btStartStopCall:
|
case R.id.btStartStopCall:
|
||||||
ReadSettings();
|
readSettings();
|
||||||
if (viERunning || voERunning) {
|
if (viERunning || voERunning) {
|
||||||
StopAll();
|
stopAll();
|
||||||
wakeLock.release(); // release the wake lock
|
wakeLock.release(); // release the wake lock
|
||||||
btStartStopCall.setText(R.string.startCall);
|
btStartStopCall.setText(R.string.startCall);
|
||||||
}
|
} else if (enableVoice || enableVideo){
|
||||||
else if (enableVoice || enableVideo){
|
startCall();
|
||||||
StartCall();
|
|
||||||
wakeLock.acquire(); // screen stay on during the call
|
wakeLock.acquire(); // screen stay on during the call
|
||||||
btStartStopCall.setText(R.string.stopCall);
|
btStartStopCall.setText(R.string.stopCall);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.btExit:
|
case R.id.btExit:
|
||||||
StopAll();
|
stopAll();
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
case R.id.cbLoopback:
|
case R.id.cbLoopback:
|
||||||
@ -869,9 +855,8 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
if (loopbackMode) {
|
if (loopbackMode) {
|
||||||
remoteIp = LOOPBACK_IP;
|
remoteIp = LOOPBACK_IP;
|
||||||
etRemoteIp.setText(LOOPBACK_IP);
|
etRemoteIp.setText(LOOPBACK_IP);
|
||||||
}
|
} else {
|
||||||
else {
|
getLocalIpAddress();
|
||||||
GetLocalIpAddress();
|
|
||||||
etRemoteIp.setText(remoteIp);
|
etRemoteIp.setText(remoteIp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -881,19 +866,17 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
case R.id.cbStats:
|
case R.id.cbStats:
|
||||||
isStatsOn = cbStats.isChecked();
|
isStatsOn = cbStats.isChecked();
|
||||||
if (isStatsOn) {
|
if (isStatsOn) {
|
||||||
AddStatsView();
|
addStatusView();
|
||||||
}
|
} else {
|
||||||
else {
|
removeStatusView();
|
||||||
RemoveSatsView();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cbCPULoad:
|
case R.id.cbCPULoad:
|
||||||
isCPULoadOn = cbCPULoad.isChecked();
|
isCPULoadOn = cbCPULoad.isChecked();
|
||||||
if (isCPULoadOn) {
|
if (isCPULoadOn) {
|
||||||
StartCPULoad();
|
startCPULoad();
|
||||||
}
|
} else {
|
||||||
else {
|
stopCPULoad();
|
||||||
StopCPULoad();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.radio_surface:
|
case R.id.radio_surface:
|
||||||
@ -905,73 +888,70 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
case R.id.cbNack:
|
case R.id.cbNack:
|
||||||
enableNack = cbEnableNack.isChecked();
|
enableNack = cbEnableNack.isChecked();
|
||||||
if (viERunning) {
|
if (viERunning) {
|
||||||
ViEAndroidAPI.EnableNACK(channel, enableNack);
|
vieAndroidAPI.EnableNACK(channel, enableNack);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cbSpeaker:
|
case R.id.cbSpeaker:
|
||||||
enableSpeaker = cbEnableSpeaker.isChecked();
|
enableSpeaker = cbEnableSpeaker.isChecked();
|
||||||
if (voERunning){
|
if (voERunning) {
|
||||||
RouteAudio(enableSpeaker);
|
routeAudio(enableSpeaker);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cbDebugRecording:
|
case R.id.cbDebugRecording:
|
||||||
if(voERunning && webrtcDebugDir != null) {
|
if (voERunning && webrtcDebugDir != null) {
|
||||||
if (cbEnableDebugAPM.isChecked() ) {
|
if (cbEnableDebugAPM.isChecked()) {
|
||||||
ViEAndroidAPI.VoE_StartDebugRecording(
|
vieAndroidAPI.VoE_StartDebugRecording(
|
||||||
webrtcDebugDir + String.format("/apm_%d.dat",
|
webrtcDebugDir + String.format("/apm_%d.dat",
|
||||||
System.currentTimeMillis()));
|
System.currentTimeMillis()));
|
||||||
}
|
} else {
|
||||||
else {
|
vieAndroidAPI.VoE_StopDebugRecording();
|
||||||
ViEAndroidAPI.VoE_StopDebugRecording();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cbVoiceRTPDump:
|
case R.id.cbVoiceRTPDump:
|
||||||
if(voERunning && webrtcDebugDir != null) {
|
if (voERunning && webrtcDebugDir != null) {
|
||||||
if (cbEnableVoiceRTPDump.isChecked() ) {
|
if (cbEnableVoiceRTPDump.isChecked()) {
|
||||||
ViEAndroidAPI.VoE_StartIncomingRTPDump(channel,
|
vieAndroidAPI.VoE_StartIncomingRTPDump(channel,
|
||||||
webrtcDebugDir + String.format("/voe_%d.rtp",
|
webrtcDebugDir + String.format("/voe_%d.rtp",
|
||||||
System.currentTimeMillis()));
|
System.currentTimeMillis()));
|
||||||
}
|
} else {
|
||||||
else {
|
vieAndroidAPI.VoE_StopIncomingRTPDump(channel);
|
||||||
ViEAndroidAPI.VoE_StopIncomingRTPDump(channel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cbVideoRTPDump:
|
case R.id.cbVideoRTPDump:
|
||||||
if(viERunning && webrtcDebugDir != null) {
|
if (viERunning && webrtcDebugDir != null) {
|
||||||
if (cbEnableVideoRTPDump.isChecked() ) {
|
if (cbEnableVideoRTPDump.isChecked()) {
|
||||||
ViEAndroidAPI.StartIncomingRTPDump(channel,
|
vieAndroidAPI.StartIncomingRTPDump(channel,
|
||||||
webrtcDebugDir + String.format("/vie_%d.rtp",
|
webrtcDebugDir + String.format("/vie_%d.rtp",
|
||||||
System.currentTimeMillis()));
|
System.currentTimeMillis()));
|
||||||
}
|
} else {
|
||||||
else {
|
vieAndroidAPI.StopIncomingRTPDump(channel);
|
||||||
ViEAndroidAPI.StopIncomingRTPDump(channel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cbAutoGainControl:
|
case R.id.cbAutoGainControl:
|
||||||
enableAGC=cbEnableAGC.isChecked();
|
enableAGC = cbEnableAGC.isChecked();
|
||||||
if(voERunning) {
|
if (voERunning) {
|
||||||
ViEAndroidAPI.VoE_SetAGCStatus(enableAGC);
|
vieAndroidAPI.VoE_SetAGCStatus(enableAGC);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cbNoiseSuppression:
|
case R.id.cbNoiseSuppression:
|
||||||
enableNS=cbEnableNS.isChecked();
|
enableNS = cbEnableNS.isChecked();
|
||||||
if(voERunning) {
|
if (voERunning) {
|
||||||
ViEAndroidAPI.VoE_SetNSStatus(enableNS);
|
vieAndroidAPI.VoE_SetNSStatus(enableNS);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cbAECM:
|
case R.id.cbAECM:
|
||||||
enableAECM = cbEnableAECM.isChecked();
|
enableAECM = cbEnableAECM.isChecked();
|
||||||
if (voERunning) {
|
if (voERunning) {
|
||||||
ViEAndroidAPI.VoE_SetECStatus(enableAECM);
|
vieAndroidAPI.VoE_SetECStatus(enableAECM);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadSettings() {
|
private void readSettings() {
|
||||||
codecType = spCodecType.getSelectedItemPosition();
|
codecType = spCodecType.getSelectedItemPosition();
|
||||||
voiceCodecType = spVoiceCodecType.getSelectedItemPosition();
|
voiceCodecType = spVoiceCodecType.getSelectedItemPosition();
|
||||||
|
|
||||||
@ -1006,26 +986,27 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
int position, long id) {
|
int position, long id) {
|
||||||
if ((adapterView == spCodecType || adapterView == spCodecSize) &&
|
if ((adapterView == spCodecType || adapterView == spCodecSize) &&
|
||||||
viERunning) {
|
viERunning) {
|
||||||
ReadSettings();
|
readSettings();
|
||||||
// change the codectype
|
// change the codectype
|
||||||
if (enableVideoReceive) {
|
if (enableVideoReceive) {
|
||||||
if (0 != ViEAndroidAPI.SetReceiveCodec(channel, codecType,
|
if (0 != vieAndroidAPI.SetReceiveCodec(channel, codecType,
|
||||||
INIT_BITRATE, codecSizeWidth,
|
INIT_BITRATE, codecSizeWidth,
|
||||||
codecSizeHeight,
|
codecSizeHeight,
|
||||||
RECEIVE_CODEC_FRAMERATE))
|
RECEIVE_CODEC_FRAMERATE)) {
|
||||||
Log.d(TAG, "ViE set receive codec failed");
|
Log.d(TAG, "ViE set receive codec failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (enableVideoSend) {
|
if (enableVideoSend) {
|
||||||
if (0 != ViEAndroidAPI.SetSendCodec(channel, codecType,
|
if (0 != vieAndroidAPI.SetSendCodec(channel, codecType,
|
||||||
INIT_BITRATE, codecSizeWidth, codecSizeHeight,
|
INIT_BITRATE, codecSizeWidth, codecSizeHeight,
|
||||||
SEND_CODEC_FRAMERATE))
|
SEND_CODEC_FRAMERATE)) {
|
||||||
Log.d(TAG, "ViE set send codec failed");
|
Log.d(TAG, "ViE set send codec failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if ((adapterView == spVoiceCodecType) && voERunning) {
|
||||||
else if ((adapterView == spVoiceCodecType) && voERunning) {
|
|
||||||
// change voice engine codec
|
// change voice engine codec
|
||||||
ReadSettings();
|
readSettings();
|
||||||
if (0 != ViEAndroidAPI.VoE_SetSendCodec(voiceChannel, voiceCodecType)) {
|
if (0 != vieAndroidAPI.VoE_SetSendCodec(voiceChannel, voiceCodecType)) {
|
||||||
Log.d(TAG, "VoE set send codec failed");
|
Log.d(TAG, "VoE set send codec failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1035,17 +1016,17 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
Log.d(TAG, "No setting selected");
|
Log.d(TAG, "No setting selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int UpdateStats(int in_frameRateI, int in_bitRateI, int in_packetLoss,
|
public int updateStats(int inFrameRateI, int inBitRateI,
|
||||||
int in_frameRateO, int in_bitRateO) {
|
int inPacketLoss, int inFrameRateO, int inBitRateO) {
|
||||||
frameRateI = in_frameRateI;
|
frameRateI = inFrameRateI;
|
||||||
bitRateI = in_bitRateI;
|
bitRateI = inBitRateI;
|
||||||
packetLoss = in_packetLoss;
|
packetLoss = inPacketLoss;
|
||||||
frameRateO = in_frameRateO;
|
frameRateO = inFrameRateO;
|
||||||
bitRateO = in_bitRateO;
|
bitRateO = inBitRateO;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddStatsView() {
|
private void addStatusView() {
|
||||||
if (statsView != null) {
|
if (statsView != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1063,45 +1044,42 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
statsView.setBackgroundColor(0);
|
statsView.setBackgroundColor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveSatsView() {
|
private void removeStatusView() {
|
||||||
mTabHost.removeView(statsView);
|
mTabHost.removeView(statsView);
|
||||||
statsView = null;
|
statsView = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartCPULoad() {
|
private void startCPULoad() {
|
||||||
if (null == mBackgroundLoad) {
|
if (null == mBackgroundLoad) {
|
||||||
mBackgroundLoad = new Thread(new Runnable() {
|
mBackgroundLoad = new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Log.v(TAG, "Background load started");
|
Log.v(TAG, "Background load started");
|
||||||
mIsBackgroudLoadRunning = true;
|
mIsBackgroudLoadRunning = true;
|
||||||
try{
|
try {
|
||||||
while (mIsBackgroudLoadRunning) {
|
while (mIsBackgroudLoadRunning) {
|
||||||
// This while simulates cpu load.
|
// This while loop simulates cpu load.
|
||||||
// Log.v(TAG, "Runnable!!!");
|
// Log.v(TAG, "Runnable!!!");
|
||||||
}
|
}
|
||||||
}
|
} catch (Throwable t) {
|
||||||
catch(Throwable t) {
|
Log.v(TAG, "startCPULoad failed");
|
||||||
Log.v(TAG, "StartCPULoad failed");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mBackgroundLoad.start();
|
mBackgroundLoad.start();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (mBackgroundLoad.getState() == Thread.State.TERMINATED) {
|
if (mBackgroundLoad.getState() == Thread.State.TERMINATED) {
|
||||||
mBackgroundLoad.start();
|
mBackgroundLoad.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StopCPULoad() {
|
private void stopCPULoad() {
|
||||||
if (null != mBackgroundLoad) {
|
if (null != mBackgroundLoad) {
|
||||||
mIsBackgroudLoadRunning = false;
|
mIsBackgroudLoadRunning = false;
|
||||||
try{
|
try {
|
||||||
mBackgroundLoad.join();
|
mBackgroundLoad.join();
|
||||||
}
|
} catch (Throwable t) {
|
||||||
catch(Throwable t) {
|
Log.v(TAG, "stopCPULoad failed");
|
||||||
Log.v(TAG, "StopCPULoad failed");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user