mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[fix] fix crash due to rtp receivers destroy
This commit is contained in:
@@ -6,10 +6,12 @@
|
||||
|
||||
#define RTCP_SR_INTERVAL 1000
|
||||
|
||||
RtpAudioSender::RtpAudioSender() {}
|
||||
RtpAudioSender::RtpAudioSender() { SetPeriod(std::chrono::milliseconds(5)); }
|
||||
|
||||
RtpAudioSender::RtpAudioSender(std::shared_ptr<IOStatistics> io_statistics)
|
||||
: io_statistics_(io_statistics) {}
|
||||
: io_statistics_(io_statistics) {
|
||||
SetPeriod(std::chrono::milliseconds(5));
|
||||
}
|
||||
|
||||
RtpAudioSender::~RtpAudioSender() {
|
||||
if (rtp_statistics_) {
|
||||
@@ -140,6 +142,5 @@ bool RtpAudioSender::Process() {
|
||||
rtp_statistics_->UpdateSentBytes(last_send_bytes_);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
return true;
|
||||
}
|
||||
@@ -9,7 +9,9 @@
|
||||
RtpDataSender::RtpDataSender() {}
|
||||
|
||||
RtpDataSender::RtpDataSender(std::shared_ptr<IOStatistics> io_statistics)
|
||||
: io_statistics_(io_statistics) {}
|
||||
: io_statistics_(io_statistics) {
|
||||
SetPeriod(std::chrono::milliseconds(5));
|
||||
}
|
||||
|
||||
RtpDataSender::~RtpDataSender() {
|
||||
if (rtp_statistics_) {
|
||||
@@ -140,6 +142,5 @@ bool RtpDataSender::Process() {
|
||||
rtp_statistics_->UpdateSentBytes(last_send_bytes_);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
return true;
|
||||
}
|
||||
@@ -20,7 +20,10 @@ RtpVideoReceiver::RtpVideoReceiver()
|
||||
[this](int64_t bitrate_bps, std::vector<uint32_t> ssrcs) {
|
||||
SendRemb(bitrate_bps, ssrcs);
|
||||
}),
|
||||
clock_(Clock::GetRealTimeClockShared()) {}
|
||||
clock_(Clock::GetRealTimeClockShared()) {
|
||||
SetPeriod(std::chrono::milliseconds(5));
|
||||
// rtcp_thread_ = std::thread(&RtpVideoReceiver::RtcpThread, this);
|
||||
}
|
||||
|
||||
RtpVideoReceiver::RtpVideoReceiver(std::shared_ptr<IOStatistics> io_statistics)
|
||||
: io_statistics_(io_statistics),
|
||||
@@ -34,7 +37,8 @@ RtpVideoReceiver::RtpVideoReceiver(std::shared_ptr<IOStatistics> io_statistics)
|
||||
SendRemb(bitrate_bps, ssrcs);
|
||||
}),
|
||||
clock_(Clock::GetRealTimeClockShared()) {
|
||||
rtcp_thread_ = std::thread(&RtpVideoReceiver::RtcpThread, this);
|
||||
SetPeriod(std::chrono::milliseconds(5));
|
||||
// rtcp_thread_ = std::thread(&RtpVideoReceiver::RtcpThread, this);
|
||||
|
||||
#ifdef SAVE_RTP_RECV_STREAM
|
||||
file_rtp_recv_ = fopen("rtp_recv_stream.h264", "w+b");
|
||||
@@ -45,19 +49,18 @@ RtpVideoReceiver::RtpVideoReceiver(std::shared_ptr<IOStatistics> io_statistics)
|
||||
}
|
||||
|
||||
RtpVideoReceiver::~RtpVideoReceiver() {
|
||||
if (rtp_statistics_) {
|
||||
rtp_statistics_->Stop();
|
||||
}
|
||||
|
||||
rtcp_stop_.store(true);
|
||||
rtcp_cv_.notify_one();
|
||||
|
||||
rtcp_cv_.notify_all();
|
||||
if (rtcp_thread_.joinable()) {
|
||||
rtcp_thread_.join();
|
||||
}
|
||||
|
||||
SSRCManager::Instance().DeleteSsrc(feedback_ssrc_);
|
||||
|
||||
if (rtp_statistics_) {
|
||||
rtp_statistics_->Stop();
|
||||
}
|
||||
|
||||
#ifdef SAVE_RTP_RECV_STREAM
|
||||
if (file_rtp_recv_) {
|
||||
fflush(file_rtp_recv_);
|
||||
@@ -469,12 +472,11 @@ bool RtpVideoReceiver::Process() {
|
||||
}
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
return true;
|
||||
}
|
||||
|
||||
void RtpVideoReceiver::RtcpThread() {
|
||||
while (!rtcp_stop_) {
|
||||
while (!rtcp_stop_.load()) {
|
||||
std::unique_lock<std::mutex> lock(rtcp_mtx_);
|
||||
if (rtcp_cv_.wait_for(
|
||||
lock, std::chrono::milliseconds(rtcp_tcc_interval_ms_),
|
||||
|
||||
@@ -12,6 +12,7 @@ RtpVideoSender::RtpVideoSender() {}
|
||||
|
||||
RtpVideoSender::RtpVideoSender(std::shared_ptr<IOStatistics> io_statistics)
|
||||
: io_statistics_(io_statistics) {
|
||||
SetPeriod(std::chrono::milliseconds(5));
|
||||
#ifdef SAVE_RTP_SENT_STREAM
|
||||
file_rtp_sent_ = fopen("rtp_sent_stream.h264", "w+b");
|
||||
if (!file_rtp_sent_) {
|
||||
@@ -162,6 +163,5 @@ bool RtpVideoSender::Process() {
|
||||
rtp_statistics_->UpdateSentBytes(last_send_bytes_);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
return true;
|
||||
}
|
||||
@@ -44,7 +44,11 @@ void VideoChannelReceive::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||
rtp_video_receiver_->Start();
|
||||
}
|
||||
|
||||
void VideoChannelReceive::Destroy() {}
|
||||
void VideoChannelReceive::Destroy() {
|
||||
if (rtp_video_receiver_) {
|
||||
rtp_video_receiver_->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
int VideoChannelReceive::OnReceiveRtpPacket(const char *data, size_t size) {
|
||||
if (ice_io_statistics_) {
|
||||
|
||||
Reference in New Issue
Block a user