General cleanup on AppRTC Android Demo codebase

Review-Url: https://codereview.webrtc.org/1998483003
Cr-Commit-Position: refs/heads/master@{#12828}
This commit is contained in:
sakal
2016-05-20 06:28:33 -07:00
committed by Commit bot
parent 2036135620
commit 7268f28520
15 changed files with 75 additions and 85 deletions

View File

@ -2,7 +2,6 @@
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">

View File

@ -2,7 +2,6 @@
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -64,7 +63,7 @@
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_above="@+id/capture_format_slider_call" android:layout_above="@+id/capture_format_slider_call"
android:textSize="16sp" android:textSize="16sp"
android:text="Slide to change capture format"/> android:text="@string/capture_format_change_text"/>
<SeekBar <SeekBar
android:id="@+id/capture_format_slider_call" android:id="@+id/capture_format_slider_call"

View File

@ -2,7 +2,6 @@
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -22,7 +21,7 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:textStyle="bold" android:textStyle="bold"
android:textColor="#C000FF00" android:textColor="#C000FF00"
android:textSize="12dp" android:textSize="12sp"
android:layout_margin="8dp"/> android:layout_margin="8dp"/>
<TableLayout <TableLayout

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name" translatable="no">AppRTC</string> <string name="app_name" translatable="false">AppRTC</string>
<string name="settings_name" translatable="no">AppRTC Settings</string> <string name="settings_name" translatable="false">AppRTC Settings</string>
<string name="disconnect_call">Disconnect Call</string> <string name="disconnect_call">Disconnect Call</string>
<string name="room_description"> <string name="room_description">
Please enter a room name. Room names are shared with everyone, so think Please enter a room name. Room names are shared with everyone, so think
@ -20,6 +20,8 @@
<string name="add">Add</string> <string name="add">Add</string>
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="switch_camera">Switch front/back camera</string> <string name="switch_camera">Switch front/back camera</string>
<string name="capture_format_change_text">Slide to change capture format</string>
<string name="muted">Muted</string>
<string name="toggle_debug">Toggle debug view</string> <string name="toggle_debug">Toggle debug view</string>
<string name="toggle_mic">Toggle microphone on/off</string> <string name="toggle_mic">Toggle microphone on/off</string>
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>

View File

@ -240,7 +240,7 @@ public class AppRTCAudioManager {
+ ", n=" + name + ", n=" + name
+ ", sb=" + isInitialStickyBroadcast()); + ", sb=" + isInitialStickyBroadcast());
boolean hasWiredHeadset = (state == STATE_PLUGGED) ? true : false; boolean hasWiredHeadset = (state == STATE_PLUGGED);
switch (state) { switch (state) {
case STATE_UNPLUGGED: case STATE_UNPLUGGED:
updateAudioDeviceState(hasWiredHeadset); updateAudioDeviceState(hasWiredHeadset);

View File

@ -24,7 +24,7 @@ public interface AppRTCClient {
/** /**
* Struct holding the connection parameters of an AppRTC room. * Struct holding the connection parameters of an AppRTC room.
*/ */
public static class RoomConnectionParameters { class RoomConnectionParameters {
public final String roomUrl; public final String roomUrl;
public final String roomId; public final String roomId;
public final boolean loopback; public final boolean loopback;
@ -41,37 +41,37 @@ public interface AppRTCClient {
* parameters. Once connection is established onConnectedToRoom() * parameters. Once connection is established onConnectedToRoom()
* callback with room parameters is invoked. * callback with room parameters is invoked.
*/ */
public void connectToRoom(RoomConnectionParameters connectionParameters); void connectToRoom(RoomConnectionParameters connectionParameters);
/** /**
* Send offer SDP to the other participant. * Send offer SDP to the other participant.
*/ */
public void sendOfferSdp(final SessionDescription sdp); void sendOfferSdp(final SessionDescription sdp);
/** /**
* Send answer SDP to the other participant. * Send answer SDP to the other participant.
*/ */
public void sendAnswerSdp(final SessionDescription sdp); void sendAnswerSdp(final SessionDescription sdp);
/** /**
* Send Ice candidate to the other participant. * Send Ice candidate to the other participant.
*/ */
public void sendLocalIceCandidate(final IceCandidate candidate); void sendLocalIceCandidate(final IceCandidate candidate);
/** /**
* Send removed ICE candidates to the other participant. * Send removed ICE candidates to the other participant.
*/ */
public void sendLocalIceCandidateRemovals(final IceCandidate[] candidates); void sendLocalIceCandidateRemovals(final IceCandidate[] candidates);
/** /**
* Disconnect from room. * Disconnect from room.
*/ */
public void disconnectFromRoom(); void disconnectFromRoom();
/** /**
* Struct holding the signaling parameters of an AppRTC room. * Struct holding the signaling parameters of an AppRTC room.
*/ */
public static class SignalingParameters { class SignalingParameters {
public final List<PeerConnection.IceServer> iceServers; public final List<PeerConnection.IceServer> iceServers;
public final boolean initiator; public final boolean initiator;
public final String clientId; public final String clientId;
@ -100,36 +100,36 @@ public interface AppRTCClient {
* *
* <p>Methods are guaranteed to be invoked on the UI thread of |activity|. * <p>Methods are guaranteed to be invoked on the UI thread of |activity|.
*/ */
public static interface SignalingEvents { interface SignalingEvents {
/** /**
* Callback fired once the room's signaling parameters * Callback fired once the room's signaling parameters
* SignalingParameters are extracted. * SignalingParameters are extracted.
*/ */
public void onConnectedToRoom(final SignalingParameters params); void onConnectedToRoom(final SignalingParameters params);
/** /**
* Callback fired once remote SDP is received. * Callback fired once remote SDP is received.
*/ */
public void onRemoteDescription(final SessionDescription sdp); void onRemoteDescription(final SessionDescription sdp);
/** /**
* Callback fired once remote Ice candidate is received. * Callback fired once remote Ice candidate is received.
*/ */
public void onRemoteIceCandidate(final IceCandidate candidate); void onRemoteIceCandidate(final IceCandidate candidate);
/** /**
* Callback fired once remote Ice candidate removals are received. * Callback fired once remote Ice candidate removals are received.
*/ */
public void onRemoteIceCandidatesRemoved(final IceCandidate[] candidates); void onRemoteIceCandidatesRemoved(final IceCandidate[] candidates);
/** /**
* Callback fired once channel is closed. * Callback fired once channel is closed.
*/ */
public void onChannelClose(); void onChannelClose();
/** /**
* Callback fired once channel error happened. * Callback fired once channel error happened.
*/ */
public void onChannelError(final String description); void onChannelError(final String description);
} }
} }

View File

@ -57,7 +57,7 @@ public class AppRTCProximitySensor implements SensorEventListener {
} }
/** /**
* Activate the proximity sensor. Also do initializtion if called for the * Activate the proximity sensor. Also do initialization if called for the
* first time. * first time.
*/ */
public boolean start() { public boolean start() {
@ -125,7 +125,7 @@ public class AppRTCProximitySensor implements SensorEventListener {
/** /**
* Get default proximity sensor if it exists. Tablet devices (e.g. Nexus 7) * Get default proximity sensor if it exists. Tablet devices (e.g. Nexus 7)
* does not support this type of sensor and false will be retured in such * does not support this type of sensor and false will be returned in such
* cases. * cases.
*/ */
private boolean initDefaultSensor() { private boolean initDefaultSensor() {
@ -146,24 +146,24 @@ public class AppRTCProximitySensor implements SensorEventListener {
return; return;
} }
StringBuilder info = new StringBuilder("Proximity sensor: "); StringBuilder info = new StringBuilder("Proximity sensor: ");
info.append("name=" + proximitySensor.getName()); info.append("name=").append(proximitySensor.getName());
info.append(", vendor: " + proximitySensor.getVendor()); info.append(", vendor: ").append(proximitySensor.getVendor());
info.append(", power: " + proximitySensor.getPower()); info.append(", power: ").append(proximitySensor.getPower());
info.append(", resolution: " + proximitySensor.getResolution()); info.append(", resolution: ").append(proximitySensor.getResolution());
info.append(", max range: " + proximitySensor.getMaximumRange()); info.append(", max range: ").append(proximitySensor.getMaximumRange());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
// Added in API level 9. // Added in API level 9.
info.append(", min delay: " + proximitySensor.getMinDelay()); info.append(", min delay: ").append(proximitySensor.getMinDelay());
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
// Added in API level 20. // Added in API level 20.
info.append(", type: " + proximitySensor.getStringType()); info.append(", type: ").append(proximitySensor.getStringType());
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Added in API level 21. // Added in API level 21.
info.append(", max delay: " + proximitySensor.getMaxDelay()); info.append(", max delay: ").append(proximitySensor.getMaxDelay());
info.append(", reporting mode: " + proximitySensor.getReportingMode()); info.append(", reporting mode: ").append(proximitySensor.getReportingMode());
info.append(", isWakeUpSensor: " + proximitySensor.isWakeUpSensor()); info.append(", isWakeUpSensor: ").append(proximitySensor.isWakeUpSensor());
} }
Log.d(TAG, info.toString()); Log.d(TAG, info.toString());
} }

View File

@ -42,11 +42,11 @@ public class CallFragment extends Fragment {
* Call control interface for container activity. * Call control interface for container activity.
*/ */
public interface OnCallEvents { public interface OnCallEvents {
public void onCallHangUp(); void onCallHangUp();
public void onCameraSwitch(); void onCameraSwitch();
public void onVideoScalingSwitch(ScalingType scalingType); void onVideoScalingSwitch(ScalingType scalingType);
public void onCaptureFormatChange(int width, int height, int framerate); void onCaptureFormatChange(int width, int height, int framerate);
public boolean onToggleMic(); boolean onToggleMic();
} }
@Override @Override

View File

@ -69,7 +69,7 @@ public class CaptureQualityController implements SeekBar.OnSeekBarChangeListener
width = 0; width = 0;
height = 0; height = 0;
framerate = 0; framerate = 0;
captureFormatText.setText("Muted"); captureFormatText.setText(R.string.muted);
return; return;
} }

View File

@ -141,7 +141,6 @@ public class ConnectActivity extends AppCompatActivity {
CallActivity.EXTRA_RUNTIME, 0); CallActivity.EXTRA_RUNTIME, 0);
String room = sharedPref.getString(keyprefRoom, ""); String room = sharedPref.getString(keyprefRoom, "");
connectToRoom(room, true, loopback, runTimeMs); connectToRoom(room, true, loopback, runTimeMs);
return;
} }
addFavoriteButton = (FloatingActionButton) findViewById(R.id.add_favorite_button); addFavoriteButton = (FloatingActionButton) findViewById(R.id.add_favorite_button);

View File

@ -53,7 +53,7 @@ import java.util.concurrent.TimeUnit;
* CpuMonitor objects. * CpuMonitor objects.
* *
* <p>If we can gather enough info to generate a sensible result, * <p>If we can gather enough info to generate a sensible result,
* sampleCpuUtilization returns true. It is designed to never through an * sampleCpuUtilization returns true. It is designed to never throw an
* exception. * exception.
* *
* <p>sampleCpuUtilization should not be called too often in its present form, * <p>sampleCpuUtilization should not be called too often in its present form,

View File

@ -176,48 +176,48 @@ public class PeerConnectionClient {
/** /**
* Peer connection events. * Peer connection events.
*/ */
public static interface PeerConnectionEvents { public interface PeerConnectionEvents {
/** /**
* Callback fired once local SDP is created and set. * Callback fired once local SDP is created and set.
*/ */
public void onLocalDescription(final SessionDescription sdp); void onLocalDescription(final SessionDescription sdp);
/** /**
* Callback fired once local Ice candidate is generated. * Callback fired once local Ice candidate is generated.
*/ */
public void onIceCandidate(final IceCandidate candidate); void onIceCandidate(final IceCandidate candidate);
/** /**
* Callback fired once local ICE candidates are removed. * Callback fired once local ICE candidates are removed.
*/ */
public void onIceCandidatesRemoved(final IceCandidate[] candidates); void onIceCandidatesRemoved(final IceCandidate[] candidates);
/** /**
* Callback fired once connection is established (IceConnectionState is * Callback fired once connection is established (IceConnectionState is
* CONNECTED). * CONNECTED).
*/ */
public void onIceConnected(); void onIceConnected();
/** /**
* Callback fired once connection is closed (IceConnectionState is * Callback fired once connection is closed (IceConnectionState is
* DISCONNECTED). * DISCONNECTED).
*/ */
public void onIceDisconnected(); void onIceDisconnected();
/** /**
* Callback fired once peer connection is closed. * Callback fired once peer connection is closed.
*/ */
public void onPeerConnectionClosed(); void onPeerConnectionClosed();
/** /**
* Callback fired once peer connection statistics is ready. * Callback fired once peer connection statistics is ready.
*/ */
public void onPeerConnectionStatsReady(final StatsReport[] reports); void onPeerConnectionStatsReady(final StatsReport[] reports);
/** /**
* Callback fired once peer connection error happened. * Callback fired once peer connection error happened.
*/ */
public void onPeerConnectionError(final String description); void onPeerConnectionError(final String description);
} }
private PeerConnectionClient() { private PeerConnectionClient() {
@ -327,11 +327,8 @@ public class PeerConnectionClient {
Log.d(TAG, "Pereferred video codec: " + preferredVideoCodec); Log.d(TAG, "Pereferred video codec: " + preferredVideoCodec);
// Check if ISAC is used by default. // Check if ISAC is used by default.
preferIsac = false; preferIsac = peerConnectionParameters.audioCodec != null
if (peerConnectionParameters.audioCodec != null && peerConnectionParameters.audioCodec.equals(AUDIO_CODEC_ISAC);
&& peerConnectionParameters.audioCodec.equals(AUDIO_CODEC_ISAC)) {
preferIsac = true;
}
// Enable/disable OpenSL ES playback. // Enable/disable OpenSL ES playback.
if (!peerConnectionParameters.useOpenSLES) { if (!peerConnectionParameters.useOpenSLES) {
@ -503,7 +500,8 @@ public class PeerConnectionClient {
if (peerConnectionParameters.aecDump) { if (peerConnectionParameters.aecDump) {
try { try {
aecDumpFileDescriptor = ParcelFileDescriptor.open( aecDumpFileDescriptor = ParcelFileDescriptor.open(
new File("/sdcard/Download/audio.aecdump"), new File(Environment.getExternalStorageDirectory().getPath()
+ "Download/audio.aecdump"),
ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_READ_WRITE |
ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_CREATE |
ParcelFileDescriptor.MODE_TRUNCATE); ParcelFileDescriptor.MODE_TRUNCATE);
@ -564,11 +562,7 @@ public class PeerConnectionClient {
} }
} }
} }
if (minWidth * minHeight >= 1280 * 720) { return minWidth * minHeight >= 1280 * 720;
return true;
} else {
return false;
}
} }
private void getStats() { private void getStats() {
@ -869,7 +863,6 @@ public class PeerConnectionClient {
Matcher codecMatcher = codecPattern.matcher(lines[i]); Matcher codecMatcher = codecPattern.matcher(lines[i]);
if (codecMatcher.matches()) { if (codecMatcher.matches()) {
codecRtpMap = codecMatcher.group(1); codecRtpMap = codecMatcher.group(1);
continue;
} }
} }
if (mLineIndex == -1) { if (mLineIndex == -1) {

View File

@ -45,17 +45,17 @@ public class RoomParametersFetcher {
/** /**
* Room parameters fetcher callbacks. * Room parameters fetcher callbacks.
*/ */
public static interface RoomParametersFetcherEvents { public interface RoomParametersFetcherEvents {
/** /**
* Callback fired once the room's signaling parameters * Callback fired once the room's signaling parameters
* SignalingParameters are extracted. * SignalingParameters are extracted.
*/ */
public void onSignalingParametersReady(final SignalingParameters params); void onSignalingParametersReady(final SignalingParameters params);
/** /**
* Callback for room parameters extraction error. * Callback for room parameters extraction error.
*/ */
public void onSignalingParametersError(final String description); void onSignalingParametersError(final String description);
} }
public RoomParametersFetcher(String roomUrl, String roomMessage, public RoomParametersFetcher(String roomUrl, String roomMessage,

View File

@ -65,9 +65,9 @@ public class WebSocketChannelClient {
* All events are dispatched from a looper executor thread. * All events are dispatched from a looper executor thread.
*/ */
public interface WebSocketChannelEvents { public interface WebSocketChannelEvents {
public void onWebSocketMessage(final String message); void onWebSocketMessage(final String message);
public void onWebSocketClose(); void onWebSocketClose();
public void onWebSocketError(final String description); void onWebSocketError(final String description);
} }
public WebSocketChannelClient(LooperExecutor executor, WebSocketChannelEvents events) { public WebSocketChannelClient(LooperExecutor executor, WebSocketChannelEvents events) {
@ -113,7 +113,7 @@ public class WebSocketChannelClient {
Log.w(TAG, "WebSocket register() in state " + state); Log.w(TAG, "WebSocket register() in state " + state);
return; return;
} }
Log.d(TAG, "Registering WebSocket for room " + roomID + ". CLientID: " + clientID); Log.d(TAG, "Registering WebSocket for room " + roomID + ". ClientID: " + clientID);
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
try { try {
json.put("cmd", "register"); json.put("cmd", "register");
@ -159,7 +159,6 @@ public class WebSocketChannelClient {
} }
break; break;
} }
return;
} }
// This call can be used to send WebSocket messages before WebSocket // This call can be used to send WebSocket messages before WebSocket
@ -171,7 +170,7 @@ public class WebSocketChannelClient {
public void disconnect(boolean waitForComplete) { public void disconnect(boolean waitForComplete) {
checkIfCalledOnValidThread(); checkIfCalledOnValidThread();
Log.d(TAG, "Disonnect WebSocket. State: " + state); Log.d(TAG, "Disconnect WebSocket. State: " + state);
if (state == WebSocketConnectionState.REGISTERED) { if (state == WebSocketConnectionState.REGISTERED) {
// Send "bye" to WebSocket server. // Send "bye" to WebSocket server.
send("{\"type\": \"bye\"}"); send("{\"type\": \"bye\"}");
@ -200,7 +199,7 @@ public class WebSocketChannelClient {
} }
} }
} }
Log.d(TAG, "Disonnecting WebSocket done."); Log.d(TAG, "Disconnecting WebSocket done.");
} }
private void reportError(final String errorMessage) { private void reportError(final String errorMessage) {

View File

@ -34,8 +34,8 @@ public class AsyncHttpURLConnection {
* Http requests callbacks. * Http requests callbacks.
*/ */
public interface AsyncHttpEvents { public interface AsyncHttpEvents {
public void onHttpError(String errorMessage); void onHttpError(String errorMessage);
public void onHttpComplete(String response); void onHttpComplete(String response);
} }
public AsyncHttpURLConnection(String method, String url, String message, public AsyncHttpURLConnection(String method, String url, String message,