This commit is contained in:
cxh 2025-11-14 15:40:14 +08:00
parent c70d14eadb
commit 2af451d123
5 changed files with 10 additions and 13 deletions

View File

@ -12,9 +12,3 @@
// 启动 MQTT 客户端线程(内部自动重连、订阅等) // 启动 MQTT 客户端线程(内部自动重连、订阅等)
void mqtt_client_thread_func(); void mqtt_client_thread_func();
// 外部可访问的 MQTT 客户端指针
extern std::shared_ptr<MQTTClient> mqtt_client;
// 请求 MQTT 客户端重启
extern std::atomic<bool> mqtt_restart_required;

View File

@ -67,4 +67,6 @@ class RecordManager
std::thread scan_thread_; std::thread scan_thread_;
bool running_ = false; bool running_ = false;
int scan_interval_sec_ = 60; int scan_interval_sec_ = 60;
}; };
extern std::shared_ptr<RecordManager> g_record_manager;

View File

@ -36,7 +36,8 @@ int main()
Logger::init(get_executable_dir_file_path("logs"), 7); Logger::init(get_executable_dir_file_path("logs"), 7);
LOG_INFO("[MAIN] ===== Vehicle Video Service Starting ====="); LOG_INFO("[MAIN] ===== Vehicle Video Service Starting =====");
RecordManager rm("/home/aiec/srs/conf/kun_record.conf"); // 创建全局 RecordManager 实例
g_record_manager = std::make_shared<RecordManager>("/home/aiec/srs/conf/kun_record.conf");
try try
{ {

View File

@ -9,8 +9,10 @@
#include <queue> #include <queue>
#include <thread> #include <thread>
#include "record_manager.hpp"
std::shared_ptr<MQTTClient> mqtt_client; std::shared_ptr<MQTTClient> mqtt_client;
std::atomic<bool> mqtt_restart_required{false};
extern std::atomic<bool> g_running; extern std::atomic<bool> g_running;
std::atomic<bool> g_streaming{false}; std::atomic<bool> g_streaming{false};
std::string g_dispatch_id; std::string g_dispatch_id;
@ -106,8 +108,6 @@ static void handle_video_down_request(const nlohmann::json& req)
// 发布回复 // 发布回复
mqtt_client->publish(g_app_config.mqtt.topics.video_down, resp.dump(-1), 1); mqtt_client->publish(g_app_config.mqtt.topics.video_down, resp.dump(-1), 1);
LOG_INFO("[video_down] response sent");
} }
static void handle_record_query_request(const nlohmann::json& req) {} static void handle_record_query_request(const nlohmann::json& req) {}
@ -202,8 +202,6 @@ void mqtt_client_thread_func()
mqtt_client.reset(); mqtt_client.reset();
} }
mqtt_restart_required = false;
if (!g_running) break; if (!g_running) break;
// 短暂等待再重连 // 短暂等待再重连

View File

@ -7,6 +7,8 @@
#include "logger.hpp" #include "logger.hpp"
std::shared_ptr<RecordManager> g_record_manager = nullptr;
namespace fs = std::filesystem; namespace fs = std::filesystem;
// //