mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[feat] clean rtp packet buffer queue when ice destroyed
This commit is contained in:
@@ -23,25 +23,23 @@ void AudioChannelReceive::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||
}
|
||||
});
|
||||
|
||||
rtp_audio_receiver_->SetSendDataFunc(
|
||||
[this](const char *data, size_t size) -> int {
|
||||
if (!ice_agent_) {
|
||||
LOG_ERROR("ice_agent_ is nullptr");
|
||||
return -1;
|
||||
}
|
||||
rtp_audio_receiver_->SetSendDataFunc([this](const char *data,
|
||||
size_t size) -> int {
|
||||
if (!ice_agent_) {
|
||||
LOG_ERROR("ice_agent_ is nullptr");
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto ice_state = ice_agent_->GetIceState();
|
||||
auto ice_state = ice_agent_->GetIceState();
|
||||
|
||||
if (ice_state != NICE_COMPONENT_STATE_CONNECTED &&
|
||||
ice_state != NICE_COMPONENT_STATE_READY) {
|
||||
LOG_ERROR("Ice is not connected, state = [{}]",
|
||||
nice_component_state_to_string(ice_state));
|
||||
return -2;
|
||||
}
|
||||
if (ICE_STATE_NULLPTR == ice_state || ICE_STATE_DESTROYED == ice_state) {
|
||||
LOG_ERROR("Ice is not connected, state = [{}]", (int)ice_state);
|
||||
return -2;
|
||||
}
|
||||
|
||||
ice_io_statistics_->UpdateAudioOutboundBytes((uint32_t)size);
|
||||
return ice_agent_->Send(data, size);
|
||||
});
|
||||
ice_io_statistics_->UpdateAudioOutboundBytes((uint32_t)size);
|
||||
return ice_agent_->Send(data, size);
|
||||
});
|
||||
}
|
||||
|
||||
void AudioChannelReceive::Destroy() {}
|
||||
|
||||
@@ -25,10 +25,7 @@ void AudioChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||
|
||||
auto ice_state = ice_agent_->GetIceState();
|
||||
|
||||
if (ice_state != NICE_COMPONENT_STATE_CONNECTED &&
|
||||
ice_state != NICE_COMPONENT_STATE_READY) {
|
||||
LOG_ERROR("Ice is not connected, state = [{}]",
|
||||
nice_component_state_to_string(ice_state));
|
||||
if (ICE_STATE_DESTROYED == ice_state) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,25 +23,23 @@ void DataChannelReceive::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||
}
|
||||
});
|
||||
|
||||
rtp_data_receiver_->SetSendDataFunc(
|
||||
[this](const char *data, size_t size) -> int {
|
||||
if (!ice_agent_) {
|
||||
LOG_ERROR("ice_agent_ is nullptr");
|
||||
return -1;
|
||||
}
|
||||
rtp_data_receiver_->SetSendDataFunc([this](const char *data,
|
||||
size_t size) -> int {
|
||||
if (!ice_agent_) {
|
||||
LOG_ERROR("ice_agent_ is nullptr");
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto ice_state = ice_agent_->GetIceState();
|
||||
auto ice_state = ice_agent_->GetIceState();
|
||||
|
||||
if (ice_state != NICE_COMPONENT_STATE_CONNECTED &&
|
||||
ice_state != NICE_COMPONENT_STATE_READY) {
|
||||
LOG_ERROR("Ice is not connected, state = [{}]",
|
||||
nice_component_state_to_string(ice_state));
|
||||
return -2;
|
||||
}
|
||||
if (ICE_STATE_NULLPTR == ice_state || ICE_STATE_DESTROYED == ice_state) {
|
||||
LOG_ERROR("Ice is not connected, state = [{}]", (int)ice_state);
|
||||
return -2;
|
||||
}
|
||||
|
||||
ice_io_statistics_->UpdateDataOutboundBytes((uint32_t)size);
|
||||
return ice_agent_->Send(data, size);
|
||||
});
|
||||
ice_io_statistics_->UpdateDataOutboundBytes((uint32_t)size);
|
||||
return ice_agent_->Send(data, size);
|
||||
});
|
||||
}
|
||||
|
||||
void DataChannelReceive::Destroy() {}
|
||||
|
||||
@@ -25,10 +25,7 @@ void DataChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||
|
||||
auto ice_state = ice_agent_->GetIceState();
|
||||
|
||||
if (ice_state != NICE_COMPONENT_STATE_CONNECTED &&
|
||||
ice_state != NICE_COMPONENT_STATE_READY) {
|
||||
LOG_ERROR("Ice is not connected, state = [{}]",
|
||||
nice_component_state_to_string(ice_state));
|
||||
if (ICE_STATE_DESTROYED == ice_state) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,25 +23,23 @@ void VideoChannelReceive::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||
on_receive_complete_frame_(video_frame);
|
||||
});
|
||||
|
||||
rtp_video_receiver_->SetSendDataFunc(
|
||||
[this](const char *data, size_t size) -> int {
|
||||
if (!ice_agent_) {
|
||||
LOG_ERROR("ice_agent_ is nullptr");
|
||||
return -1;
|
||||
}
|
||||
rtp_video_receiver_->SetSendDataFunc([this](const char *data,
|
||||
size_t size) -> int {
|
||||
if (!ice_agent_) {
|
||||
LOG_ERROR("ice_agent_ is nullptr");
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto ice_state = ice_agent_->GetIceState();
|
||||
auto ice_state = ice_agent_->GetIceState();
|
||||
|
||||
if (ice_state != NICE_COMPONENT_STATE_CONNECTED &&
|
||||
ice_state != NICE_COMPONENT_STATE_READY) {
|
||||
LOG_ERROR("Ice is not connected, state = [{}]",
|
||||
nice_component_state_to_string(ice_state));
|
||||
return -2;
|
||||
}
|
||||
if (ICE_STATE_NULLPTR == ice_state || ICE_STATE_DESTROYED == ice_state) {
|
||||
LOG_ERROR("Ice is not connected, state = [{}]", (int)ice_state);
|
||||
return -2;
|
||||
}
|
||||
|
||||
ice_io_statistics_->UpdateVideoOutboundBytes((uint32_t)size);
|
||||
return ice_agent_->Send(data, size);
|
||||
});
|
||||
ice_io_statistics_->UpdateVideoOutboundBytes((uint32_t)size);
|
||||
return ice_agent_->Send(data, size);
|
||||
});
|
||||
|
||||
rtp_video_receiver_->Start();
|
||||
}
|
||||
|
||||
@@ -31,10 +31,7 @@ void VideoChannelSend::Initialize(rtp::PAYLOAD_TYPE payload_type) {
|
||||
|
||||
auto ice_state = ice_agent_->GetIceState();
|
||||
|
||||
if (ice_state != NICE_COMPONENT_STATE_CONNECTED &&
|
||||
ice_state != NICE_COMPONENT_STATE_READY) {
|
||||
// LOG_ERROR("Ice is not connected, state = [{}]",
|
||||
// nice_component_state_to_string(ice_state));
|
||||
if (ICE_STATE_DESTROYED == ice_state) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,10 @@ int RtpAudioSender::SendRtpPacket(std::shared_ptr<RtpPacket> rtp_packet) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 != data_send_func_((const char*)rtp_packet->Buffer().data(),
|
||||
rtp_packet->Size())) {
|
||||
LOG_ERROR("Send rtp packet failed");
|
||||
int ret = data_send_func_((const char*)rtp_packet->Buffer().data(),
|
||||
rtp_packet->Size());
|
||||
if (-2 == ret) {
|
||||
rtp_packet_queue_.clear();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,10 @@ int RtpDataSender::SendRtpPacket(std::shared_ptr<RtpPacket> rtp_packet) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 != data_send_func_((const char*)rtp_packet->Buffer().data(),
|
||||
rtp_packet->Size())) {
|
||||
LOG_ERROR("Send rtp packet failed");
|
||||
int ret = data_send_func_((const char*)rtp_packet->Buffer().data(),
|
||||
rtp_packet->Size());
|
||||
if (-2 == ret) {
|
||||
rtp_packet_queue_.clear();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,9 +85,11 @@ int RtpVideoSender::SendRtpPacket(
|
||||
}
|
||||
|
||||
last_rtp_timestamp_ = rtp_packet_to_send->capture_time().ms();
|
||||
if (0 != data_send_func_((const char*)rtp_packet_to_send->Buffer().data(),
|
||||
rtp_packet_to_send->Size())) {
|
||||
// LOG_ERROR("Send rtp packet failed");
|
||||
|
||||
int ret = data_send_func_((const char*)rtp_packet_to_send->Buffer().data(),
|
||||
rtp_packet_to_send->Size());
|
||||
if (-2 == ret) {
|
||||
rtp_packet_queue_.clear();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -131,8 +133,9 @@ int RtpVideoSender::SendRtcpSR(SenderReport& rtcp_sr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (data_send_func_((const char*)rtcp_sr.Buffer(), rtcp_sr.Size())) {
|
||||
LOG_ERROR("Send SR failed");
|
||||
int ret = data_send_func_((const char*)rtcp_sr.Buffer(), rtcp_sr.Size());
|
||||
if (ret != 0) {
|
||||
LOG_ERROR("Send rtcp sr failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user