mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-16 13:05:59 +08:00
优化WebApi ListRtpServer接口实现 (#4436)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user