Fix some Android lint warnings in AppRTCMobile.
Bug: webrtc:6597 Change-Id: I73e304ff03a5fcb166ff7bca61319904ef495426 Reviewed-on: https://webrtc-review.googlesource.com/15322 Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20439}
This commit is contained in:

committed by
Commit Bot

parent
68e56a5951
commit
2729c16143
@ -28,7 +28,6 @@ import org.webrtc.ThreadUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -54,7 +53,7 @@ public class AppRTCAudioManager {
|
||||
}
|
||||
|
||||
/** Selected audio device change event. */
|
||||
public static interface AudioManagerEvents {
|
||||
public interface AudioManagerEvents {
|
||||
// Callback fired once audio device is changed or list of available audio devices changed.
|
||||
void onAudioDeviceChanged(
|
||||
AudioDevice selectedAudioDevice, Set<AudioDevice> availableAudioDevices);
|
||||
@ -101,7 +100,7 @@ public class AppRTCAudioManager {
|
||||
|
||||
// Contains a list of available audio devices. A Set collection is used to
|
||||
// avoid duplicate elements.
|
||||
private Set<AudioDevice> audioDevices = new HashSet<AudioDevice>();
|
||||
private Set<AudioDevice> audioDevices = new HashSet<>();
|
||||
|
||||
// Broadcast receiver for wired headset intent broadcasts.
|
||||
private BroadcastReceiver wiredHeadsetReceiver;
|
||||
@ -154,7 +153,7 @@ public class AppRTCAudioManager {
|
||||
hasWiredHeadset = (state == STATE_PLUGGED);
|
||||
updateAudioDeviceState();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** Construction. */
|
||||
static AppRTCAudioManager create(Context context) {
|
||||
@ -225,7 +224,7 @@ public class AppRTCAudioManager {
|
||||
// logging for now.
|
||||
@Override
|
||||
public void onAudioFocusChange(int focusChange) {
|
||||
String typeOfChange = "AUDIOFOCUS_NOT_DEFINED";
|
||||
final String typeOfChange;
|
||||
switch (focusChange) {
|
||||
case AudioManager.AUDIOFOCUS_GAIN:
|
||||
typeOfChange = "AUDIOFOCUS_GAIN";
|
||||
@ -388,7 +387,7 @@ public class AppRTCAudioManager {
|
||||
/** Returns current set of available/selectable audio devices. */
|
||||
public Set<AudioDevice> getAudioDevices() {
|
||||
ThreadUtils.checkIsOnMainThread();
|
||||
return Collections.unmodifiableSet(new HashSet<AudioDevice>(audioDevices));
|
||||
return Collections.unmodifiableSet(new HashSet<>(audioDevices));
|
||||
}
|
||||
|
||||
/** Returns the currently selected audio device. */
|
||||
@ -560,7 +559,7 @@ public class AppRTCAudioManager {
|
||||
}
|
||||
|
||||
// Update selected audio device.
|
||||
AudioDevice newAudioDevice = selectedAudioDevice;
|
||||
final AudioDevice newAudioDevice;
|
||||
|
||||
if (bluetoothManager.getState() == AppRTCBluetoothManager.State.SCO_CONNECTED) {
|
||||
// If a Bluetooth is connected, then it should be used as output audio
|
||||
|
@ -187,7 +187,7 @@ public class AppRTCBluetoothManager {
|
||||
}
|
||||
Log.d(TAG, "onReceive done: BT state=" + bluetoothState);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** Construction. */
|
||||
static AppRTCBluetoothManager create(Context context, AppRTCAudioManager audioManager) {
|
||||
|
@ -185,11 +185,9 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
|
||||
private SurfaceViewRenderer pipRenderer;
|
||||
private SurfaceViewRenderer fullscreenRenderer;
|
||||
private VideoFileRenderer videoFileRenderer;
|
||||
private final List<VideoRenderer.Callbacks> remoteRenderers =
|
||||
new ArrayList<VideoRenderer.Callbacks>();
|
||||
private final List<VideoRenderer.Callbacks> remoteRenderers = new ArrayList<>();
|
||||
private Toast logToast;
|
||||
private boolean commandLineRun;
|
||||
private int runTimeMs;
|
||||
private boolean activityRunning;
|
||||
private RoomConnectionParameters roomConnectionParameters;
|
||||
private PeerConnectionParameters peerConnectionParameters;
|
||||
@ -226,8 +224,8 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
|
||||
signalingParameters = null;
|
||||
|
||||
// Create UI controls.
|
||||
pipRenderer = (SurfaceViewRenderer) findViewById(R.id.pip_video_view);
|
||||
fullscreenRenderer = (SurfaceViewRenderer) findViewById(R.id.fullscreen_video_view);
|
||||
pipRenderer = findViewById(R.id.pip_video_view);
|
||||
fullscreenRenderer = findViewById(R.id.fullscreen_video_view);
|
||||
callFragment = new CallFragment();
|
||||
hudFragment = new HudFragment();
|
||||
|
||||
@ -348,7 +346,7 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
|
||||
intent.getBooleanExtra(EXTRA_ENABLE_LEVEL_CONTROL, false),
|
||||
intent.getBooleanExtra(EXTRA_DISABLE_WEBRTC_AGC_AND_HPF, false), dataChannelParameters);
|
||||
commandLineRun = intent.getBooleanExtra(EXTRA_CMDLINE, false);
|
||||
runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0);
|
||||
int runTimeMs = intent.getIntExtra(EXTRA_RUNTIME, 0);
|
||||
|
||||
Log.d(TAG, "VIDEO_FILE: '" + intent.getStringExtra(EXTRA_VIDEO_FILE_AS_CAMERA) + "'");
|
||||
|
||||
@ -714,7 +712,7 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
|
||||
}
|
||||
|
||||
private VideoCapturer createVideoCapturer() {
|
||||
VideoCapturer videoCapturer = null;
|
||||
final VideoCapturer videoCapturer;
|
||||
String videoFileAsCamera = getIntent().getStringExtra(EXTRA_VIDEO_FILE_AS_CAMERA);
|
||||
if (videoFileAsCamera != null) {
|
||||
try {
|
||||
|
@ -26,9 +26,7 @@ import org.webrtc.RendererCommon.ScalingType;
|
||||
* Fragment for call control.
|
||||
*/
|
||||
public class CallFragment extends Fragment {
|
||||
private View controlView;
|
||||
private TextView contactView;
|
||||
private ImageButton disconnectButton;
|
||||
private ImageButton cameraSwitchButton;
|
||||
private ImageButton videoScalingButton;
|
||||
private ImageButton toggleMuteButton;
|
||||
@ -52,16 +50,16 @@ public class CallFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
controlView = inflater.inflate(R.layout.fragment_call, container, false);
|
||||
View controlView = inflater.inflate(R.layout.fragment_call, container, false);
|
||||
|
||||
// Create UI controls.
|
||||
contactView = (TextView) controlView.findViewById(R.id.contact_name_call);
|
||||
disconnectButton = (ImageButton) controlView.findViewById(R.id.button_call_disconnect);
|
||||
cameraSwitchButton = (ImageButton) controlView.findViewById(R.id.button_call_switch_camera);
|
||||
videoScalingButton = (ImageButton) controlView.findViewById(R.id.button_call_scaling_mode);
|
||||
toggleMuteButton = (ImageButton) controlView.findViewById(R.id.button_call_toggle_mic);
|
||||
captureFormatText = (TextView) controlView.findViewById(R.id.capture_format_text_call);
|
||||
captureFormatSlider = (SeekBar) controlView.findViewById(R.id.capture_format_slider_call);
|
||||
contactView = controlView.findViewById(R.id.contact_name_call);
|
||||
ImageButton disconnectButton = controlView.findViewById(R.id.button_call_disconnect);
|
||||
cameraSwitchButton = controlView.findViewById(R.id.button_call_switch_camera);
|
||||
videoScalingButton = controlView.findViewById(R.id.button_call_scaling_mode);
|
||||
toggleMuteButton = controlView.findViewById(R.id.button_call_toggle_mic);
|
||||
captureFormatText = controlView.findViewById(R.id.capture_format_text_call);
|
||||
captureFormatSlider = controlView.findViewById(R.id.capture_format_slider_call);
|
||||
|
||||
// Add buttons click events.
|
||||
disconnectButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -47,48 +47,21 @@ public class ConnectActivity extends Activity {
|
||||
private static final int REMOVE_FAVORITE_INDEX = 0;
|
||||
private static boolean commandLineRun = false;
|
||||
|
||||
private ImageButton connectButton;
|
||||
private ImageButton addFavoriteButton;
|
||||
private EditText roomEditText;
|
||||
private ListView roomListView;
|
||||
private SharedPreferences sharedPref;
|
||||
private String keyprefVideoCallEnabled;
|
||||
private String keyprefScreencapture;
|
||||
private String keyprefCamera2;
|
||||
private String keyprefResolution;
|
||||
private String keyprefFps;
|
||||
private String keyprefCaptureQualitySlider;
|
||||
private String keyprefVideoBitrateType;
|
||||
private String keyprefVideoBitrateValue;
|
||||
private String keyprefVideoCodec;
|
||||
private String keyprefAudioBitrateType;
|
||||
private String keyprefAudioBitrateValue;
|
||||
private String keyprefAudioCodec;
|
||||
private String keyprefHwCodecAcceleration;
|
||||
private String keyprefCaptureToTexture;
|
||||
private String keyprefFlexfec;
|
||||
private String keyprefNoAudioProcessingPipeline;
|
||||
private String keyprefAecDump;
|
||||
private String keyprefOpenSLES;
|
||||
private String keyprefDisableBuiltInAec;
|
||||
private String keyprefDisableBuiltInAgc;
|
||||
private String keyprefDisableBuiltInNs;
|
||||
private String keyprefEnableLevelControl;
|
||||
private String keyprefDisableWebRtcAGCAndHPF;
|
||||
private String keyprefDisplayHud;
|
||||
private String keyprefTracing;
|
||||
private String keyprefRoomServerUrl;
|
||||
private String keyprefRoom;
|
||||
private String keyprefRoomList;
|
||||
private ArrayList<String> roomList;
|
||||
private ArrayAdapter<String> adapter;
|
||||
private String keyprefEnableDataChannel;
|
||||
private String keyprefOrdered;
|
||||
private String keyprefMaxRetransmitTimeMs;
|
||||
private String keyprefMaxRetransmits;
|
||||
private String keyprefDataProtocol;
|
||||
private String keyprefNegotiated;
|
||||
private String keyprefDataId;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -97,45 +70,19 @@ public class ConnectActivity extends Activity {
|
||||
// Get setting keys.
|
||||
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
||||
sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
keyprefVideoCallEnabled = getString(R.string.pref_videocall_key);
|
||||
keyprefScreencapture = getString(R.string.pref_screencapture_key);
|
||||
keyprefCamera2 = getString(R.string.pref_camera2_key);
|
||||
keyprefResolution = getString(R.string.pref_resolution_key);
|
||||
keyprefFps = getString(R.string.pref_fps_key);
|
||||
keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_key);
|
||||
keyprefVideoBitrateType = getString(R.string.pref_maxvideobitrate_key);
|
||||
keyprefVideoBitrateValue = getString(R.string.pref_maxvideobitratevalue_key);
|
||||
keyprefVideoCodec = getString(R.string.pref_videocodec_key);
|
||||
keyprefHwCodecAcceleration = getString(R.string.pref_hwcodec_key);
|
||||
keyprefCaptureToTexture = getString(R.string.pref_capturetotexture_key);
|
||||
keyprefFlexfec = getString(R.string.pref_flexfec_key);
|
||||
keyprefAudioBitrateType = getString(R.string.pref_startaudiobitrate_key);
|
||||
keyprefAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key);
|
||||
keyprefAudioCodec = getString(R.string.pref_audiocodec_key);
|
||||
keyprefNoAudioProcessingPipeline = getString(R.string.pref_noaudioprocessing_key);
|
||||
keyprefAecDump = getString(R.string.pref_aecdump_key);
|
||||
keyprefOpenSLES = getString(R.string.pref_opensles_key);
|
||||
keyprefDisableBuiltInAec = getString(R.string.pref_disable_built_in_aec_key);
|
||||
keyprefDisableBuiltInAgc = getString(R.string.pref_disable_built_in_agc_key);
|
||||
keyprefDisableBuiltInNs = getString(R.string.pref_disable_built_in_ns_key);
|
||||
keyprefEnableLevelControl = getString(R.string.pref_enable_level_control_key);
|
||||
keyprefDisableWebRtcAGCAndHPF = getString(R.string.pref_disable_webrtc_agc_and_hpf_key);
|
||||
keyprefDisplayHud = getString(R.string.pref_displayhud_key);
|
||||
keyprefTracing = getString(R.string.pref_tracing_key);
|
||||
keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key);
|
||||
keyprefRoom = getString(R.string.pref_room_key);
|
||||
keyprefRoomList = getString(R.string.pref_room_list_key);
|
||||
keyprefEnableDataChannel = getString(R.string.pref_enable_datachannel_key);
|
||||
keyprefOrdered = getString(R.string.pref_ordered_key);
|
||||
keyprefMaxRetransmitTimeMs = getString(R.string.pref_max_retransmit_time_ms_key);
|
||||
keyprefMaxRetransmits = getString(R.string.pref_max_retransmits_key);
|
||||
keyprefDataProtocol = getString(R.string.pref_data_protocol_key);
|
||||
keyprefNegotiated = getString(R.string.pref_negotiated_key);
|
||||
keyprefDataId = getString(R.string.pref_data_id_key);
|
||||
|
||||
setContentView(R.layout.activity_connect);
|
||||
|
||||
roomEditText = (EditText) findViewById(R.id.room_edittext);
|
||||
roomEditText = findViewById(R.id.room_edittext);
|
||||
roomEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
||||
@ -148,13 +95,13 @@ public class ConnectActivity extends Activity {
|
||||
});
|
||||
roomEditText.requestFocus();
|
||||
|
||||
roomListView = (ListView) findViewById(R.id.room_listview);
|
||||
roomListView = findViewById(R.id.room_listview);
|
||||
roomListView.setEmptyView(findViewById(android.R.id.empty));
|
||||
roomListView.setOnItemClickListener(roomListClickListener);
|
||||
registerForContextMenu(roomListView);
|
||||
connectButton = (ImageButton) findViewById(R.id.connect_button);
|
||||
ImageButton connectButton = findViewById(R.id.connect_button);
|
||||
connectButton.setOnClickListener(connectListener);
|
||||
addFavoriteButton = (ImageButton) findViewById(R.id.add_favorite_button);
|
||||
addFavoriteButton = findViewById(R.id.add_favorite_button);
|
||||
addFavoriteButton.setOnClickListener(addFavoriteListener);
|
||||
|
||||
// If an implicit VIEW intent is launching the app, go directly to that URL.
|
||||
@ -233,7 +180,7 @@ public class ConnectActivity extends Activity {
|
||||
super.onResume();
|
||||
String room = sharedPref.getString(keyprefRoom, "");
|
||||
roomEditText.setText(room);
|
||||
roomList = new ArrayList<String>();
|
||||
roomList = new ArrayList<>();
|
||||
String roomListJson = sharedPref.getString(keyprefRoomList, null);
|
||||
if (roomListJson != null) {
|
||||
try {
|
||||
@ -245,7 +192,7 @@ public class ConnectActivity extends Activity {
|
||||
Log.e(TAG, "Failed to load room list: " + e.toString());
|
||||
}
|
||||
}
|
||||
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, roomList);
|
||||
adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, roomList);
|
||||
roomListView.setAdapter(adapter);
|
||||
if (adapter.getCount() > 0) {
|
||||
roomListView.requestFocus();
|
||||
@ -321,7 +268,7 @@ public class ConnectActivity extends Activity {
|
||||
|
||||
private void connectToRoom(String roomId, boolean commandLineRun, boolean loopback,
|
||||
boolean useValuesFromIntent, int runTimeMs) {
|
||||
this.commandLineRun = commandLineRun;
|
||||
ConnectActivity.commandLineRun = commandLineRun;
|
||||
|
||||
// roomId is random for loopback.
|
||||
if (loopback) {
|
||||
|
@ -224,23 +224,18 @@ class CpuMonitor {
|
||||
}
|
||||
|
||||
private void init() {
|
||||
try {
|
||||
FileReader fin = new FileReader("/sys/devices/system/cpu/present");
|
||||
try {
|
||||
try (FileReader fin = new FileReader("/sys/devices/system/cpu/present")) {
|
||||
BufferedReader reader = new BufferedReader(fin);
|
||||
Scanner scanner = new Scanner(reader).useDelimiter("[-\n]");
|
||||
scanner.nextInt(); // Skip leading number 0.
|
||||
cpusPresent = 1 + scanner.nextInt();
|
||||
scanner.close();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Cannot do CPU stats due to /sys/devices/system/cpu/present parsing problem");
|
||||
} finally {
|
||||
fin.close();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.e(TAG, "Cannot do CPU stats since /sys/devices/system/cpu/present is missing");
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Error closing file");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Cannot do CPU stats due to /sys/devices/system/cpu/present parsing problem");
|
||||
}
|
||||
|
||||
cpuFreqMax = new long[cpusPresent];
|
||||
@ -437,14 +432,9 @@ class CpuMonitor {
|
||||
*/
|
||||
private long readFreqFromFile(String fileName) {
|
||||
long number = 0;
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(fileName));
|
||||
try {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(fileName))) {
|
||||
String line = reader.readLine();
|
||||
number = parseLong(line);
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
// CPU core is off, so file with its scaling frequency .../cpufreq/scaling_cur_freq
|
||||
// is not present. This is not an error.
|
||||
@ -473,9 +463,7 @@ class CpuMonitor {
|
||||
long userTime = 0;
|
||||
long systemTime = 0;
|
||||
long idleTime = 0;
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader("/proc/stat"));
|
||||
try {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader("/proc/stat"))) {
|
||||
// line should contain something like this:
|
||||
// cpu 5093818 271838 3512830 165934119 101374 447076 272086 0 0 0
|
||||
// user nice system idle iowait irq softirq
|
||||
@ -493,17 +481,11 @@ class CpuMonitor {
|
||||
systemTime += parseLong(lines[6]); // irq
|
||||
systemTime += parseLong(lines[7]); // softirq
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Problems parsing /proc/stat", e);
|
||||
return null;
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.e(TAG, "Cannot open /proc/stat for reading", e);
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Problems reading /proc/stat", e);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Problems parsing /proc/stat", e);
|
||||
return null;
|
||||
}
|
||||
return new ProcStat(userTime, systemTime, idleTime);
|
||||
|
@ -233,7 +233,7 @@ public class DirectRTCClient implements AppRTCClient, TCPChannelClient.TCPChanne
|
||||
|
||||
SignalingParameters parameters = new SignalingParameters(
|
||||
// Ice servers are not needed for direct connections.
|
||||
new LinkedList<PeerConnection.IceServer>(),
|
||||
new LinkedList<>(),
|
||||
isServer, // Server side acts as the initiator on direct connections.
|
||||
null, // clientId
|
||||
null, // wssUrl
|
||||
@ -269,7 +269,7 @@ public class DirectRTCClient implements AppRTCClient, TCPChannelClient.TCPChanne
|
||||
|
||||
SignalingParameters parameters = new SignalingParameters(
|
||||
// Ice servers are not needed for direct connections.
|
||||
new LinkedList<PeerConnection.IceServer>(),
|
||||
new LinkedList<>(),
|
||||
false, // This code will only be run on the client side. So, we are not the initiator.
|
||||
null, // clientId
|
||||
null, // wssUrl
|
||||
|
@ -28,7 +28,6 @@ import java.util.Map;
|
||||
* Fragment for HUD statistics display.
|
||||
*/
|
||||
public class HudFragment extends Fragment {
|
||||
private View controlView;
|
||||
private TextView encoderStatView;
|
||||
private TextView hudViewBwe;
|
||||
private TextView hudViewConnection;
|
||||
@ -43,15 +42,15 @@ public class HudFragment extends Fragment {
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
controlView = inflater.inflate(R.layout.fragment_hud, container, false);
|
||||
View controlView = inflater.inflate(R.layout.fragment_hud, container, false);
|
||||
|
||||
// Create UI controls.
|
||||
encoderStatView = (TextView) controlView.findViewById(R.id.encoder_stat_call);
|
||||
hudViewBwe = (TextView) controlView.findViewById(R.id.hud_stat_bwe);
|
||||
hudViewConnection = (TextView) controlView.findViewById(R.id.hud_stat_connection);
|
||||
hudViewVideoSend = (TextView) controlView.findViewById(R.id.hud_stat_video_send);
|
||||
hudViewVideoRecv = (TextView) controlView.findViewById(R.id.hud_stat_video_recv);
|
||||
toggleDebugButton = (ImageButton) controlView.findViewById(R.id.button_toggle_debug);
|
||||
encoderStatView = controlView.findViewById(R.id.encoder_stat_call);
|
||||
hudViewBwe = controlView.findViewById(R.id.hud_stat_bwe);
|
||||
hudViewConnection = controlView.findViewById(R.id.hud_stat_connection);
|
||||
hudViewVideoSend = controlView.findViewById(R.id.hud_stat_video_send);
|
||||
hudViewVideoRecv = controlView.findViewById(R.id.hud_stat_video_recv);
|
||||
toggleDebugButton = controlView.findViewById(R.id.button_toggle_debug);
|
||||
|
||||
toggleDebugButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -105,7 +104,7 @@ public class HudFragment extends Fragment {
|
||||
}
|
||||
|
||||
private Map<String, String> getReportMap(StatsReport report) {
|
||||
Map<String, String> reportMap = new HashMap<String, String>();
|
||||
Map<String, String> reportMap = new HashMap<>();
|
||||
for (StatsReport.Value value : report.values) {
|
||||
reportMap.put(value.name, value.value);
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -134,7 +133,6 @@ public class PeerConnectionClient {
|
||||
private int videoHeight;
|
||||
private int videoFps;
|
||||
private MediaConstraints audioConstraints;
|
||||
private ParcelFileDescriptor aecDumpFileDescriptor;
|
||||
private MediaConstraints sdpMediaConstraints;
|
||||
private PeerConnectionParameters peerConnectionParameters;
|
||||
// Queued remote ICE candidates are consumed only after both local and
|
||||
@ -600,7 +598,7 @@ public class PeerConnectionClient {
|
||||
Log.d(TAG, "Create peer connection.");
|
||||
|
||||
Log.d(TAG, "PCConstraints: " + pcConstraints.toString());
|
||||
queuedRemoteCandidates = new LinkedList<IceCandidate>();
|
||||
queuedRemoteCandidates = new LinkedList<>();
|
||||
|
||||
if (videoCallEnabled) {
|
||||
factory.setVideoHwAccelerationOptions(
|
||||
@ -649,7 +647,7 @@ public class PeerConnectionClient {
|
||||
|
||||
if (peerConnectionParameters.aecDump) {
|
||||
try {
|
||||
aecDumpFileDescriptor =
|
||||
ParcelFileDescriptor aecDumpFileDescriptor =
|
||||
ParcelFileDescriptor.open(new File(Environment.getExternalStorageDirectory().getPath()
|
||||
+ File.separator + "Download/audio.aecdump"),
|
||||
ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_CREATE
|
||||
@ -715,11 +713,7 @@ public class PeerConnectionClient {
|
||||
}
|
||||
|
||||
public boolean isHDVideo() {
|
||||
if (!videoCallEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return videoWidth * videoHeight >= 1280 * 720;
|
||||
return videoCallEnabled && videoWidth * videoHeight >= 1280 * 720;
|
||||
}
|
||||
|
||||
public EglBase.Context getRenderContext() {
|
||||
@ -1072,11 +1066,11 @@ public class PeerConnectionClient {
|
||||
}
|
||||
final List<String> header = origLineParts.subList(0, 3);
|
||||
final List<String> unpreferredPayloadTypes =
|
||||
new ArrayList<String>(origLineParts.subList(3, origLineParts.size()));
|
||||
new ArrayList<>(origLineParts.subList(3, origLineParts.size()));
|
||||
unpreferredPayloadTypes.removeAll(preferredPayloadTypes);
|
||||
// Reconstruct the line with |preferredPayloadTypes| moved to the beginning of the payload
|
||||
// types.
|
||||
final List<String> newLineParts = new ArrayList<String>();
|
||||
final List<String> newLineParts = new ArrayList<>();
|
||||
newLineParts.addAll(header);
|
||||
newLineParts.addAll(preferredPayloadTypes);
|
||||
newLineParts.addAll(unpreferredPayloadTypes);
|
||||
@ -1092,11 +1086,11 @@ public class PeerConnectionClient {
|
||||
}
|
||||
// A list with all the payload types with name |codec|. The payload types are integers in the
|
||||
// range 96-127, but they are stored as strings here.
|
||||
final List<String> codecPayloadTypes = new ArrayList<String>();
|
||||
final List<String> codecPayloadTypes = new ArrayList<>();
|
||||
// a=rtpmap:<payload type> <encoding name>/<clock rate> [/<encoding parameters>]
|
||||
final Pattern codecPattern = Pattern.compile("^a=rtpmap:(\\d+) " + codec + "(/\\d+)+[\r]?$");
|
||||
for (int i = 0; i < lines.length; ++i) {
|
||||
Matcher codecMatcher = codecPattern.matcher(lines[i]);
|
||||
for (String line : lines) {
|
||||
Matcher codecMatcher = codecPattern.matcher(line);
|
||||
if (codecMatcher.matches()) {
|
||||
codecPayloadTypes.add(codecMatcher.group(1));
|
||||
}
|
||||
@ -1127,7 +1121,7 @@ public class PeerConnectionClient {
|
||||
|
||||
private void switchCameraInternal() {
|
||||
if (videoCapturer instanceof CameraVideoCapturer) {
|
||||
if (!videoCallEnabled || isError || videoCapturer == null) {
|
||||
if (!videoCallEnabled || isError) {
|
||||
Log.e(TAG, "Failed to switch camera. Video: " + videoCallEnabled + ". Error : " + isError);
|
||||
return; // No video is sent or only one camera is available or error happened.
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ public class RoomParametersFetcher {
|
||||
private final RoomParametersFetcherEvents events;
|
||||
private final String roomUrl;
|
||||
private final String roomMessage;
|
||||
private AsyncHttpURLConnection httpConnection;
|
||||
|
||||
/**
|
||||
* Room parameters fetcher callbacks.
|
||||
@ -64,7 +63,7 @@ public class RoomParametersFetcher {
|
||||
|
||||
public void makeRequest() {
|
||||
Log.d(TAG, "Connecting to room: " + roomUrl);
|
||||
httpConnection =
|
||||
AsyncHttpURLConnection httpConnection =
|
||||
new AsyncHttpURLConnection("POST", roomUrl, roomMessage, new AsyncHttpEvents() {
|
||||
@Override
|
||||
public void onHttpError(String errorMessage) {
|
||||
@ -100,7 +99,7 @@ public class RoomParametersFetcher {
|
||||
String wssPostUrl = roomJson.getString("wss_post_url");
|
||||
boolean initiator = (roomJson.getBoolean("is_initiator"));
|
||||
if (!initiator) {
|
||||
iceCandidates = new LinkedList<IceCandidate>();
|
||||
iceCandidates = new LinkedList<>();
|
||||
String messagesString = roomJson.getString("messages");
|
||||
JSONArray messages = new JSONArray(messagesString);
|
||||
for (int i = 0; i < messages.length(); ++i) {
|
||||
@ -161,7 +160,7 @@ public class RoomParametersFetcher {
|
||||
// off the main thread!
|
||||
private LinkedList<PeerConnection.IceServer> requestTurnServers(String url)
|
||||
throws IOException, JSONException {
|
||||
LinkedList<PeerConnection.IceServer> turnServers = new LinkedList<PeerConnection.IceServer>();
|
||||
LinkedList<PeerConnection.IceServer> turnServers = new LinkedList<>();
|
||||
Log.d(TAG, "Request TURN from: " + url);
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
connection.setDoOutput(true);
|
||||
@ -203,7 +202,7 @@ public class RoomParametersFetcher {
|
||||
throws JSONException {
|
||||
JSONObject json = new JSONObject(pcConfig);
|
||||
JSONArray servers = json.getJSONArray("iceServers");
|
||||
LinkedList<PeerConnection.IceServer> ret = new LinkedList<PeerConnection.IceServer>();
|
||||
LinkedList<PeerConnection.IceServer> ret = new LinkedList<>();
|
||||
for (int i = 0; i < servers.length(); ++i) {
|
||||
JSONObject server = servers.getJSONObject(i);
|
||||
String url = server.getString("urls");
|
||||
|
@ -41,7 +41,6 @@ public class WebSocketChannelClient {
|
||||
private final WebSocketChannelEvents events;
|
||||
private final Handler handler;
|
||||
private WebSocketConnection ws;
|
||||
private WebSocketObserver wsObserver;
|
||||
private String wsServerUrl;
|
||||
private String postServerUrl;
|
||||
private String roomID;
|
||||
@ -73,7 +72,7 @@ public class WebSocketChannelClient {
|
||||
this.events = events;
|
||||
roomID = null;
|
||||
clientID = null;
|
||||
wsSendQueue = new LinkedList<String>();
|
||||
wsSendQueue = new LinkedList<>();
|
||||
state = WebSocketConnectionState.NEW;
|
||||
}
|
||||
|
||||
@ -93,7 +92,7 @@ public class WebSocketChannelClient {
|
||||
|
||||
Log.d(TAG, "Connecting WebSocket to: " + wsUrl + ". Post URL: " + postUrl);
|
||||
ws = new WebSocketConnection();
|
||||
wsObserver = new WebSocketObserver();
|
||||
WebSocketObserver wsObserver = new WebSocketObserver();
|
||||
try {
|
||||
ws.connect(new URI(wsServerUrl), wsObserver);
|
||||
} catch (URISyntaxException e) {
|
||||
|
@ -26,7 +26,6 @@ import android.support.test.InstrumentationRegistry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.appspot.apprtc.CallActivity;
|
||||
import org.appspot.apprtc.ConnectActivity;
|
||||
import org.appspot.apprtc.R;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
@ -79,7 +79,7 @@ public class PeerConnectionClientTest implements PeerConnectionEvents {
|
||||
private boolean isClosed;
|
||||
private boolean isIceConnected;
|
||||
private SessionDescription localSdp;
|
||||
private List<IceCandidate> iceCandidates = new LinkedList<IceCandidate>();
|
||||
private List<IceCandidate> iceCandidates = new LinkedList<>();
|
||||
private final Object localSdpEvent = new Object();
|
||||
private final Object iceCandidateEvent = new Object();
|
||||
private final Object iceConnectedEvent = new Object();
|
||||
@ -284,7 +284,7 @@ public class PeerConnectionClientTest implements PeerConnectionEvents {
|
||||
PeerConnectionClient createPeerConnectionClient(MockSink localRenderer,
|
||||
MockRenderer remoteRenderer, PeerConnectionParameters peerConnectionParameters,
|
||||
VideoCapturer videoCapturer) {
|
||||
List<PeerConnection.IceServer> iceServers = new LinkedList<PeerConnection.IceServer>();
|
||||
List<PeerConnection.IceServer> iceServers = new LinkedList<>();
|
||||
SignalingParameters signalingParameters =
|
||||
new SignalingParameters(iceServers, true, // iceServers, initiator.
|
||||
null, null, null, // clientId, wssUrl, wssPostUrl.
|
||||
@ -303,8 +303,7 @@ public class PeerConnectionClientTest implements PeerConnectionEvents {
|
||||
}
|
||||
|
||||
private PeerConnectionParameters createParametersForAudioCall() {
|
||||
PeerConnectionParameters peerConnectionParameters = new PeerConnectionParameters(
|
||||
false, /* videoCallEnabled */
|
||||
return new PeerConnectionParameters(false, /* videoCallEnabled */
|
||||
true, /* loopback */
|
||||
false, /* tracing */
|
||||
// Video codec parameters.
|
||||
@ -322,8 +321,6 @@ public class PeerConnectionClientTest implements PeerConnectionEvents {
|
||||
false, /* aecDump */
|
||||
false /* useOpenSLES */, false /* disableBuiltInAEC */, false /* disableBuiltInAGC */,
|
||||
false /* disableBuiltInNS */, false /* enableLevelControl */, false /* disableWebRtcAGC */);
|
||||
|
||||
return peerConnectionParameters;
|
||||
}
|
||||
|
||||
private VideoCapturer createCameraCapturer(boolean captureToTexture) {
|
||||
@ -341,8 +338,7 @@ public class PeerConnectionClientTest implements PeerConnectionEvents {
|
||||
}
|
||||
|
||||
private PeerConnectionParameters createParametersForVideoCall(String videoCodec) {
|
||||
PeerConnectionParameters peerConnectionParameters = new PeerConnectionParameters(
|
||||
true, /* videoCallEnabled */
|
||||
return new PeerConnectionParameters(true, /* videoCallEnabled */
|
||||
true, /* loopback */
|
||||
false, /* tracing */
|
||||
// Video codec parameters.
|
||||
@ -360,8 +356,6 @@ public class PeerConnectionClientTest implements PeerConnectionEvents {
|
||||
false, /* aecDump */
|
||||
false /* useOpenSLES */, false /* disableBuiltInAEC */, false /* disableBuiltInAGC */,
|
||||
false /* disableBuiltInNS */, false /* enableLevelControl */, false /* disableWebRtcAGC */);
|
||||
|
||||
return peerConnectionParameters;
|
||||
}
|
||||
|
||||
@Before
|
||||
|
Reference in New Issue
Block a user