From f46a23d01d6140aa9b3005c3bc09237f2ad65f9b Mon Sep 17 00:00:00 2001 From: cxh Date: Fri, 17 Oct 2025 13:38:55 +0800 Subject: [PATCH] 1 --- src/main.cpp | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 58cc581..1135860 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,14 +1,15 @@ // main.cpp +#include + +#include +#include +#include +#include + #include "app_config.hpp" -#include "rtmp_manager.hpp" #include "logger.hpp" #include "mqtt_client_wrapper.hpp" - -#include -#include -#include -#include -#include +#include "rtmp_manager.hpp" std::atomic g_running(true); @@ -48,24 +49,26 @@ int main() // 初始化 GStreamer RTMPManager::init(); + RTMPManager::start_all_record_streams(); // 启动 MQTT 线程 - std::thread mqtt_thread([] - { - try + std::thread mqtt_thread( + [] { - LOG_INFO("[MAIN] MQTT thread started."); - mqtt_client_thread_func(); // 在回调里执行推流控制 - } - catch (const std::exception &e) - { - LOG_ERROR(std::string("[MAIN] MQTT thread crashed: ") + e.what()); - } - LOG_INFO("[MAIN] MQTT thread exiting..."); }); + try + { + LOG_INFO("[MAIN] MQTT thread started."); + mqtt_client_thread_func(); // 在回调里执行推流控制 + } + catch (const std::exception &e) + { + LOG_ERROR(std::string("[MAIN] MQTT thread crashed: ") + e.what()); + } + LOG_INFO("[MAIN] MQTT thread exiting..."); + }); // 主循环,仅等待退出信号 - while (g_running.load(std::memory_order_relaxed)) - std::this_thread::sleep_for(std::chrono::milliseconds(200)); + while (g_running.load(std::memory_order_relaxed)) std::this_thread::sleep_for(std::chrono::milliseconds(200)); LOG_INFO("[MAIN] Shutdown requested. Cleaning up...");