From a72d87cca7d836a1850aaa22bfb4e003fb8ff0b9 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 15 Dec 2023 16:46:43 +0800 Subject: [PATCH] BugFix: MediaSource unregister after 3 seconds after calling close_streams (#3132) To avoid frequent creation and destruction of UdpSession, RtpSession will be destructed 3 seconds after triggering onError. --- src/Rtp/RtpSession.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Rtp/RtpSession.cpp b/src/Rtp/RtpSession.cpp index 85f0c2fb..40db50f3 100644 --- a/src/Rtp/RtpSession.cpp +++ b/src/Rtp/RtpSession.cpp @@ -46,11 +46,7 @@ RtpSession::RtpSession(const Socket::Ptr &sock) } } -RtpSession::~RtpSession() { - if (_process) { - RtpSelector::Instance().delProcess(_stream_id, _process.get()); - } -} +RtpSession::~RtpSession() = default; void RtpSession::onRecv(const Buffer::Ptr &data) { if (_is_udp) { @@ -62,6 +58,9 @@ void RtpSession::onRecv(const Buffer::Ptr &data) { void RtpSession::onError(const SockException &err) { WarnP(this) << _stream_id << " " << err; + if (_process) { + RtpSelector::Instance().delProcess(_stream_id, _process.get()); + } } void RtpSession::onManager() {