Commit 100a31fc authored by Olivier Crête's avatar Olivier Crête
Browse files

agent: Factor out creating the TurnServer structure

parent 59a23cfe
......@@ -1930,22 +1930,13 @@ nice_agent_set_relay_info(NiceAgent *agent,
goto done;
}
turn = g_slice_new0 (TurnServer);
turn = turn_server_new (server_ip, server_port, username, password, type);
nice_address_init (&turn->server);
if (nice_address_set_from_string (&turn->server, server_ip)) {
nice_address_set_port (&turn->server, server_port);
} else {
g_slice_free (TurnServer, turn);
if (!turn) {
ret = FALSE;
goto done;
}
turn->username = g_strdup (username);
turn->password = g_strdup (password);
turn->type = type;
nice_debug ("Agent %p: added relay server [%s]:%d of type %d to s/c %d/%d "
"with user/pass : %s -- %s", agent, server_ip, server_port, type,
stream_id, component_id, username, password);
......
......@@ -1070,3 +1070,25 @@ component_input_source_new (NiceAgent *agent, guint stream_id,
return (GSource *) component_source;
}
TurnServer *
turn_server_new (const gchar *server_ip, guint server_port,
const gchar *username, const gchar *password, NiceRelayType type)
{
TurnServer *turn = g_slice_new (TurnServer);
nice_address_init (&turn->server);
if (nice_address_set_from_string (&turn->server, server_ip)) {
nice_address_set_port (&turn->server, server_port);
} else {
g_slice_free (TurnServer, turn);
return NULL;
}
turn->username = g_strdup (username);
turn->password = g_strdup (password);
turn->type = type;
return turn;
}
......@@ -260,6 +260,11 @@ component_has_io_callback (Component *component);
void
component_clean_turn_servers (Component *component);
TurnServer *
turn_server_new (const gchar *server_ip, guint server_port,
const gchar *username, const gchar *password, NiceRelayType type);
G_END_DECLS
#endif /* _NICE_COMPONENT_H */
......
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