[feat] clean rtp packet buffer queue when ice destroyed

This commit is contained in:
dijunkun
2025-03-05 17:48:33 +08:00
parent 0dbc0236bf
commit 02f00642e9
11 changed files with 82 additions and 82 deletions

View File

@@ -335,23 +335,20 @@ int IceAgent::GatherCandidates() {
return 0;
}
NiceComponentState IceAgent::GetIceState() {
ICE_STATE IceAgent::GetIceState() {
if (!nice_inited_) {
LOG_ERROR("Nice agent has not been initialized");
return NiceComponentState::NICE_COMPONENT_STATE_LAST;
return ICE_STATE_NOT_INITIALIZED;
}
if (nullptr == agent_) {
LOG_ERROR("Nice agent is nullptr");
return NiceComponentState::NICE_COMPONENT_STATE_LAST;
return ICE_STATE_NULLPTR;
}
if (destroyed_) {
LOG_ERROR("Nice agent is destroyed");
return NiceComponentState::NICE_COMPONENT_STATE_LAST;
return ICE_STATE_DESTROYED;
}
state_ = nice_agent_get_component_state(agent_, stream_id_, 1);
state_ = (ICE_STATE)nice_agent_get_component_state(agent_, stream_id_, 1);
return state_;
}
@@ -377,7 +374,7 @@ int IceAgent::Send(const char *data, size_t size) {
return -1;
}
// if (NiceComponentState::NICE_COMPONENT_STATE_READY !=
// if (ICE_STATE_READY !=
// nice_agent_get_component_state(agent_, stream_id_, 1)) {
// LOG_ERROR("Nice agent not ready");
// return -1;

View File

@@ -9,6 +9,19 @@
#include "glib.h"
#include "nice/agent.h"
typedef enum {
ICE_STATE_DISCONNECTED,
ICE_STATE_GATHERING,
ICE_STATE_CONNECTING,
ICE_STATE_CONNECTED,
ICE_STATE_READY,
ICE_STATE_FAILED,
ICE_STATE_NOT_INITIALIZED,
ICE_STATE_DESTROYED,
ICE_STATE_NULLPTR,
ICE_STATE_LAST
} ICE_STATE;
typedef void (*nice_cb_state_changed_t)(NiceAgent* agent, guint stream_id,
guint component_id,
NiceComponentState state,
@@ -56,7 +69,7 @@ class IceAgent {
int GatherCandidates();
NiceComponentState GetIceState();
ICE_STATE GetIceState();
int SetRemoteGatheringDone();
@@ -99,7 +112,7 @@ class IceAgent {
uint32_t n_components_ = 1;
// char* local_sdp_ = nullptr;
std::string local_sdp_ = "";
NiceComponentState state_ = NiceComponentState::NICE_COMPONENT_STATE_LAST;
ICE_STATE state_ = ICE_STATE_LAST;
bool destroyed_ = false;
gboolean agent_closed_ = false;