1
This commit is contained in:
parent
e44e914297
commit
f46a23d01d
25
src/main.cpp
25
src/main.cpp
@ -1,14 +1,15 @@
|
|||||||
// main.cpp
|
// main.cpp
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <chrono>
|
||||||
|
#include <csignal>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "rtmp_manager.hpp"
|
|
||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
#include "mqtt_client_wrapper.hpp"
|
#include "mqtt_client_wrapper.hpp"
|
||||||
|
#include "rtmp_manager.hpp"
|
||||||
#include <thread>
|
|
||||||
#include <atomic>
|
|
||||||
#include <csignal>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
std::atomic<bool> g_running(true);
|
std::atomic<bool> g_running(true);
|
||||||
|
|
||||||
@ -48,9 +49,11 @@ int main()
|
|||||||
|
|
||||||
// 初始化 GStreamer
|
// 初始化 GStreamer
|
||||||
RTMPManager::init();
|
RTMPManager::init();
|
||||||
|
RTMPManager::start_all_record_streams();
|
||||||
|
|
||||||
// 启动 MQTT 线程
|
// 启动 MQTT 线程
|
||||||
std::thread mqtt_thread([]
|
std::thread mqtt_thread(
|
||||||
|
[]
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -61,11 +64,11 @@ int main()
|
|||||||
{
|
{
|
||||||
LOG_ERROR(std::string("[MAIN] MQTT thread crashed: ") + e.what());
|
LOG_ERROR(std::string("[MAIN] MQTT thread crashed: ") + e.what());
|
||||||
}
|
}
|
||||||
LOG_INFO("[MAIN] MQTT thread exiting..."); });
|
LOG_INFO("[MAIN] MQTT thread exiting...");
|
||||||
|
});
|
||||||
|
|
||||||
// 主循环,仅等待退出信号
|
// 主循环,仅等待退出信号
|
||||||
while (g_running.load(std::memory_order_relaxed))
|
while (g_running.load(std::memory_order_relaxed)) std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
|
||||||
|
|
||||||
LOG_INFO("[MAIN] Shutdown requested. Cleaning up...");
|
LOG_INFO("[MAIN] Shutdown requested. Cleaning up...");
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user