mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
修复addStreamProxy后,马上startSendRtp,触发的无人观看事件回调是MediaSourceNull的信息,导致无法关闭流bug(#2120)
This commit is contained in:
parent
754073918a
commit
68ea5465cc
@ -245,8 +245,9 @@ bool MultiMediaSourceMuxer::isRecording(MediaSource &sender, Recorder::type type
|
||||
void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceEvent::SendRtpArgs &args, const std::function<void(uint16_t, const toolkit::SockException &)> cb) {
|
||||
#if defined(ENABLE_RTPPROXY)
|
||||
auto rtp_sender = std::make_shared<RtpSender>(getOwnerPoller(sender));
|
||||
auto sender_ptr = sender.shared_from_this();
|
||||
weak_ptr<MultiMediaSourceMuxer> 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宏"));
|
||||
|
Loading…
Reference in New Issue
Block a user