#pragma once #include #include #include #include #include #include class RtspFrameGrabber { public: explicit RtspFrameGrabber(const std::string &rtsp_url); ~RtspFrameGrabber(); bool start(); void stop(); bool capture_jpeg(const std::string &filename); bool is_ready() const; const std::string &get_rtsp_url() const { return rtsp_url_; } private: void decode_loop(); private: std::string rtsp_url_; std::thread worker_; std::atomic running_{false}; std::atomic ready_{false}; mutable std::mutex frame_mutex_; void *opaque_impl_ = nullptr; }; class RtspManager { public: RtspManager() = default; ~RtspManager(); void configure(const std::unordered_map &side_sources); void shutdown(); std::string capture_side_frame(int source_id); bool is_ready(int source_id) const; private: std::unordered_map> side_grabbers_; mutable std::mutex mgr_mutex_; };