From fef85da7712495c09a967e4181e8314075cd018c Mon Sep 17 00:00:00 2001 From: waken <33921191+mc373906408@users.noreply.github.com> Date: Thu, 31 Aug 2023 10:53:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B0=83=E7=94=A8close=5Fstr?= =?UTF-8?q?eam=E5=90=8C=E6=97=B6=E8=B0=83=E7=94=A8getMediaList=E5=BC=95?= =?UTF-8?q?=E5=8F=91=E7=9A=84=E5=B4=A9=E6=BA=83=20(#2800)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 复现条件:chrome打开webrtc demo网页,网页会每秒调用getMediaList。添加一条rtsp拉流,然后再调用close_stream,会偶现进入RtspPlayer::getPacketLossRate函数,然后_rtcp_context为空拿不到指针 --- src/Rtsp/RtspPlayer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 676d89b1..f6a13fda 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -544,6 +544,9 @@ float RtspPlayer::getPacketLossRate(TrackType type) const { size_t lost = 0, expected = 0; try { auto track_idx = getTrackIndexByTrackType(type); + if (_rtcp_context.empty()) { + return 0; + } auto ctx = _rtcp_context[track_idx]; lost = ctx->getLost(); expected = ctx->getExpectedPackets();