修改dockerfile,增加ffmpeg
This commit is contained in:
parent
3683bd94d6
commit
005168b8e1
|
|
@ -52,7 +52,7 @@
|
|||
"354",
|
||||
"350"
|
||||
],
|
||||
"mode": 2,
|
||||
"mode": 1,
|
||||
"model_path": "/app/models/human_detection.rknn",
|
||||
"rknn_thread_num": 3,
|
||||
"time_threshold_sec": 3
|
||||
|
|
@ -93,7 +93,7 @@
|
|||
"354",
|
||||
"350"
|
||||
],
|
||||
"mode": 2,
|
||||
"mode": 1,
|
||||
"model_path": "/app/models/human_detection.rknn",
|
||||
"rknn_thread_num": 3,
|
||||
"time_threshold_sec": 3
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ RUN unzip -q /tmp/librga-1.10.0.zip -d /tmp/ && \
|
|||
# -----------------------------------------------------------------------------
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
ffmpeg \
|
||||
gstreamer1.0-rockchip \
|
||||
libgstreamer1.0-dev \
|
||||
libgstreamer-plugins-base1.0-dev \
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ LightController::LightController(std::string baseUrl, std::string token)
|
|||
: baseUrl(baseUrl), token(token) {
|
||||
// 启动后台工作线程
|
||||
running_ = true;
|
||||
InitializeDevices();
|
||||
worker_thread_ = std::thread(&LightController::WorkerLoop, this);
|
||||
spdlog::info("[LightController] Worker thread started.");
|
||||
}
|
||||
|
|
@ -97,7 +98,11 @@ void LightController::UpdateAutoLight(std::string deviceId, std::string sourceId
|
|||
bool is_on = !votes.empty();
|
||||
|
||||
// 只有状态改变才触发
|
||||
if (was_on != is_on) {
|
||||
if (was_on != is_on || deviceStatus[deviceId]) {
|
||||
if (deviceStatus[deviceId]) {
|
||||
spdlog::info("[AutoLight] ForceControll.");
|
||||
}
|
||||
deviceStatus[deviceId] = false;
|
||||
std::string action = is_on ? "1" : "0";
|
||||
spdlog::info("[AutoLight] Logic Change: Device {} -> {}", deviceId, is_on ? "ON" : "OFF");
|
||||
|
||||
|
|
@ -126,7 +131,11 @@ void LightController::RemoveSession(std::string sourceId) {
|
|||
votes.erase(sourceId);
|
||||
bool is_on = !votes.empty();
|
||||
|
||||
if (was_on && !is_on) {
|
||||
if ((was_on && !is_on) || deviceStatus[deviceId]) {
|
||||
if (deviceStatus[deviceId]) {
|
||||
spdlog::info("[AutoLight] ForceControll.");
|
||||
}
|
||||
deviceStatus[deviceId] = false;
|
||||
spdlog::info("[AutoLight] Source {} disconnect. Turning OFF {}.", sourceId,
|
||||
deviceId);
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ public:
|
|||
void UpdateAutoLight(std::string deviceId, std::string sourceId, bool voteOn);
|
||||
void RemoveSession(std::string sourceId);
|
||||
|
||||
public:
|
||||
std::map<std::string, bool> deviceStatus;
|
||||
|
||||
private:
|
||||
static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp);
|
||||
bool SendHttpCommand(std::string deviceId, std::string switchType);
|
||||
|
|
@ -41,4 +44,14 @@ private:
|
|||
// 待执行的任务表:Key=设备ID, Value=动作("1"或"0")
|
||||
// 使用 map 的好处是:同一个设备的多次指令会自动覆盖,只保留最新的!
|
||||
std::map<std::string, std::string> pending_actions_;
|
||||
|
||||
void InitializeDevices() {
|
||||
// 假设这些是你的设备 ID
|
||||
std::vector<std::string> deviceIds = {"349", "350", "351", "352", "353", "354"};
|
||||
|
||||
// 遍历 ID 并初始化为 false
|
||||
for (const auto& id : deviceIds) {
|
||||
deviceStatus[id] = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -781,6 +781,7 @@ void WebServer::setup_routes() {
|
|||
auto service = m_video_manager.getService(stream_id);
|
||||
if (service) {
|
||||
service->set_analysis_mode(1);
|
||||
|
||||
affected_streams.push_back(stream_id);
|
||||
}
|
||||
}
|
||||
|
|
@ -961,6 +962,7 @@ void WebServer::setup_routes() {
|
|||
* - mode: 1 (普通报警), 2 (快速响应)
|
||||
*/
|
||||
CROW_ROUTE((*this), "/api/video/mode").methods("POST"_method)([this](const crow::request& req) {
|
||||
LightController* ctrl = &m_light_controller;
|
||||
crow::json::rvalue j_body;
|
||||
try {
|
||||
j_body = crow::json::load(req.body);
|
||||
|
|
@ -980,6 +982,12 @@ void WebServer::setup_routes() {
|
|||
if (service) {
|
||||
// 调用内存中的对象修改状态
|
||||
bool result = service->set_analysis_mode(mode);
|
||||
if (mode == 2) {
|
||||
for (auto& [id, status] : ctrl->deviceStatus){
|
||||
status = true;
|
||||
spdlog::info("force controll set:{}", status);
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
spdlog::warn("Failed to set runtime mode for stream {}", stream_id);
|
||||
// 注意:这里即使运行时失败,只要配置能保存,也可以继续往下走,或者直接返回错误
|
||||
|
|
|
|||
Loading…
Reference in New Issue