diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WebcamPixelFormat.java b/src/main/java/com/sparrowwallet/sparrow/control/WebcamPixelFormat.java index 2850d483..fe72cf65 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WebcamPixelFormat.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WebcamPixelFormat.java @@ -3,20 +3,18 @@ package com.sparrowwallet.sparrow.control; import com.sparrowwallet.drongo.OsType; public enum WebcamPixelFormat { - //Only V4L2 formats defined in linux/videodev2.h are required here - PIX_FMT_RGB24("RGB3", true, true), - PIX_FMT_YUYV("YUYV", true, true), - PIX_FMT_MJPG("MJPG", true, false), - PIX_FMT_NV12("NV12", false, false); + //Only V4L2 formats defined in linux/videodev2.h are required here, declared in order of priority for supported formats + PIX_FMT_RGB24("RGB3", true), + PIX_FMT_YUYV("YUYV", true), + PIX_FMT_MJPG("MJPG", true), + PIX_FMT_NV12("NV12", false); private final String name; private final boolean supported; - private final boolean preferred; - WebcamPixelFormat(String name, boolean supported, boolean preferred) { + WebcamPixelFormat(String name, boolean supported) { this.name = name; this.supported = supported; - this.preferred = preferred; } public String getName() { @@ -27,10 +25,6 @@ public enum WebcamPixelFormat { return supported; } - public boolean isPreferred() { - return preferred; - } - public String toString() { return name; } @@ -69,13 +63,11 @@ public enum WebcamPixelFormat { public static int getPriority(WebcamPixelFormat pixelFormat) { if(pixelFormat == null) { - return 2; - } else if(pixelFormat.isPreferred()) { - return 0; + return values().length; } else if(pixelFormat.isSupported()) { - return 1; + return pixelFormat.ordinal(); } else { - return 3; + return values().length + 1; } } } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WebcamService.java b/src/main/java/com/sparrowwallet/sparrow/control/WebcamService.java index 8350daf7..e7f97973 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/WebcamService.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/WebcamService.java @@ -137,7 +137,7 @@ public class WebcamService extends ScheduledService { List deviceFormats = new ArrayList<>(device.getFormats()); - //On *nix prioritise supported camera pixel formats, preferring RGB3 and YUYV over MJPG + //On *nix prioritise supported camera pixel formats, preferring RGB3, then YUYV, then MJPG //On macOS and Windows, camera pixel format is largely abstracted away if(OsType.getCurrent() == OsType.UNIX) { deviceFormats.sort((f1, f2) -> {