From 05dbbbe975b02a4d906162abbf995424dba048fb Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jun 2024 12:34:16 +0800 Subject: [PATCH] Dispose source when no publishers. --- trunk/src/app/srs_app_srt_source.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/trunk/src/app/srs_app_srt_source.cpp b/trunk/src/app/srs_app_srt_source.cpp index 39d15d0222..ea915dfb22 100644 --- a/trunk/src/app/srs_app_srt_source.cpp +++ b/trunk/src/app/srs_app_srt_source.cpp @@ -970,8 +970,8 @@ void SrsSrtSource::on_consumer_destroy(SrsSrtConsumer* consumer) it = consumers.erase(it); } - // Destroy and cleanup source when no consumers. - if (consumers.empty()) { + // Destroy and cleanup source when no publishers and consumers. + if (can_publish_ && consumers.empty()) { _srs_srt_sources->eliminate(req); } } @@ -1027,6 +1027,11 @@ void SrsSrtSource::on_unpublish() bridge_->on_unpublish(); srs_freep(bridge_); } + + // Destroy and cleanup source when no publishers and consumers. + if (can_publish_ && consumers.empty()) { + _srs_srt_sources->eliminate(req); + } } srs_error_t SrsSrtSource::on_packet(SrsSrtPacket* packet)