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/raw_istream.h> 27 #include "SourceImpl.h" 28 #include "UsbCameraBuffer.h" 29 #include "UsbCameraProperty.h" 41 void SetProperty(
int property,
int value, CS_Status* status)
override;
43 CS_Status* status)
override;
46 void SetBrightness(
int brightness, CS_Status* status)
override;
47 int GetBrightness(CS_Status* status)
const override;
48 void SetWhiteBalanceAuto(CS_Status* status)
override;
49 void SetWhiteBalanceHoldCurrent(CS_Status* status)
override;
50 void SetWhiteBalanceManual(
int value, CS_Status* status)
override;
51 void SetExposureAuto(CS_Status* status)
override;
52 void SetExposureHoldCurrent(CS_Status* status)
override;
53 void SetExposureManual(
int value, CS_Status* status)
override;
55 bool SetVideoMode(
const VideoMode& mode, CS_Status* status)
override;
56 bool SetPixelFormat(VideoMode::PixelFormat pixelFormat,
57 CS_Status* status)
override;
58 bool SetResolution(
int width,
int height, CS_Status* status)
override;
59 bool SetFPS(
int fps, CS_Status* status)
override;
61 void NumSinksChanged()
override;
62 void NumSinksEnabledChanged()
override;
64 std::string GetPath() {
return m_path; }
77 kNumSinksEnabledChanged,
84 : kind(kind_), from(std::this_thread::get_id()) {}
93 std::unique_ptr<PropertyImpl> CreateEmptyProperty(
99 bool CacheProperties(CS_Status* status)
const override;
103 CS_StatusValue SendAndWait(
Message&& msg)
const;
105 void Send(
Message&& msg)
const;
108 void CameraThreadMain();
111 void DeviceDisconnect();
112 void DeviceConnect();
113 bool DeviceStreamOn();
114 bool DeviceStreamOff();
115 void DeviceProcessCommands();
116 void DeviceSetMode();
118 void DeviceCacheMode();
119 void DeviceCacheProperty(std::unique_ptr<UsbCameraProperty> rawProp);
120 void DeviceCacheProperties();
121 void DeviceCacheVideoModes();
124 CS_StatusValue DeviceProcessCommand(std::unique_lock<std::mutex>& lock,
126 CS_StatusValue DeviceCmdSetMode(std::unique_lock<std::mutex>& lock,
128 CS_StatusValue DeviceCmdSetProperty(std::unique_lock<std::mutex>& lock,
141 bool m_modeSetPixelFormat{
false};
142 bool m_modeSetResolution{
false};
143 bool m_modeSetFPS{
false};
145 unsigned m_capabilities = 0;
148 static constexpr
int kNumBuffers = 4;
150 std::array<UsbCameraBuffer, kNumBuffers> m_buffers;
159 std::atomic_int m_fd;
160 std::atomic_int m_command_fd;
163 std::atomic_bool m_active;
164 std::thread m_cameraThread;
167 bool m_hd3000{
false};
174 mutable std::vector<Message> m_commands;
175 mutable std::vector<std::pair<std::thread::id, CS_StatusValue>> m_responses;
176 mutable std::condition_variable m_responseCv;
181 #endif // CSCORE_USBCAMERAIMPL_H_ Definition: SinkImpl.h:19
Definition: SourceImpl.h:30
Definition: UsbCameraProperty.h:23
Definition: UsbCameraImpl.h:33
Definition: UsbCameraImpl.h:67
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:42
Video mode.
Definition: cscore_cpp.h:46