prefer yuyv to mjpg capture format

This commit is contained in:
Craig Raw 2025-04-03 14:15:19 +02:00
parent 2fa8e5fd70
commit 6f0a30cc25

View file

@ -3,20 +3,22 @@ package com.sparrowwallet.sparrow.control;
import com.sparrowwallet.drongo.OsType; import com.sparrowwallet.drongo.OsType;
public enum WebcamPixelFormat { public enum WebcamPixelFormat {
PIX_FMT_420V("420v", true), PIX_FMT_420V("420v", true, true),
PIX_FMT_YUVS("yuvs", true), PIX_FMT_YUVS("yuvs", true, true),
PIX_FMT_RGB24("RGB3", true), PIX_FMT_RGB24("RGB3", true, true),
PIX_FMT_YUYV("YUYV", true), PIX_FMT_YUYV("YUYV", true, true),
PIX_FMT_MJPG("MJPG", true), PIX_FMT_MJPG("MJPG", true, false),
PIX_FMT_YUY2("YUY2", true), PIX_FMT_YUY2("YUY2", true, true),
PIX_FMT_NV12("NV12", false); PIX_FMT_NV12("NV12", false, false);
private final String name; private final String name;
private final boolean supported; private final boolean supported;
private final boolean preferred;
WebcamPixelFormat(String name, boolean supported) { WebcamPixelFormat(String name, boolean supported, boolean preferred) {
this.name = name; this.name = name;
this.supported = supported; this.supported = supported;
this.preferred = preferred;
} }
public String getName() { public String getName() {
@ -27,6 +29,10 @@ public enum WebcamPixelFormat {
return supported; return supported;
} }
public boolean isPreferred() {
return preferred;
}
public String toString() { public String toString() {
return name; return name;
} }
@ -65,11 +71,13 @@ public enum WebcamPixelFormat {
public static int getPriority(WebcamPixelFormat pixelFormat) { public static int getPriority(WebcamPixelFormat pixelFormat) {
if(pixelFormat == null) { if(pixelFormat == null) {
return 1;
} else if(pixelFormat.isSupported()) {
return 0;
} else {
return 2; return 2;
} else if(pixelFormat.isPreferred()) {
return 0;
} else if(pixelFormat.isSupported()) {
return 1;
} else {
return 3;
} }
} }
} }