yituo_video/include/rtsp_manager.hpp
2025-09-09 09:57:24 +08:00

32 lines
860 B
C++

// rtsp_manager.hpp
#pragma once
#include <gst/gst.h>
#include <gst/rtsp-server/rtsp-server.h>
#include "app_config.hpp"
// RTSP 管理器,负责启动/关闭 RTSP 服务器
class RTSPManager
{
public:
static void init();
static void start(const std::vector<Camera> &cameras);
static void stop();
// === 新增方法:按需挂载/卸载摄像头 ===
static void mount_camera(const Camera &cam);
static void unmount_camera(const Camera &cam);
// === 新增方法:查询播放状态 ===
static bool is_streaming(const std::string &cam_name);
private:
static GMainLoop *loop;
static GstRTSPServer *server;
// === 新增:维护每个摄像头的播放状态 ===
static std::unordered_map<std::string, bool> streaming_status;
static GstRTSPMediaFactory *create_media_factory(const Camera &cam);
};