WPILibC++  unspecified
UsbCameraProperty.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2017 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 #include <mutex>
17 
18 #include "PropertyImpl.h"
19 
20 namespace cs {
21 
22 // Property data
24  public:
25  UsbCameraProperty() = default;
26  explicit UsbCameraProperty(llvm::StringRef name_) : PropertyImpl{name_} {}
27 
28  // Normalized property constructor
29  UsbCameraProperty(llvm::StringRef name_, int rawIndex_,
30  const UsbCameraProperty& rawProp, int defaultValue_,
31  int value_)
32  : PropertyImpl(name_, rawProp.propKind, 1, defaultValue_, value_),
33  percentage{true},
34  propPair{rawIndex_},
35  id{rawProp.id},
36  type{rawProp.type} {
37  hasMinimum = true;
38  minimum = 0;
39  hasMaximum = true;
40  maximum = 100;
41  }
42 
43 #ifdef __linux__
44 #ifdef VIDIOC_QUERY_EXT_CTRL
45  explicit UsbCameraProperty(const struct v4l2_query_ext_ctrl& ctrl);
46 #endif
47  explicit UsbCameraProperty(const struct v4l2_queryctrl& ctrl);
48 
49  static std::unique_ptr<UsbCameraProperty> DeviceQuery(int fd, __u32* id);
50 
51  bool DeviceGet(std::unique_lock<std::mutex>& lock, int fd);
52  bool DeviceSet(std::unique_lock<std::mutex>& lock, int fd) const;
53  bool DeviceSet(std::unique_lock<std::mutex>& lock, int fd, int newValue,
54  llvm::StringRef newValueStr) const;
55 #endif
56 
57  // If this is a percentage (rather than raw) property
58  bool percentage{false};
59 
60  // If not 0, index of corresponding raw/percentage property
61  int propPair{0};
62 
63  unsigned id{0}; // implementation-level id
64  int type{0}; // implementation type, not CS_PropertyKind!
65 };
66 
67 } // namespace cs
68 
69 #endif // CSCORE_USBCAMERAPROPERTY_H_
Definition: SinkImpl.h:19
Definition: PropertyImpl.h:21
Definition: UsbCameraProperty.h:23
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:42