Added setting to choose which camera to use + improved reload devices to not use legacy capture filter code directly
This commit is contained in:
parent
d753ca238b
commit
a0c3fe58cb
7 changed files with 86 additions and 31 deletions
|
@ -539,11 +539,37 @@ public class LinphoneManager implements SensorEventListener {
|
||||||
PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
|
PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
|
||||||
mContext.getPackageName() + ";manager_proximity_sensor");
|
mContext.getPackageName() + ";manager_proximity_sensor");
|
||||||
|
|
||||||
|
resetCameraFromPreferences();
|
||||||
|
|
||||||
mAccountCreator = mCore.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
|
mAccountCreator = mCore.createAccountCreator(LinphonePreferences.instance().getXmlrpcUrl());
|
||||||
mAccountCreator.setListener(mAccountCreatorListener);
|
mAccountCreator.setListener(mAccountCreatorListener);
|
||||||
mCallGsmON = false;
|
mCallGsmON = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetCameraFromPreferences() {
|
||||||
|
Core core = getCore();
|
||||||
|
if (core == null) return;
|
||||||
|
|
||||||
|
boolean useFrontCam = LinphonePreferences.instance().useFrontCam();
|
||||||
|
String firstDevice = null;
|
||||||
|
for (String camera : core.getVideoDevicesList()) {
|
||||||
|
if (firstDevice == null) {
|
||||||
|
firstDevice = camera;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useFrontCam) {
|
||||||
|
if (camera.contains("Front")) {
|
||||||
|
Log.i("[Manager] Found front facing camera: " + camera);
|
||||||
|
core.setVideoDevice(camera);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i("[Manager] Using first camera available: " + firstDevice);
|
||||||
|
core.setVideoDevice(firstDevice);
|
||||||
|
}
|
||||||
|
|
||||||
/* Account linking */
|
/* Account linking */
|
||||||
|
|
||||||
public void isAccountWithAlias() {
|
public void isAccountWithAlias() {
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.linphone.LinphoneManager;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.CoreListenerStub;
|
import org.linphone.core.CoreListenerStub;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
import org.linphone.core.tools.Log;
|
||||||
|
|
||||||
public class QrCodeConfigurationAssistantActivity extends AssistantActivity {
|
public class QrCodeConfigurationAssistantActivity extends AssistantActivity {
|
||||||
private TextureView mQrcodeView;
|
private TextureView mQrcodeView;
|
||||||
|
@ -105,19 +105,20 @@ public class QrCodeConfigurationAssistantActivity extends AssistantActivity {
|
||||||
Core core = LinphoneManager.getCore();
|
Core core = LinphoneManager.getCore();
|
||||||
if (core == null) return;
|
if (core == null) return;
|
||||||
|
|
||||||
int camId = 0;
|
String firstDevice = null;
|
||||||
AndroidCameraConfiguration.AndroidCamera[] cameras =
|
for (String camera : core.getVideoDevicesList()) {
|
||||||
AndroidCameraConfiguration.retrieveCameras();
|
if (firstDevice == null) {
|
||||||
for (AndroidCameraConfiguration.AndroidCamera androidCamera : cameras) {
|
firstDevice = camera;
|
||||||
if (!androidCamera.frontFacing) camId = androidCamera.id;
|
}
|
||||||
}
|
|
||||||
String[] devices = core.getVideoDevicesList();
|
|
||||||
String newDevice = devices[camId];
|
|
||||||
|
|
||||||
String currentDevice = core.getVideoDevice();
|
if (camera.contains("Back")) {
|
||||||
if (currentDevice != null && currentDevice.equals(newDevice)) {
|
Log.i("[QR Code] Found back facing camera: " + camera);
|
||||||
return;
|
core.setVideoDevice(camera);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
core.setVideoDevice(newDevice);
|
|
||||||
|
Log.i("[QR Code] Using first camera available: " + firstDevice);
|
||||||
|
core.setVideoDevice(firstDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,6 +329,14 @@ public class LinphonePreferences {
|
||||||
getConfig().setBool("app", "front_camera_default", frontcam);
|
getConfig().setBool("app", "front_camera_default", frontcam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCameraDevice() {
|
||||||
|
return getLc().getVideoDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCameraDevice(String device) {
|
||||||
|
getLc().setVideoDevice(device);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isVideoEnabled() {
|
public boolean isVideoEnabled() {
|
||||||
if (getLc() == null) return false;
|
if (getLc() == null) return false;
|
||||||
return getLc().videoSupported() && getLc().videoEnabled();
|
return getLc().videoSupported() && getLc().videoEnabled();
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class VideoSettingsFragment extends SettingsFragment {
|
||||||
private TextSetting mBandwidth;
|
private TextSetting mBandwidth;
|
||||||
private LinearLayout mVideoCodecs;
|
private LinearLayout mVideoCodecs;
|
||||||
private TextView mVideoCodecsHeader;
|
private TextView mVideoCodecsHeader;
|
||||||
|
private ListSetting mCameraDevices;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,6 +83,9 @@ public class VideoSettingsFragment extends SettingsFragment {
|
||||||
|
|
||||||
mAutoAccept = mRootView.findViewById(R.id.pref_video_automatically_accept_video);
|
mAutoAccept = mRootView.findViewById(R.id.pref_video_automatically_accept_video);
|
||||||
|
|
||||||
|
mCameraDevices = mRootView.findViewById(R.id.pref_video_camera_device);
|
||||||
|
initCameraDevicesList();
|
||||||
|
|
||||||
mOverlay = mRootView.findViewById(R.id.pref_overlay);
|
mOverlay = mRootView.findViewById(R.id.pref_overlay);
|
||||||
|
|
||||||
mPreset = mRootView.findViewById(R.id.pref_video_preset);
|
mPreset = mRootView.findViewById(R.id.pref_video_preset);
|
||||||
|
@ -148,6 +152,14 @@ public class VideoSettingsFragment extends SettingsFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mCameraDevices.setListener(
|
||||||
|
new SettingListenerBase() {
|
||||||
|
@Override
|
||||||
|
public void onListValueChanged(int position, String newLabel, String newValue) {
|
||||||
|
mPrefs.setCameraDevice(newValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mOverlay.setListener(
|
mOverlay.setListener(
|
||||||
new SettingListenerBase() {
|
new SettingListenerBase() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -213,6 +225,8 @@ public class VideoSettingsFragment extends SettingsFragment {
|
||||||
|
|
||||||
mAutoAccept.setChecked(mPrefs.shouldAutomaticallyAcceptVideoRequests());
|
mAutoAccept.setChecked(mPrefs.shouldAutomaticallyAcceptVideoRequests());
|
||||||
|
|
||||||
|
mCameraDevices.setValue(mPrefs.getCameraDevice());
|
||||||
|
|
||||||
mOverlay.setChecked(mPrefs.isOverlayEnabled());
|
mOverlay.setChecked(mPrefs.isOverlayEnabled());
|
||||||
if (Version.sdkAboveOrEqual(Version.API26_O_80)
|
if (Version.sdkAboveOrEqual(Version.API26_O_80)
|
||||||
&& getResources().getBoolean(R.bool.allow_pip_while_video_call)) {
|
&& getResources().getBoolean(R.bool.allow_pip_while_video_call)) {
|
||||||
|
@ -306,4 +320,19 @@ public class VideoSettingsFragment extends SettingsFragment {
|
||||||
mVideoCodecs.setVisibility(show ? View.VISIBLE : View.GONE);
|
mVideoCodecs.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||||
mVideoCodecsHeader.setVisibility(show ? View.VISIBLE : View.GONE);
|
mVideoCodecsHeader.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initCameraDevicesList() {
|
||||||
|
List<String> entries = new ArrayList<>();
|
||||||
|
List<String> values = new ArrayList<>();
|
||||||
|
|
||||||
|
Core core = LinphoneManager.getCore();
|
||||||
|
if (core != null) {
|
||||||
|
for (String camera : core.getVideoDevicesList()) {
|
||||||
|
entries.add(camera);
|
||||||
|
values.add(camera);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mCameraDevices.setItems(entries, values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ import org.linphone.core.Factory;
|
||||||
import org.linphone.core.LogCollectionState;
|
import org.linphone.core.LogCollectionState;
|
||||||
import org.linphone.core.ProxyConfig;
|
import org.linphone.core.ProxyConfig;
|
||||||
import org.linphone.core.tools.Log;
|
import org.linphone.core.tools.Log;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
|
||||||
import org.linphone.settings.LinphonePreferences;
|
import org.linphone.settings.LinphonePreferences;
|
||||||
|
|
||||||
/** Helpers. */
|
/** Helpers. */
|
||||||
|
@ -227,25 +226,10 @@ public final class LinphoneUtils {
|
||||||
Core core = LinphoneManager.getCore();
|
Core core = LinphoneManager.getCore();
|
||||||
if (core == null) return;
|
if (core == null) return;
|
||||||
|
|
||||||
Log.i("[Utils] Reloading camera");
|
Log.i("[Utils] Reloading camera devices");
|
||||||
core.reloadVideoDevices();
|
core.reloadVideoDevices();
|
||||||
|
|
||||||
boolean useFrontCam = LinphonePreferences.instance().useFrontCam();
|
LinphoneManager.getInstance().resetCameraFromPreferences();
|
||||||
int camId = 0;
|
|
||||||
AndroidCameraConfiguration.AndroidCamera[] cameras =
|
|
||||||
AndroidCameraConfiguration.retrieveCameras();
|
|
||||||
for (AndroidCameraConfiguration.AndroidCamera androidCamera : cameras) {
|
|
||||||
if (androidCamera.frontFacing == useFrontCam) {
|
|
||||||
camId = androidCamera.id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String[] devices = core.getVideoDevicesList();
|
|
||||||
if (camId >= devices.length) {
|
|
||||||
camId = 0;
|
|
||||||
}
|
|
||||||
String newDevice = devices[camId];
|
|
||||||
core.setVideoDevice(newDevice);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDisplayableUsernameFromAddress(String sipAddress) {
|
public static String getDisplayableUsernameFromAddress(String sipAddress) {
|
||||||
|
|
|
@ -37,6 +37,12 @@
|
||||||
linphone:subtitle="@string/pref_video_automatically_accept_video"
|
linphone:subtitle="@string/pref_video_automatically_accept_video"
|
||||||
linphone:title="@string/pref_video_automatically_accept_video_title" />
|
linphone:title="@string/pref_video_automatically_accept_video_title" />
|
||||||
|
|
||||||
|
<org.linphone.settings.widget.ListSetting
|
||||||
|
android:id="@+id/pref_video_camera_device"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
linphone:title="@string/pref_video_camera_device" />
|
||||||
|
|
||||||
<org.linphone.settings.widget.SwitchSetting
|
<org.linphone.settings.widget.SwitchSetting
|
||||||
android:id="@+id/pref_overlay"
|
android:id="@+id/pref_overlay"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -421,6 +421,7 @@
|
||||||
|
|
||||||
<!-- Video settings -->
|
<!-- Video settings -->
|
||||||
<string name="pref_video_title">Video</string>
|
<string name="pref_video_title">Video</string>
|
||||||
|
<string name="pref_video_camera_device">Camera</string>
|
||||||
<string name="pref_overlay">Video overlay</string>
|
<string name="pref_overlay">Video overlay</string>
|
||||||
<string name="pref_overlay_summary">Display call video in overlay when outside the application</string>
|
<string name="pref_overlay_summary">Display call video in overlay when outside the application</string>
|
||||||
<string name="pref_video_use_front_camera_title">Use front camera</string>
|
<string name="pref_video_use_front_camera_title">Use front camera</string>
|
||||||
|
|
Loading…
Reference in a new issue