From 9a5fdd3dace7436f3dbaa3e791c112b85654d5a8 Mon Sep 17 00:00:00 2001 From: zwcarl <154851816+zwcarl@users.noreply.github.com> Date: Sun, 9 Jun 2024 10:42:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=84=E6=92=ADbug=20(#360?= =?UTF-8?q?2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当多个客户端拉同一个组播源时,如果此时源被析构,会偶现使用该源的组播对象没有被析构的情况,在RtpMultiCaster的_rtp_reader->setDetachCB回调函数中,先移除该组播对象再通知上层session可以解决此问题 --------- Co-authored-by: zhengwang --- src/Rtsp/RtpMultiCaster.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Rtsp/RtpMultiCaster.cpp b/src/Rtsp/RtpMultiCaster.cpp index fefc0f84..c358e68e 100644 --- a/src/Rtsp/RtpMultiCaster.cpp +++ b/src/Rtsp/RtpMultiCaster.cpp @@ -144,7 +144,16 @@ RtpMultiCaster::RtpMultiCaster(SocketHelper &helper, const string &local_ip, con }); }); - _rtp_reader->setDetachCB([this]() { + string strKey = StrPrinter << local_ip << " " << vhost << " " << app << " " << stream << endl; + _rtp_reader->setDetachCB([this, strKey]() { + { + lock_guard lck(g_mtx); + auto it = g_multi_caster_map.find(strKey); + if (it != g_multi_caster_map.end()) { + g_multi_caster_map.erase(it); + } + } + unordered_map _detach_map_copy; { lock_guard lck(_mtx);