Improve WebRTCDemo
Description: This cl basically bring video and audio alive and add couple features to existing demo application, 1. Remove "stats" tab, add on screen stats display 2. Add a button to select surfaceview or opengl render Also some reformat and minor bug-fixes are included BUG= TEST=build on android Review URL: https://webrtc-codereview.appspot.com/579010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2244 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
f6e27f5e03
commit
d2d54c72b6
@ -15,7 +15,9 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
</TextView>
|
</TextView>
|
||||||
<LinearLayout android:id="@+id/LinearLayout02"
|
|
||||||
|
<LinearLayout android:orientation="horizontal"
|
||||||
|
android:id="@+id/LinearLayout02"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="fill_parent">
|
android:layout_width="fill_parent">
|
||||||
<CheckBox android:layout_width="wrap_content"
|
<CheckBox android:layout_width="wrap_content"
|
||||||
@ -28,14 +30,13 @@
|
|||||||
android:id="@+id/cbVideoSend"
|
android:id="@+id/cbVideoSend"
|
||||||
android:text="@string/enableVideoSend">
|
android:text="@string/enableVideoSend">
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<CheckBox android:layout_width="wrap_content"
|
<CheckBox android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/cbVoice"
|
android:id="@+id/cbVoice"
|
||||||
android:text="@string/enableVoice">
|
android:text="@string/enableVoice">
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView android:id="@+id/TextView02"
|
<TextView android:id="@+id/TextView02"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -46,9 +47,41 @@
|
|||||||
android:id="@+id/etRemoteIp" >
|
android:id="@+id/etRemoteIp" >
|
||||||
</EditText>
|
</EditText>
|
||||||
|
|
||||||
|
<LinearLayout android:orientation="horizontal"
|
||||||
|
android:id="@+id/LinearLayout03"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="fill_parent">
|
||||||
<CheckBox android:layout_width="wrap_content"
|
<CheckBox android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/cbLoopback"
|
android:id="@+id/cbLoopback"
|
||||||
android:text="@string/loopback">
|
android:text="@string/loopback">
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
<CheckBox android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/cbStats"
|
||||||
|
android:text="@string/stats">
|
||||||
|
</CheckBox>
|
||||||
|
<RadioGroup
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:id="@+id/radio_group1">
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radio_surface"
|
||||||
|
android:onClick="onClick"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/surfaceview"
|
||||||
|
android:checked="true"
|
||||||
|
android:textColor="#f00"/>
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radio_opengl"
|
||||||
|
android:onClick="onClick"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/opengl"
|
||||||
|
android:textColor="#0f0" />
|
||||||
|
</RadioGroup>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent" android:orientation="vertical"
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<TextView android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textSize="24dip"
|
|
||||||
android:text="Stats">
|
|
||||||
</TextView>
|
|
||||||
|
|
||||||
<TextView android:id="@+id/TextView03"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
</TextView>
|
|
||||||
|
|
||||||
<TextView android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:id="@+id/tvLocalIp"
|
|
||||||
android:textStyle="bold">
|
|
||||||
</TextView>
|
|
||||||
|
|
||||||
<TextView android:id="@+id/TextView03"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
</TextView>
|
|
||||||
|
|
||||||
<TextView android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:id="@+id/tvFrameRateI"
|
|
||||||
android:textStyle="bold">
|
|
||||||
</TextView>
|
|
||||||
<TextView android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:id="@+id/tvBitRateI"
|
|
||||||
android:textStyle="bold">
|
|
||||||
</TextView>
|
|
||||||
<TextView android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:id="@+id/tvPacketLoss"
|
|
||||||
android:textStyle="bold">
|
|
||||||
</TextView>
|
|
||||||
|
|
||||||
<TextView android:id="@+id/TextView03"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
</TextView>
|
|
||||||
|
|
||||||
<TextView android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:id="@+id/tvFrameRateO"
|
|
||||||
android:textStyle="bold">
|
|
||||||
</TextView>
|
|
||||||
<TextView android:layout_height="wrap_content"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:id="@+id/tvBitRateO"
|
|
||||||
android:textStyle="bold">
|
|
||||||
</TextView>
|
|
||||||
</LinearLayout>
|
|
@ -19,7 +19,6 @@
|
|||||||
<include android:id="@+id/tab_config" layout="@layout/main" />
|
<include android:id="@+id/tab_config" layout="@layout/main" />
|
||||||
<include android:id="@+id/tab_vconfig" layout="@layout/vconfig" />
|
<include android:id="@+id/tab_vconfig" layout="@layout/vconfig" />
|
||||||
<include android:id="@+id/tab_aconfig" layout="@layout/aconfig" />
|
<include android:id="@+id/tab_aconfig" layout="@layout/aconfig" />
|
||||||
<include android:id="@+id/tab_stats" layout="@layout/stats" />
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</TabHost>
|
</TabHost>
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
<string name="codecSize">Codec Size</string>
|
<string name="codecSize">Codec Size</string>
|
||||||
<string name="remoteIp">Remote IP address</string>
|
<string name="remoteIp">Remote IP address</string>
|
||||||
<string name="loopback">Loopback</string>
|
<string name="loopback">Loopback</string>
|
||||||
|
<string name="stats">Stats</string>
|
||||||
<string name="startListen">Start Listen</string>
|
<string name="startListen">Start Listen</string>
|
||||||
<string name="startSend">Start Send</string>
|
<string name="startSend">Start Send</string>
|
||||||
<string name="startBoth">Start Both</string>
|
<string name="startBoth">Start Both</string>
|
||||||
@ -32,5 +33,6 @@
|
|||||||
<string name="stopCall">StopCall</string>
|
<string name="stopCall">StopCall</string>
|
||||||
<string name="exit">Exit</string>
|
<string name="exit">Exit</string>
|
||||||
<string name="speaker">Speaker</string>
|
<string name="speaker">Speaker</string>
|
||||||
<string name="h263DecSw">H263 SW Decoder</string>
|
<string name="surfaceview">SurfaceView</string>
|
||||||
|
<string name="opengl">OpenGL</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -17,10 +17,17 @@ import java.util.Enumeration;
|
|||||||
|
|
||||||
import org.webrtc.videoengine.ViERenderer;
|
import org.webrtc.videoengine.ViERenderer;
|
||||||
|
|
||||||
|
|
||||||
import android.app.TabActivity;
|
import android.app.TabActivity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.DashPathEffect;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Path;
|
||||||
|
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.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -28,6 +35,7 @@ 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.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
@ -35,6 +43,7 @@ import android.view.View;
|
|||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
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.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
@ -43,6 +52,7 @@ import android.widget.CheckBox;
|
|||||||
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
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.TextView;
|
||||||
@ -74,9 +84,9 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
private boolean enableTrace = false;
|
private boolean enableTrace = false;
|
||||||
|
|
||||||
// Constant
|
// Constant
|
||||||
private static final String LOG_TAG = "*WEBRTCJ*";
|
private static final String TAG = "WEBRTC";
|
||||||
private static final int RECEIVE_CODEC_FRAMERATE = 30;
|
private static final int RECEIVE_CODEC_FRAMERATE = 30;
|
||||||
private static final int SEND_CODEC_FRAMERATE = 15;
|
private static final int SEND_CODEC_FRAMERATE = 30;
|
||||||
private static final int INIT_BITRATE = 400;
|
private static final int INIT_BITRATE = 400;
|
||||||
|
|
||||||
private static final int EXPIRARY_YEAR = 2010;
|
private static final int EXPIRARY_YEAR = 2010;
|
||||||
@ -96,20 +106,23 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
private Button btStartStopCall;
|
private Button btStartStopCall;
|
||||||
private Button btSwitchCamera;
|
private Button btSwitchCamera;
|
||||||
|
|
||||||
//Global Settings
|
// Global Settings
|
||||||
private CheckBox cbVideoSend;
|
private CheckBox cbVideoSend;
|
||||||
private boolean enableVideoSend = true;
|
private boolean enableVideoSend = true;
|
||||||
private CheckBox cbVideoReceive;
|
private CheckBox cbVideoReceive;
|
||||||
private boolean enableVideoReceive = true;
|
private boolean enableVideoReceive = true;
|
||||||
private boolean enableVideo = true;
|
private boolean enableVideo = true;
|
||||||
private CheckBox cbVoice;
|
private CheckBox cbVoice;
|
||||||
private boolean enableVoice = false;
|
private boolean enableVoice = true;
|
||||||
private EditText etRemoteIp;
|
private EditText etRemoteIp;
|
||||||
private String remoteIp = "10.1.100.68";
|
private String remoteIp = "10.1.100.68";
|
||||||
private CheckBox cbLoopback;
|
private CheckBox cbLoopback;
|
||||||
private boolean loopbackMode = true;
|
private boolean loopbackMode = true;
|
||||||
|
private CheckBox cbStats;
|
||||||
|
private boolean isStatsOn = true;
|
||||||
|
private boolean isSurfaceView = true;
|
||||||
|
|
||||||
//Video settings
|
// Video settings
|
||||||
private Spinner spCodecType;
|
private Spinner spCodecType;
|
||||||
private int codecType = 0;
|
private int codecType = 0;
|
||||||
private Spinner spCodecSize;
|
private Spinner spCodecSize;
|
||||||
@ -122,9 +135,9 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
private CheckBox cbEnableNack;
|
private CheckBox cbEnableNack;
|
||||||
private boolean enableNack = false;
|
private boolean enableNack = false;
|
||||||
|
|
||||||
//Audio settings
|
// Audio settings
|
||||||
private Spinner spVoiceCodecType;
|
private Spinner spVoiceCodecType;
|
||||||
private int voiceCodecType = 5; //PCMU = 5
|
private int voiceCodecType = 5; // PCMU = 5
|
||||||
private TextView etARxPort;
|
private TextView etARxPort;
|
||||||
private int receivePortVoice = 11113;
|
private int receivePortVoice = 11113;
|
||||||
private TextView etATxPort;
|
private TextView etATxPort;
|
||||||
@ -138,12 +151,7 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
private CheckBox cbEnableNS;
|
private CheckBox cbEnableNS;
|
||||||
private boolean enableNS = false;
|
private boolean enableNS = false;
|
||||||
|
|
||||||
//Stats
|
// Stats variables
|
||||||
private TextView tvFrameRateI;
|
|
||||||
private TextView tvBitRateI;
|
|
||||||
private TextView tvPacketLoss;
|
|
||||||
private TextView tvFrameRateO;
|
|
||||||
private TextView tvBitRateO;
|
|
||||||
private int frameRateI;
|
private int frameRateI;
|
||||||
private int bitRateI;
|
private int bitRateI;
|
||||||
private int packetLoss;
|
private int packetLoss;
|
||||||
@ -158,7 +166,8 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
int currentOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
|
int currentOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
|
||||||
int currentCameraOrientation = 0;
|
int currentCameraOrientation = 0;
|
||||||
|
|
||||||
//Convert current display orientation to how much the camera should be rotated.
|
private StatsView statsView = null;
|
||||||
|
|
||||||
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();
|
||||||
@ -176,7 +185,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
else {
|
else {
|
||||||
result=(cameraOrientation - degrees+360) % 360;
|
result=(cameraOrientation - degrees+360) % 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,47 +199,46 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
// Called when the activity is first created.
|
// Called when the activity is first created.
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
Log.d(TAG, "onCreate");
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
// Set screen orientation
|
||||||
|
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, LOG_TAG);
|
PowerManager.SCREEN_DIM_WAKE_LOCK, TAG);
|
||||||
|
|
||||||
setContentView(R.layout.tabhost);
|
setContentView(R.layout.tabhost);
|
||||||
mTabHost = getTabHost();
|
mTabHost = getTabHost();
|
||||||
|
|
||||||
//Video tab
|
// Main tab
|
||||||
mTabSpecVideo = mTabHost.newTabSpec("tab_video");
|
mTabSpecVideo = mTabHost.newTabSpec("tab_video");
|
||||||
mTabSpecVideo.setIndicator("Video");
|
mTabSpecVideo.setIndicator("Main");
|
||||||
mTabSpecVideo.setContent(R.id.tab_video);
|
mTabSpecVideo.setContent(R.id.tab_video);
|
||||||
mTabHost.addTab(mTabSpecVideo);
|
mTabHost.addTab(mTabSpecVideo);
|
||||||
|
|
||||||
//Shared config tab
|
// Shared config tab
|
||||||
mTabHost = getTabHost();
|
mTabHost = getTabHost();
|
||||||
mTabSpecConfig = mTabHost.newTabSpec("tab_config");
|
mTabSpecConfig = mTabHost.newTabSpec("tab_config");
|
||||||
mTabSpecConfig.setIndicator("Config");
|
mTabSpecConfig.setIndicator("Settings");
|
||||||
mTabSpecConfig.setContent(R.id.tab_config);
|
mTabSpecConfig.setContent(R.id.tab_config);
|
||||||
mTabHost.addTab(mTabSpecConfig);
|
mTabHost.addTab(mTabSpecConfig);
|
||||||
|
|
||||||
TabSpec mTabv;
|
TabSpec mTabv;
|
||||||
mTabv = mTabHost.newTabSpec("tab_vconfig");
|
mTabv = mTabHost.newTabSpec("tab_vconfig");
|
||||||
mTabv.setIndicator("V. Config");
|
mTabv.setIndicator("Video");
|
||||||
mTabv.setContent(R.id.tab_vconfig);
|
mTabv.setContent(R.id.tab_vconfig);
|
||||||
mTabHost.addTab(mTabv);
|
mTabHost.addTab(mTabv);
|
||||||
TabSpec mTaba;
|
TabSpec mTaba;
|
||||||
mTaba = mTabHost.newTabSpec("tab_aconfig");
|
mTaba = mTabHost.newTabSpec("tab_aconfig");
|
||||||
mTaba.setIndicator("A. Config");
|
mTaba.setIndicator("Audio");
|
||||||
mTaba.setContent(R.id.tab_aconfig);
|
mTaba.setContent(R.id.tab_aconfig);
|
||||||
mTabHost.addTab(mTaba);
|
mTabHost.addTab(mTaba);
|
||||||
TabSpec mTabs;
|
|
||||||
mTabs = mTabHost.newTabSpec("tab_stats");
|
|
||||||
mTabs.setIndicator("Stats");
|
|
||||||
mTabs.setContent(R.id.tab_stats);
|
|
||||||
mTabHost.addTab(mTabs);
|
|
||||||
|
|
||||||
int childCount = mTabHost.getTabWidget().getChildCount();
|
int childCount = mTabHost.getTabWidget().getChildCount();
|
||||||
for (int i=0; i<childCount; i++)
|
for (int i=0; i<childCount; i++)
|
||||||
@ -251,25 +258,54 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class StatsView extends View{
|
||||||
|
public StatsView(Context context){
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
|
||||||
|
Paint mLoadPaint = new Paint();
|
||||||
|
mLoadPaint.setAntiAlias(true);
|
||||||
|
mLoadPaint.setTextSize(16);
|
||||||
|
mLoadPaint.setARGB(255, 255, 255, 255);
|
||||||
|
|
||||||
|
String mLoadText;
|
||||||
|
mLoadText = "> " + frameRateI + " fps/" + bitRateI + "k bps/ " + packetLoss;
|
||||||
|
canvas.drawText(mLoadText, 4, 172, mLoadPaint);
|
||||||
|
mLoadText = "< " + frameRateO + " fps/ " + bitRateO + "k bps";
|
||||||
|
canvas.drawText(mLoadText, 4, 192, mLoadPaint);
|
||||||
|
|
||||||
|
updateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateDisplay() {
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String GetLocalIpAddress() {
|
private String GetLocalIpAddress() {
|
||||||
String localIPs = "";
|
String localIPs = "";
|
||||||
try {
|
try {
|
||||||
for (Enumeration<NetworkInterface> en = NetworkInterface
|
for (Enumeration<NetworkInterface> en = NetworkInterface
|
||||||
.getNetworkInterfaces(); en.hasMoreElements();) {
|
.getNetworkInterfaces(); en.hasMoreElements();) {
|
||||||
NetworkInterface intf = en.nextElement();
|
NetworkInterface intf = en.nextElement();
|
||||||
for (Enumeration<InetAddress> enumIpAddr = intf
|
for (Enumeration<InetAddress> enumIpAddr =
|
||||||
.getInetAddresses(); enumIpAddr.hasMoreElements();) {
|
intf.getInetAddresses();
|
||||||
|
enumIpAddr.hasMoreElements(); ) {
|
||||||
InetAddress inetAddress = enumIpAddr.nextElement();
|
InetAddress inetAddress = enumIpAddr.nextElement();
|
||||||
if (!inetAddress.isLoopbackAddress()) {
|
if (!inetAddress.isLoopbackAddress()) {
|
||||||
localIPs += inetAddress.getHostAddress().toString() + " ";
|
localIPs +=
|
||||||
//set the remote ip address the same as
|
inetAddress.getHostAddress().toString() + " ";
|
||||||
|
// Set the remote ip address the same as
|
||||||
// the local ip address of the last netif
|
// the local ip address of the last netif
|
||||||
remoteIp = inetAddress.getHostAddress().toString();
|
remoteIp = inetAddress.getHostAddress().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SocketException ex) {
|
} catch (SocketException ex) {
|
||||||
Log.e(LOG_TAG, ex.toString());
|
Log.e(TAG, ex.toString());
|
||||||
}
|
}
|
||||||
return localIPs;
|
return localIPs;
|
||||||
}
|
}
|
||||||
@ -288,6 +324,8 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void StopAll() {
|
private void StopAll() {
|
||||||
|
Log.d(TAG, "StopAll");
|
||||||
|
|
||||||
if (ViEAndroidAPI != null) {
|
if (ViEAndroidAPI != null) {
|
||||||
if (voERunning) {
|
if (voERunning) {
|
||||||
voERunning = false;
|
voERunning = false;
|
||||||
@ -300,13 +338,11 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
ViEAndroidAPI.StopReceive(channel);
|
ViEAndroidAPI.StopReceive(channel);
|
||||||
ViEAndroidAPI.StopSend(channel);
|
ViEAndroidAPI.StopSend(channel);
|
||||||
ViEAndroidAPI.RemoveRemoteRenderer(channel);
|
ViEAndroidAPI.RemoveRemoteRenderer(channel);
|
||||||
// stop the camera
|
|
||||||
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;
|
||||||
|
|
||||||
svLocal = null;
|
svLocal = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +357,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
if (null == ViEAndroidAPI)
|
if (null == ViEAndroidAPI)
|
||||||
ViEAndroidAPI = new ViEAndroidJavaAPI(this);
|
ViEAndroidAPI = new ViEAndroidJavaAPI(this);
|
||||||
|
|
||||||
//setContentView(R.layout.main);
|
|
||||||
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);
|
||||||
@ -348,6 +383,15 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
spCodecType.setSelection(codecType);
|
spCodecType.setSelection(codecType);
|
||||||
spCodecType.setOnItemSelectedListener(this);
|
spCodecType.setOnItemSelectedListener(this);
|
||||||
|
|
||||||
|
RadioGroup radioGroup = (RadioGroup)findViewById(R.id.radio_group1);
|
||||||
|
radioGroup.clearCheck();
|
||||||
|
if (isSurfaceView == true) {
|
||||||
|
radioGroup.check(R.id.radio_surface);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
radioGroup.check(R.id.radio_opengl);
|
||||||
|
}
|
||||||
|
|
||||||
// voice codec
|
// voice codec
|
||||||
spVoiceCodecType = (Spinner) findViewById(R.id.spVoiceCodecType);
|
spVoiceCodecType = (Spinner) findViewById(R.id.spVoiceCodecType);
|
||||||
adapter = ArrayAdapter.createFromResource(this, R.array.voiceCodecType,
|
adapter = ArrayAdapter.createFromResource(this, R.array.voiceCodecType,
|
||||||
@ -364,16 +408,15 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
spCodecSize.setAdapter(adapter);
|
spCodecSize.setAdapter(adapter);
|
||||||
spCodecSize.setOnItemSelectedListener(this);
|
spCodecSize.setOnItemSelectedListener(this);
|
||||||
|
|
||||||
String ip = GetLocalIpAddress();
|
|
||||||
TextView tvLocalIp = (TextView) findViewById(R.id.tvLocalIp);
|
|
||||||
tvLocalIp.setText("Local IP address - " + ip);
|
|
||||||
|
|
||||||
etRemoteIp = (EditText) findViewById(R.id.etRemoteIp);
|
etRemoteIp = (EditText) findViewById(R.id.etRemoteIp);
|
||||||
etRemoteIp.setText(remoteIp);
|
etRemoteIp.setText(remoteIp);
|
||||||
|
|
||||||
cbLoopback = (CheckBox) findViewById(R.id.cbLoopback);
|
cbLoopback = (CheckBox) findViewById(R.id.cbLoopback);
|
||||||
cbLoopback.setChecked(loopbackMode);
|
cbLoopback.setChecked(loopbackMode);
|
||||||
|
|
||||||
|
cbStats = (CheckBox) findViewById(R.id.cbStats);
|
||||||
|
cbStats.setChecked(isStatsOn);
|
||||||
|
|
||||||
cbVoice = (CheckBox) findViewById(R.id.cbVoice);
|
cbVoice = (CheckBox) findViewById(R.id.cbVoice);
|
||||||
cbVoice.setChecked(enableVoice);
|
cbVoice.setChecked(enableVoice);
|
||||||
|
|
||||||
@ -406,33 +449,13 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
cbEnableNS = (CheckBox) findViewById(R.id.cbNoiseSuppression);
|
cbEnableNS = (CheckBox) findViewById(R.id.cbNoiseSuppression);
|
||||||
cbEnableNS.setChecked(enableNS);
|
cbEnableNS.setChecked(enableNS);
|
||||||
|
|
||||||
|
cbStats.setOnClickListener(this);
|
||||||
cbEnableNack.setOnClickListener(this);
|
cbEnableNack.setOnClickListener(this);
|
||||||
cbEnableSpeaker.setOnClickListener(this);
|
cbEnableSpeaker.setOnClickListener(this);
|
||||||
cbEnableAECM.setOnClickListener(this);
|
cbEnableAECM.setOnClickListener(this);
|
||||||
|
|
||||||
cbEnableAGC.setOnClickListener(this);
|
cbEnableAGC.setOnClickListener(this);
|
||||||
cbEnableNS.setOnClickListener(this);
|
cbEnableNS.setOnClickListener(this);
|
||||||
|
|
||||||
tvFrameRateI = (TextView) findViewById(R.id.tvFrameRateI);
|
|
||||||
tvBitRateI = (TextView) findViewById(R.id.tvBitRateI);
|
|
||||||
tvPacketLoss = (TextView) findViewById(R.id.tvPacketLoss);
|
|
||||||
tvFrameRateO = (TextView) findViewById(R.id.tvFrameRateO);
|
|
||||||
tvBitRateO = (TextView) findViewById(R.id.tvBitRateO);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
// if (remoteSurfaceView != null)
|
|
||||||
// glSurfaceView.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
// if (glSurfaceView != null)
|
|
||||||
// glSurfaceView.onResume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartCall() {
|
private void StartCall() {
|
||||||
@ -459,12 +482,13 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
remoteIp.getBytes());
|
remoteIp.getBytes());
|
||||||
|
|
||||||
if (enableVideoReceive) {
|
if (enableVideoReceive) {
|
||||||
if(android.os.Build.MANUFACTURER.equals("samsung")) {
|
if(!isSurfaceView) {
|
||||||
// Create an Open GL renderer
|
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");
|
||||||
remoteSurfaceView = ViERenderer.CreateRenderer(this, false);
|
remoteSurfaceView = ViERenderer.CreateRenderer(this, false);
|
||||||
ret = ViEAndroidAPI.AddRemoteRenderer(channel, remoteSurfaceView);
|
ret = ViEAndroidAPI.AddRemoteRenderer(channel, remoteSurfaceView);
|
||||||
}
|
}
|
||||||
@ -482,21 +506,17 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
if (enableVideoSend) {
|
if (enableVideoSend) {
|
||||||
currentCameraOrientation =
|
currentCameraOrientation =
|
||||||
ViEAndroidAPI.GetCameraOrientation(usingFrontCamera?1:0);
|
ViEAndroidAPI.GetCameraOrientation(usingFrontCamera?1:0);
|
||||||
ret = ViEAndroidAPI.SetSendCodec(channel,
|
ret = ViEAndroidAPI.SetSendCodec(channel, codecType, INIT_BITRATE,
|
||||||
codecType,
|
codecSizeWidth, codecSizeHeight, SEND_CODEC_FRAMERATE);
|
||||||
INIT_BITRATE,
|
int camId = ViEAndroidAPI.StartCamera(channel, usingFrontCamera?1:0);
|
||||||
codecSizeWidth,
|
|
||||||
codecSizeHeight,
|
|
||||||
SEND_CODEC_FRAMERATE);
|
|
||||||
int cameraId = ViEAndroidAPI.StartCamera(channel, usingFrontCamera?1:0);
|
|
||||||
|
|
||||||
if(cameraId>0) {
|
if(camId > 0) {
|
||||||
cameraId = cameraId;
|
cameraId = camId;
|
||||||
int neededRotation = GetCameraOrientation(currentCameraOrientation);
|
int neededRotation = GetCameraOrientation(currentCameraOrientation);
|
||||||
ViEAndroidAPI.SetRotation(cameraId,neededRotation);
|
ViEAndroidAPI.SetRotation(cameraId, neededRotation);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret=cameraId;
|
ret = camId;
|
||||||
}
|
}
|
||||||
ret = ViEAndroidAPI.StartSend(channel);
|
ret = ViEAndroidAPI.StartSend(channel);
|
||||||
}
|
}
|
||||||
@ -509,43 +529,47 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (enableVideoReceive) {
|
if (enableVideoReceive) {
|
||||||
if (mLlRemoteSurface != null)
|
if (mLlRemoteSurface != null) {
|
||||||
mLlRemoteSurface.addView(remoteSurfaceView);
|
mLlRemoteSurface.addView(remoteSurfaceView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isStatsOn = cbStats.isChecked();
|
||||||
|
if (isStatsOn) {
|
||||||
|
AddStatsView();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
RemoveSatsView();
|
||||||
}
|
}
|
||||||
|
|
||||||
viERunning = true;
|
viERunning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DemoLog(String msg) {
|
|
||||||
Log.d("*WEBRTC*", msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StopVoiceEngine() {
|
private void StopVoiceEngine() {
|
||||||
// Stop send
|
// Stop send
|
||||||
if (0 != ViEAndroidAPI.VoE_StopSend(voiceChannel)) {
|
if (0 != ViEAndroidAPI.VoE_StopSend(voiceChannel)) {
|
||||||
DemoLog("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)) {
|
||||||
DemoLog("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)) {
|
||||||
DemoLog("VoE stop playout failed");
|
Log.d(TAG, "VoE stop playout failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ViEAndroidAPI.VoE_DeleteChannel(voiceChannel)) {
|
if (0 != ViEAndroidAPI.VoE_DeleteChannel(voiceChannel)) {
|
||||||
DemoLog("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()) {
|
||||||
DemoLog("VoE terminate failed");
|
Log.d(TAG, "VoE terminate failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,13 +580,13 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
if (0 != ViEAndroidAPI.VoE_Init(enableTrace)) {
|
if (0 != ViEAndroidAPI.VoE_Init(enableTrace)) {
|
||||||
DemoLog("VoE init failed");
|
Log.d(TAG, "VoE init failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create channel
|
// Create channel
|
||||||
voiceChannel = ViEAndroidAPI.VoE_CreateChannel();
|
voiceChannel = ViEAndroidAPI.VoE_CreateChannel();
|
||||||
if (0 != voiceChannel) {
|
if (0 != voiceChannel) {
|
||||||
DemoLog("VoE create channel failed");
|
Log.d(TAG, "VoE create channel failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Suggest to use the voice call audio stream for hardware volume controls
|
// Suggest to use the voice call audio stream for hardware volume controls
|
||||||
@ -573,11 +597,11 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
// Set local receiver
|
// Set local receiver
|
||||||
if (0 != ViEAndroidAPI.VoE_SetLocalReceiver(voiceChannel,
|
if (0 != ViEAndroidAPI.VoE_SetLocalReceiver(voiceChannel,
|
||||||
receivePortVoice)) {
|
receivePortVoice)) {
|
||||||
DemoLog("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)) {
|
||||||
DemoLog("VoE start listen failed");
|
Log.d(TAG, "VoE start listen failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route audio
|
// Route audio
|
||||||
@ -585,31 +609,31 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
|
|
||||||
// set volume to default value
|
// set volume to default value
|
||||||
if (0 != ViEAndroidAPI.VoE_SetSpeakerVolume(volumeLevel)) {
|
if (0 != ViEAndroidAPI.VoE_SetSpeakerVolume(volumeLevel)) {
|
||||||
DemoLog("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)) {
|
||||||
DemoLog("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,
|
||||||
remoteIp)) {
|
remoteIp)) {
|
||||||
DemoLog("VoE set send destination failed");
|
Log.d(TAG, "VoE set send destination failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0 = iPCM-wb, 5 = PCMU
|
// 0 = iPCM-wb, 5 = PCMU
|
||||||
if (0 != ViEAndroidAPI.VoE_SetSendCodec(voiceChannel, voiceCodecType)) {
|
if (0 != ViEAndroidAPI.VoE_SetSendCodec(voiceChannel, voiceCodecType)) {
|
||||||
DemoLog("VoE set send codec failed");
|
Log.d(TAG, "VoE set send codec failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ViEAndroidAPI.VoE_SetECStatus(enableAECM, 5, 0, 28)){
|
if (0 != ViEAndroidAPI.VoE_SetECStatus(enableAECM, 5, 0, 28)){
|
||||||
DemoLog("VoE set EC Status failed");
|
Log.d(TAG, "VoE set EC Status failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ViEAndroidAPI.VoE_StartSend(voiceChannel)) {
|
if (0 != ViEAndroidAPI.VoE_StartSend(voiceChannel)) {
|
||||||
DemoLog("VoE start send failed");
|
Log.d(TAG, "VoE start send failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
voERunning = true;
|
voERunning = true;
|
||||||
@ -625,7 +649,7 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (0 != ViEAndroidAPI.VoE_SetLoudspeakerStatus(enableSpeaker)) {
|
if (0 != ViEAndroidAPI.VoE_SetLoudspeakerStatus(enableSpeaker)) {
|
||||||
DemoLog("VoE set louspeaker status failed");
|
Log.d(TAG, "VoE set louspeaker status failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -657,12 +681,12 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
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;
|
||||||
@ -670,6 +694,21 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
StopAll();
|
StopAll();
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
|
case R.id.cbStats:
|
||||||
|
isStatsOn = cbStats.isChecked();
|
||||||
|
if (isStatsOn) {
|
||||||
|
AddStatsView();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
RemoveSatsView();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.radio_surface:
|
||||||
|
isSurfaceView = true;
|
||||||
|
break;
|
||||||
|
case R.id.radio_opengl:
|
||||||
|
isSurfaceView = false;
|
||||||
|
break;
|
||||||
case R.id.cbNack:
|
case R.id.cbNack:
|
||||||
enableNack = cbEnableNack.isChecked();
|
enableNack = cbEnableNack.isChecked();
|
||||||
if (viERunning) {
|
if (viERunning) {
|
||||||
@ -685,22 +724,22 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
case R.id.cbAutoGainControl:
|
case R.id.cbAutoGainControl:
|
||||||
enableAGC=cbEnableAGC.isChecked();
|
enableAGC=cbEnableAGC.isChecked();
|
||||||
if(voERunning) {
|
if(voERunning) {
|
||||||
//Enable AGC default mode.
|
// Enable AGC default mode.
|
||||||
ViEAndroidAPI.VoE_SetAGCStatus(enableAGC,1);
|
ViEAndroidAPI.VoE_SetAGCStatus(enableAGC,1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cbNoiseSuppression:
|
case R.id.cbNoiseSuppression:
|
||||||
enableNS=cbEnableNS.isChecked();
|
enableNS=cbEnableNS.isChecked();
|
||||||
if(voERunning) {
|
if(voERunning) {
|
||||||
//Enable NS default mode.
|
// Enable NS default mode.
|
||||||
ViEAndroidAPI.VoE_SetNSStatus(enableNS, 1);
|
ViEAndroidAPI.VoE_SetNSStatus(enableNS, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.cbAECM:
|
case R.id.cbAECM:
|
||||||
enableAECM = cbEnableAECM.isChecked();
|
enableAECM = cbEnableAECM.isChecked();
|
||||||
if (voERunning) {
|
if (voERunning) {
|
||||||
//EC_AECM=5
|
// EC_AECM=5
|
||||||
//AECM_DEFAULT=0
|
// AECM_DEFAULT=0
|
||||||
ViEAndroidAPI.VoE_SetECStatus(enableAECM, 5, 0, 28);
|
ViEAndroidAPI.VoE_SetECStatus(enableAECM, 5, 0, 28);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -745,36 +784,35 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
|
|
||||||
public void onItemSelected(AdapterView<?> adapterView, View view,
|
public void onItemSelected(AdapterView<?> adapterView, View view,
|
||||||
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))
|
||||||
DemoLog("ViE set receive codec failed");
|
Log.d(TAG, "ViE set receive codec failed");
|
||||||
}
|
}
|
||||||
if (enableVideoSend) {
|
if (enableVideoSend) {
|
||||||
if (0!=ViEAndroidAPI.SetSendCodec(channel, codecType, INIT_BITRATE,
|
if (0 != ViEAndroidAPI.SetSendCodec(channel, codecType,
|
||||||
codecSizeWidth,
|
INIT_BITRATE, codecSizeWidth, codecSizeHeight,
|
||||||
codecSizeHeight,
|
|
||||||
SEND_CODEC_FRAMERATE))
|
SEND_CODEC_FRAMERATE))
|
||||||
DemoLog("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)) {
|
||||||
DemoLog("VoE set send codec failed");
|
Log.d(TAG, "VoE set send codec failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNothingSelected(AdapterView<?> arg0) {
|
public void onNothingSelected(AdapterView<?> arg0) {
|
||||||
DemoLog("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 in_frameRateI, int in_bitRateI, int in_packetLoss,
|
||||||
@ -784,20 +822,29 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
packetLoss = in_packetLoss;
|
packetLoss = in_packetLoss;
|
||||||
frameRateO = in_frameRateO;
|
frameRateO = in_frameRateO;
|
||||||
bitRateO = in_bitRateO;
|
bitRateO = in_bitRateO;
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
tvFrameRateI.setText("Incoming FrameRate - " +
|
|
||||||
Integer.toString(frameRateI));
|
|
||||||
tvBitRateI.setText("Incoming BitRate - " +
|
|
||||||
Integer.toString(bitRateI));
|
|
||||||
tvPacketLoss.setText("Incoming Packet Loss - " +
|
|
||||||
Integer.toString(packetLoss));
|
|
||||||
tvFrameRateO.setText("Send FrameRate - " +
|
|
||||||
Integer.toString(frameRateO));
|
|
||||||
tvBitRateO.setText("Send BitRate - " +
|
|
||||||
Integer.toString(bitRateO));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddStatsView() {
|
||||||
|
if (statsView != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
statsView = new StatsView(this);
|
||||||
|
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
|
||||||
|
WindowManager.LayoutParams.MATCH_PARENT,
|
||||||
|
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||||
|
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
|
||||||
|
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
|
||||||
|
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
|
||||||
|
PixelFormat.TRANSLUCENT);
|
||||||
|
params.gravity = Gravity.RIGHT | Gravity.TOP;
|
||||||
|
params.setTitle("Load Average");
|
||||||
|
mTabHost.addView(statsView, params);
|
||||||
|
statsView.setBackgroundColor(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveSatsView() {
|
||||||
|
mTabHost.removeView(statsView);
|
||||||
|
statsView = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user