Commit ea8b62f9 authored by Dafydd Harries's avatar Dafydd Harries

make nice_agent_get_local_candidates take stream/component ID and return a new list

darcs-hash:20070213170047-c9803-265bf06c9e14f97cfbc4f45c21068a0ba267d962.gz
parent f136ef1b
...@@ -1053,16 +1053,30 @@ nice_agent_set_stun_server (NiceAddress *addr, guint16 port) ...@@ -1053,16 +1053,30 @@ nice_agent_set_stun_server (NiceAddress *addr, guint16 port)
* nice_agent_get_local_candidates: * nice_agent_get_local_candidates:
* @agent: A NiceAgent * @agent: A NiceAgent
* *
* The caller does not own the returned GSList or the candidates contained * The caller owns the returned GSList but not the candidates contained within
* within it. * it.
* *
* Returns: a GSList of local candidates belonging to @agent * Returns: a GSList of local candidates belonging to @agent
**/ **/
const GSList * GSList *
nice_agent_get_local_candidates ( nice_agent_get_local_candidates (
NiceAgent *agent) NiceAgent *agent,
guint stream_id,
guint component_id)
{ {
return agent->local_candidates; GSList *candidates = NULL;
GSList *i;
for (i = agent->local_candidates; i; i = i->next)
{
NiceCandidate *candidate = i->data;
if (candidate->stream_id == stream_id &&
candidate->component_id == component_id)
candidates = g_slist_append (candidates, candidate);
}
return candidates;
} }
......
...@@ -119,9 +119,11 @@ nice_agent_send ( ...@@ -119,9 +119,11 @@ nice_agent_send (
guint len, guint len,
const gchar *buf); const gchar *buf);
const GSList * GSList *
nice_agent_get_local_candidates ( nice_agent_get_local_candidates (
NiceAgent *agent); NiceAgent *agent,
guint stream_id,
guint component_id);
gboolean gboolean
nice_agent_main_context_attach ( nice_agent_main_context_attach (
......
...@@ -119,7 +119,7 @@ main (gint argc, gchar *argv[]) ...@@ -119,7 +119,7 @@ main (gint argc, gchar *argv[])
{ {
NiceCandidate *candidate; NiceCandidate *candidate;
candidate = nice_agent_get_local_candidates (agent)->data; candidate = agent->local_candidates->data;
len = g_snprintf (buf, 1024, "0 0 X1 127.0.0.1 %d %s %s", len = g_snprintf (buf, 1024, "0 0 X1 127.0.0.1 %d %s %s",
candidate->addr.port, candidate->username, candidate->password); candidate->addr.port, candidate->username, candidate->password);
nice_udp_socket_send (&sock, &send_addr, len, buf); nice_udp_socket_send (&sock, &send_addr, len, buf);
......
...@@ -93,7 +93,7 @@ handle_connection (guint fileno, const struct sockaddr_in *sin, gpointer data) ...@@ -93,7 +93,7 @@ handle_connection (guint fileno, const struct sockaddr_in *sin, gpointer data)
/* send first local candidate to remote end */ /* send first local candidate to remote end */
candidate_str = nice_candidate_to_string ( candidate_str = nice_candidate_to_string (
nice_agent_get_local_candidates (agent)->data); agent->local_candidates->data);
send (fileno, candidate_str, strlen (candidate_str), 0); send (fileno, candidate_str, strlen (candidate_str), 0);
send (fileno, "\n", 1, 0); send (fileno, "\n", 1, 0);
g_free (candidate_str); g_free (candidate_str);
......
...@@ -89,7 +89,7 @@ accept_connection ( ...@@ -89,7 +89,7 @@ accept_connection (
{ {
NiceCandidate *candidate; NiceCandidate *candidate;
candidate = nice_agent_get_local_candidates (agent)->data; candidate = agent->local_candidates->data;
len = g_snprintf (buf, 1024, "0 0 X1 127.0.0.1 %d %s %s", len = g_snprintf (buf, 1024, "0 0 X1 127.0.0.1 %d %s %s",
candidate->addr.port, candidate->username, candidate->password); candidate->addr.port, candidate->username, candidate->password);
nice_udp_socket_send (sock, &send_addr, len, buf); nice_udp_socket_send (sock, &send_addr, len, buf);
......
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