6#include <condition_variable>
21#if defined(MAYAFLUX_PLATFORM_LINUX)
22inline constexpr std::string_view CAMERA_FORMAT =
"v4l2";
23#elif defined(MAYAFLUX_PLATFORM_MACOS)
24inline constexpr std::string_view CAMERA_FORMAT =
"avfoundation";
25#elif defined(MAYAFLUX_PLATFORM_WINDOWS)
26inline constexpr std::string_view CAMERA_FORMAT =
"dshow";
44 uint32_t target_width { 1920 };
45 uint32_t target_height { 1080 };
46 double target_fps { 30.0 };
96 [[nodiscard]]
bool is_open()
const;
102 [[nodiscard]] std::shared_ptr<Kakshya::CameraContainer>
create_container()
const;
120 bool pull_frame(
const std::shared_ptr<Kakshya::CameraContainer>& container);
123 [[nodiscard]] uint32_t width()
const;
126 [[nodiscard]] uint32_t height()
const;
129 [[nodiscard]]
double frame_rate()
const;
139 void set_container(
const std::shared_ptr<Kakshya::CameraContainer>& container);
149 void pull_frame_all();
152 [[nodiscard]]
const std::string& last_error()
const;
161 void setup_io_service(uint64_t reader_id);
172 uint64_t m_standalone_reader_id {};
173 bool m_owns_service {};
174 bool m_scaler_ready {};
179 std::atomic<bool> m_decode_stop {
false };
180 std::atomic<bool> m_decode_active {
false };
181 std::atomic<bool> m_frame_requested {
false };
183 void start_decode_thread();
184 void stop_decode_thread();
185 void decode_thread_func();
CameraReader(const CameraReader &)=delete
CameraReader & operator=(const CameraReader &)=delete
std::shared_ptr< Registry::Service::IOService > m_standalone_service
std::thread m_decode_thread
std::vector< uint8_t > m_sws_buf
std::shared_mutex m_ctx_mutex
CameraReader & operator=(CameraReader &&)=delete
std::weak_ptr< Kakshya::CameraContainer > m_container_ref
std::shared_ptr< VideoStreamContext > m_video
std::condition_variable m_decode_cv
std::shared_ptr< FFmpegDemuxContext > m_demux
CameraReader(CameraReader &&)=delete
std::mutex m_decode_mutex
FFmpeg device reader for live camera input with background decode.
auto create_container(Args &&... args) -> std::shared_ptr< ContainerType >
creates a new container of the specified type
std::string device_name
Platform device string.
std::string format_override
Leave empty to use CAMERA_FORMAT for current platform.
Platform-specific FFmpeg input format string for camera devices.