mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
For property events, provide property name rather than source name.
This is much more useful.
This commit is contained in:
@@ -164,7 +164,7 @@ struct CS_Event {
|
||||
CS_Source source;
|
||||
CS_Sink sink;
|
||||
|
||||
// Source/sink name
|
||||
// Source/sink/property name
|
||||
const char *name;
|
||||
|
||||
// Fields for CS_SOURCE_VIDEOMODE_CHANGED event
|
||||
|
||||
@@ -119,7 +119,7 @@ struct RawEvent {
|
||||
CS_Source sourceHandle = CS_INVALID_HANDLE;
|
||||
CS_Sink sinkHandle = CS_INVALID_HANDLE;
|
||||
|
||||
// Source/sink name
|
||||
// Source/sink/property name
|
||||
std::string name;
|
||||
|
||||
// Fields for kSourceVideoModeChanged event
|
||||
|
||||
@@ -79,7 +79,7 @@ public class VideoEvent {
|
||||
public int sourceHandle;
|
||||
public int sinkHandle;
|
||||
|
||||
// Source/sink name
|
||||
// Source/sink/property name
|
||||
public String name;
|
||||
|
||||
// Fields for kSourceVideoModeChanged event
|
||||
|
||||
@@ -188,7 +188,8 @@ int CvSourceImpl::CreateProperty(llvm::StringRef name, CS_PropertyKind kind,
|
||||
value = prop->value;
|
||||
}
|
||||
Notifier::GetInstance().NotifySourceProperty(
|
||||
*this, CS_SOURCE_PROPERTY_CREATED, ndx, kind, value, llvm::StringRef{});
|
||||
*this, CS_SOURCE_PROPERTY_CREATED, name, ndx, kind, value,
|
||||
llvm::StringRef{});
|
||||
return ndx;
|
||||
}
|
||||
|
||||
@@ -215,8 +216,8 @@ void CvSourceImpl::SetEnumPropertyChoices(int property,
|
||||
}
|
||||
prop->enumChoices = choices;
|
||||
Notifier::GetInstance().NotifySourceProperty(
|
||||
*this, CS_SOURCE_PROPERTY_CHOICES_UPDATED, property, CS_PROP_ENUM,
|
||||
prop->value, llvm::StringRef{});
|
||||
*this, CS_SOURCE_PROPERTY_CHOICES_UPDATED, prop->name, property,
|
||||
CS_PROP_ENUM, prop->value, llvm::StringRef{});
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -335,8 +335,8 @@ void HttpCameraImpl::CreateProperty(llvm::StringRef name,
|
||||
value));
|
||||
|
||||
Notifier::GetInstance().NotifySourceProperty(
|
||||
*this, CS_SOURCE_PROPERTY_CREATED, m_propertyData.size() + 1, kind, value,
|
||||
llvm::StringRef{});
|
||||
*this, CS_SOURCE_PROPERTY_CREATED, name, m_propertyData.size() + 1, kind,
|
||||
value, llvm::StringRef{});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -353,11 +353,11 @@ void HttpCameraImpl::CreateEnumProperty(
|
||||
for (const auto& choice : choices) enumChoices.emplace_back(choice);
|
||||
|
||||
Notifier::GetInstance().NotifySourceProperty(
|
||||
*this, CS_SOURCE_PROPERTY_CREATED, m_propertyData.size() + 1,
|
||||
*this, CS_SOURCE_PROPERTY_CREATED, name, m_propertyData.size() + 1,
|
||||
CS_PROP_ENUM, value, llvm::StringRef{});
|
||||
Notifier::GetInstance().NotifySourceProperty(
|
||||
*this, CS_SOURCE_PROPERTY_CHOICES_UPDATED, m_propertyData.size() + 1,
|
||||
CS_PROP_ENUM, value, llvm::StringRef{});
|
||||
*this, CS_SOURCE_PROPERTY_CHOICES_UPDATED, name,
|
||||
m_propertyData.size() + 1, CS_PROP_ENUM, value, llvm::StringRef{});
|
||||
}
|
||||
|
||||
std::unique_ptr<PropertyImpl> HttpCameraImpl::CreateEmptyProperty(
|
||||
|
||||
@@ -177,15 +177,16 @@ void Notifier::NotifySourceVideoMode(const SourceImpl& source,
|
||||
}
|
||||
|
||||
void Notifier::NotifySourceProperty(const SourceImpl& source, CS_EventKind kind,
|
||||
int property, CS_PropertyKind propertyKind,
|
||||
int value, llvm::StringRef valueStr) {
|
||||
llvm::StringRef propertyName, int property,
|
||||
CS_PropertyKind propertyKind, int value,
|
||||
llvm::StringRef valueStr) {
|
||||
auto thr = m_owner.GetThread();
|
||||
if (!thr) return;
|
||||
|
||||
auto handleData = Sources::GetInstance().Find(source);
|
||||
|
||||
thr->m_notifications.emplace(
|
||||
source.GetName(), handleData.first, static_cast<RawEvent::Kind>(kind),
|
||||
propertyName, handleData.first, static_cast<RawEvent::Kind>(kind),
|
||||
Handle{handleData.first, property, Handle::kProperty}, propertyKind,
|
||||
value, valueStr);
|
||||
thr->m_cond.notify_one();
|
||||
|
||||
@@ -46,8 +46,9 @@ class Notifier {
|
||||
void NotifySource(const SourceImpl& source, CS_EventKind kind);
|
||||
void NotifySourceVideoMode(const SourceImpl& source, const VideoMode& mode);
|
||||
void NotifySourceProperty(const SourceImpl& source, CS_EventKind kind,
|
||||
int property, CS_PropertyKind propertyKind,
|
||||
int value, llvm::StringRef valueStr);
|
||||
llvm::StringRef propertyName, int property,
|
||||
CS_PropertyKind propertyKind, int value,
|
||||
llvm::StringRef valueStr);
|
||||
void NotifySink(llvm::StringRef name, CS_Sink sink, CS_EventKind kind);
|
||||
void NotifySink(const SinkImpl& sink, CS_EventKind kind);
|
||||
void NotifySinkSourceChanged(llvm::StringRef name, CS_Sink sink,
|
||||
|
||||
@@ -337,13 +337,14 @@ void SourceImpl::PutError(llvm::StringRef msg, Frame::Time time) {
|
||||
|
||||
void SourceImpl::NotifyPropertyCreated(int propIndex, PropertyImpl& prop) {
|
||||
auto& notifier = Notifier::GetInstance();
|
||||
notifier.NotifySourceProperty(*this, CS_SOURCE_PROPERTY_CREATED, propIndex,
|
||||
prop.propKind, prop.value, prop.valueStr);
|
||||
notifier.NotifySourceProperty(*this, CS_SOURCE_PROPERTY_CREATED, prop.name,
|
||||
propIndex, prop.propKind, prop.value,
|
||||
prop.valueStr);
|
||||
// also notify choices updated event for enum types
|
||||
if (prop.propKind == CS_PROP_ENUM)
|
||||
notifier.NotifySourceProperty(*this, CS_SOURCE_PROPERTY_CHOICES_UPDATED,
|
||||
propIndex, prop.propKind, prop.value,
|
||||
llvm::StringRef{});
|
||||
prop.name, propIndex, prop.propKind,
|
||||
prop.value, llvm::StringRef{});
|
||||
}
|
||||
|
||||
void SourceImpl::UpdatePropertyValue(int property, bool setString, int value,
|
||||
@@ -359,8 +360,8 @@ void SourceImpl::UpdatePropertyValue(int property, bool setString, int value,
|
||||
// Only notify updates after we've notified created
|
||||
if (m_properties_cached)
|
||||
Notifier::GetInstance().NotifySourceProperty(
|
||||
*this, CS_SOURCE_PROPERTY_VALUE_UPDATED, property, prop->propKind,
|
||||
prop->value, prop->valueStr);
|
||||
*this, CS_SOURCE_PROPERTY_VALUE_UPDATED, prop->name, property,
|
||||
prop->propKind, prop->value, prop->valueStr);
|
||||
}
|
||||
|
||||
void SourceImpl::ReleaseImage(std::unique_ptr<Image> image) {
|
||||
|
||||
Reference in New Issue
Block a user