From 28fb35faf58d401a2c3be72b27bedea6b2a3c4ce Mon Sep 17 00:00:00 2001 From: dijunkun Date: Fri, 14 Jun 2024 13:43:21 +0800 Subject: [PATCH] Check ice status by using ice_transmission::state_ instead of nice_agent_get_component_state() method --- src/ice/ice_agent.cpp | 10 +++++----- src/transmission/ice_transmission.cpp | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/ice/ice_agent.cpp b/src/ice/ice_agent.cpp index 72e1179..81ab6c5 100644 --- a/src/ice/ice_agent.cpp +++ b/src/ice/ice_agent.cpp @@ -228,11 +228,11 @@ int IceAgent::Send(const char *data, size_t size) { return -1; } - if (NiceComponentState::NICE_COMPONENT_STATE_READY != - nice_agent_get_component_state(agent_, stream_id_, 1)) { - LOG_ERROR("Nice agent not ready"); - return -1; - } + // if (NiceComponentState::NICE_COMPONENT_STATE_READY != + // nice_agent_get_component_state(agent_, stream_id_, 1)) { + // LOG_ERROR("Nice agent not ready"); + // return -1; + // } nice_agent_send(agent_, stream_id_, 1, size, data); return 0; diff --git a/src/transmission/ice_transmission.cpp b/src/transmission/ice_transmission.cpp index c2933f6..0d1b9b4 100644 --- a/src/transmission/ice_transmission.cpp +++ b/src/transmission/ice_transmission.cpp @@ -53,6 +53,10 @@ int IceTransmission::InitIceTransmission( return -1; } + if (state_ != NICE_COMPONENT_STATE_READY) { + return -2; + } + return ice_agent_->Send(data, size); }); rtp_video_receiver_->SetOnReceiveCompleteFrame( @@ -73,6 +77,10 @@ int IceTransmission::InitIceTransmission( return -1; } + if (state_ != NICE_COMPONENT_STATE_READY) { + return -2; + } + return ice_agent_->Send(data, size); }); @@ -93,6 +101,10 @@ int IceTransmission::InitIceTransmission( return -1; } + if (state_ != NICE_COMPONENT_STATE_READY) { + return -2; + } + return ice_agent_->Send(data, size); }); @@ -106,6 +118,10 @@ int IceTransmission::InitIceTransmission( return -1; } + if (state_ != NICE_COMPONENT_STATE_READY) { + return -2; + } + return ice_agent_->Send(data, size); }); @@ -119,6 +135,10 @@ int IceTransmission::InitIceTransmission( return -1; } + if (state_ != NICE_COMPONENT_STATE_READY) { + return -2; + } + return ice_agent_->Send(data, size); }); rtp_data_receiver_->SetOnReceiveData(