sweeper_video/include/rtsp_manager.hpp
2025-09-09 11:31:11 +08:00

42 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// rtsp_manager.hpp
#pragma once
#include <gst/gst.h>
#include <gst/rtsp-server/rtsp-server.h>
#include "app_config.hpp"
#include <unordered_map>
#include <string>
#include <mutex>
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;
static GstRTSPServer *server;
static std::unordered_map<std::string, bool> streaming_status;
// 工厂创建函数
static GstRTSPMediaFactory *create_media_factory(const Camera &cam);
// --- 把挂载/卸载函数变成私有静态成员 ---
static gboolean mount_camera_in_main(gpointer data);
static gboolean unmount_camera_in_main(gpointer data);
// --- 静态 mutex 和工厂表 ---
static std::unordered_map<std::string, GstRTSPMediaFactory *> mounted_factories;
static std::mutex mounted_factories_mutex;
// 新增bus 回调处理 EOS
static GstBusSyncReply bus_sync_callback(GstBus *bus, GstMessage *msg, gpointer user_data);
};