mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Add method to get source/sink type.
Also provide convenience method to enumerate all sinks connected to a source.
This commit is contained in:
@@ -398,6 +398,20 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createCvSource
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cscore_CameraServerJNI
|
||||
* Method: getSourceType
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceType
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSourceType(source, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cscore_CameraServerJNI
|
||||
* Method: getSourceName
|
||||
@@ -582,6 +596,21 @@ JNIEXPORT jobjectArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSour
|
||||
return jarr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cscore_CameraServerJNI
|
||||
* Method: enumerateSourceSinks
|
||||
* Signature: (I)[I
|
||||
*/
|
||||
JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceSinks
|
||||
(JNIEnv *env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallVector<CS_Sink, 16> buf;
|
||||
auto arr = cs::EnumerateSourceSinks(source, buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJIntArray(env, arr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cscore_CameraServerJNI
|
||||
* Method: copySource
|
||||
@@ -732,6 +761,20 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createCvSink
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cscore_CameraServerJNI
|
||||
* Method: getSinkType
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkType
|
||||
(JNIEnv *env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSinkType(sink, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_cscore_CameraServerJNI
|
||||
* Method: getSinkName
|
||||
|
||||
@@ -110,6 +110,7 @@ public class CameraServerJNI {
|
||||
//
|
||||
// Source Functions
|
||||
//
|
||||
public static native int getSourceType(int source);
|
||||
public static native String getSourceName(int source);
|
||||
public static native String getSourceDescription(int source);
|
||||
public static native long getSourceLastFrameTime(int source);
|
||||
@@ -122,6 +123,7 @@ public class CameraServerJNI {
|
||||
public static native boolean setSourceResolution(int source, int width, int height);
|
||||
public static native boolean setSourceFPS(int source, int fps);
|
||||
public static native VideoMode[] enumerateSourceVideoModes(int source);
|
||||
public static native int[] enumerateSourceSinks(int source);
|
||||
public static native int copySource(int source);
|
||||
public static native void releaseSource(int source);
|
||||
|
||||
@@ -146,6 +148,7 @@ public class CameraServerJNI {
|
||||
//
|
||||
// Sink Functions
|
||||
//
|
||||
public static native int getSinkType(int sink);
|
||||
public static native String getSinkName(int sink);
|
||||
public static native String getSinkDescription(int sink);
|
||||
public static native void setSinkSource(int sink, int source);
|
||||
|
||||
@@ -11,6 +11,20 @@ package edu.wpi.cscore;
|
||||
/// consist of multiple images (e.g. from a stereo or depth camera); these
|
||||
/// are called channels.
|
||||
public class VideoSink {
|
||||
public enum Type {
|
||||
kUnknown(0), kMJPEG(2), kCv(4);
|
||||
private int value;
|
||||
|
||||
private Type(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
static final Type[] m_typeValues = Type.values();
|
||||
|
||||
protected VideoSink(int handle) {
|
||||
m_handle = handle;
|
||||
}
|
||||
@@ -42,6 +56,11 @@ public class VideoSink {
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
/// Get the type of the sink.
|
||||
public Type getType() {
|
||||
return m_typeValues[CameraServerJNI.getSinkType(m_handle)];
|
||||
}
|
||||
|
||||
/// Get the name of the sink. The name is an arbitrary identifier
|
||||
/// provided when the sink is created, and should be unique.
|
||||
public String getName() {
|
||||
|
||||
@@ -11,6 +11,20 @@ package edu.wpi.cscore;
|
||||
/// consist of multiple images (e.g. from a stereo or depth camera); these
|
||||
/// are called channels.
|
||||
public class VideoSource {
|
||||
public enum Type {
|
||||
kUnknown(0), kUSB(1), kHTTP(2), kCv(4);
|
||||
private int value;
|
||||
|
||||
private Type(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
static final Type[] m_typeValues = Type.values();
|
||||
|
||||
protected VideoSource(int handle) {
|
||||
m_handle = handle;
|
||||
}
|
||||
@@ -42,6 +56,11 @@ public class VideoSource {
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
/// Get the type of the source.
|
||||
public Type getType() {
|
||||
return m_typeValues[CameraServerJNI.getSourceType(m_handle)];
|
||||
}
|
||||
|
||||
/// Get the name of the source. The name is an arbitrary identifier
|
||||
/// provided when the source is created, and should be unique.
|
||||
public String getName() {
|
||||
@@ -129,6 +148,17 @@ public class VideoSource {
|
||||
return CameraServerJNI.enumerateSourceVideoModes(m_handle);
|
||||
}
|
||||
|
||||
/// Enumerate all sinks connected to this source.
|
||||
/// @return Vector of sinks.
|
||||
public VideoSink[] enumerateSinks() {
|
||||
int[] handles = CameraServerJNI.enumerateSourceSinks(m_handle);
|
||||
VideoSink[] rv = new VideoSink[handles.length];
|
||||
for (int i=0; i<handles.length; i++) {
|
||||
rv[i] = new VideoSink(handles[i]);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/// Enumerate all existing sources.
|
||||
/// @return Vector of sources.
|
||||
public static VideoSource[] enumerateSources() {
|
||||
|
||||
Reference in New Issue
Block a user