35 lines
911 B
C++
35 lines
911 B
C++
// rtsp_manager.hpp
|
|
#pragma once
|
|
|
|
#include <gst/gst.h>
|
|
#include <gst/rtsp-server/rtsp-server.h>
|
|
#include "app_config.hpp"
|
|
#include <mutex>
|
|
|
|
// 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 GMainContext *main_context; // 新增:保存 loop 的 context
|
|
static GstRTSPServer *server;
|
|
|
|
// 播放状态表
|
|
static std::unordered_map<std::string, bool> streaming_status;
|
|
|
|
// 创建 MediaFactory
|
|
static GstRTSPMediaFactory *create_media_factory(const Camera &cam);
|
|
};
|