10#include <duvc-ctl/detail/com_helpers.h>
26 throw std::invalid_argument(
27 "Device must be valid and opened before creating KsPropertySet. "
28 "Call open_camera(device) first.");
34 throw std::runtime_error(
35 "Failed to obtain device filter. Device may not be properly opened "
36 "or may have been disconnected.");
40 basefilter_ = std::move(
filter);
44 if (!mfksproxy_dll_) {
45 throw std::runtime_error(
"Failed to load mfksproxy.dll.");
55 throw std::runtime_error(
56 "Device does not support KsPropertySet interface. "
57 "This device may not expose vendor-specific properties. "
65 throw std::runtime_error(
66 "QueryInterface succeeded but returned null pointer. "
67 "This indicates a driver or COM issue.");
81detail::com_ptr<IKsPropertySet> KsPropertySet::get_property_set()
const {
85 detail::com_ptr<IKsPropertySet> props;
86 HRESULT hr = basefilter_->QueryInterface(IID_PPV_ARGS(props.put()));
100 if (mfksproxy_dll_ !=
nullptr) {
102 mfksproxy_dll_ =
nullptr;
107 : device_(std::move(
other.device_)),
108 basefilter_(std::move(
other.basefilter_)),
109 mfksproxy_dll_(
other.mfksproxy_dll_) {
110 other.mfksproxy_dll_ =
nullptr;
114 if (
this != &
other) {
117 if (mfksproxy_dll_ !=
nullptr) {
122 device_ = std::move(
other.device_);
123 basefilter_ = std::move(
other.basefilter_);
124 mfksproxy_dll_ =
other.mfksproxy_dll_;
125 other.mfksproxy_dll_ =
nullptr;
132 return static_cast<bool>(basefilter_);
137 auto props = get_property_set();
140 "Property set interface not available");
157 auto props = get_property_set();
160 "Property set interface not available");
169 "Failed to get property size: " +
175 hr =
props->Get(property_set, property_id,
nullptr, 0, data.data(),
181 "Failed to get property data: " +
187 return Ok(std::move(data));
192 const std::vector<uint8_t> &data) {
193 auto props = get_property_set();
196 "Property set interface not available");
200 const_cast<uint8_t *
>(data.data()),
201 static_cast<ULONG>(data.size()));
221 if (data.size() !=
sizeof(T)) {
223 "Property data size mismatch: expected " +
224 std::to_string(
sizeof(T)) +
" bytes, got " +
225 std::to_string(data.size()));
229 std::memcpy(&value, data.data(),
sizeof(T));
237 std::vector<uint8_t> data(
sizeof(T));
238 std::memcpy(data.data(), &value,
sizeof(T));
244KsPropertySet::get_property_typed<uint32_t>(
const GUID &,
uint32_t);
246KsPropertySet::get_property_typed<int32_t>(
const GUID &,
uint32_t);
251KsPropertySet::set_property_typed<uint32_t>(
const GUID &,
uint32_t,
254KsPropertySet::set_property_typed<int32_t>(
const GUID &,
uint32_t,
257KsPropertySet::set_property_typed<bool>(
const GUID &,
uint32_t,
const bool &);
RAII wrapper for IKsPropertySet interface.
Result< T > get_property_typed(const GUID &property_set, uint32_t property_id)
Get typed property value.
Result< uint32_t > query_support(const GUID &property_set, uint32_t property_id)
Query property support.
Result< void > set_property_typed(const GUID &property_set, uint32_t property_id, const T &value)
Set typed property value.
Result< void > set_property(const GUID &property_set, uint32_t property_id, const std::vector< uint8_t > &data)
Set property data.
KsPropertySet & operator=(const KsPropertySet &)=delete
bool is_valid() const
Check if property set is valid.
Result< std::vector< uint8_t > > get_property(const GUID &property_set, uint32_t property_id)
Get property data.
KsPropertySet(const Device &device)
Create KsPropertySet from device.
~KsPropertySet()
Destructor.
Result type that can contain either a value or an error.
const T & value() const &
Get the value (assumes success)
bool is_ok() const
Check if result contains a value (success)
const Error & error() const
Get the error (assumes error)
Device enumeration and management functions.
HRESULT decoder and diagnostics utilities.
IKsPropertySet wrapper for vendor properties.
com_ptr< IBaseFilter > open_device_filter(const Device &dev)
@ InvalidValue
Property value out of range.
@ PropertyNotSupported
Property not supported by device.
@ SystemError
System/platform error.
std::string decode_hresult(HRESULT hr)
Decode HRESULT to human-readable string.
Result< void > Ok()
Helper to create successful void Result.
Represents a camera device.
bool is_valid() const
Check if device has valid identifying information.