diff options
-rw-r--r-- | libkms++/drmobject.cpp | 17 | ||||
-rw-r--r-- | libkms++/drmobject.h | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/libkms++/drmobject.cpp b/libkms++/drmobject.cpp index 063ae32..ed7a71d 100644 --- a/libkms++/drmobject.cpp +++ b/libkms++/drmobject.cpp @@ -58,7 +58,22 @@ uint64_t DrmObject::get_prop_value(const string& name) const return m_prop_values.at(prop->id()); } - throw invalid_argument(string(name) + ": property not found"); + throw invalid_argument("property not found: " + name); +} + +int DrmObject::set_prop_value(uint32_t id, uint64_t value) +{ + return drmModeObjectSetProperty(card().fd(), this->id(), this->object_type(), id, value); +} + +int DrmObject::set_prop_value(const string &name, uint64_t value) +{ + Property* prop = card().get_prop(name); + + if (prop == nullptr) + throw invalid_argument("property not found: " + name); + + return set_prop_value(prop->id(), value); } void DrmObject::set_id(uint32_t id) diff --git a/libkms++/drmobject.h b/libkms++/drmobject.h index 2ff1b04..516d70e 100644 --- a/libkms++/drmobject.h +++ b/libkms++/drmobject.h @@ -27,6 +27,10 @@ public: const std::map<uint32_t, uint64_t>& get_prop_map() const { return m_prop_values; } + + int set_prop_value(uint32_t id, uint64_t value); + int set_prop_value(const std::string& name, uint64_t value); + protected: DrmObject(Card& card, uint32_t object_type); DrmObject(Card& card, uint32_t id, uint32_t object_type, uint32_t idx = 0); |