mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-06 10:57:50 +08:00
优化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
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:
parent
acb12d7806
commit
c89caf560a
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user