From: Paul Adenot Date: Wed, 4 Nov 2020 13:03:00 +0000 Subject: Bug 1675042 - Put IR camera last in the device selection list, so that they are never the default. r=dminor Differential Revision: https://phabricator.services.mozilla.com/D95764 Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/754900ff2a2b1c32878baf3c76d7c0e8219419ff --- sdk/android/api/org/webrtc/Camera1Enumerator.java | 5 +++++ sdk/android/api/org/webrtc/Camera2Enumerator.java | 12 ++++++++++++ sdk/android/api/org/webrtc/CameraEnumerator.java | 1 + 3 files changed, 18 insertions(+) diff --git a/sdk/android/api/org/webrtc/Camera1Enumerator.java b/sdk/android/api/org/webrtc/Camera1Enumerator.java index fb1a21f323..4a1aacdb05 100644 --- a/sdk/android/api/org/webrtc/Camera1Enumerator.java +++ b/sdk/android/api/org/webrtc/Camera1Enumerator.java @@ -63,6 +63,11 @@ public class Camera1Enumerator implements CameraEnumerator { return info != null && info.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK; } + @Override + public boolean isInfrared(String deviceName) { + return false; + } + @Override public List getSupportedFormats(String deviceName) { return getSupportedFormats(getCameraIndex(deviceName)); diff --git a/sdk/android/api/org/webrtc/Camera2Enumerator.java b/sdk/android/api/org/webrtc/Camera2Enumerator.java index 456d8cd060..44e239ad8e 100644 --- a/sdk/android/api/org/webrtc/Camera2Enumerator.java +++ b/sdk/android/api/org/webrtc/Camera2Enumerator.java @@ -74,6 +74,18 @@ public class Camera2Enumerator implements CameraEnumerator { == CameraMetadata.LENS_FACING_BACK; } + @Override + public boolean isInfrared(String deviceName) { + CameraCharacteristics characteristics = getCameraCharacteristics(deviceName); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + Integer colors = characteristics.get(CameraCharacteristics.SENSOR_INFO_COLOR_FILTER_ARRANGEMENT); + return colors != null && colors.equals(CameraCharacteristics.SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_NIR); + } + + return false; + } + @Nullable @Override public List getSupportedFormats(String deviceName) { diff --git a/sdk/android/api/org/webrtc/CameraEnumerator.java b/sdk/android/api/org/webrtc/CameraEnumerator.java index dc954b62e0..db34d542c8 100644 --- a/sdk/android/api/org/webrtc/CameraEnumerator.java +++ b/sdk/android/api/org/webrtc/CameraEnumerator.java @@ -18,6 +18,7 @@ public interface CameraEnumerator { public String[] getDeviceNames(); public boolean isFrontFacing(String deviceName); public boolean isBackFacing(String deviceName); + public boolean isInfrared(String deviceName); public List getSupportedFormats(String deviceName); public CameraVideoCapturer createCapturer( -- 2.34.1