修复调用close_stream同时调用getMediaList引发的崩溃 (#2800)

复现条件:chrome打开webrtc
demo网页,网页会每秒调用getMediaList。添加一条rtsp拉流,然后再调用close_stream,会偶现进入RtspPlayer::getPacketLossRate函数,然后_rtcp_context为空拿不到指针
This commit is contained in:
waken 2023-08-31 10:53:46 +08:00 committed by GitHub
parent 81966f2c48
commit fef85da771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -544,6 +544,9 @@ float RtspPlayer::getPacketLossRate(TrackType type) const {
size_t lost = 0, expected = 0; size_t lost = 0, expected = 0;
try { try {
auto track_idx = getTrackIndexByTrackType(type); auto track_idx = getTrackIndexByTrackType(type);
if (_rtcp_context.empty()) {
return 0;
}
auto ctx = _rtcp_context[track_idx]; auto ctx = _rtcp_context[track_idx];
lost = ctx->getLost(); lost = ctx->getLost();
expected = ctx->getExpectedPackets(); expected = ctx->getExpectedPackets();