mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
openRtpServer接口不允许添加重复的stream_id
This commit is contained in:
parent
363673dd00
commit
d6d861c401
@ -762,19 +762,23 @@ void installWebApi() {
|
||||
CHECK_ARGS("port", "enable_tcp", "stream_id");
|
||||
|
||||
auto stream_id = allArgs["stream_id"];
|
||||
|
||||
lock_guard<recursive_mutex> lck(s_rtpServerMapMtx);
|
||||
if(s_rtpServerMap.find(stream_id) != s_rtpServerMap.end()) {
|
||||
//为了防止RtpProcess所有权限混乱的问题,不允许重复添加相同的stream_id
|
||||
throw InvalidArgsException("该stream_id已存在");
|
||||
}
|
||||
|
||||
RtpServer::Ptr server = std::make_shared<RtpServer>();
|
||||
server->start(allArgs["port"], stream_id, allArgs["enable_tcp"].as<bool>());
|
||||
|
||||
server->setOnDetach([stream_id]() {
|
||||
//设置rtp超时移除事件
|
||||
lock_guard<recursive_mutex> lck(s_rtpServerMapMtx);
|
||||
s_rtpServerMap.erase(stream_id);
|
||||
});
|
||||
|
||||
lock_guard<recursive_mutex> lck(s_rtpServerMapMtx);
|
||||
//保存对象,强制覆盖
|
||||
s_rtpServerMap[stream_id] = server;
|
||||
|
||||
//保存对象
|
||||
s_rtpServerMap.emplace(stream_id, server);
|
||||
//回复json
|
||||
val["port"] = server->getPort();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user