This commit is contained in:
cxh 2025-10-14 17:29:53 +08:00
parent eac59f687e
commit 8c6c0802aa

View File

@ -10,7 +10,7 @@
#include <chrono>
// 可通过这些开关快速启用/禁用线程进行调试
constexpr bool ENABLE_RTSP_THREAD = true; // 设置为 false 禁用 RTSP 线程
constexpr bool ENABLE_RTMP_THREAD = true; // 设置为 false 禁用 RTSP 线程
constexpr bool ENABLE_MQTT_THREAD = true; // 设置为 false 禁用 MQTT 线程
std::atomic<bool> g_running(true);
@ -54,7 +54,7 @@ int main()
std::atomic<bool> mqtt_thread_exited(false);
// 先在主线程初始化 GStreamer
RTSPManager::init();
RTMPManager::init();
std::thread rtsp_thread;
std::thread mqtt_thread;
@ -98,20 +98,6 @@ int main()
const auto poll_interval = std::chrono::milliseconds(100);
auto deadline = std::chrono::steady_clock::now() + max_wait;
if (ENABLE_RTSP_THREAD)
{
RTSPManager::stop();
auto stop_deadline = std::chrono::steady_clock::now() + std::chrono::seconds(10);
while (RTSPManager::is_any_streaming() && std::chrono::steady_clock::now() < stop_deadline)
{
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
if (rtsp_thread.joinable())
rtsp_thread.join();
}
// 重置 MQTT 线程等待的截止时间
deadline = std::chrono::steady_clock::now() + max_wait;