From 4bb3ad5637b5541df515fa9a9d69143310397c60 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 15 Jan 2021 16:58:23 +0800 Subject: [PATCH] For #2142, Fix bug for fixing memory leak for bridger. 4.0.62 --- trunk/src/app/srs_app_rtc_source.cpp | 11 ++++++++++- trunk/src/app/srs_app_rtc_source.hpp | 1 + trunk/src/core/srs_core_version4.hpp | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index 0503d2f96..979078b15 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -531,6 +531,11 @@ srs_error_t SrsRtcStream::on_rtp(SrsRtpPacket2* pkt) return err; } +bool SrsRtcStream::has_stream_desc() +{ + return stream_desc_; +} + void SrsRtcStream::set_stream_desc(SrsRtcStreamDescription* stream_desc) { srs_freep(stream_desc_); @@ -615,7 +620,11 @@ SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcStream* source) video_payload->set_h264_param_desc("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f"); } - source_->set_stream_desc(stream_desc); + // If the stream description has already been setup by RTC publisher, + // we should ignore and it's ok, because we only need to setup it for bridger. + if (!source_->has_stream_desc()) { + source_->set_stream_desc(stream_desc); + } } SrsRtcFromRtmpBridger::~SrsRtcFromRtmpBridger() diff --git a/trunk/src/app/srs_app_rtc_source.hpp b/trunk/src/app/srs_app_rtc_source.hpp index bdc841bbe..bd6328aa7 100644 --- a/trunk/src/app/srs_app_rtc_source.hpp +++ b/trunk/src/app/srs_app_rtc_source.hpp @@ -216,6 +216,7 @@ public: // Consume the shared RTP packet, user must free it. srs_error_t on_rtp(SrsRtpPacket2* pkt); // Set and get stream description for souce + bool has_stream_desc(); void set_stream_desc(SrsRtcStreamDescription* stream_desc); std::vector get_track_desc(std::string type, std::string media_type); }; diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 703765e60..1c994c88a 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION4_HPP #define SRS_CORE_VERSION4_HPP -#define SRS_VERSION4_REVISION 61 +#define SRS_VERSION4_REVISION 62 #endif