From 20b60267890358520ec63ed619782564e40be90a Mon Sep 17 00:00:00 2001 From: Tiny Date: Thu, 27 Dec 2018 11:33:00 +0800 Subject: [PATCH] fix(uvc osx): pu API support --- src/mynteye/uvc/macosx/uvc-vvuvckit.cc | 67 +++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/src/mynteye/uvc/macosx/uvc-vvuvckit.cc b/src/mynteye/uvc/macosx/uvc-vvuvckit.cc index 90a227e..06e1aad 100644 --- a/src/mynteye/uvc/macosx/uvc-vvuvckit.cc +++ b/src/mynteye/uvc/macosx/uvc-vvuvckit.cc @@ -313,18 +313,69 @@ MYNTEYE_API std::string get_video_name(const device &device) { MYNTEYE_API bool pu_control_range( const device &device, Option option, int32_t *min, int32_t *max, int32_t *def) { - MYNTEYE_UNUSED(device); - MYNTEYE_UNUSED(option); - MYNTEYE_UNUSED(min); - MYNTEYE_UNUSED(max); + struct device &dev = const_cast (device); + switch (option) { + case Option::GAIN: { + *max = dev.getMaxCameraSetting(GAIN); + *min = dev.getMinCameraSetting(GAIN); + *def = dev.getDefaultCameraSetting(GAIN); + } break; + case Option::BRIGHTNESS: { + *max = dev.getMaxCameraSetting(BRIGHTNESS); + *min = dev.getMinCameraSetting(BRIGHTNESS); + *def = dev.getDefaultCameraSetting(BRIGHTNESS); + } break; + case Option::CONTRAST: { + *max = dev.getMaxCameraSetting(CONTRAST); + *min = dev.getMinCameraSetting(CONTRAST); + *def = dev.getDefaultCameraSetting(CONTRAST); + } break; + default: { + LOG(WARNING) << __func__ + << " failed: the option " + << static_cast(option) << "is invalid!"; + } break; + } return true; } MYNTEYE_API bool pu_control_query( const device &device, Option option, pu_query query, int32_t *value) { - MYNTEYE_UNUSED(device); - MYNTEYE_UNUSED(option); - MYNTEYE_UNUSED(query); - MYNTEYE_UNUSED(value); + struct device &dev = const_cast (device); + if (query == PU_QUERY_SET) { + switch (option) { + case Option::GAIN: + return dev.setCameraSetting(GAIN, *value); + case Option::BRIGHTNESS: + return dev.setCameraSetting(BRIGHTNESS, *value); + case Option::CONTRAST: + return dev.setCameraSetting(CONTRAST, *value); + default: { + LOG(WARNING) << __func__ + << " failed: the option " + << static_cast(option) << "is invalid!"; + } return false; + } + } else if (query == PU_QUERY_GET) { + switch (option) { + case Option::GAIN: + *value = dev.getCameraSetting(GAIN); + case Option::BRIGHTNESS: + *value = dev.getCameraSetting(BRIGHTNESS); + case Option::CONTRAST: + *value = dev.getCameraSetting(CONTRAST); + default: { + LOG(WARNING) << __func__ + << " failed: the option " + << static_cast(option) << "is invalid!"; + } return false; + } + return true; + } else { + LOG(WARNING) << __func__ + << " failed: the query " + << static_cast(query) << "is invalid!"; + return false; + } return true; }