From 74a935a8cd96de3c9fc4124b2538626b76dc3d81 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Thu, 24 Jun 2021 13:20:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84simulcast=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/WebRtcTransport.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 22e85d4f..ccdeab38 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -792,8 +792,11 @@ void WebRtcTransportImp::onRtp_l(const char *buf, size_t len, bool rtx) { } } //解析并排序rtp - assert(ref); - ref->inputRtp(info->media->type, info->plan_rtp->sample_rate, (uint8_t *) buf, len); + if (ref) { + ref->inputRtp(info->media->type, info->plan_rtp->sample_rate, (uint8_t *) buf, len); + } else { + WarnL << "rtp dropped, ssrc:" << ssrc << ", is rtx:" << rtx; + } return; } @@ -945,7 +948,7 @@ void WebRtcTransportImp::onShutdown(const SockException &ex){ bool WebRtcTransportImp::close(MediaSource &sender, bool force) { //此回调在其他线程触发 - if(!_push_src || (!force && _push_src->totalReaderCount())){ + if (!force && totalReaderCount(sender)) { return false; } string err = StrPrinter << "close media:" << sender.getSchema() << "/" << sender.getVhost() << "/" << sender.getApp() << "/" << sender.getId() << " " << force; @@ -954,7 +957,11 @@ bool WebRtcTransportImp::close(MediaSource &sender, bool force) { } int WebRtcTransportImp::totalReaderCount(MediaSource &sender) { - return _push_src ? _push_src->totalReaderCount() : sender.readerCount(); + auto total_count = 0; + for (auto &src : _push_src_simulcast) { + total_count += src.second->totalReaderCount(); + } + return total_count; } MediaOriginType WebRtcTransportImp::getOriginType(MediaSource &sender) const {