From 6382fcb3be041ab338afc44bae10b411b3bea365 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Thu, 11 Aug 2022 18:36:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A1=AE=E4=BF=9Don=5Fpublish=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=9B=9E=E8=B0=83=E6=97=B6=E7=BA=BF=E7=A8=8B=E5=AE=89?= =?UTF-8?q?=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtp/RtpProcess.cpp | 29 ++++++++++++++++++----------- srt/SrtTransportImp.cpp | 29 ++++++++++++++++++----------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index b0027f69..bc5f69ec 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -244,17 +244,24 @@ void RtpProcess::emitOnPublish() { if (!strong_self) { return; } - if (err.empty()) { - strong_self->_muxer = std::make_shared(strong_self->_media_info._vhost, - strong_self->_media_info._app, - strong_self->_media_info._streamid, 0.0f, - option); - strong_self->_muxer->setMediaListener(strong_self); - strong_self->doCachedFunc(); - InfoP(strong_self) << "允许RTP推流"; - } else { - WarnP(strong_self) << "禁止RTP推流:" << err; - } + auto poller = strong_self->_sock ? strong_self->_sock->getPoller() : EventPollerPool::Instance().getPoller(); + poller->async([weak_self, err, option]() { + auto strong_self = weak_self.lock(); + if (!strong_self) { + return; + } + if (err.empty()) { + strong_self->_muxer = std::make_shared(strong_self->_media_info._vhost, + strong_self->_media_info._app, + strong_self->_media_info._streamid,0.0f, + option); + strong_self->_muxer->setMediaListener(strong_self); + strong_self->doCachedFunc(); + InfoP(strong_self) << "允许RTP推流"; + } else { + WarnP(strong_self) << "禁止RTP推流:" << err; + } + }); }; //触发推流鉴权事件 diff --git a/srt/SrtTransportImp.cpp b/srt/SrtTransportImp.cpp index ca5c0082..36ac8b05 100644 --- a/srt/SrtTransportImp.cpp +++ b/srt/SrtTransportImp.cpp @@ -161,17 +161,24 @@ void SrtTransportImp::emitOnPublish() { if (!strong_self) { return; } - if (err.empty()) { - strong_self->_muxer = std::make_shared( - strong_self->_media_info._vhost, strong_self->_media_info._app, strong_self->_media_info._streamid, - 0.0f, option); - strong_self->_muxer->setMediaListener(strong_self); - strong_self->doCachedFunc(); - InfoP(strong_self) << "允许 srt 推流"; - } else { - WarnP(strong_self) << "禁止 srt 推流:" << err; - strong_self->onShutdown(SockException(Err_refused, err)); - } + strong_self->getPoller()->async([weak_self, err, option](){ + auto strong_self = weak_self.lock(); + if (!strong_self) { + return; + } + if (err.empty()) { + strong_self->_muxer = std::make_shared(strong_self->_media_info._vhost, + strong_self->_media_info._app, + strong_self->_media_info._streamid,0.0f, + option); + strong_self->_muxer->setMediaListener(strong_self); + strong_self->doCachedFunc(); + InfoP(strong_self) << "允许 srt 推流"; + } else { + WarnP(strong_self) << "禁止 srt 推流:" << err; + strong_self->onShutdown(SockException(Err_refused, err)); + } + }); }; // 触发推流鉴权事件