给openrtpserver接口添加enable_reuse参数 (#1372)

* 修改rtpopen逻辑

* 给openrtpserver接口添加enable_reuse端口
This commit is contained in:
wangcker
2022-01-14 21:53:01 +08:00
committed by GitHub
parent a3e628449e
commit e8b0993493
3 changed files with 13 additions and 6 deletions

View File

@@ -1025,7 +1025,10 @@ void installWebApi() {
api_regist("/index/api/openRtpServer",[](API_ARGS_MAP){
CHECK_SECRET();
CHECK_ARGS("port", "enable_tcp", "stream_id");
bool enable_reuse=true;
if(!allArgs["enable_reuse"].empty()){
enable_reuse = allArgs["enable_reuse"].as<bool>();
}
auto stream_id = allArgs["stream_id"];
lock_guard<recursive_mutex> lck(s_rtpServerMapMtx);
@@ -1034,8 +1037,12 @@ void installWebApi() {
throw InvalidArgsException("该stream_id已存在");
}
RtpServer::Ptr server = std::make_shared<RtpServer>();
server->start(allArgs["port"], stream_id, allArgs["enable_tcp"].as<bool>());
server->start(allArgs["port"], stream_id, allArgs["enable_tcp"].as<bool>(),"0.0.0.0",enable_reuse);
server->setOnDetach([stream_id]() {
//设置rtp超时移除事件
lock_guard<recursive_mutex> lck(s_rtpServerMapMtx);