File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
webcam-capture/src/main/java/com/github/sarxos/webcam Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 88import java .util .Collections ;
99import java .util .Iterator ;
1010import java .util .List ;
11+ import java .util .Map ;
1112import java .util .concurrent .CopyOnWriteArrayList ;
1213import java .util .concurrent .ExecutorService ;
1314import java .util .concurrent .Executors ;
2021import org .slf4j .LoggerFactory ;
2122
2223import com .github .sarxos .webcam .WebcamDevice .BufferAccess ;
24+ import com .github .sarxos .webcam .WebcamDevice .Configurable ;
2325import com .github .sarxos .webcam .WebcamUpdater .DefaultDelayCalculator ;
2426import com .github .sarxos .webcam .WebcamUpdater .DelayCalculator ;
2527import com .github .sarxos .webcam .ds .buildin .WebcamDefaultDevice ;
@@ -764,6 +766,23 @@ public void getImageBytes(ByteBuffer target) {
764766 }
765767 }
766768
769+ /**
770+ * If the underlying device implements Configurable interface, specified
771+ * parameters are passed to it. May be called before the open method or
772+ * later in dependence of the device implementation.
773+ *
774+ * @param parameters - Map of parameters changing device defaults
775+ * @see Configurable
776+ */
777+ public void setParameters (Map <String , ?> parameters ) {
778+ WebcamDevice device = getDevice ();
779+ if (device instanceof Configurable ) {
780+ ((Configurable ) device ).setParameters (parameters );
781+ } else {
782+ LOG .debug ("Webcam device {} is not configurable" , device );
783+ }
784+ }
785+
767786 /**
768787 * Is webcam ready to be read.
769788 *
Original file line number Diff line number Diff line change 33import java .awt .Dimension ;
44import java .awt .image .BufferedImage ;
55import java .nio .ByteBuffer ;
6+ import java .util .Map ;
67
78
89/**
@@ -56,6 +57,27 @@ public static interface FPSSource {
5657
5758 }
5859
60+ /**
61+ * This interface may be implemented by devices which expect any specific
62+ * parameters.
63+ *
64+ * @author Martin Krok (krok32)
65+ */
66+ public static interface Configurable {
67+
68+ /**
69+ * Sets device parameters. Each device implementation may accept its own
70+ * set of parameters. All accepted keys, value types, possible values
71+ * and defaults should be reasonably documented by the implementor. May
72+ * be called before the open method or later in dependence of the device
73+ * implementation.
74+ *
75+ * @param parameters - Map of parameters changing device defaults
76+ * @see Webcam#setParameters(Map)
77+ */
78+ void setParameters (Map <String , ?> parameters );
79+ }
80+
5981 /**
6082 * Get device name.
6183 *
You can’t perform that action at this time.
0 commit comments