mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-21 03:35:15 +01:00
Some cleanups
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
42b71b9710
commit
413e962ef4
@ -428,7 +428,14 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createCameraEnumerator() {
|
private void createCameraEnumerator() {
|
||||||
if (Camera2Enumerator.isSupported(this)) {
|
boolean camera2EnumeratorIsSupported = false;
|
||||||
|
try {
|
||||||
|
camera2EnumeratorIsSupported = Camera2Enumerator.isSupported(this);
|
||||||
|
} catch (final Throwable throwable) {
|
||||||
|
Log.w(TAG, "Camera2Enumator threw an error");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (camera2EnumeratorIsSupported) {
|
||||||
cameraEnumerator = new Camera2Enumerator(this);
|
cameraEnumerator = new Camera2Enumerator(this);
|
||||||
} else {
|
} else {
|
||||||
cameraEnumerator = new Camera1Enumerator(true);
|
cameraEnumerator = new Camera1Enumerator(true);
|
||||||
@ -548,14 +555,6 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
rootEglBase = EglBase.create();
|
rootEglBase = EglBase.create();
|
||||||
createCameraEnumerator();
|
createCameraEnumerator();
|
||||||
|
|
||||||
//Initialize PeerConnectionFactory globals.
|
|
||||||
PeerConnectionFactory.InitializationOptions initializationOptions = PeerConnectionFactory.InitializationOptions
|
|
||||||
.builder(this)
|
|
||||||
.setEnableVideoHwAcceleration(true)
|
|
||||||
.setFieldTrials(null)
|
|
||||||
.createInitializationOptions();
|
|
||||||
PeerConnectionFactory.initialize(initializationOptions);
|
|
||||||
|
|
||||||
//Create a new PeerConnectionFactory instance.
|
//Create a new PeerConnectionFactory instance.
|
||||||
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
|
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
|
||||||
peerConnectionFactory = new PeerConnectionFactory(options);
|
peerConnectionFactory = new PeerConnectionFactory(options);
|
||||||
@ -968,14 +967,22 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
leavingCall = true;
|
leavingCall = true;
|
||||||
inCall = false;
|
inCall = false;
|
||||||
dispose(null);
|
|
||||||
|
if (videoCapturer != null) {
|
||||||
|
try {
|
||||||
|
videoCapturer.stopCapture();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Log.e(TAG, "Failed to stop capturing while hanging up");
|
||||||
|
}
|
||||||
|
videoCapturer.dispose();
|
||||||
|
videoCapturer = null;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < magicPeerConnectionWrapperList.size(); i++) {
|
for (int i = 0; i < magicPeerConnectionWrapperList.size(); i++) {
|
||||||
endPeerConnection(magicPeerConnectionWrapperList.get(i).getSessionId());
|
endPeerConnection(magicPeerConnectionWrapperList.get(i).getSessionId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dueToNetworkChange) {
|
|
||||||
pipVideoView.release();
|
pipVideoView.release();
|
||||||
|
|
||||||
if (audioSource != null) {
|
if (audioSource != null) {
|
||||||
@ -988,19 +995,7 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
audioManager = null;
|
audioManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (videoCapturer != null) {
|
|
||||||
try {
|
|
||||||
videoCapturer.stopCapture();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Log.e(TAG, "Failed to stop capturing while hanging up");
|
|
||||||
}
|
|
||||||
videoCapturer.dispose();
|
|
||||||
videoCapturer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.d(TAG, "Closing video source.");
|
|
||||||
if (videoSource != null) {
|
if (videoSource != null) {
|
||||||
videoSource.dispose();
|
|
||||||
videoSource = null;
|
videoSource = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1009,15 +1004,12 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
peerConnectionFactory = null;
|
peerConnectionFactory = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
localMediaStream.removeTrack(localAudioTrack);
|
|
||||||
localMediaStream.removeTrack(localVideoTrack);
|
|
||||||
localMediaStream = null;
|
localMediaStream = null;
|
||||||
localAudioTrack = null;
|
localAudioTrack = null;
|
||||||
localVideoTrack = null;
|
localVideoTrack = null;
|
||||||
|
|
||||||
hangupNetworkCalls();
|
hangupNetworkCalls();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void hangupNetworkCalls() {
|
private void hangupNetworkCalls() {
|
||||||
String credentials = ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken());
|
String credentials = ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken());
|
||||||
@ -1131,6 +1123,7 @@ public class CallActivity extends AppCompatActivity {
|
|||||||
hangup(false);
|
hangup(false);
|
||||||
}
|
}
|
||||||
//this.unregisterReceiver(networkBroadcastReceier);
|
//this.unregisterReceiver(networkBroadcastReceier);
|
||||||
|
rootEglBase.release();
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,10 +43,16 @@ import com.nextcloud.talk.utils.database.user.UserModule;
|
|||||||
import com.squareup.leakcanary.LeakCanary;
|
import com.squareup.leakcanary.LeakCanary;
|
||||||
import com.squareup.leakcanary.RefWatcher;
|
import com.squareup.leakcanary.RefWatcher;
|
||||||
|
|
||||||
|
import org.webrtc.PeerConnectionFactory;
|
||||||
|
import org.webrtc.voiceengine.WebRtcAudioManager;
|
||||||
|
import org.webrtc.voiceengine.WebRtcAudioUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
@ -107,6 +113,54 @@ public class NextcloudTalkApplication extends MultiDexApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
AEC blacklist and SL_ES_WHITELIST are borrowed from Signal
|
||||||
|
https://github.com/WhisperSystems/Signal-Android/blob/551470123d006b76a68d705d131bb12513a5e683/src/org/thoughtcrime/securesms/ApplicationContext.java
|
||||||
|
*/
|
||||||
|
private void initializeWebRtc() {
|
||||||
|
try {
|
||||||
|
Set<String> HARDWARE_AEC_BLACKLIST = new HashSet<String>() {{
|
||||||
|
add("D6503"); // Sony Xperia Z2 D6503
|
||||||
|
add("ONE A2005"); // OnePlus 2
|
||||||
|
add("MotoG3"); // Moto G (3rd Generation)
|
||||||
|
add("Nexus 6P"); // Nexus 6p
|
||||||
|
add("Pixel"); // Pixel
|
||||||
|
add("Pixel XL"); // Pixel XL
|
||||||
|
add("MI 4LTE"); // Xiami Mi4
|
||||||
|
add("Redmi Note 3"); // Redmi Note 3
|
||||||
|
add("Redmi Note 4"); // Redmi Note 4
|
||||||
|
add("SM-G900F"); // Samsung Galaxy S5
|
||||||
|
add("g3_kt_kr"); // LG G3
|
||||||
|
add("SM-G930F"); // Samsung Galaxy S7
|
||||||
|
add("Xperia SP"); // Sony Xperia SP
|
||||||
|
add("Nexus 6"); // Nexus 6
|
||||||
|
add("ONE E1003"); // OnePlus X
|
||||||
|
add("One"); // OnePlus One
|
||||||
|
add("Moto G5");
|
||||||
|
}};
|
||||||
|
|
||||||
|
Set<String> OPEN_SL_ES_WHITELIST = new HashSet<String>() {{
|
||||||
|
add("Pixel");
|
||||||
|
add("Pixel XL");
|
||||||
|
}};
|
||||||
|
|
||||||
|
if (HARDWARE_AEC_BLACKLIST.contains(Build.MODEL)) {
|
||||||
|
WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!OPEN_SL_ES_WHITELIST.contains(Build.MODEL)) {
|
||||||
|
WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions.builder(this)
|
||||||
|
.setEnableVideoHwAcceleration(true)
|
||||||
|
.createInitializationOptions());
|
||||||
|
} catch (UnsatisfiedLinkError e) {
|
||||||
|
Log.w(TAG, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region Overridden methods
|
//region Overridden methods
|
||||||
@ -115,8 +169,10 @@ public class NextcloudTalkApplication extends MultiDexApplication {
|
|||||||
super.onCreate();
|
super.onCreate();
|
||||||
JobManager.create(this).addJobCreator(new MagicJobCreator());
|
JobManager.create(this).addJobCreator(new MagicJobCreator());
|
||||||
FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(false);
|
FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(false);
|
||||||
|
|
||||||
sharedApplication = this;
|
sharedApplication = this;
|
||||||
|
|
||||||
|
initializeWebRtc();
|
||||||
useCompatVectorIfNeeded();
|
useCompatVectorIfNeeded();
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user