diff --git a/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java b/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java index 4408f52ae0..339694769f 100644 --- a/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java +++ b/cscore/src/main/java/edu/wpi/cscore/CameraServerJNI.java @@ -89,6 +89,8 @@ public class CameraServerJNI { public static native boolean setSourcePixelFormat(int source, int pixelFormat); public static native boolean setSourceResolution(int source, int width, int height); public static native boolean setSourceFPS(int source, int fps); + public static native boolean setSourceConfigJson(int source, String config); + public static native String getSourceConfigJson(int source); public static native VideoMode[] enumerateSourceVideoModes(int source); public static native int[] enumerateSourceSinks(int source); public static native int copySource(int source); diff --git a/cscore/src/main/java/edu/wpi/cscore/VideoSource.java b/cscore/src/main/java/edu/wpi/cscore/VideoSource.java index b7d6bd522c..cac344ced1 100644 --- a/cscore/src/main/java/edu/wpi/cscore/VideoSource.java +++ b/cscore/src/main/java/edu/wpi/cscore/VideoSource.java @@ -270,6 +270,45 @@ public class VideoSource implements AutoCloseable { return CameraServerJNI.setSourceFPS(m_handle, fps); } + /** + * Set video mode and properties from a JSON configuration string. + * + *
The format of the JSON input is: + * + *
+ * {
+ * "pixel format": "MJPEG", "YUYV", etc
+ * "width": video mode width
+ * "height": video mode height
+ * "fps": video mode fps
+ * "brightness": percentage brightness
+ * "white balance": "auto", "hold", or value
+ * "exposure": "auto", "hold", or value
+ * "properties": [
+ * {
+ * "name": property name
+ * "value": property value
+ * }
+ * ]
+ * }
+ *
+ *
+ * @param config configuration
+ * @return True if set successfully
+ */
+ public boolean setConfigJson(String config) {
+ return CameraServerJNI.setSourceConfigJson(m_handle, config);
+ }
+
+ /**
+ * Get a JSON configuration string.
+ *
+ * @return JSON configuration string
+ */
+ public String getConfigJson() {
+ return CameraServerJNI.getSourceConfigJson(m_handle);
+ }
+
/**
* Get the actual FPS.
*
diff --git a/cscore/src/main/native/cpp/MjpegServerImpl.cpp b/cscore/src/main/native/cpp/MjpegServerImpl.cpp
index 40c4a36b04..73d312cdb3 100644
--- a/cscore/src/main/native/cpp/MjpegServerImpl.cpp
+++ b/cscore/src/main/native/cpp/MjpegServerImpl.cpp
@@ -67,7 +67,8 @@ static const char* startRootPage =
"\n"
"\n"
"