mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Add methods to get property name and enumerate properties.
Also add method to remove property by handle.
This commit is contained in:
@@ -52,6 +52,7 @@ enum CS_PropertyType {
|
||||
|
||||
enum CS_PropertyType CS_GetPropertyType(CS_Property property,
|
||||
CS_Status* status);
|
||||
char* CS_GetPropertyName(CS_Property property, CS_Status* status);
|
||||
CS_Bool CS_GetBooleanProperty(CS_Property property, CS_Status* status);
|
||||
void CS_SetBooleanProperty(CS_Property property, CS_Bool value,
|
||||
CS_Status* status);
|
||||
@@ -93,6 +94,8 @@ char* CS_GetSourceDescription(CS_Source source, CS_Status* status);
|
||||
uint64_t CS_GetSourceLastFrameTime(CS_Source source, CS_Status* status);
|
||||
int CS_GetSourceNumChannels(CS_Source source, CS_Status* status);
|
||||
CS_Bool CS_IsSourceConnected(CS_Source source, CS_Status* status);
|
||||
CS_Property* EnumerateSourceProperties(CS_Source source, int* count,
|
||||
CS_Status* status);
|
||||
CS_Source CS_CopySource(CS_Source source, CS_Status* status);
|
||||
void CS_ReleaseSource(CS_Source source, CS_Status* status);
|
||||
|
||||
@@ -112,10 +115,11 @@ CS_Property CS_CreateSourceProperty(CS_Source source, const char* name,
|
||||
CS_Status* status);
|
||||
CS_Property CS_CreateSourcePropertyCallback(
|
||||
CS_Source source, const char* name, enum CS_PropertyType type, void* data,
|
||||
void (*onChange)(void* data, const char* name, CS_Property property),
|
||||
CS_Status* status);
|
||||
void CS_RemoveSourceProperty(CS_Source source, const char* name,
|
||||
void (*onChange)(void* data, CS_Property property), CS_Status* status);
|
||||
void CS_RemoveSourceProperty(CS_Source source, CS_Property property,
|
||||
CS_Status* status);
|
||||
void CS_RemoveSourcePropertyByName(CS_Source source, const char* name,
|
||||
CS_Status* status);
|
||||
|
||||
//
|
||||
// Sink Creation Functions
|
||||
@@ -205,6 +209,8 @@ void CS_ReleaseEnumeratedSinks(CS_Sink* sinks, int count);
|
||||
void CS_FreeString(char* str);
|
||||
void CS_FreeEnumPropertyChoices(char** choices, int count);
|
||||
|
||||
void CS_FreeEnumeratedProperties(CS_Property* properties, int count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -49,6 +49,9 @@ struct USBCameraInfo {
|
||||
//
|
||||
|
||||
CS_PropertyType GetPropertyType(CS_Property property, CS_Status* status);
|
||||
std::string GetPropertyName(CS_Property property, CS_Status* status);
|
||||
void GetPropertyName(CS_Property property, llvm::SmallVectorImpl<char>& name,
|
||||
CS_Status* status);
|
||||
bool GetBooleanProperty(CS_Property property, CS_Status* status);
|
||||
void SetBooleanProperty(CS_Property property, bool value, CS_Status* status);
|
||||
double GetDoubleProperty(CS_Property property, CS_Status* status);
|
||||
@@ -94,6 +97,9 @@ void GetSourceDescription(CS_Source source, llvm::SmallVectorImpl<char>& desc,
|
||||
uint64_t GetSourceLastFrameTime(CS_Source source, CS_Status* status);
|
||||
int GetSourceNumChannels(CS_Source source, CS_Status* status);
|
||||
bool IsSourceConnected(CS_Source source, CS_Status* status);
|
||||
void EnumerateSourceProperties(CS_Source source,
|
||||
llvm::SmallVectorImpl<CS_Property>& properties,
|
||||
CS_Status* status);
|
||||
CS_Source CopySource(CS_Source source, CS_Status* status);
|
||||
void ReleaseSource(CS_Source source, CS_Status* status);
|
||||
|
||||
@@ -111,8 +117,9 @@ CS_Property CreateSourceProperty(CS_Source source, llvm::StringRef name,
|
||||
CS_PropertyType type, CS_Status* status);
|
||||
CS_Property CreateSourcePropertyCallback(
|
||||
CS_Source source, llvm::StringRef name, CS_PropertyType type,
|
||||
std::function<void(llvm::StringRef name, CS_Property property)> onChange,
|
||||
CS_Status* status);
|
||||
std::function<void(CS_Property property)> onChange, CS_Status* status);
|
||||
void RemoveSourceProperty(CS_Source source, CS_Property property,
|
||||
CS_Status* status);
|
||||
void RemoveSourceProperty(CS_Source source, llvm::StringRef name,
|
||||
CS_Status* status);
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ class VideoProperty {
|
||||
|
||||
VideoProperty() : m_handle(0), m_type(kNone) {}
|
||||
|
||||
std::string GetName() const;
|
||||
|
||||
Type type() const { return m_type; }
|
||||
|
||||
explicit operator bool() const { return m_type != kNone; }
|
||||
@@ -117,6 +119,9 @@ class VideoSource {
|
||||
/// the given name exists)
|
||||
VideoProperty GetProperty(llvm::StringRef name);
|
||||
|
||||
/// Enumerate all properties of this source.
|
||||
std::vector<VideoProperty> EnumerateProperties() const;
|
||||
|
||||
CS_Status GetLastStatus() const { return m_status; }
|
||||
|
||||
/// Enumerate all existing sources.
|
||||
@@ -200,8 +205,11 @@ class CvSource : public VideoSource {
|
||||
/// @return Property
|
||||
VideoProperty CreateProperty(
|
||||
llvm::StringRef name, VideoProperty::Type type,
|
||||
std::function<void(llvm::StringRef name, VideoProperty property)>
|
||||
onChange);
|
||||
std::function<void(VideoProperty property)> onChange);
|
||||
|
||||
/// Remove a property.
|
||||
/// @param property Property
|
||||
void RemoveProperty(VideoProperty property);
|
||||
|
||||
/// Remove a property.
|
||||
/// @param name Property name
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
namespace cs {
|
||||
|
||||
inline std::string VideoProperty::GetName() const {
|
||||
m_status = 0;
|
||||
return GetPropertyName(m_handle, &m_status);
|
||||
}
|
||||
|
||||
inline bool VideoProperty::GetBoolean() const {
|
||||
m_status = 0;
|
||||
return GetBooleanProperty(m_handle, &m_status);
|
||||
@@ -187,17 +192,19 @@ inline VideoProperty CvSource::CreateProperty(llvm::StringRef name,
|
||||
|
||||
inline VideoProperty CvSource::CreateProperty(
|
||||
llvm::StringRef name, VideoProperty::Type type,
|
||||
std::function<void(llvm::StringRef name, VideoProperty property)>
|
||||
onChange) {
|
||||
std::function<void(VideoProperty property)> onChange) {
|
||||
m_status = 0;
|
||||
return VideoProperty{CreateSourcePropertyCallback(
|
||||
m_handle, name, static_cast<CS_PropertyType>(static_cast<int>(type)),
|
||||
[=](llvm::StringRef name, CS_Property property) {
|
||||
onChange(name, VideoProperty{property});
|
||||
},
|
||||
[=](CS_Property property) { onChange(VideoProperty{property}); },
|
||||
&m_status)};
|
||||
}
|
||||
|
||||
inline void CvSource::RemoveProperty(VideoProperty property) {
|
||||
m_status = 0;
|
||||
RemoveSourceProperty(m_handle, property.m_handle, &m_status);
|
||||
}
|
||||
|
||||
inline void CvSource::RemoveProperty(llvm::StringRef name) {
|
||||
m_status = 0;
|
||||
RemoveSourceProperty(m_handle, name, &m_status);
|
||||
|
||||
Reference in New Issue
Block a user