Commit fef85da7 by waken Committed by GitHub

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

复现条件:chrome打开webrtc
demo网页,网页会每秒调用getMediaList。添加一条rtsp拉流,然后再调用close_stream,会偶现进入RtspPlayer::getPacketLossRate函数,然后_rtcp_context为空拿不到指针
parent 81966f2c
...@@ -544,6 +544,9 @@ float RtspPlayer::getPacketLossRate(TrackType type) const { ...@@ -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();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论