8 #ifndef CSCORE_USBCAMERAIMPL_H_ 9 #define CSCORE_USBCAMERAIMPL_H_ 12 #include <linux/videodev2.h> 22 #include <llvm/STLExtras.h> 23 #include <llvm/SmallVector.h> 24 #include <llvm/raw_ostream.h> 25 #include <support/condition_variable.h> 26 #include <support/mutex.h> 27 #include <support/raw_istream.h> 29 #include "SourceImpl.h" 30 #include "UsbCameraBuffer.h" 31 #include "UsbCameraProperty.h" 43 void SetProperty(
int property,
int value, CS_Status* status)
override;
45 CS_Status* status)
override;
48 void SetBrightness(
int brightness, CS_Status* status)
override;
49 int GetBrightness(CS_Status* status)
const override;
50 void SetWhiteBalanceAuto(CS_Status* status)
override;
51 void SetWhiteBalanceHoldCurrent(CS_Status* status)
override;
52 void SetWhiteBalanceManual(
int value, CS_Status* status)
override;
53 void SetExposureAuto(CS_Status* status)
override;
54 void SetExposureHoldCurrent(CS_Status* status)
override;
55 void SetExposureManual(
int value, CS_Status* status)
override;
57 bool SetVideoMode(
const VideoMode& mode, CS_Status* status)
override;
58 bool SetPixelFormat(VideoMode::PixelFormat pixelFormat,
59 CS_Status* status)
override;
60 bool SetResolution(
int width,
int height, CS_Status* status)
override;
61 bool SetFPS(
int fps, CS_Status* status)
override;
63 void NumSinksChanged()
override;
64 void NumSinksEnabledChanged()
override;
66 std::string GetPath() {
return m_path; }
79 kNumSinksEnabledChanged,
86 : kind(kind_), from(std::this_thread::get_id()) {}
95 std::unique_ptr<PropertyImpl> CreateEmptyProperty(
101 bool CacheProperties(CS_Status* status)
const override;
105 CS_StatusValue SendAndWait(
Message&& msg)
const;
107 void Send(
Message&& msg)
const;
110 void CameraThreadMain();
113 void DeviceDisconnect();
114 void DeviceConnect();
115 bool DeviceStreamOn();
116 bool DeviceStreamOff();
117 void DeviceProcessCommands();
118 void DeviceSetMode();
120 void DeviceCacheMode();
121 void DeviceCacheProperty(std::unique_ptr<UsbCameraProperty> rawProp);
122 void DeviceCacheProperties();
123 void DeviceCacheVideoModes();
126 CS_StatusValue DeviceProcessCommand(std::unique_lock<wpi::mutex>& lock,
128 CS_StatusValue DeviceCmdSetMode(std::unique_lock<wpi::mutex>& lock,
130 CS_StatusValue DeviceCmdSetProperty(std::unique_lock<wpi::mutex>& lock,
143 bool m_modeSetPixelFormat{
false};
144 bool m_modeSetResolution{
false};
145 bool m_modeSetFPS{
false};
147 unsigned m_capabilities = 0;
150 static constexpr
int kNumBuffers = 4;
152 std::array<UsbCameraBuffer, kNumBuffers> m_buffers;
161 std::atomic_int m_fd;
162 std::atomic_int m_command_fd;
165 std::atomic_bool m_active;
166 std::thread m_cameraThread;
169 bool m_lifecam_exposure{
false};
176 mutable std::vector<Message> m_commands;
177 mutable std::vector<std::pair<std::thread::id, CS_StatusValue>> m_responses;
178 mutable wpi::condition_variable m_responseCv;
183 #endif // CSCORE_USBCAMERAIMPL_H_ Definition: SinkImpl.h:19
Definition: SourceImpl.h:30
Definition: UsbCameraProperty.h:24
Definition: UsbCameraImpl.h:35
Definition: UsbCameraImpl.h:69
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:42
Video mode.
Definition: cscore_cpp.h:46