From 4c66e3c37a80a4732a0f7494f1ece34127569f58 Mon Sep 17 00:00:00 2001 From: cxh Date: Wed, 15 Oct 2025 13:13:29 +0800 Subject: [PATCH] temp --- include/rtmp_manager.hpp | 2 +- src/rtmp_manager.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/rtmp_manager.hpp b/include/rtmp_manager.hpp index 8a826a0..e9c2fb7 100644 --- a/include/rtmp_manager.hpp +++ b/include/rtmp_manager.hpp @@ -62,7 +62,7 @@ private: static GstElement *create_pipeline(const Camera &cam, StreamType type); static std::string make_stream_key(const std::string &cam_name, StreamType type); static void update_status(const std::string &key, const StreamStatus &status); - static void publish_stream_status(const Camera &cam, StreamType type, const std::string &seqNo, bool ok, const std::string &reason); + static void publish_stream_status(const std::string &cam_name, StreamType type, const std::string &seqNo, bool ok, const std::string &reason); static inline std::string stream_type_suffix(StreamType type) { return (type == StreamType::MAIN) ? "_main" : "_sub"; diff --git a/src/rtmp_manager.cpp b/src/rtmp_manager.cpp index e90309f..92589aa 100644 --- a/src/rtmp_manager.cpp +++ b/src/rtmp_manager.cpp @@ -79,20 +79,22 @@ GstElement *RTMPManager::create_pipeline(const Camera &cam, StreamType type) void RTMPManager::publish_stream_status(const std::string &cam_name, StreamType type, const std::string &seqNo, bool ok, const std::string &reason) { - // 获取摄像头 index + // 找 camera index int cam_index = -1; + Camera *cam_ptr = nullptr; for (size_t i = 0; i < g_app_config.cameras.size(); ++i) { if (g_app_config.cameras[i].name == cam_name) { cam_index = static_cast(i); + cam_ptr = &g_app_config.cameras[i]; break; } } nlohmann::json ch_resp; ch_resp["loc"] = cam_index; - ch_resp["url"] = ok ? get_stream_url(cam_name, type) : ""; + ch_resp["url"] = ok && cam_ptr ? get_stream_url(cam_ptr->name, type) : ""; ch_resp["result"] = ok ? 0 : 1; ch_resp["reason"] = reason;