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

agent: Factor out creating the TurnServer structure

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