temp
This commit is contained in:
parent
eac59f687e
commit
8c6c0802aa
18
src/main.cpp
18
src/main.cpp
@ -10,7 +10,7 @@
|
|||||||
#include <chrono>
|
#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 线程
|
constexpr bool ENABLE_MQTT_THREAD = true; // 设置为 false 禁用 MQTT 线程
|
||||||
|
|
||||||
std::atomic<bool> g_running(true);
|
std::atomic<bool> g_running(true);
|
||||||
@ -54,7 +54,7 @@ int main()
|
|||||||
std::atomic<bool> mqtt_thread_exited(false);
|
std::atomic<bool> mqtt_thread_exited(false);
|
||||||
|
|
||||||
// 先在主线程初始化 GStreamer
|
// 先在主线程初始化 GStreamer
|
||||||
RTSPManager::init();
|
RTMPManager::init();
|
||||||
|
|
||||||
std::thread rtsp_thread;
|
std::thread rtsp_thread;
|
||||||
std::thread mqtt_thread;
|
std::thread mqtt_thread;
|
||||||
@ -98,20 +98,6 @@ int main()
|
|||||||
const auto poll_interval = std::chrono::milliseconds(100);
|
const auto poll_interval = std::chrono::milliseconds(100);
|
||||||
auto deadline = std::chrono::steady_clock::now() + max_wait;
|
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 线程等待的截止时间
|
// 重置 MQTT 线程等待的截止时间
|
||||||
deadline = std::chrono::steady_clock::now() + max_wait;
|
deadline = std::chrono::steady_clock::now() + max_wait;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user