mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +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:
@@ -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