diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index ae4a47c8..56c1aa10 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -520,6 +520,7 @@ MediaSource::Ptr MediaSource::createFromMP4(const string &schema, const string & void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){ if (size || totalReaderCount(sender)) { //还有人观看该视频,不触发关闭事件 + _async_close_timer = nullptr; return; } //没有任何人观看该视频源,表明该源可以关闭了 diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index 1a86083d..52e34657 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -307,7 +307,11 @@ void MultiMediaSourceMuxer::setTrackListener(const std::weak_ptrtotalReaderCount() + _rtp_sender.size(); +#else return _muxer->totalReaderCount(); +#endif } void MultiMediaSourceMuxer::setTimeStamp(uint32_t stamp) { @@ -358,6 +362,10 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const string &dst_ bool MultiMediaSourceMuxer::stopSendRtp(MediaSource &sender, const string& ssrc){ #if defined(ENABLE_RTPPROXY) + onceToken token(nullptr, [&]() { + //关闭rtp推流,可能触发无人观看事件 + MediaSourceEventInterceptor::onReaderChanged(sender, totalReaderCount()); + }); if (ssrc.empty()) { //关闭全部 lock_guard lck(_rtp_sender_mtx);