From 81cf93a2bfe24f5fb13ef7a59e59da5f3c3f11d7 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Wed, 19 Jan 2022 17:44:58 +0800 Subject: [PATCH] =?UTF-8?q?openRtpServer=E6=8E=A5=E5=8F=A3=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E5=85=B3=E9=97=ADreuse=5Fport=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=EF=BC=8C=E9=98=B2=E6=AD=A2=E7=AB=AF=E5=8F=A3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 6 +----- src/Rtp/RtpServer.cpp | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 5db5bae8..b8434921 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1025,10 +1025,6 @@ 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(); - } auto stream_id = allArgs["stream_id"]; lock_guard lck(s_rtpServerMapMtx); @@ -1038,7 +1034,7 @@ void installWebApi() { } RtpServer::Ptr server = std::make_shared(); - server->start(allArgs["port"], stream_id, allArgs["enable_tcp"].as(), "0.0.0.0", enable_reuse); + server->start(allArgs["port"], stream_id, allArgs["enable_tcp"].as(), "0.0.0.0", false); server->setOnDetach([stream_id]() { //设置rtp超时移除事件 lock_guard lck(s_rtpServerMapMtx); diff --git a/src/Rtp/RtpServer.cpp b/src/Rtp/RtpServer.cpp index 29e2341d..5464c091 100644 --- a/src/Rtp/RtpServer.cpp +++ b/src/Rtp/RtpServer.cpp @@ -84,7 +84,7 @@ private: std::shared_ptr _rtcp_addr; }; -void RtpServer::start(uint16_t local_port, const string &stream_id, bool enable_tcp, const char *local_ip,bool enable_reuse) { +void RtpServer::start(uint16_t local_port, const string &stream_id, bool enable_tcp, const char *local_ip, bool enable_reuse) { //创建udp服务器 Socket::Ptr rtp_socket = Socket::createSocket(nullptr, true); Socket::Ptr rtcp_socket = Socket::createSocket(nullptr, true); @@ -95,10 +95,10 @@ void RtpServer::start(uint16_t local_port, const string &stream_id, bool enable //取偶数端口 rtp_socket = pair.first; rtcp_socket = pair.second; - } else if (!rtp_socket->bindUdpSock(local_port, local_ip,enable_reuse)) { + } else if (!rtp_socket->bindUdpSock(local_port, local_ip, enable_reuse)) { //用户指定端口 throw std::runtime_error(StrPrinter << "创建rtp端口 " << local_ip << ":" << local_port << " 失败:" << get_uv_errmsg(true)); - } else if(!rtcp_socket->bindUdpSock(rtp_socket->get_local_port() + 1, local_ip,enable_reuse)) { + } else if(!rtcp_socket->bindUdpSock(rtp_socket->get_local_port() + 1, local_ip, enable_reuse)) { // rtcp端口 throw std::runtime_error(StrPrinter << "创建rtcp端口 " << local_ip << ":" << local_port << " 失败:" << get_uv_errmsg(true)); }