mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Fix warning when destroy connection in TURN mode
This commit is contained in:
@@ -44,7 +44,7 @@ int IceAgent::CreateIceAgent(nice_cb_state_changed_t on_state_changed,
|
|||||||
|
|
||||||
agent_ = nice_agent_new_full(g_main_loop_get_context(gloop_),
|
agent_ = nice_agent_new_full(g_main_loop_get_context(gloop_),
|
||||||
NICE_COMPATIBILITY_RFC5245,
|
NICE_COMPATIBILITY_RFC5245,
|
||||||
(NiceAgentOption)(NICE_AGENT_OPTION_RELIABLE));
|
(NiceAgentOption)(NICE_AGENT_OPTION_NONE));
|
||||||
|
|
||||||
if (agent_ == nullptr) {
|
if (agent_ == nullptr) {
|
||||||
LOG_ERROR("Failed to create agent_");
|
LOG_ERROR("Failed to create agent_");
|
||||||
@@ -73,6 +73,8 @@ int IceAgent::CreateIceAgent(nice_cb_state_changed_t on_state_changed,
|
|||||||
turn_port_, turn_username_.c_str(),
|
turn_port_, turn_username_.c_str(),
|
||||||
turn_password_.c_str(), NICE_RELAY_TYPE_TURN_UDP);
|
turn_password_.c_str(), NICE_RELAY_TYPE_TURN_UDP);
|
||||||
|
|
||||||
|
g_object_set(agent_, "force-relay", true, NULL);
|
||||||
|
|
||||||
nice_agent_attach_recv(agent_, stream_id_, 1,
|
nice_agent_attach_recv(agent_, stream_id_, 1,
|
||||||
g_main_loop_get_context(gloop_), on_recv_,
|
g_main_loop_get_context(gloop_), on_recv_,
|
||||||
user_ptr_);
|
user_ptr_);
|
||||||
@@ -93,12 +95,23 @@ int IceAgent::CreateIceAgent(nice_cb_state_changed_t on_state_changed,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cb_closed(GObject *src, GAsyncResult *res, gpointer data) {
|
||||||
|
LOG_ERROR("cb_closed");
|
||||||
|
NiceAgent *agent = NICE_AGENT(src);
|
||||||
|
g_debug("test-turn:%s: %p", G_STRFUNC, agent);
|
||||||
|
|
||||||
|
*((gboolean *)data) = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
int IceAgent::DestroyIceAgent() {
|
int IceAgent::DestroyIceAgent() {
|
||||||
if (!nice_inited_) {
|
if (!nice_inited_) {
|
||||||
LOG_ERROR("Nice agent has not been initialized");
|
LOG_ERROR("Nice agent has not been initialized");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nice_agent_remove_stream(agent_, stream_id_);
|
||||||
|
nice_agent_close_async(agent_, cb_closed, &agent_closed_);
|
||||||
|
|
||||||
destroyed_ = true;
|
destroyed_ = true;
|
||||||
g_main_loop_quit(gloop_);
|
g_main_loop_quit(gloop_);
|
||||||
|
|
||||||
@@ -127,7 +140,7 @@ char *IceAgent::GenerateLocalSdp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local_sdp_ = nice_agent_generate_local_sdp(agent_);
|
local_sdp_ = nice_agent_generate_local_sdp(agent_);
|
||||||
// LOG_INFO("Generate local sdp:[\n{}]", local_sdp_);
|
LOG_INFO("Generate local sdp:[\n{}]", local_sdp_);
|
||||||
|
|
||||||
return local_sdp_;
|
return local_sdp_;
|
||||||
}
|
}
|
||||||
@@ -220,6 +233,7 @@ int IceAgent::Send(const char *data, size_t size) {
|
|||||||
|
|
||||||
if (NiceComponentState::NICE_COMPONENT_STATE_READY !=
|
if (NiceComponentState::NICE_COMPONENT_STATE_READY !=
|
||||||
nice_agent_get_component_state(agent_, stream_id_, 1)) {
|
nice_agent_get_component_state(agent_, stream_id_, 1)) {
|
||||||
|
LOG_ERROR("Nice agent not ready");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class IceAgent {
|
|||||||
char* local_sdp_ = nullptr;
|
char* local_sdp_ = nullptr;
|
||||||
NiceComponentState state_ = NiceComponentState::NICE_COMPONENT_STATE_LAST;
|
NiceComponentState state_ = NiceComponentState::NICE_COMPONENT_STATE_LAST;
|
||||||
bool destroyed_ = false;
|
bool destroyed_ = false;
|
||||||
|
gboolean agent_closed_ = false;
|
||||||
|
|
||||||
nice_cb_state_changed_t on_state_changed_;
|
nice_cb_state_changed_t on_state_changed_;
|
||||||
nice_cb_candidate_t on_candidate_;
|
nice_cb_candidate_t on_candidate_;
|
||||||
|
|||||||
Reference in New Issue
Block a user