listStreamProxy与listStreamPusherProxy支持key筛选参数
Some checks are pending
Android / build (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
Docker / build (push) Waiting to run
Linux / build (push) Waiting to run
Linux_Python / build (push) Waiting to run
macOS / build (push) Waiting to run
macOS_Python / build (push) Waiting to run
Windows / build (push) Waiting to run
Windows_Python / build (push) Waiting to run

This commit is contained in:
xia-chu 2026-03-18 11:23:22 +08:00
parent 22a8a9a2ec
commit fa7b0639d8
2 changed files with 17 additions and 9 deletions

View File

@ -1247,7 +1247,7 @@ void installWebApi() {
Json::Value item = ToJson(p); Json::Value item = ToJson(p);
item["key"] = key; item["key"] = key;
val["data"].append(item); val["data"].append(item);
}); }, allArgs["key"]);
}); });
api_regist("/index/api/listStreamProxy", [](API_ARGS_MAP) { api_regist("/index/api/listStreamProxy", [](API_ARGS_MAP) {
CHECK_SECRET(); CHECK_SECRET();
@ -1255,7 +1255,7 @@ void installWebApi() {
Json::Value item = ToJson(p); Json::Value item = ToJson(p);
item["key"] = key; item["key"] = key;
val["data"].append(item); val["data"].append(item);
}); }, allArgs["key"]);
}); });
// 动态添加rtsp/rtmp拉流代理 [AUTO-TRANSLATED:2616537c] // 动态添加rtsp/rtmp拉流代理 [AUTO-TRANSLATED:2616537c]
// Dynamically add rtsp/rtmp pull stream proxy // Dynamically add rtsp/rtmp pull stream proxy

View File

@ -295,12 +295,20 @@ public:
return it->second; return it->second;
} }
void for_each(const std::function<void(const std::string&, const Pointer&)>& cb) { void for_each(const std::function<void(const std::string &, const Pointer &)> &cb, const std::string &key = {}) {
std::lock_guard<std::recursive_mutex> lck(_mtx); std::lock_guard<std::recursive_mutex> lck(_mtx);
if (key.empty()) {
auto it = _map.begin(); auto it = _map.begin();
while (it != _map.end()) { while (it != _map.end()) {
cb(it->first, it->second); cb(it->first, it->second);
it++; ++it;
}
} else {
auto it = _map.find(key);
if (it == _map.end()) {
throw std::invalid_argument("key not found: " + key);
}
cb(key, it->second);
} }
} }