Commit 73c24910 authored by Dafydd Harries's avatar Dafydd Harries
Browse files

implement ice_agent_add_remote_candidate

darcs-hash:20070110160508-c9803-d49e47bb68b69a17f425f54082b6259a5f3da9e1.gz
parent f3f89f98
......@@ -464,10 +464,26 @@ ice_agent_add_local_address (Agent *agent, Address *addr)
void
ice_agent_add_remote_candidate (Agent *a, Candidate *c)
ice_agent_add_remote_candidate (
Agent *agent,
CandidateType type,
Address *addr,
guint port)
{
/* append to agent->remote_candidates */
/* for each component, generate a new check with the new candidate */
Candidate *candidate;
candidate = candidate_new (type);
/* do remote candidates need IDs? */
candidate->id = 0;
candidate->addr = address_dup (addr);
candidate->port = port;
agent->remote_candidates = g_slist_append (agent->remote_candidates,
candidate);
/* later: for each component, generate a new check with the new candidate */
}
......@@ -514,7 +530,6 @@ ice_agent_free (Agent *agent)
g_slist_free (agent->local_candidates);
agent->local_candidates = NULL;
/*
for (i = agent->remote_candidates; i; i = i->next)
{
Candidate *c = (Candidate *) i->data;
......@@ -524,7 +539,6 @@ ice_agent_free (Agent *agent)
g_slist_free (agent->remote_candidates);
agent->remote_candidates = NULL;
*/
for (i = agent->streams; i; i = i->next)
{
......
......@@ -105,6 +105,7 @@ struct _agent
guint next_candidate_id;
GSList *local_addresses;
GSList *local_candidates;
GSList *remote_candidates;
GSList *streams;
GSList *events;
};
......@@ -122,7 +123,12 @@ void
ice_agent_set_candidate_port (Agent *agent, guint candidate_id, guint port);
void
ice_agent_free (Agent *agent);
void
ice_agent_add_remote_candidate (
Agent *agent,
CandidateType type,
Address *addr,
guint port);
#endif /* _AGENT_H */
......@@ -7,10 +7,13 @@ gint
main (void)
{
Agent *agent;
Address *addr;
Address *addr_local, *addr_remote;
Candidate *candidate;
Event *event;
addr_local = address_new_ipv4_from_string ("192.168.0.1");
addr_remote = address_new_ipv4_from_string ("192.168.0.2");
agent = ice_agent_new ();
g_assert (agent->local_addresses == NULL);
......@@ -18,12 +21,12 @@ main (void)
g_assert (ice_agent_pop_event (agent) == NULL);
/* add one local address */
addr = address_new_ipv4_from_string ("192.168.0.1");
ice_agent_add_local_address (agent, addr);
ice_agent_add_local_address (agent, addr_local);
g_assert (agent->local_addresses != NULL);
g_assert (g_slist_length (agent->local_addresses) == 1);
g_assert (address_equal ((Address *) agent->local_addresses->data, addr));
g_assert (address_equal ((Address *) agent->local_addresses->data,
addr_local));
/* no candidates should be generated until we have a stream */
g_assert (agent->local_candidates == NULL);
......@@ -35,6 +38,7 @@ main (void)
g_assert (agent->local_candidates != NULL);
g_assert (g_slist_length (agent->local_candidates) == 1);
candidate = (Candidate *) agent->local_candidates->data;
g_assert (address_equal (candidate->addr, addr_local));
g_assert (candidate->id == 1);
g_assert (candidate->port == 0);
......@@ -43,7 +47,7 @@ main (void)
g_assert (ice_agent_pop_event (agent) == NULL);
g_assert (event != NULL);
g_assert (event->type == EVENT_REQUEST_PORT);
g_assert (address_equal (event->request_port.addr, addr));
g_assert (address_equal (event->request_port.addr, addr_local));
g_assert (event->request_port.candidate_id == 1);
event_free (event);
......@@ -59,10 +63,18 @@ main (void)
event_free (event);
/* add remote candidate */
ice_agent_add_remote_candidate (agent, CANDIDATE_TYPE_HOST, addr_remote,
2345);
g_assert (agent->remote_candidates != NULL);
g_assert (g_slist_length (agent->remote_candidates) == 1);
candidate = (Candidate *) agent->remote_candidates->data;
g_assert (address_equal (candidate->addr, addr_remote));
g_assert (candidate->port == 2345);
/* check there's no unexpected events, and clean up */
g_assert (ice_agent_pop_event (agent) == NULL);
address_free (addr);
address_free (addr_local);
address_free (addr_remote);
ice_agent_free (agent);
return 0;
}
......
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