Improved camera switching algorithm
This commit is contained in:
parent
2fb953e80e
commit
426262c3d7
1 changed files with 17 additions and 23 deletions
|
@ -87,32 +87,26 @@ public class CallManager {
|
||||||
|
|
||||||
public void switchCamera() {
|
public void switchCamera() {
|
||||||
Core core = LinphoneManager.getCore();
|
Core core = LinphoneManager.getCore();
|
||||||
try {
|
if (core == null) return;
|
||||||
String currentDevice = core.getVideoDevice();
|
|
||||||
String[] devices = core.getVideoDevicesList();
|
|
||||||
int index = 0;
|
|
||||||
for (String d : devices) {
|
|
||||||
if (d.equals(currentDevice)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
String newDevice;
|
String currentDevice = core.getVideoDevice();
|
||||||
if (index == 1) newDevice = devices[0];
|
Log.i("[Call Manager] Current camera device is " + currentDevice);
|
||||||
else if (devices.length > 1) newDevice = devices[1];
|
|
||||||
else newDevice = devices[index];
|
String[] devices = core.getVideoDevicesList();
|
||||||
core.setVideoDevice(newDevice);
|
for (String d : devices) {
|
||||||
|
if (!d.equals(currentDevice) && !d.equals("StaticImage: Static picture")) {
|
||||||
Call call = core.getCurrentCall();
|
Log.i("[Call Manager] New camera device will be " + d);
|
||||||
if (call == null) {
|
core.setVideoDevice(d);
|
||||||
Log.w("[Call Manager] Trying to switch camera while not in call");
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
call.update(null);
|
|
||||||
} catch (ArithmeticException ae) {
|
|
||||||
Log.e("[Call Manager] [Video] Cannot switch camera: no camera");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Call call = core.getCurrentCall();
|
||||||
|
if (call == null) {
|
||||||
|
Log.i("[Call Manager] Switching camera while not in call");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
call.update(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean acceptCall(Call call) {
|
public boolean acceptCall(Call call) {
|
||||||
|
|
Loading…
Reference in a new issue