From acd63a7901e3cf2c9deec8d6c246dde403353b20 Mon Sep 17 00:00:00 2001 From: cxh Date: Wed, 15 Oct 2025 15:46:27 +0800 Subject: [PATCH] temp --- src/rtmp_manager.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/rtmp_manager.cpp b/src/rtmp_manager.cpp index e33ce2c..bc970f6 100644 --- a/src/rtmp_manager.cpp +++ b/src/rtmp_manager.cpp @@ -256,3 +256,34 @@ void RTMPManager::stream_loop(Camera cam, StreamType type, StreamContext *ctx) LOG_INFO("[RTMP] Stream loop ended for " + key); } + +bool RTMPManager::is_streaming(const std::string &cam_name, StreamType type) +{ + std::lock_guard lock(streams_mutex); + auto it = streams.find(make_stream_key(cam_name, type)); + return it != streams.end() && it->second->running.load(); +} + +bool RTMPManager::is_any_streaming() +{ + std::lock_guard lock(streams_mutex); + for (auto &kv : streams) + if (kv.second->running.load()) return true; + return false; +} + +void RTMPManager::stop_all() +{ + std::vector> ctxs; + { + std::lock_guard lock(streams_mutex); + for (auto &kv : streams) kv.second->running.store(false); + for (auto &kv : streams) ctxs.push_back(std::move(kv.second)); + streams.clear(); + } + + for (auto &ctx : ctxs) + if (ctx->thread.joinable()) ctx->thread.join(); + + LOG_INFO("[RTMP] stop_all completed."); +}