From 68ea5465cc39f103a90125dc41bf1fcb1bfc9b59 Mon Sep 17 00:00:00 2001 From: monktan89 Date: Tue, 29 Nov 2022 11:33:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DaddStreamProxy=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E9=A9=AC=E4=B8=8AstartSendRtp=EF=BC=8C=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E7=9A=84=E6=97=A0=E4=BA=BA=E8=A7=82=E7=9C=8B=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=9B=9E=E8=B0=83=E6=98=AFMediaSourceNull=E7=9A=84?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E5=AF=BC=E8=87=B4=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=B5=81bug(#2120)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/MultiMediaSourceMuxer.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index 7dd3027b..c6985b17 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -245,8 +245,9 @@ bool MultiMediaSourceMuxer::isRecording(MediaSource &sender, Recorder::type type void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceEvent::SendRtpArgs &args, const std::function cb) { #if defined(ENABLE_RTPPROXY) auto rtp_sender = std::make_shared(getOwnerPoller(sender)); + auto sender_ptr = sender.shared_from_this(); weak_ptr weak_self = shared_from_this(); - rtp_sender->startSend(args, [args, weak_self, rtp_sender, cb](uint16_t local_port, const SockException &ex) mutable { + rtp_sender->startSend(args, [args, weak_self, rtp_sender, cb, sender_ptr](uint16_t local_port, const SockException &ex) mutable { cb(local_port, ex); auto strong_self = weak_self.lock(); if (!strong_self || ex) { @@ -258,17 +259,17 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceE rtp_sender->addTrackCompleted(); auto ssrc = args.ssrc; - rtp_sender->setOnClose([weak_self, ssrc](const toolkit::SockException &ex) { + rtp_sender->setOnClose([weak_self, ssrc, sender_ptr](const toolkit::SockException &ex) { if (auto strong_self = weak_self.lock()) { WarnL << "stream:" << strong_self->shortUrl() << " stop send rtp:" << ssrc << ", reason:" << ex.what(); strong_self->_rtp_sender.erase(ssrc); //触发观看人数统计 - strong_self->onReaderChanged(MediaSource::NullMediaSource(), strong_self->totalReaderCount()); + strong_self->onReaderChanged(*sender_ptr, strong_self->totalReaderCount()); NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastSendRtpStopped, *strong_self, ssrc, ex); } }); strong_self->_rtp_sender[args.ssrc] = std::move(rtp_sender); - strong_self->onReaderChanged(MediaSource::NullMediaSource(), strong_self->totalReaderCount()); + strong_self->onReaderChanged(*sender_ptr, strong_self->totalReaderCount()); }); #else cb(0, SockException(Err_other, "该功能未启用,编译时请打开ENABLE_RTPPROXY宏"));