优化WebApi ListRtpServer接口实现 (#4436)
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled

This commit is contained in:
ShineSea 2025-09-08 19:00:45 +08:00 committed by GitHub
parent acb12d7806
commit c89caf560a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -318,8 +318,6 @@ template <typename Type>
class ServiceController {
public:
using Pointer = std::shared_ptr<Type>;
std::unordered_map<std::string, Pointer> _map;
mutable std::recursive_mutex _mtx;
void clear() {
decltype(_map) copy;
@ -388,6 +386,10 @@ public:
assert(it.second);
return server;
}
private:
std::unordered_map<std::string, Pointer> _map;
mutable std::recursive_mutex _mtx;
};
// 拉流代理器列表 [AUTO-TRANSLATED:6dcfb11f]
@ -1560,20 +1562,18 @@ void installWebApi() {
api_regist("/index/api/listRtpServer",[](API_ARGS_MAP){
CHECK_SECRET();
std::lock_guard<std::recursive_mutex> lck(s_rtp_server._mtx);
for (auto &pr : s_rtp_server._map) {
auto vec = split(pr.first, "/");
s_rtp_server.for_each([&val](const std::string &key, const RtpServer::Ptr &rtps) {
auto vec = split(key, "/");
Value obj;
obj["vhost"] = vec[0];
obj["app"] = vec[1];
obj["stream_id"] = vec[2];
auto& rtps = pr.second;
obj["port"] = rtps->getPort();
obj["ssrc"] = rtps->getSSRC();
obj["tcp_mode"] = rtps->getTcpMode();
obj["only_track"] = rtps->getOnlyTrack();
val["data"].append(obj);
}
});
});
static auto start_send_rtp = [] (bool passive, API_ARGS_MAP_ASYNC) {