Index: webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java |
diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java |
index 3763c9e68260250eb2262db3f60ce3baea046ce2..8fdcc391298d990b088b0da09bea99e966c5c6dd 100644 |
--- a/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java |
+++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java |
@@ -42,68 +42,41 @@ import org.webrtc.SurfaceViewRenderer; |
* Activity for peer connection call setup, call waiting |
* and call view. |
*/ |
-public class CallActivity extends Activity |
- implements AppRTCClient.SignalingEvents, |
- PeerConnectionClient.PeerConnectionEvents, |
- CallFragment.OnCallEvents { |
- |
- public static final String EXTRA_ROOMID = |
- "org.appspot.apprtc.ROOMID"; |
- public static final String EXTRA_LOOPBACK = |
- "org.appspot.apprtc.LOOPBACK"; |
- public static final String EXTRA_VIDEO_CALL = |
- "org.appspot.apprtc.VIDEO_CALL"; |
- public static final String EXTRA_CAMERA2 = |
- "org.appspot.apprtc.CAMERA2"; |
- public static final String EXTRA_VIDEO_WIDTH = |
- "org.appspot.apprtc.VIDEO_WIDTH"; |
- public static final String EXTRA_VIDEO_HEIGHT = |
- "org.appspot.apprtc.VIDEO_HEIGHT"; |
- public static final String EXTRA_VIDEO_FPS = |
- "org.appspot.apprtc.VIDEO_FPS"; |
+public class CallActivity extends Activity implements AppRTCClient.SignalingEvents, |
+ PeerConnectionClient.PeerConnectionEvents, |
+ CallFragment.OnCallEvents { |
+ public static final String EXTRA_ROOMID = "org.appspot.apprtc.ROOMID"; |
+ public static final String EXTRA_LOOPBACK = "org.appspot.apprtc.LOOPBACK"; |
+ public static final String EXTRA_VIDEO_CALL = "org.appspot.apprtc.VIDEO_CALL"; |
+ public static final String EXTRA_CAMERA2 = "org.appspot.apprtc.CAMERA2"; |
+ public static final String EXTRA_VIDEO_WIDTH = "org.appspot.apprtc.VIDEO_WIDTH"; |
+ public static final String EXTRA_VIDEO_HEIGHT = "org.appspot.apprtc.VIDEO_HEIGHT"; |
+ public static final String EXTRA_VIDEO_FPS = "org.appspot.apprtc.VIDEO_FPS"; |
public static final String EXTRA_VIDEO_CAPTUREQUALITYSLIDER_ENABLED = |
"org.appsopt.apprtc.VIDEO_CAPTUREQUALITYSLIDER"; |
- public static final String EXTRA_VIDEO_BITRATE = |
- "org.appspot.apprtc.VIDEO_BITRATE"; |
- public static final String EXTRA_VIDEOCODEC = |
- "org.appspot.apprtc.VIDEOCODEC"; |
- public static final String EXTRA_HWCODEC_ENABLED = |
- "org.appspot.apprtc.HWCODEC"; |
- public static final String EXTRA_CAPTURETOTEXTURE_ENABLED = |
- "org.appspot.apprtc.CAPTURETOTEXTURE"; |
- public static final String EXTRA_AUDIO_BITRATE = |
- "org.appspot.apprtc.AUDIO_BITRATE"; |
- public static final String EXTRA_AUDIOCODEC = |
- "org.appspot.apprtc.AUDIOCODEC"; |
+ public static final String EXTRA_VIDEO_BITRATE = "org.appspot.apprtc.VIDEO_BITRATE"; |
+ public static final String EXTRA_VIDEOCODEC = "org.appspot.apprtc.VIDEOCODEC"; |
+ public static final String EXTRA_HWCODEC_ENABLED = "org.appspot.apprtc.HWCODEC"; |
+ public static final String EXTRA_CAPTURETOTEXTURE_ENABLED = "org.appspot.apprtc.CAPTURETOTEXTURE"; |
+ public static final String EXTRA_AUDIO_BITRATE = "org.appspot.apprtc.AUDIO_BITRATE"; |
+ public static final String EXTRA_AUDIOCODEC = "org.appspot.apprtc.AUDIOCODEC"; |
public static final String EXTRA_NOAUDIOPROCESSING_ENABLED = |
"org.appspot.apprtc.NOAUDIOPROCESSING"; |
- public static final String EXTRA_AECDUMP_ENABLED = |
- "org.appspot.apprtc.AECDUMP"; |
- public static final String EXTRA_OPENSLES_ENABLED = |
- "org.appspot.apprtc.OPENSLES"; |
- public static final String EXTRA_DISABLE_BUILT_IN_AEC = |
- "org.appspot.apprtc.DISABLE_BUILT_IN_AEC"; |
- public static final String EXTRA_DISABLE_BUILT_IN_AGC = |
- "org.appspot.apprtc.DISABLE_BUILT_IN_AGC"; |
- public static final String EXTRA_DISABLE_BUILT_IN_NS = |
- "org.appspot.apprtc.DISABLE_BUILT_IN_NS"; |
- public static final String EXTRA_ENABLE_LEVEL_CONTROL = |
- "org.appspot.apprtc.ENABLE_LEVEL_CONTROL"; |
- public static final String EXTRA_DISPLAY_HUD = |
- "org.appspot.apprtc.DISPLAY_HUD"; |
+ public static final String EXTRA_AECDUMP_ENABLED = "org.appspot.apprtc.AECDUMP"; |
+ public static final String EXTRA_OPENSLES_ENABLED = "org.appspot.apprtc.OPENSLES"; |
+ public static final String EXTRA_DISABLE_BUILT_IN_AEC = "org.appspot.apprtc.DISABLE_BUILT_IN_AEC"; |
+ public static final String EXTRA_DISABLE_BUILT_IN_AGC = "org.appspot.apprtc.DISABLE_BUILT_IN_AGC"; |
+ public static final String EXTRA_DISABLE_BUILT_IN_NS = "org.appspot.apprtc.DISABLE_BUILT_IN_NS"; |
+ public static final String EXTRA_ENABLE_LEVEL_CONTROL = "org.appspot.apprtc.ENABLE_LEVEL_CONTROL"; |
+ public static final String EXTRA_DISPLAY_HUD = "org.appspot.apprtc.DISPLAY_HUD"; |
public static final String EXTRA_TRACING = "org.appspot.apprtc.TRACING"; |
- public static final String EXTRA_CMDLINE = |
- "org.appspot.apprtc.CMDLINE"; |
- public static final String EXTRA_RUNTIME = |
- "org.appspot.apprtc.RUNTIME"; |
+ public static final String EXTRA_CMDLINE = "org.appspot.apprtc.CMDLINE"; |
+ public static final String EXTRA_RUNTIME = "org.appspot.apprtc.RUNTIME"; |
private static final String TAG = "CallRTCClient"; |
// List of mandatory application permissions. |
- private static final String[] MANDATORY_PERMISSIONS = { |
- "android.permission.MODIFY_AUDIO_SETTINGS", |
- "android.permission.RECORD_AUDIO", |
- "android.permission.INTERNET" |
- }; |
+ private static final String[] MANDATORY_PERMISSIONS = {"android.permission.MODIFY_AUDIO_SETTINGS", |
+ "android.permission.RECORD_AUDIO", "android.permission.INTERNET"}; |
// Peer connection statistics callback period in ms. |
private static final int STAT_CALLBACK_PERIOD = 1000; |
@@ -152,22 +125,16 @@ public class CallActivity extends Activity |
@Override |
public void onCreate(Bundle savedInstanceState) { |
super.onCreate(savedInstanceState); |
- Thread.setDefaultUncaughtExceptionHandler( |
- new UnhandledExceptionHandler(this)); |
+ Thread.setDefaultUncaughtExceptionHandler(new UnhandledExceptionHandler(this)); |
// Set window styles for fullscreen-window size. Needs to be done before |
// adding content. |
requestWindowFeature(Window.FEATURE_NO_TITLE); |
- getWindow().addFlags( |
- LayoutParams.FLAG_FULLSCREEN |
- | LayoutParams.FLAG_KEEP_SCREEN_ON |
- | LayoutParams.FLAG_DISMISS_KEYGUARD |
- | LayoutParams.FLAG_SHOW_WHEN_LOCKED |
+ getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN | LayoutParams.FLAG_KEEP_SCREEN_ON |
+ | LayoutParams.FLAG_DISMISS_KEYGUARD | LayoutParams.FLAG_SHOW_WHEN_LOCKED |
| LayoutParams.FLAG_TURN_SCREEN_ON); |
- getWindow().getDecorView().setSystemUiVisibility( |
- View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
- | View.SYSTEM_UI_FLAG_FULLSCREEN |
- | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); |
+ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
+ | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); |
setContentView(R.layout.activity_call); |
iceConnected = false; |
@@ -232,30 +199,24 @@ public class CallActivity extends Activity |
boolean loopback = intent.getBooleanExtra(EXTRA_LOOPBACK, false); |
boolean tracing = intent.getBooleanExtra(EXTRA_TRACING, false); |
- boolean useCamera2 = Camera2Enumerator.isSupported(this) |
- && intent.getBooleanExtra(EXTRA_CAMERA2, true); |
- |
- peerConnectionParameters = new PeerConnectionParameters( |
- intent.getBooleanExtra(EXTRA_VIDEO_CALL, true), |
- loopback, |
- tracing, |
- useCamera2, |
- intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0), |
- intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0), |
- intent.getIntExtra(EXTRA_VIDEO_FPS, 0), |
- intent.getIntExtra(EXTRA_VIDEO_BITRATE, 0), |
- intent.getStringExtra(EXTRA_VIDEOCODEC), |
- intent.getBooleanExtra(EXTRA_HWCODEC_ENABLED, true), |
- intent.getBooleanExtra(EXTRA_CAPTURETOTEXTURE_ENABLED, false), |
- intent.getIntExtra(EXTRA_AUDIO_BITRATE, 0), |
- intent.getStringExtra(EXTRA_AUDIOCODEC), |
- intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false), |
- intent.getBooleanExtra(EXTRA_AECDUMP_ENABLED, false), |
- intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false), |
- intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AEC, false), |
- intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AGC, false), |
- intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_NS, false), |
- intent.getBooleanExtra(EXTRA_ENABLE_LEVEL_CONTROL, false)); |
+ boolean useCamera2 = |
+ Camera2Enumerator.isSupported(this) && intent.getBooleanExtra(EXTRA_CAMERA2, true); |
+ |
+ peerConnectionParameters = |
+ new PeerConnectionParameters(intent.getBooleanExtra(EXTRA_VIDEO_CALL, true), loopback, |
+ tracing, useCamera2, intent.getIntExtra(EXTRA_VIDEO_WIDTH, 0), |
+ intent.getIntExtra(EXTRA_VIDEO_HEIGHT, 0), intent.getIntExtra(EXTRA_VIDEO_FPS, 0), |
+ intent.getIntExtra(EXTRA_VIDEO_BITRATE, 0), intent.getStringExtra(EXTRA_VIDEOCODEC), |
+ intent.getBooleanExtra(EXTRA_HWCODEC_ENABLED, true), |
+ intent.getBooleanExtra(EXTRA_CAPTURETOTEXTURE_ENABLED, false), |
+ intent.getIntExtra(EXTRA_AUDIO_BITRATE, 0), intent.getStringExtra(EXTRA_AUDIOCODEC), |
+ intent.getBooleanExtra(EXTRA_NOAUDIOPROCESSING_ENABLED, false), |
+ intent.getBooleanExtra(EXTRA_AECDUMP_ENABLED, false), |
+ intent.getBooleanExtra(EXTRA_OPENSLES_ENABLED, false), |
+ intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AEC, false), |
+ intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_AGC, false), |
+ intent.getBooleanExtra(EXTRA_DISABLE_BUILT_IN_NS, false), |
+ intent.getBooleanExtra(EXTRA_ENABLE_LEVEL_CONTROL, false)); |
commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false); |
runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0); |
@@ -268,8 +229,7 @@ public class CallActivity extends Activity |
appRtcClient = new DirectRTCClient(this); |
} |
// Create connection parameters. |
- roomConnectionParameters = new RoomConnectionParameters( |
- roomUri.toString(), roomId, loopback); |
+ roomConnectionParameters = new RoomConnectionParameters(roomUri.toString(), roomId, loopback); |
// Create CPU monitor |
cpuMonitor = new CpuMonitor(this); |
@@ -419,21 +379,19 @@ public class CallActivity extends Activity |
callStartedTimeMs = System.currentTimeMillis(); |
// Start room connection. |
- logAndToast(getString(R.string.connecting_to, |
- roomConnectionParameters.roomUrl)); |
+ logAndToast(getString(R.string.connecting_to, roomConnectionParameters.roomUrl)); |
appRtcClient.connectToRoom(roomConnectionParameters); |
// Create and audio manager that will take care of audio routing, |
// audio modes, audio device enumeration etc. |
audioManager = AppRTCAudioManager.create(this, new Runnable() { |
- // This method will be called each time the audio state (number and |
- // type of devices) has been changed. |
- @Override |
- public void run() { |
- onAudioManagerChangedState(); |
- } |
+ // This method will be called each time the audio state (number and |
+ // type of devices) has been changed. |
+ @Override |
+ public void run() { |
+ onAudioManagerChangedState(); |
} |
- ); |
+ }); |
// Store existing audio settings and change audio mode to |
// MODE_IN_COMMUNICATION for best possible VoIP performance. |
Log.d(TAG, "Initializing the audio manager..."); |
@@ -499,13 +457,16 @@ public class CallActivity extends Activity |
.setTitle(getText(R.string.channel_error_title)) |
.setMessage(errorMessage) |
.setCancelable(false) |
- .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { |
- @Override |
- public void onClick(DialogInterface dialog, int id) { |
- dialog.cancel(); |
- disconnect(); |
- } |
- }).create().show(); |
+ .setNeutralButton(R.string.ok, |
+ new DialogInterface.OnClickListener() { |
+ @Override |
+ public void onClick(DialogInterface dialog, int id) { |
+ dialog.cancel(); |
+ disconnect(); |
+ } |
+ }) |
+ .create() |
+ .show(); |
} |
} |
@@ -539,8 +500,8 @@ public class CallActivity extends Activity |
signalingParameters = params; |
logAndToast("Creating peer connection, delay=" + delta + "ms"); |
- peerConnectionClient.createPeerConnection(rootEglBase.getEglBaseContext(), |
- localRender, remoteRender, signalingParameters); |
+ peerConnectionClient.createPeerConnection( |
+ rootEglBase.getEglBaseContext(), localRender, remoteRender, signalingParameters); |
if (signalingParameters.initiator) { |
logAndToast("Creating OFFER..."); |
@@ -716,8 +677,7 @@ public class CallActivity extends Activity |
} |
@Override |
- public void onPeerConnectionClosed() { |
- } |
+ public void onPeerConnectionClosed() {} |
@Override |
public void onPeerConnectionStatsReady(final StatsReport[] reports) { |