temp
This commit is contained in:
parent
5137f45e30
commit
f6a332d120
@ -17,7 +17,7 @@ public:
|
|||||||
static void start_camera(const Camera &cam, StreamType type);
|
static void start_camera(const Camera &cam, StreamType type);
|
||||||
static void stop_camera(const std::string &cam_name, StreamType type);
|
static void stop_camera(const std::string &cam_name, StreamType type);
|
||||||
static void stop_all();
|
static void stop_all();
|
||||||
static bool is_streaming(const std::string &cam_name);
|
static bool is_streaming(const std::string &cam_name, StreamType type);
|
||||||
static bool is_any_streaming();
|
static bool is_any_streaming();
|
||||||
|
|
||||||
// 获取推流 URL,用于应答
|
// 获取推流 URL,用于应答
|
||||||
@ -26,8 +26,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
struct StreamContext
|
struct StreamContext
|
||||||
{
|
{
|
||||||
|
std::atomic<bool> running;
|
||||||
std::thread thread;
|
std::thread thread;
|
||||||
std::atomic<bool> running{false};
|
|
||||||
|
StreamContext() : running(false) {} // 确保 atomic 初始化
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unordered_map<std::string, StreamContext> streams;
|
static std::unordered_map<std::string, StreamContext> streams;
|
||||||
|
|||||||
@ -8,6 +8,8 @@
|
|||||||
std::unordered_map<std::string, RTMPManager::StreamContext> RTMPManager::streams;
|
std::unordered_map<std::string, RTMPManager::StreamContext> RTMPManager::streams;
|
||||||
std::mutex RTMPManager::streams_mutex;
|
std::mutex RTMPManager::streams_mutex;
|
||||||
|
|
||||||
|
LOG_INFO(std::string(debug));
|
||||||
|
|
||||||
static inline std::string stream_type_suffix(StreamType type)
|
static inline std::string stream_type_suffix(StreamType type)
|
||||||
{
|
{
|
||||||
return (type == StreamType::MAIN) ? "_main" : "_sub";
|
return (type == StreamType::MAIN) ? "_main" : "_sub";
|
||||||
@ -180,7 +182,7 @@ void RTMPManager::start_camera(const Camera &cam, StreamType type)
|
|||||||
ctx.running = true;
|
ctx.running = true;
|
||||||
ctx.thread = std::thread([cam, type]()
|
ctx.thread = std::thread([cam, type]()
|
||||||
{ RTMPManager::stream_loop(cam, type); });
|
{ RTMPManager::stream_loop(cam, type); });
|
||||||
streams[key] = std::move(ctx);
|
streams.emplace(key, std::move(ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTMPManager::stop_camera(const std::string &cam_name, StreamType type)
|
void RTMPManager::stop_camera(const std::string &cam_name, StreamType type)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user