[fix] stop threads when DestroyIceTransmission() called

This commit is contained in:
dijunkun
2024-10-18 17:15:33 +08:00
parent 30c167e6cc
commit 35d4f522c5
5 changed files with 39 additions and 21 deletions

View File

@@ -83,7 +83,8 @@ int AomAv1Decoder::Decode(
return -1;
}
if (img_ = aom_codec_get_frame(&aom_av1_decoder_ctx_, &iter)) {
img_ = aom_codec_get_frame(&aom_av1_decoder_ctx_, &iter);
if (img_) {
{
aom_codec_frame_flags_t flags;
ret = aom_codec_control(&aom_av1_decoder_ctx_, AOMD_GET_FRAME_FLAGS,

View File

@@ -956,6 +956,7 @@ void PeerConnection::ProcessIceWorkMsg(const IceWorkMsg &msg) {
}
case IceWorkMsg::Type::Destroy: {
for (auto &user_id_it : ice_transmission_list_) {
LOG_ERROR("Destroy transmission");
user_id_it.second->DestroyIceTransmission();
}
ice_transmission_list_.clear();

View File

@@ -1,5 +1,7 @@
#include "io_statistics.h"
#include "log.h"
IOStatistics::IOStatistics(
std::function<void(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t,
uint32_t, uint32_t, uint32_t)>
@@ -8,13 +10,7 @@ IOStatistics::IOStatistics(
interval_ = 1000;
}
IOStatistics::~IOStatistics() {
running_ = false;
cond_var_.notify_one();
if (statistics_thread_.joinable()) {
statistics_thread_.join();
}
}
IOStatistics::~IOStatistics() {}
void IOStatistics::Process() {
while (running_) {
@@ -56,6 +52,14 @@ void IOStatistics::Start() {
}
}
void IOStatistics::Stop() {
running_ = false;
cond_var_.notify_one();
if (statistics_thread_.joinable()) {
statistics_thread_.join();
}
}
void IOStatistics::UpdateVideoInboundBytes(uint32_t bytes) {
video_inbound_bytes_ += bytes;
}

View File

@@ -22,6 +22,7 @@ class IOStatistics {
public:
void Start();
void Stop();
void UpdateVideoInboundBytes(uint32_t bytes);
void UpdateVideoOutboundBytes(uint32_t bytes);

View File

@@ -22,19 +22,7 @@ IceTransmission::IceTransmission(
ice_ws_transport_(ice_ws_transmission),
on_ice_status_change_(on_ice_status_change) {}
IceTransmission::~IceTransmission() {
if (rtp_video_sender_) {
rtp_video_sender_->Stop();
}
if (rtp_audio_sender_) {
rtp_audio_sender_->Stop();
}
if (rtp_data_sender_) {
rtp_data_sender_->Stop();
}
}
IceTransmission::~IceTransmission() {}
int IceTransmission::SetLocalCapabilities(
bool use_trickle_ice, bool use_reliable_ice, bool enable_turn,
@@ -351,6 +339,29 @@ int IceTransmission::DestroyIceTransmission() {
if (on_ice_status_change_) {
on_ice_status_change_("closed");
}
if (ice_io_statistics_) {
ice_io_statistics_->Stop();
}
if (rtp_video_receiver_) {
rtp_video_receiver_->Stop();
}
if (rtp_video_sender_) {
rtp_video_sender_->Stop();
}
if (rtp_audio_sender_) {
rtp_audio_sender_->Stop();
}
if (rtp_data_sender_) {
rtp_data_sender_->Stop();
}
LOG_ERROR("threads stoped");
return ice_agent_->DestroyIceAgent();
}