2016-11-05 13:13:09 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
|
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2016-11-05 22:11:55 -07:00
|
|
|
package edu.wpi.cscore;
|
2016-11-05 13:13:09 -07:00
|
|
|
|
|
|
|
|
/// Video event
|
|
|
|
|
public class VideoEvent {
|
2016-11-15 23:54:50 -08:00
|
|
|
public enum Kind {
|
2016-11-18 10:44:31 -08:00
|
|
|
kUnknown(0x0000),
|
2016-11-05 13:13:09 -07:00
|
|
|
kSourceCreated(0x0001),
|
|
|
|
|
kSourceDestroyed(0x0002),
|
|
|
|
|
kSourceConnected(0x0004),
|
|
|
|
|
kSourceDisconnected(0x0008),
|
|
|
|
|
kSourceVideoModesUpdated(0x0010),
|
|
|
|
|
kSourceVideoModeChanged(0x0020),
|
2016-11-18 10:24:14 -08:00
|
|
|
kSourcePropertyCreated(0x0040),
|
|
|
|
|
kSourcePropertyValueUpdated(0x0080),
|
|
|
|
|
kSourcePropertyChoicesUpdated(0x0100),
|
|
|
|
|
kSinkSourceChanged(0x0200),
|
|
|
|
|
kSinkCreated(0x0400),
|
|
|
|
|
kSinkDestroyed(0x0800),
|
|
|
|
|
kSinkEnabled(0x1000),
|
2016-11-18 12:38:54 -08:00
|
|
|
kSinkDisabled(0x2000),
|
|
|
|
|
kNetworkInterfacesChanged(0x4000);
|
2016-11-05 13:13:09 -07:00
|
|
|
|
|
|
|
|
private int value;
|
|
|
|
|
|
2016-11-15 23:54:50 -08:00
|
|
|
private Kind(int value) {
|
2016-11-05 13:13:09 -07:00
|
|
|
this.value = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getValue() {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-18 10:44:31 -08:00
|
|
|
|
|
|
|
|
public static Kind getKindFromInt(int kind) {
|
|
|
|
|
switch (kind) {
|
|
|
|
|
case 0x0001: return Kind.kSourceCreated;
|
|
|
|
|
case 0x0002: return Kind.kSourceDestroyed;
|
|
|
|
|
case 0x0004: return Kind.kSourceConnected;
|
|
|
|
|
case 0x0008: return Kind.kSourceDisconnected;
|
|
|
|
|
case 0x0010: return Kind.kSourceVideoModesUpdated;
|
|
|
|
|
case 0x0020: return Kind.kSourceVideoModeChanged;
|
|
|
|
|
case 0x0040: return Kind.kSourcePropertyCreated;
|
|
|
|
|
case 0x0080: return Kind.kSourcePropertyValueUpdated;
|
|
|
|
|
case 0x0100: return Kind.kSourcePropertyChoicesUpdated;
|
|
|
|
|
case 0x0200: return Kind.kSinkSourceChanged;
|
|
|
|
|
case 0x0400: return Kind.kSinkCreated;
|
|
|
|
|
case 0x0800: return Kind.kSinkDestroyed;
|
|
|
|
|
case 0x1000: return Kind.kSinkEnabled;
|
|
|
|
|
case 0x2000: return Kind.kSinkDisabled;
|
2016-11-18 12:38:54 -08:00
|
|
|
case 0x4000: return Kind.kNetworkInterfacesChanged;
|
2016-11-18 10:44:31 -08:00
|
|
|
default: return Kind.kUnknown;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-05 13:13:09 -07:00
|
|
|
|
2016-11-15 23:54:50 -08:00
|
|
|
VideoEvent(int kind, int source, int sink, String name, int pixelFormat,
|
|
|
|
|
int width, int height, int fps, int property, int propertyKind,
|
2016-11-05 13:13:09 -07:00
|
|
|
int value, String valueStr) {
|
2016-11-18 10:44:31 -08:00
|
|
|
this.kind = getKindFromInt(kind);
|
2016-11-05 13:13:09 -07:00
|
|
|
this.sourceHandle = source;
|
|
|
|
|
this.sinkHandle = sink;
|
|
|
|
|
this.name = name;
|
|
|
|
|
this.mode = new VideoMode(pixelFormat, width, height, fps);
|
|
|
|
|
this.propertyHandle = property;
|
2016-11-18 10:44:31 -08:00
|
|
|
this.propertyKind = VideoProperty.getKindFromInt(propertyKind);
|
2016-11-05 13:13:09 -07:00
|
|
|
this.value = value;
|
|
|
|
|
this.valueStr = valueStr;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 23:54:50 -08:00
|
|
|
public Kind kind;
|
2016-11-05 13:13:09 -07:00
|
|
|
|
|
|
|
|
// Valid for kSource* and kSink* respectively
|
2016-11-18 13:20:50 -08:00
|
|
|
public int sourceHandle;
|
|
|
|
|
public int sinkHandle;
|
2016-11-05 13:13:09 -07:00
|
|
|
|
|
|
|
|
// Source/sink name
|
|
|
|
|
public String name;
|
|
|
|
|
|
|
|
|
|
// Fields for kSourceVideoModeChanged event
|
|
|
|
|
public VideoMode mode;
|
|
|
|
|
|
|
|
|
|
// Fields for kSourceProperty* events
|
|
|
|
|
private int propertyHandle;
|
2016-11-15 23:54:50 -08:00
|
|
|
public VideoProperty.Kind propertyKind;
|
2016-11-05 13:13:09 -07:00
|
|
|
public int value;
|
|
|
|
|
public String valueStr;
|
|
|
|
|
|
|
|
|
|
public VideoSource getSource() {
|
|
|
|
|
return new VideoSource(CameraServerJNI.copySource(sourceHandle));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public VideoSink getSink() {
|
|
|
|
|
return new VideoSink(CameraServerJNI.copySink(sinkHandle));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public VideoProperty getProperty() {
|
2016-11-15 23:54:50 -08:00
|
|
|
return new VideoProperty(propertyHandle, propertyKind);
|
2016-11-05 13:13:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|