Commit 71b744eb authored by Olivier Crête's avatar Olivier Crête 👻

agent: Remove useless checks and simplify error handling in priv_add_remote_candidate

parent 62991736
......@@ -1907,7 +1907,6 @@ static gboolean priv_add_remote_candidate (
{
Component *component;
NiceCandidate *candidate;
gboolean error_flag = FALSE;
if (!agent_find_component (agent, stream_id, component_id, NULL, &component))
return FALSE;
......@@ -1950,58 +1949,53 @@ static gboolean priv_add_remote_candidate (
candidate->password = g_strdup (password);
}
if (conn_check_add_for_candidate (agent, stream_id, component, candidate) < 0)
error_flag = TRUE;
goto errors;
}
else {
/* case 2: add a new candidate */
candidate = nice_candidate_new (type);
if (candidate) {
component->remote_candidates = g_slist_append (component->remote_candidates,
candidate);
candidate->stream_id = stream_id;
candidate->component_id = component_id;
candidate->type = type;
if (addr)
candidate->addr = *addr;
{
gchar tmpbuf[INET6_ADDRSTRLEN] = {0};
if(addr)
nice_address_to_string (addr, tmpbuf);
nice_debug ("Agent %p : Adding remote candidate with addr [%s]:%u"
" for s%d/c%d. U/P '%s'/'%s' prio: %u", agent, tmpbuf,
addr? nice_address_get_port (addr) : 0, stream_id, component_id,
username, password, priority);
}
if (base_addr)
candidate->base_addr = *base_addr;
component->remote_candidates = g_slist_append (component->remote_candidates,
candidate);
candidate->transport = transport;
candidate->priority = priority;
candidate->username = g_strdup (username);
candidate->password = g_strdup (password);
candidate->stream_id = stream_id;
candidate->component_id = component_id;
if (foundation)
g_strlcpy (candidate->foundation, foundation,
NICE_CANDIDATE_MAX_FOUNDATION);
candidate->type = type;
if (addr)
candidate->addr = *addr;
if (conn_check_add_for_candidate (agent, stream_id, component, candidate) < 0)
error_flag = TRUE;
{
gchar tmpbuf[INET6_ADDRSTRLEN] = {0};
if(addr)
nice_address_to_string (addr, tmpbuf);
nice_debug ("Agent %p : Adding remote candidate with addr [%s]:%u"
" for s%d/c%d. U/P '%s'/'%s' prio: %u", agent, tmpbuf,
addr? nice_address_get_port (addr) : 0, stream_id, component_id,
username, password, priority);
}
else /* memory alloc error: candidate creation */
error_flag = TRUE;
}
if (error_flag) {
if (candidate)
nice_candidate_free (candidate);
return FALSE;
if (base_addr)
candidate->base_addr = *base_addr;
candidate->transport = transport;
candidate->priority = priority;
candidate->username = g_strdup (username);
candidate->password = g_strdup (password);
if (foundation)
g_strlcpy (candidate->foundation, foundation,
NICE_CANDIDATE_MAX_FOUNDATION);
if (conn_check_add_for_candidate (agent, stream_id, component, candidate) < 0)
goto errors;
}
return TRUE;
errors:
nice_candidate_free (candidate);
return FALSE;
}
NICEAPI_EXPORT gboolean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment