Package edu.wpi.first.cscore
Class CameraServerJNI
java.lang.Object
edu.wpi.first.cscore.CameraServerJNI
public class CameraServerJNI extends Object
CameraServer JNI.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CameraServerJNI.Helper
Sets whether JNI should be loaded in the static block.static interface
CameraServerJNI.LoggerFunction
Logger functional interface.static class
CameraServerJNI.TelemetryKind
Telemetry kind. -
Method Summary
Modifier and Type Method Description static int
addListener(Consumer<VideoEvent> listener, int eventMask, boolean immediateNotify)
Adds listener.static int
addPolledListener(int poller, int eventMask, boolean immediateNotify)
Add polled listener.static void
cancelPollListener(int poller)
Cancels poll listener.static int
copySink(int sink)
Copies sink.static int
copySource(int source)
Copies source.static int
createHttpCamera(String name, String url, int kind)
Creates an HTTP camera.static int
createHttpCameraMulti(String name, String[] urls, int kind)
Creates an HTTP camera from multiple URLs.static int
createListenerPoller()
Creates listener poller.static int
createMjpegServer(String name, String listenAddress, int port)
Creates an MJPEG server.static int
createRawSink(String name)
Creates a raw sink.static int
createRawSource(String name, int pixelFormat, int width, int height, int fps)
Creates a raw source.static int
createSourceProperty(int source, String name, int kind, int minimum, int maximum, int step, int defaultValue, int value)
Creates a source property.static int
createUsbCameraDev(String name, int dev)
Creates a new USB camera by device.static int
createUsbCameraPath(String name, String path)
Creates a new USB camera by path.static void
destroyListenerPoller(int poller)
Destroys listener poller.static int[]
enumerateSinkProperties(int sink)
Returns list of sink property handles.static int[]
enumerateSinks()
Returns list of sinks.static int[]
enumerateSourceProperties(int source)
Returns list of source property handles.static int[]
enumerateSources()
Returns list of sources.static int[]
enumerateSourceSinks(int source)
Returns list of source sinks.static VideoMode[]
enumerateSourceVideoModes(int source)
Returns list of source's supported video modes.static UsbCameraInfo[]
enumerateUsbCameras()
Returns list of USB cameras.static void
forceLoad()
Force load the library.static int
getCameraBrightness(int source)
Returns camera brightness.static String[]
getEnumPropertyChoices(int property)
Returns enum of possible property value strings.static String
getHostname()
Returns hostname.static int
getHttpCameraKind(int source)
Returns HTTP camera kind.static String[]
getHttpCameraUrls(int source)
Returns HTTP camera URLs.static String
getMjpegServerListenAddress(int sink)
Returns MJPEG server listen address.static int
getMjpegServerPort(int sink)
Returns MJPEG server port.static String[]
getNetworkInterfaces()
Returns list of network interfaces.static int
getProperty(int property)
Returns property value.static int
getPropertyDefault(int property)
Returns property default value.static int
getPropertyKind(int property)
Returns property kind.static int
getPropertyMax(int property)
Returns property maximum.static int
getPropertyMin(int property)
Returns property minimum.static String
getPropertyName(int property)
Returns property name.static int
getPropertyStep(int property)
Returns property step.static String
getSinkConfigJson(int sink)
Returns sink configuration JSON.static String
getSinkDescription(int sink)
Returns sink description.static String
getSinkError(int sink)
Returns sink error message.static int
getSinkKind(int sink)
Returns sink kind.static String
getSinkName(int sink)
Returns sink name.static int
getSinkProperty(int sink, String name)
Returns sink property.static int
getSinkSource(int sink)
Returns sink source.static int
getSinkSourceProperty(int sink, String name)
Returns sink source property.static String
getSourceConfigJson(int source)
Returns source configuration JSON.static String
getSourceDescription(int source)
Returns source description.static int
getSourceKind(int source)
Returns source kind.static long
getSourceLastFrameTime(int source)
Returns source's last frame time.static String
getSourceName(int source)
Returns source name.static int
getSourceProperty(int source, String name)
Returns source property.static VideoMode
getSourceVideoMode(int source)
Returns source video mode.static String
getStringProperty(int property)
Returns property value as a string.static double
getTelemetryAverageValue(int handle, int kind)
Returns telemetry average value.static double
getTelemetryAverageValue(int handle, CameraServerJNI.TelemetryKind kind)
Returns telemetry average value.static double
getTelemetryElapsedTime()
Returns telemetry elapsed time.static long
getTelemetryValue(int handle, int kind)
Returns telemetry value.static long
getTelemetryValue(int handle, CameraServerJNI.TelemetryKind kind)
Returns telemetry value.static UsbCameraInfo
getUsbCameraInfo(int source)
Returns USB camera info.static String
getUsbCameraPath(int source)
Returns USB camera path.static long
grabRawSinkFrame(int sink, RawFrame frame, long nativeObj)
Returns raw sink frame.static long
grabRawSinkFrameTimeout(int sink, RawFrame frame, long nativeObj, double timeout)
Returns raw sink frame timeout.static boolean
isSourceConnected(int source)
Returns true if source is connected.static boolean
isSourceEnabled(int source)
Returns true if source is enabled.static void
notifySourceError(int source, String msg)
Notify source error.static VideoEvent[]
pollListener(int poller)
Polls listener.static VideoEvent[]
pollListenerTimeout(int poller, double timeout)
Polls listener with timeout.static void
putRawSourceFrame(int source, long frame)
Puts raw frame into source.static void
putRawSourceFrameBB(int source, ByteBuffer data, int size, int width, int height, int stride, int pixelFormat)
Puts raw frame into source.static void
putRawSourceFrameData(int source, long data, int size, int width, int height, int stride, int pixelFormat)
Puts raw frame into source.static void
releaseSink(int sink)
Releases sink.static void
releaseSource(int source)
Releases source.static void
removeListener(int handle)
Removes listener.static void
runMainRunLoop()
Runs main run loop.static int
runMainRunLoopTimeout(double timeoutSeconds)
Runs main run loop with timeout.static void
setCameraBrightness(int source, int brightness)
Sets camera brightness.static void
setCameraExposureAuto(int source)
Sets camera exposure to auto.static void
setCameraExposureHoldCurrent(int source)
Sets camera exposure to "hold current".static void
setCameraExposureManual(int source, int value)
Sets camera exposure to the given value.static void
setCameraWhiteBalanceAuto(int source)
Sets camera white balance to auto.static void
setCameraWhiteBalanceHoldCurrent(int source)
Sets camera white balance to "hold current".static void
setCameraWhiteBalanceManual(int source, int value)
Sets camera white balance to the given value.static void
setHttpCameraUrls(int source, String[] urls)
Sets HTTP camera URLs.static void
setLogger(CameraServerJNI.LoggerFunction func, int minLevel)
Sets logger.static void
setProperty(int property, int value)
Sets property value.static boolean
setSinkConfigJson(int sink, String config)
Sets sink configuration JSON.static void
setSinkDescription(int sink, String description)
Sets sink description.static void
setSinkEnabled(int sink, boolean enabled)
Sets sink enable.static void
setSinkSource(int sink, int source)
Sets sink source.static boolean
setSourceConfigJson(int source, String config)
Sets source configuration JSON.static void
setSourceConnected(int source, boolean connected)
Sets whether source is connected.static void
setSourceConnectionStrategy(int source, int strategy)
Sets source connection strategy.static void
setSourceDescription(int source, String description)
Sets source description.static void
setSourceEnumPropertyChoices(int source, int property, String[] choices)
Sets list of possible property values.static boolean
setSourceFPS(int source, int fps)
Sets source FPS.static boolean
setSourcePixelFormat(int source, int pixelFormat)
Sets source pixel format.static boolean
setSourceResolution(int source, int width, int height)
Sets source resolution.static boolean
setSourceVideoMode(int source, int pixelFormat, int width, int height, int fps)
Sets source video mode.static void
setStringProperty(int property, String value)
Sets property value to a string.static void
setTelemetryPeriod(double seconds)
Sets telemetry period.static void
setUsbCameraPath(int source, String path)
Sets USB camera path.static void
stopMainRunLoop()
Stops main run loop.
-
Method Details
-
forceLoad
Force load the library.- Throws:
IOException
- if library load failed
-
getPropertyKind
Returns property kind.- Parameters:
property
- Property handle.- Returns:
- Property kind.
-
getPropertyName
Returns property name.- Parameters:
property
- Property handle.- Returns:
- Property name.
-
getProperty
Returns property value.- Parameters:
property
- Property handle.- Returns:
- Property value.
-
setProperty
Sets property value.- Parameters:
property
- Property handle.value
- Property value.
-
getPropertyMin
Returns property minimum.- Parameters:
property
- Property handle.- Returns:
- Property minimum.
-
getPropertyMax
Returns property maximum.- Parameters:
property
- Property handle.- Returns:
- Property maximum.
-
getPropertyStep
Returns property step.- Parameters:
property
- Property handle.- Returns:
- Property step.
-
getPropertyDefault
Returns property default value.- Parameters:
property
- Property handle.- Returns:
- Property default value.
-
getStringProperty
Returns property value as a string.- Parameters:
property
- Property handle.- Returns:
- Property value as a string.
-
setStringProperty
Sets property value to a string.- Parameters:
property
- Property handle.value
- Property value string.
-
getEnumPropertyChoices
Returns enum of possible property value strings.- Parameters:
property
- Property handle.- Returns:
- Enum of possible property value strings.
-
createUsbCameraDev
Creates a new USB camera by device.- Parameters:
name
- USB camera name.dev
- USB camera device number.- Returns:
- USB camera handle.
-
createUsbCameraPath
Creates a new USB camera by path.- Parameters:
name
- USB camera name.path
- USB camera path.- Returns:
- USB camera handle.
-
createHttpCamera
Creates an HTTP camera.- Parameters:
name
- HTTP camera name.url
- HTTP camera stream URL.kind
- HTTP camera kind.- Returns:
- HTTP camera handle.
-
createHttpCameraMulti
Creates an HTTP camera from multiple URLs.- Parameters:
name
- HTTP camera name.urls
- HTTP camera stream URLs.kind
- HTTP camera kind.- Returns:
- HTTP camera handle.
-
createRawSource
Creates a raw source.- Parameters:
name
- Source name.pixelFormat
- Pixel format.width
- Image width.height
- Image height.fps
- Source frames per second.- Returns:
- Raw source handle.
-
getSourceKind
Returns source kind.- Parameters:
source
- Source handle.- Returns:
- Source kind.
-
getSourceName
Returns source name.- Parameters:
source
- Source handle.- Returns:
- Source name.
-
getSourceDescription
Returns source description.- Parameters:
source
- Source handle.- Returns:
- Source description.
-
getSourceLastFrameTime
Returns source's last frame time.- Parameters:
source
- Source handle.- Returns:
- Source's last frame time.
-
setSourceConnectionStrategy
Sets source connection strategy.- Parameters:
source
- Source handle.strategy
- Connection strategy.
-
isSourceConnected
Returns true if source is connected.- Parameters:
source
- Source handle.- Returns:
- True if source is connected.
-
isSourceEnabled
Returns true if source is enabled.- Parameters:
source
- Source handle.- Returns:
- True if source is enabled.
-
getSourceProperty
Returns source property.- Parameters:
source
- Source handle.name
- Source property name.- Returns:
- Source property.
-
enumerateSourceProperties
Returns list of source property handles.- Parameters:
source
- Source handle.- Returns:
- List of source property handles.
-
getSourceVideoMode
Returns source video mode.- Parameters:
source
- Source handle.- Returns:
- Source video mode.
-
setSourceVideoMode
public static boolean setSourceVideoMode(int source, int pixelFormat, int width, int height, int fps)Sets source video mode.- Parameters:
source
- Source handle.pixelFormat
- Pixel format.width
- Image width.height
- Image height.fps
- Source frames per second.- Returns:
- True if set succeeded.
-
setSourcePixelFormat
Sets source pixel format.- Parameters:
source
- Source handle.pixelFormat
- Source pixel format.- Returns:
- True if set succeeded.
-
setSourceResolution
Sets source resolution.- Parameters:
source
- Source handle.width
- Image width.height
- Image height.- Returns:
- True if set succeeded.
-
setSourceFPS
Sets source FPS.- Parameters:
source
- Source handle.fps
- Source frames per second.- Returns:
- True if set succeeded.
-
setSourceConfigJson
Sets source configuration JSON.- Parameters:
source
- Source handle.config
- Configuration JSON.- Returns:
- True if set succeeded.
-
getSourceConfigJson
Returns source configuration JSON.- Parameters:
source
- Source handle.- Returns:
- Source configuration JSON.
-
enumerateSourceVideoModes
Returns list of source's supported video modes.- Parameters:
source
- Source handle.- Returns:
- List of source's supported video modes.
-
enumerateSourceSinks
Returns list of source sinks.- Parameters:
source
- Source handle.- Returns:
- List of source sinks.
-
copySource
Copies source.- Parameters:
source
- Source handle.- Returns:
- New source handle.
-
releaseSource
Releases source.- Parameters:
source
- Source handle.
-
setCameraBrightness
Sets camera brightness.- Parameters:
source
- Source handle.brightness
- Brightness.
-
getCameraBrightness
Returns camera brightness.- Parameters:
source
- Source handle.- Returns:
- Camera brightness.
-
setCameraWhiteBalanceAuto
Sets camera white balance to auto.- Parameters:
source
- Source handle.
-
setCameraWhiteBalanceHoldCurrent
Sets camera white balance to "hold current".- Parameters:
source
- Source handle.
-
setCameraWhiteBalanceManual
Sets camera white balance to the given value.- Parameters:
source
- Source handle.value
- White balance.
-
setCameraExposureAuto
Sets camera exposure to auto.- Parameters:
source
- Source handle.
-
setCameraExposureHoldCurrent
Sets camera exposure to "hold current".- Parameters:
source
- Source handle.
-
setCameraExposureManual
Sets camera exposure to the given value.- Parameters:
source
- Source handle.value
- Exposure.
-
setUsbCameraPath
Sets USB camera path.- Parameters:
source
- Source handle.path
- USB camera path.
-
getUsbCameraPath
Returns USB camera path.- Parameters:
source
- Source handle.- Returns:
- USB camera path.
-
getUsbCameraInfo
Returns USB camera info.- Parameters:
source
- Source handle.- Returns:
- USB camera info.
-
getHttpCameraKind
Returns HTTP camera kind.- Parameters:
source
- Source handle.- Returns:
- HTTP camera kind.
-
setHttpCameraUrls
Sets HTTP camera URLs.- Parameters:
source
- Source handle.urls
- HTTP camera URLs.
-
getHttpCameraUrls
Returns HTTP camera URLs.- Parameters:
source
- Source handle.- Returns:
- HTTP camera URLs.
-
putRawSourceFrame
Puts raw frame into source.- Parameters:
source
- Source handle.frame
- Frame handle.
-
putRawSourceFrameBB
public static void putRawSourceFrameBB(int source, ByteBuffer data, int size, int width, int height, int stride, int pixelFormat)Puts raw frame into source.- Parameters:
source
- Source handle.data
- Frame byte buffer.size
- Frame size.width
- Frame width.height
- Frame height.stride
- Frame stride.pixelFormat
- Frame pixel format.
-
putRawSourceFrameData
public static void putRawSourceFrameData(int source, long data, int size, int width, int height, int stride, int pixelFormat)Puts raw frame into source.- Parameters:
source
- Source handle.data
- Frame handle.size
- Frame size.width
- Frame width.height
- Frame height.stride
- Frame stride.pixelFormat
- Frame pixel format.
-
notifySourceError
Notify source error.- Parameters:
source
- Source handle.msg
- Error message.
-
setSourceConnected
Sets whether source is connected.- Parameters:
source
- Source handle.connected
- True if source is connected.
-
setSourceDescription
Sets source description.- Parameters:
source
- Source handle.description
- Source description.
-
createSourceProperty
public static int createSourceProperty(int source, String name, int kind, int minimum, int maximum, int step, int defaultValue, int value)Creates a source property.- Parameters:
source
- Source handle.name
- Property name.kind
- Property kind.minimum
- Property minimum.maximum
- Property maximum.step
- Property step.defaultValue
- Property default value.value
- Property value.- Returns:
- Source property handle.
-
setSourceEnumPropertyChoices
Sets list of possible property values.- Parameters:
source
- Source handle.property
- Property handle.choices
- List of possible property values.
-
createMjpegServer
Creates an MJPEG server.- Parameters:
name
- MJPEG server name.listenAddress
- IP address at which server should listen.port
- Port on which server should listen.- Returns:
- MJPEG server handle.
-
createRawSink
Creates a raw sink.- Parameters:
name
- Sink name.- Returns:
- Raw sink handle.
-
getSinkKind
Returns sink kind.- Parameters:
sink
- Sink handle.- Returns:
- Sink kind.
-
getSinkName
Returns sink name.- Parameters:
sink
- Sink handle.- Returns:
- Sink name.
-
getSinkDescription
Returns sink description.- Parameters:
sink
- Sink handle.- Returns:
- Sink description.
-
getSinkProperty
Returns sink property.- Parameters:
sink
- Sink handle.name
- Property name.- Returns:
- Sink property handle.
-
enumerateSinkProperties
Returns list of sink property handles.- Parameters:
sink
- Sink handle.- Returns:
- List of sink property handles.
-
setSinkConfigJson
Sets sink configuration JSON.- Parameters:
sink
- Sink handle.config
- Configuration JSON.- Returns:
- True if set succeeded.
-
getSinkConfigJson
Returns sink configuration JSON.- Parameters:
sink
- Sink handle.- Returns:
- Sink configuration JSON.
-
setSinkSource
Sets sink source.- Parameters:
sink
- Sink handle.source
- Source handle.
-
getSinkSourceProperty
Returns sink source property.- Parameters:
sink
- Sink handle.name
- Property name.- Returns:
- Sink source property handle.
-
getSinkSource
Returns sink source.- Parameters:
sink
- Sink handle.- Returns:
- Sink source handle.
-
copySink
Copies sink.- Parameters:
sink
- Sink handle.- Returns:
- New sink handle.
-
releaseSink
Releases sink.- Parameters:
sink
- Sink handle.
-
getMjpegServerListenAddress
Returns MJPEG server listen address.- Parameters:
sink
- Sink handle.- Returns:
- MJPEG server listen address.
-
getMjpegServerPort
Returns MJPEG server port.- Parameters:
sink
- Sink handle.- Returns:
- MJPEG server port.
-
setSinkDescription
Sets sink description.- Parameters:
sink
- Sink handle.description
- Sink description.
-
grabRawSinkFrame
Returns raw sink frame.- Parameters:
sink
- Sink handle.frame
- Raw frame.nativeObj
- Native object.- Returns:
- Raw sink frame handle.
-
grabRawSinkFrameTimeout
public static long grabRawSinkFrameTimeout(int sink, RawFrame frame, long nativeObj, double timeout)Returns raw sink frame timeout.- Parameters:
sink
- Sink handle.frame
- Raw frame.nativeObj
- Native object.timeout
- Timeout in seconds.- Returns:
- Raw sink frame timeout.
-
getSinkError
Returns sink error message.- Parameters:
sink
- Sink handle.- Returns:
- Sink error message.
-
setSinkEnabled
Sets sink enable.- Parameters:
sink
- Sink handle.enabled
- True if sink should be enabled.
-
addListener
public static int addListener(Consumer<VideoEvent> listener, int eventMask, boolean immediateNotify)Adds listener.- Parameters:
listener
- Video event callback.eventMask
- Event mask.immediateNotify
- True to immediately notify on event.- Returns:
- Listener handle.
-
removeListener
Removes listener.- Parameters:
handle
- Listener handle.
-
createListenerPoller
Creates listener poller.- Returns:
- Listener poller handle.
-
destroyListenerPoller
Destroys listener poller.- Parameters:
poller
- Listener poller handle.
-
addPolledListener
Add polled listener.- Parameters:
poller
- Poller handle.eventMask
- Event mask.immediateNotify
- True to immediately notify on event.- Returns:
- Polled listener handle.
-
pollListener
Polls listener.- Parameters:
poller
- Poller handle.- Returns:
- List of video events.
- Throws:
InterruptedException
- if polling was interrupted.
-
pollListenerTimeout
public static VideoEvent[] pollListenerTimeout(int poller, double timeout) throws InterruptedExceptionPolls listener with timeout.- Parameters:
poller
- Poller handle.timeout
- Timeout in seconds.- Returns:
- List of video events.
- Throws:
InterruptedException
- if polling was interrupted.
-
cancelPollListener
Cancels poll listener.- Parameters:
poller
- Poller handle.
-
setTelemetryPeriod
Sets telemetry period.- Parameters:
seconds
- Telemetry period in seconds.
-
getTelemetryElapsedTime
Returns telemetry elapsed time.- Returns:
- Telemetry elapsed time.
-
getTelemetryValue
Returns telemetry value.- Parameters:
handle
- Telemetry handle.kind
- Telemetry kind.- Returns:
- Telemetry value.
-
getTelemetryValue
Returns telemetry value.- Parameters:
handle
- Telemetry handle.kind
- Telemetry kind.- Returns:
- Telemetry value.
-
getTelemetryAverageValue
Returns telemetry average value.- Parameters:
handle
- Telemetry handle.kind
- Telemetry kind.- Returns:
- Telemetry average value.
-
getTelemetryAverageValue
Returns telemetry average value.- Parameters:
handle
- Telemetry handle.kind
- Telemetry kind.- Returns:
- Telemetry average value.
-
setLogger
Sets logger.- Parameters:
func
- Logger function.minLevel
- Minimum logging level.
-
enumerateUsbCameras
Returns list of USB cameras.- Returns:
- List of USB cameras.
-
enumerateSources
Returns list of sources.- Returns:
- List of sources.
-
enumerateSinks
Returns list of sinks.- Returns:
- List of sinks.
-
getHostname
Returns hostname.- Returns:
- Hostname.
-
getNetworkInterfaces
Returns list of network interfaces.- Returns:
- List of network interfaces.
-
runMainRunLoop
Runs main run loop. -
runMainRunLoopTimeout
Runs main run loop with timeout.- Parameters:
timeoutSeconds
- Timeout in seconds.- Returns:
- 3 on timeout, 2 on signal, 1 on other.
-
stopMainRunLoop
Stops main run loop.
-