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() {
|
||||
Core core = LinphoneManager.getCore();
|
||||
try {
|
||||
if (core == null) return;
|
||||
|
||||
String currentDevice = core.getVideoDevice();
|
||||
Log.i("[Call Manager] Current camera device is " + currentDevice);
|
||||
|
||||
String[] devices = core.getVideoDevicesList();
|
||||
int index = 0;
|
||||
for (String d : devices) {
|
||||
if (d.equals(currentDevice)) {
|
||||
if (!d.equals(currentDevice) && !d.equals("StaticImage: Static picture")) {
|
||||
Log.i("[Call Manager] New camera device will be " + d);
|
||||
core.setVideoDevice(d);
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
String newDevice;
|
||||
if (index == 1) newDevice = devices[0];
|
||||
else if (devices.length > 1) newDevice = devices[1];
|
||||
else newDevice = devices[index];
|
||||
core.setVideoDevice(newDevice);
|
||||
|
||||
Call call = core.getCurrentCall();
|
||||
if (call == null) {
|
||||
Log.w("[Call Manager] Trying to switch camera while not in call");
|
||||
Log.i("[Call Manager] Switching camera while not in call");
|
||||
return;
|
||||
}
|
||||
call.update(null);
|
||||
} catch (ArithmeticException ae) {
|
||||
Log.e("[Call Manager] [Video] Cannot switch camera: no camera");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean acceptCall(Call call) {
|
||||
|
|
Loading…
Reference in a new issue