mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Fix memory leak
This commit is contained in:
parent
03389f5e8c
commit
78fcaaf7b1
2 changed files with 20 additions and 2 deletions
|
@ -943,6 +943,18 @@ SrsRtcPublishStream::~SrsRtcPublishStream()
|
|||
source->on_unpublish();
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)video_tracks_.size(); ++i) {
|
||||
SrsRtcVideoRecvTrack* track = video_tracks_.at(i);
|
||||
srs_freep(track);
|
||||
}
|
||||
video_tracks_.clear();
|
||||
|
||||
for (int i = 0; i < (int)audio_tracks_.size(); ++i) {
|
||||
SrsRtcAudioRecvTrack* track = audio_tracks_.at(i);
|
||||
srs_freep(track);
|
||||
}
|
||||
audio_tracks_.clear();
|
||||
|
||||
srs_freep(timer_);
|
||||
srs_freep(pli_worker_);
|
||||
srs_freep(pli_epp);
|
||||
|
@ -1785,7 +1797,7 @@ srs_error_t SrsRtcConnection::add_publisher(SrsRequest* req, const SrsSdp& remot
|
|||
source->set_stream_created();
|
||||
|
||||
// Apply the SDP to source.
|
||||
source->set_stream_desc(stream_desc->copy());
|
||||
source->set_stream_desc(stream_desc);
|
||||
|
||||
// TODO: FIXME: What happends when error?
|
||||
if ((err = create_publisher(req, stream_desc)) != srs_success) {
|
||||
|
|
|
@ -481,6 +481,9 @@ void SrsRtcStream::on_unpublish()
|
|||
h->on_unpublish();
|
||||
}
|
||||
|
||||
// release unpublish stream description.
|
||||
set_stream_desc(NULL);
|
||||
|
||||
// TODO: FIXME: Handle by statistic.
|
||||
}
|
||||
|
||||
|
@ -527,8 +530,11 @@ srs_error_t SrsRtcStream::on_rtp(SrsRtpPacket2* pkt)
|
|||
void SrsRtcStream::set_stream_desc(SrsRtcStreamDescription* stream_desc)
|
||||
{
|
||||
srs_freep(stream_desc_);
|
||||
|
||||
if (stream_desc) {
|
||||
stream_desc_ = stream_desc->copy();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<SrsRtcTrackDescription*> SrsRtcStream::get_track_desc(std::string type, std::string media_name)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue