mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-19 16:27: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 {
|
class ServiceController {
|
||||||
public:
|
public:
|
||||||
using Pointer = std::shared_ptr<Type>;
|
using Pointer = std::shared_ptr<Type>;
|
||||||
std::unordered_map<std::string, Pointer> _map;
|
|
||||||
mutable std::recursive_mutex _mtx;
|
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
decltype(_map) copy;
|
decltype(_map) copy;
|
||||||
@ -388,6 +386,10 @@ public:
|
|||||||
assert(it.second);
|
assert(it.second);
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unordered_map<std::string, Pointer> _map;
|
||||||
|
mutable std::recursive_mutex _mtx;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 拉流代理器列表 [AUTO-TRANSLATED:6dcfb11f]
|
// 拉流代理器列表 [AUTO-TRANSLATED:6dcfb11f]
|
||||||
@ -1560,20 +1562,18 @@ void installWebApi() {
|
|||||||
api_regist("/index/api/listRtpServer",[](API_ARGS_MAP){
|
api_regist("/index/api/listRtpServer",[](API_ARGS_MAP){
|
||||||
CHECK_SECRET();
|
CHECK_SECRET();
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> lck(s_rtp_server._mtx);
|
s_rtp_server.for_each([&val](const std::string &key, const RtpServer::Ptr &rtps) {
|
||||||
for (auto &pr : s_rtp_server._map) {
|
auto vec = split(key, "/");
|
||||||
auto vec = split(pr.first, "/");
|
|
||||||
Value obj;
|
Value obj;
|
||||||
obj["vhost"] = vec[0];
|
obj["vhost"] = vec[0];
|
||||||
obj["app"] = vec[1];
|
obj["app"] = vec[1];
|
||||||
obj["stream_id"] = vec[2];
|
obj["stream_id"] = vec[2];
|
||||||
auto& rtps = pr.second;
|
|
||||||
obj["port"] = rtps->getPort();
|
obj["port"] = rtps->getPort();
|
||||||
obj["ssrc"] = rtps->getSSRC();
|
obj["ssrc"] = rtps->getSSRC();
|
||||||
obj["tcp_mode"] = rtps->getTcpMode();
|
obj["tcp_mode"] = rtps->getTcpMode();
|
||||||
obj["only_track"] = rtps->getOnlyTrack();
|
obj["only_track"] = rtps->getOnlyTrack();
|
||||||
val["data"].append(obj);
|
val["data"].append(obj);
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
static auto start_send_rtp = [] (bool passive, API_ARGS_MAP_ASYNC) {
|
static auto start_send_rtp = [] (bool passive, API_ARGS_MAP_ASYNC) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user