From 5bcfba1da43b359b6d8bbb5e2c739646a7409157 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 17 Feb 2023 23:02:09 +0800 Subject: [PATCH] =?UTF-8?q?startSendRtpPassive=E6=8E=A5=E5=8F=A3=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=BF=9E=E6=8E=A5=E8=B6=85=E6=97=B6=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=9Aclose=5Fdelay=5Fms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postman/ZLMediaKit.postman_collection.json | 6 ++++++ server/WebApi.cpp | 2 ++ src/Common/MediaSource.h | 4 ++-- src/Rtp/RtpSender.cpp | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/postman/ZLMediaKit.postman_collection.json b/postman/ZLMediaKit.postman_collection.json index 6bf86d54..2bd206cf 100644 --- a/postman/ZLMediaKit.postman_collection.json +++ b/postman/ZLMediaKit.postman_collection.json @@ -1755,6 +1755,12 @@ "value": "", "description": "发送rtp同时接收,一般用于双向语言对讲, 如果不为空,说明开启接收,值为接收流的id", "disabled": true + }, + { + "key": "close_delay_ms", + "value": "5000", + "description": "等待tcp连接超时时间,单位毫秒,默认5000毫秒", + "disabled": true } ] } diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 3f5b36dd..dc50b2ed 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1238,6 +1238,8 @@ void installWebApi() { args.use_ps = allArgs["use_ps"].empty() ? true : allArgs["use_ps"].as(); args.only_audio = allArgs["only_audio"].as(); args.recv_stream_id = allArgs["recv_stream_id"]; + //tcp被动服务器等待链接超时时间 + args.tcp_passive_close_delay_ms = allArgs["close_delay_ms"]; TraceL << "startSendRtpPassive, pt " << int(args.pt) << " ps " << args.use_ps << " audio " << args.only_audio; src->getOwnerPoller()->async([=]() mutable { diff --git a/src/Common/MediaSource.h b/src/Common/MediaSource.h index 90ca24f1..c06a7c83 100644 --- a/src/Common/MediaSource.h +++ b/src/Common/MediaSource.h @@ -112,8 +112,8 @@ public: //udp发送时,是否开启rr rtcp接收超时判断 bool udp_rtcp_timeout = false; - //tcp被动发送服务器延时关闭事件,单位毫秒 - uint32_t tcp_passive_close_delay_ms = 5 * 1000; + //tcp被动发送服务器延时关闭事件,单位毫秒;设置为0时,则使用默认值5000ms + uint32_t tcp_passive_close_delay_ms = 0; //udp 发送时,rr rtcp包接收超时时间,单位毫秒 uint32_t rtcp_timeout_ms = 30 * 1000; //udp 发送时,发送sr rtcp包间隔,单位毫秒 diff --git a/src/Rtp/RtpSender.cpp b/src/Rtp/RtpSender.cpp index b7d32b76..39a0e907 100644 --- a/src/Rtp/RtpSender.cpp +++ b/src/Rtp/RtpSender.cpp @@ -66,7 +66,8 @@ void RtpSender::startSend(const MediaSourceEvent::SendRtpArgs &args, const funct is_wait = false; } // tcp服务器默认开启5秒 - auto delay_task = _poller->doDelayTask(_args.tcp_passive_close_delay_ms, [tcp_listener, cb,is_wait]() mutable { + auto delay = _args.tcp_passive_close_delay_ms ? _args.tcp_passive_close_delay_ms : 5000; + auto delay_task = _poller->doDelayTask(delay, [tcp_listener, cb, is_wait]() mutable { if (is_wait) { cb(0, SockException(Err_timeout, "wait tcp connection timeout")); }