From: Tomas Wenström Date: Mon, 13 Jul 2020 20:31:30 +0000 (+0200) Subject: Add video device to config X-Git-Url: http://dolda2000.com/gitweb/?p=kaka%2Fcakelight.git;a=commitdiff_plain;h=7434e71cc01dde2cc9bde4856f7ec396aa67d535 Add video device to config --- diff --git a/src/kaka/cakelight/Configuration.java b/src/kaka/cakelight/Configuration.java index a24f411..9975658 100644 --- a/src/kaka/cakelight/Configuration.java +++ b/src/kaka/cakelight/Configuration.java @@ -54,6 +54,8 @@ public class Configuration { public int bpp; public int format; public double saturation; + public String device; + public boolean deviceIsAutomatic; public CropConfiguration crop; public ListConfiguration list; @@ -61,6 +63,8 @@ public class Configuration { width = Integer.parseInt(get(prop, "video.width", "720")); height = Integer.parseInt(get(prop, "video.height", "576")); bpp = Integer.parseInt(get(prop, "video.bpp", "2")); + device = get(prop, "video.device", "auto"); + deviceIsAutomatic = "auto".equals(device); switch (get(prop, "video.format", "").toUpperCase()) { case "YUYV": format = Imgproc.COLOR_YUV2BGR_YUYV; diff --git a/src/kaka/cakelight/mode/VideoMode.java b/src/kaka/cakelight/mode/VideoMode.java index 41b599a..a8397dc 100644 --- a/src/kaka/cakelight/mode/VideoMode.java +++ b/src/kaka/cakelight/mode/VideoMode.java @@ -25,7 +25,12 @@ public class VideoMode extends Mode { @Override public void enter(Configuration config) { this.config = config; - deviceListener.startListening(); + if (config.video.deviceIsAutomatic) { + deviceListener.startListening(); + } else { + File videoDevice = new File(config.video.device); + startGrabberThread(videoDevice); + } } @Override @@ -44,7 +49,9 @@ public class VideoMode extends Mode { @Override public void exit() { grabberThread.interrupt(); - deviceListener.stopListening(); + if (config.video.deviceIsAutomatic) { + deviceListener.stopListening(); + } } private void startGrabberThread(File videoDevice) {