mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
cscore: Add properties support to VideoSink (#1228)
Refactor the Property internals into PropertyContainer.
This commit is contained in:
@@ -154,7 +154,10 @@ enum CS_EventKind {
|
||||
CS_SINK_ENABLED = 0x1000,
|
||||
CS_SINK_DISABLED = 0x2000,
|
||||
CS_NETWORK_INTERFACES_CHANGED = 0x4000,
|
||||
CS_TELEMETRY_UPDATED = 0x8000
|
||||
CS_TELEMETRY_UPDATED = 0x8000,
|
||||
CS_SINK_PROPERTY_CREATED = 0x10000,
|
||||
CS_SINK_PROPERTY_VALUE_UPDATED = 0x20000,
|
||||
CS_SINK_PROPERTY_CHOICES_UPDATED = 0x40000
|
||||
};
|
||||
|
||||
//
|
||||
@@ -315,6 +318,10 @@ CS_Sink CS_CreateCvSinkCallback(const char* name, void* data,
|
||||
enum CS_SinkKind CS_GetSinkKind(CS_Sink sink, CS_Status* status);
|
||||
char* CS_GetSinkName(CS_Sink sink, CS_Status* status);
|
||||
char* CS_GetSinkDescription(CS_Sink sink, CS_Status* status);
|
||||
CS_Property CS_GetSinkProperty(CS_Sink sink, const char* name,
|
||||
CS_Status* status);
|
||||
CS_Property* CS_EnumerateSinkProperties(CS_Sink sink, int* count,
|
||||
CS_Status* status);
|
||||
void CS_SetSinkSource(CS_Sink sink, CS_Source source, CS_Status* status);
|
||||
CS_Property CS_GetSinkSourceProperty(CS_Sink sink, const char* name,
|
||||
CS_Status* status);
|
||||
|
||||
@@ -85,7 +85,10 @@ struct RawEvent {
|
||||
kSinkEnabled = CS_SINK_ENABLED,
|
||||
kSinkDisabled = CS_SINK_DISABLED,
|
||||
kNetworkInterfacesChanged = CS_NETWORK_INTERFACES_CHANGED,
|
||||
kTelemetryUpdated = CS_TELEMETRY_UPDATED
|
||||
kTelemetryUpdated = CS_TELEMETRY_UPDATED,
|
||||
kSinkPropertyCreated = CS_SINK_PROPERTY_CREATED,
|
||||
kSinkPropertyValueUpdated = CS_SINK_PROPERTY_VALUE_UPDATED,
|
||||
kSinkPropertyChoicesUpdated = CS_SINK_PROPERTY_CHOICES_UPDATED
|
||||
};
|
||||
|
||||
RawEvent() = default;
|
||||
@@ -265,6 +268,10 @@ wpi::StringRef GetSinkName(CS_Sink sink, wpi::SmallVectorImpl<char>& buf,
|
||||
std::string GetSinkDescription(CS_Sink sink, CS_Status* status);
|
||||
wpi::StringRef GetSinkDescription(CS_Sink sink, wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status);
|
||||
CS_Property GetSinkProperty(CS_Sink sink, wpi::StringRef name,
|
||||
CS_Status* status);
|
||||
wpi::ArrayRef<CS_Property> EnumerateSinkProperties(
|
||||
CS_Sink sink, wpi::SmallVectorImpl<CS_Property>& vec, CS_Status* status);
|
||||
void SetSinkSource(CS_Sink sink, CS_Source source, CS_Status* status);
|
||||
CS_Property GetSinkSourceProperty(CS_Sink sink, wpi::StringRef name,
|
||||
CS_Status* status);
|
||||
|
||||
@@ -502,6 +502,15 @@ class VideoSink {
|
||||
/// Get the sink description. This is sink-kind specific.
|
||||
std::string GetDescription() const;
|
||||
|
||||
/// Get a property of the sink.
|
||||
/// @param name Property name
|
||||
/// @return Property (kind Property::kNone if no property with
|
||||
/// the given name exists)
|
||||
VideoProperty GetProperty(wpi::StringRef name);
|
||||
|
||||
/// Enumerate all properties of this sink.
|
||||
std::vector<VideoProperty> EnumerateProperties() const;
|
||||
|
||||
/// Configure which source should provide frames to this sink. Each sink
|
||||
/// can accept frames from only a single source, but a single source can
|
||||
/// provide frames to multiple clients.
|
||||
|
||||
@@ -459,6 +459,11 @@ inline std::string VideoSink::GetDescription() const {
|
||||
return GetSinkDescription(m_handle, &m_status);
|
||||
}
|
||||
|
||||
inline VideoProperty VideoSink::GetProperty(wpi::StringRef name) {
|
||||
m_status = 0;
|
||||
return VideoProperty{GetSinkProperty(m_handle, name, &m_status)};
|
||||
}
|
||||
|
||||
inline void VideoSink::SetSource(VideoSource source) {
|
||||
m_status = 0;
|
||||
if (!source)
|
||||
|
||||
Reference in New Issue
Block a user