// rtmp_manager.hpp #pragma once #include #include #include #include #include #include #include #include "app_config.hpp" #include "logger.hpp" class RTMPManager { public: struct StreamStatus { bool running{false}; std::string last_error; }; static void init(); static void start_all(); static void stop_all(); static bool is_streaming(const std::string &cam_name); static std::string get_stream_url(const std::string &cam_name); static std::vector> get_all_status(); private: struct StreamContext { std::atomic running{false}; std::thread thread; StreamStatus status; }; static void stream_loop(Camera cam, StreamContext *ctx); static GstElement *create_pipeline(const Camera &cam); static std::string make_key(const std::string &name); static std::unordered_map> streams; static std::mutex streams_mutex; // 参数 static constexpr int RETRY_BASE_DELAY_MS = 3000; };