38 lines
705 B
C++
38 lines
705 B
C++
|
|
// main.cpp
|
||
|
|
#include "app_config.hpp"
|
||
|
|
#include "rtsp_manager.hpp"
|
||
|
|
#include "logger.hpp"
|
||
|
|
#include <atomic>
|
||
|
|
#include <csignal>
|
||
|
|
|
||
|
|
std::atomic<bool> g_running(true);
|
||
|
|
|
||
|
|
void signalHandler(int signum)
|
||
|
|
{
|
||
|
|
g_running = false;
|
||
|
|
RTSPManager::stop();
|
||
|
|
}
|
||
|
|
|
||
|
|
int main()
|
||
|
|
{
|
||
|
|
signal(SIGINT, signalHandler);
|
||
|
|
signal(SIGPIPE, SIG_IGN);
|
||
|
|
|
||
|
|
// 初始化日志文件
|
||
|
|
Logger::set_log_to_file("app.log");
|
||
|
|
|
||
|
|
try
|
||
|
|
{
|
||
|
|
g_app_config = AppConfig::load_from_file("config.json");
|
||
|
|
}
|
||
|
|
catch (const std::exception &e)
|
||
|
|
{
|
||
|
|
LOG_ERROR(std::string("Failed to load config: ") + e.what());
|
||
|
|
return -1;
|
||
|
|
}
|
||
|
|
|
||
|
|
RTSPManager::init();
|
||
|
|
RTSPManager::start(g_app_config.cameras);
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
}
|