WPILibC++  unspecified
UsbCameraProperty.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef CSCORE_USBCAMERAPROPERTY_H_
9 #define CSCORE_USBCAMERAPROPERTY_H_
10 
11 #ifdef __linux__
12 #include <linux/videodev2.h>
13 #endif
14 
15 #include <memory>
16 
17 #include <wpi/mutex.h>
18 
19 #include "PropertyImpl.h"
20 
21 namespace cs {
22 
23 // Property data
25  public:
26  UsbCameraProperty() = default;
27  explicit UsbCameraProperty(wpi::StringRef name_) : PropertyImpl{name_} {}
28 
29  // Normalized property constructor
30  UsbCameraProperty(wpi::StringRef name_, int rawIndex_,
31  const UsbCameraProperty& rawProp, int defaultValue_,
32  int value_)
33  : PropertyImpl(name_, rawProp.propKind, 1, defaultValue_, value_),
34  percentage{true},
35  propPair{rawIndex_},
36  id{rawProp.id},
37  type{rawProp.type} {
38  hasMinimum = true;
39  minimum = 0;
40  hasMaximum = true;
41  maximum = 100;
42  }
43 
44 #ifdef __linux__
45 #ifdef VIDIOC_QUERY_EXT_CTRL
46  explicit UsbCameraProperty(const struct v4l2_query_ext_ctrl& ctrl);
47 #endif
48  explicit UsbCameraProperty(const struct v4l2_queryctrl& ctrl);
49 
50  static std::unique_ptr<UsbCameraProperty> DeviceQuery(int fd, __u32* id);
51 
52  bool DeviceGet(std::unique_lock<wpi::mutex>& lock, int fd);
53  bool DeviceSet(std::unique_lock<wpi::mutex>& lock, int fd) const;
54  bool DeviceSet(std::unique_lock<wpi::mutex>& lock, int fd, int newValue,
55  wpi::StringRef newValueStr) const;
56 #endif
57 
58  // If this is a percentage (rather than raw) property
59  bool percentage{false};
60 
61  // If not 0, index of corresponding raw/percentage property
62  int propPair{0};
63 
64  unsigned id{0}; // implementation-level id
65  int type{0}; // implementation type, not CS_PropertyKind!
66 };
67 
68 } // namespace cs
69 
70 #endif // CSCORE_USBCAMERAPROPERTY_H_
Definition: CvSourceImpl.h:19
Definition: PropertyImpl.h:21
Definition: UsbCameraProperty.h:24
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49