catch NPE when detecting camera facing. fixes #3820

This commit is contained in:
Daniel Gultsch 2020-07-09 20:11:09 +02:00
parent 1107529f56
commit bf85a55930
1 changed files with 9 additions and 1 deletions

View File

@ -509,7 +509,7 @@ public class WebRTCWrapper {
final CameraEnumerator enumerator = getCameraEnumerator();
final Set<String> deviceNames = ImmutableSet.copyOf(enumerator.getDeviceNames());
for (final String deviceName : deviceNames) {
if (enumerator.isFrontFacing(deviceName)) {
if (isFrontFacing(enumerator, deviceName)) {
final CapturerChoice capturerChoice = of(enumerator, deviceName, deviceNames);
if (capturerChoice == null) {
return Optional.absent();
@ -525,6 +525,14 @@ public class WebRTCWrapper {
}
}
private static boolean isFrontFacing(final CameraEnumerator cameraEnumerator, final String deviceName) {
try {
return cameraEnumerator.isFrontFacing(deviceName);
} catch (final NullPointerException e) {
return false;
}
}
public PeerConnection.PeerConnectionState getState() {
return requirePeerConnection().connectionState();
}