Add video device to config
authorTomas Wenström <tomas.wenstrom@gmail.com>
Mon, 13 Jul 2020 20:31:30 +0000 (22:31 +0200)
committerTomas Wenström <tomas.wenstrom@gmail.com>
Mon, 13 Jul 2020 20:31:30 +0000 (22:31 +0200)
src/kaka/cakelight/Configuration.java
src/kaka/cakelight/mode/VideoMode.java

index a24f411..9975658 100644 (file)
@@ -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;
index 41b599a..a8397dc 100644 (file)
@@ -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) {