Commit 2a07eb44 authored by Olivier Crete's avatar Olivier Crete
Browse files

Port test to use NiceCandidate

darcs-hash:20080426004621-3e2dc-1866ce52eb9ba0e2fb3c5560034e289d6b024e3e.gz
parent 1baed290
......@@ -885,7 +885,7 @@ static gboolean priv_add_remote_candidate (
guint component_id,
NiceCandidateType type,
const NiceAddress *addr,
const NiceAddress *related_addr,
const NiceAddress *base_addr,
NiceCandidateTransport transport,
guint32 priority,
const gchar *username,
......@@ -906,8 +906,8 @@ static gboolean priv_add_remote_candidate (
g_debug("Update existing remote candidate %p.", candidate);
/* case 1: an existing candidate, update the attributes */
candidate->type = type;
if (related_addr)
candidate->base_addr = *related_addr;
if (base_addr)
candidate->base_addr = *base_addr;
candidate->priority = priority;
if (foundation)
strncpy(candidate->foundation, foundation, NICE_CANDIDATE_MAX_FOUNDATION);
......@@ -944,8 +944,8 @@ static gboolean priv_add_remote_candidate (
}
#endif
if (related_addr)
candidate->base_addr = *related_addr;
if (base_addr)
candidate->base_addr = *base_addr;
candidate->transport = transport;
candidate->priority = priority;
......@@ -1119,7 +1119,7 @@ nice_agent_add_remote_candidate (
* @agent: a NiceAgent
* @stream_id: the ID of the stream the candidate is for
* @component_id: the ID of the component the candidate is for
* @candidates: a list of NiceCandidateDesc items describing the candidates
* @candidates: a list of NiceCandidate items describing the candidates
*
* Sets the remote candidates for a component of a stream. Replaces
* any existing remote candidates.
......@@ -1143,18 +1143,18 @@ nice_agent_set_remote_candidates (NiceAgent *agent, guint stream_id, guint compo
g_mutex_lock (agent->mutex);
for (i = candidates; i && added >= 0; i = i->next) {
NiceCandidateDesc *d = (NiceCandidateDesc*) i->data;
NiceCandidate *d = (NiceCandidate*) i->data;
gboolean res =
priv_add_remote_candidate (agent,
stream_id,
component_id,
d->type,
d->addr,
d->related_addr,
&d->addr,
&d->base_addr,
d->transport,
d->priority,
NULL,
NULL,
d->username,
d->password,
d->foundation);
if (res)
++added;
......@@ -1591,9 +1591,6 @@ nice_agent_get_remote_candidates (
goto done;
}
/* XXX: should we expose NiceCandidate to the client, or should
* we instead return a list of NiceCandidateDesc's? */
ret = g_slist_copy (component->remote_candidates);
done:
......
......@@ -104,18 +104,6 @@ typedef enum
NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_MSN
} NiceCompatibility;
typedef struct _NiceCandidateDesc NiceCandidateDesc;
struct _NiceCandidateDesc {
gchar *foundation; /**< 1*32ice-char (NICE_CANDIDATE_MAX_FOUNDATION-1) */
guint component_id; /**< value between 1 and 256, inclusive */
NiceCandidateTransport transport;
guint32 priority; /**< value between 1 and (2**31 - 1), inclusive */
NiceAddress *addr;
NiceCandidateType type;
NiceAddress *related_addr; /**< optional */
};
typedef struct _NiceAgent NiceAgent;
typedef void (*NiceAgentRecvFunc) (
......
......@@ -199,20 +199,16 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *baseaddr)
{
NiceAddress laddr, raddr, laddr_rtcp, raddr_rtcp;
NiceCandidateDesc cdes = { /* candidate description (no ports) */
(gchar *)"1", /* foundation */
0, /* component-id; filled later */
NICE_CANDIDATE_TRANSPORT_UDP, /* transport */
100000, /* priority */
NULL, /* address */
NICE_CANDIDATE_TYPE_HOST, /* type */
baseaddr /* base-address */
};
NiceCandidate cdes;
GSList *cands;
guint ls_id, rs_id;
/* XXX: dear compiler, these are for you: */
(void)baseaddr;
memset (&cdes, 0, sizeof(NiceCandidate));
cdes.priority = 100000;
strcpy (cdes.foundation, "1");
cdes.type = NICE_CANDIDATE_TYPE_HOST;
cdes.transport = NICE_CANDIDATE_TRANSPORT_UDP;
cdes.base_addr = *baseaddr;
/* step: initialize variables modified by the callbacks */
global_components_ready = 0;
......@@ -278,14 +274,14 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress
cands = g_slist_append (NULL, &cdes);
cdes.component_id = NICE_COMPONENT_TYPE_RTP;
cdes.addr = &raddr;
cdes.addr = raddr;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.addr = &laddr;
cdes.addr = laddr;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.component_id = NICE_COMPONENT_TYPE_RTCP;
cdes.addr = &raddr_rtcp;
cdes.addr = raddr_rtcp;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands);
cdes.addr = &laddr_rtcp;
cdes.addr = laddr_rtcp;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands);
/* step: fall back to non-ICE mode on both sides */
......
......@@ -198,21 +198,27 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
g_slist_free (cands);
}
static void init_candidate (NiceCandidate *cand)
{
memset (cand, 0, sizeof(NiceCandidate));
cand->priority = 10000;
strcpy (cand->foundation, "1");
cand->type = NICE_CANDIDATE_TYPE_HOST;
cand->transport = NICE_CANDIDATE_TRANSPORT_UDP;
}
static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *baseaddr, guint ready, guint failed)
{
NiceAddress laddr, raddr, laddr_rtcp, raddr_rtcp;
NiceCandidateDesc cdes = { /* candidate description (no ports) */
(gchar *)"1", /* foundation */
0, /* component-id; filled later */
NICE_CANDIDATE_TRANSPORT_UDP, /* transport */
100000, /* priority */
NULL, /* address */
NICE_CANDIDATE_TYPE_HOST, /* type */
NULL /* base-address */
};
NiceCandidate cdes;
GSList *cands;
guint ls_id, rs_id;
init_candidate (&cdes);
/* XXX: dear compiler, this is for you */
(void)baseaddr;
......@@ -287,14 +293,14 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
ls_id, ufrag, password);
}
cdes.component_id = NICE_COMPONENT_TYPE_RTP;
cdes.addr = &raddr;
cdes.addr = raddr;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.addr = &laddr;
cdes.addr = laddr;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.component_id = NICE_COMPONENT_TYPE_RTCP;
cdes.addr = &raddr_rtcp;
cdes.addr = raddr_rtcp;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands);
cdes.addr = &laddr_rtcp;
cdes.addr = laddr_rtcp;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands);
g_slist_free (cands);
......@@ -333,18 +339,12 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *baseaddr, guint ready, guint failed)
{
NiceAddress laddr, raddr, laddr_rtcp, raddr_rtcp;
NiceCandidateDesc cdes = { /* candidate description (no ports) */
(gchar *)"1", /* foundation */
0, /* component-id; filled later */
NICE_CANDIDATE_TRANSPORT_UDP, /* transport */
100000, /* priority */
NULL, /* address */
NICE_CANDIDATE_TYPE_HOST, /* type */
NULL /* base-address */
};
NiceCandidate cdes;
GSList *cands;
guint ls_id, rs_id;
init_candidate (&cdes);
/* XXX: dear compiler, this is for you */
(void)baseaddr;
......@@ -418,10 +418,10 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N
/* step: set remote candidates for agent R (answering party) */
cands = g_slist_append (NULL, &cdes);
cdes.component_id = NICE_COMPONENT_TYPE_RTP;
cdes.addr = &laddr;
cdes.addr = laddr;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.component_id = NICE_COMPONENT_TYPE_RTCP;
cdes.addr = &laddr_rtcp;
cdes.addr = laddr_rtcp;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands);
g_debug ("test-fullmode: Set properties, next running mainloop until first check is received...");
......@@ -445,10 +445,10 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N
/* step: pass remove candidates to agent L (offering party) */
cdes.component_id = NICE_COMPONENT_TYPE_RTP;
cdes.addr = &raddr;
cdes.addr = raddr;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.component_id = NICE_COMPONENT_TYPE_RTCP;
cdes.addr = &raddr_rtcp;
cdes.addr = raddr_rtcp;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands);
g_debug ("test-fullmode: Running mainloop until connectivity checks succeeed.");
......@@ -478,18 +478,12 @@ static int run_full_test_delayed_answer (NiceAgent *lagent, NiceAgent *ragent, N
static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *baseaddr)
{
NiceAddress laddr, raddr;
NiceCandidateDesc cdes = { /* candidate description (no ports) */
(gchar *)"1", /* foundation */
NICE_COMPONENT_TYPE_RTP,
NICE_CANDIDATE_TRANSPORT_UDP, /* transport */
100000, /* priority */
NULL, /* address */
NICE_CANDIDATE_TYPE_HOST, /* type */
NULL /* base-address */
};
NiceCandidate cdes;
GSList *cands, *i;
guint ls_id, rs_id;
init_candidate (&cdes);
/* XXX: dear compiler, this is for you */
(void)baseaddr;
......@@ -565,9 +559,9 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N
nice_agent_set_remote_credentials (lagent,
ls_id, ufrag, "wrong2");
}
cdes.addr = &raddr;
cdes.addr = raddr;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.addr = &laddr;
cdes.addr = laddr;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
g_slist_free (cands);
......@@ -594,18 +588,12 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N
static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *baseaddr, gboolean role)
{
NiceAddress laddr, raddr;
NiceCandidateDesc cdes = { /* candidate description (no ports) */
(gchar *)"1", /* foundation */
NICE_COMPONENT_TYPE_RTP,
NICE_CANDIDATE_TRANSPORT_UDP, /* transport */
100000, /* priority */
NULL, /* address */
NICE_CANDIDATE_TYPE_HOST, /* type */
NULL /* base-address */
};
NiceCandidate cdes;
GSList *cands, *i;
guint ls_id, rs_id;
init_candidate (&cdes);
/* XXX: dear compiler, this is for you */
(void)baseaddr;
......@@ -680,9 +668,9 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent,
nice_agent_set_remote_credentials (lagent,
ls_id, ufrag, password);
}
cdes.addr = &raddr;
cdes.addr = raddr;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.addr = &laddr;
cdes.addr = laddr;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
g_slist_free (cands);
......
......@@ -195,15 +195,7 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *baseaddr)
{
NiceAddress laddr, raddr, laddr_rtcp, raddr_rtcp;
NiceCandidateDesc cdes = { /* candidate description (no ports) */
(gchar *)"1", /* foundation */
0, /* component-id; filled later */
NICE_CANDIDATE_TRANSPORT_UDP, /* transport */
100000, /* priority */
NULL, /* address */
NICE_CANDIDATE_TYPE_HOST, /* type */
NULL /* base-address */
};
NiceCandidate cdes;
GSList *cands;
guint ls_id, rs_id;
guint64 tie_breaker;
......@@ -211,6 +203,12 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
/* XXX: dear compiler, these are for you: */
(void)baseaddr;
memset (&cdes, 0, sizeof(NiceCandidate));
cdes.priority = 10000;
strcpy (cdes.foundation, "1");
cdes.type = NICE_CANDIDATE_TYPE_HOST;
cdes.transport = NICE_CANDIDATE_TRANSPORT_UDP;
/* step: initialize variables modified by the callbacks */
global_components_ready = 0;
global_components_ready_exit = 4;
......@@ -284,14 +282,14 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
ls_id, ufrag, password);
}
cdes.component_id = NICE_COMPONENT_TYPE_RTP;
cdes.addr = &raddr;
cdes.addr = raddr;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.addr = &laddr;
cdes.addr = laddr;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.component_id = NICE_COMPONENT_TYPE_RTCP;
cdes.addr = &raddr_rtcp;
cdes.addr = raddr_rtcp;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands);
cdes.addr = &laddr_rtcp;
cdes.addr = laddr_rtcp;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands);
g_debug ("test-restart: Set properties, next running mainloop until connectivity checks succeed...");
......@@ -347,14 +345,14 @@ static int run_restart_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *
/* step: exchange remote candidates */
cdes.component_id = NICE_COMPONENT_TYPE_RTP;
cdes.addr = &raddr;
cdes.addr = raddr;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.addr = &laddr;
cdes.addr = laddr;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
cdes.component_id = NICE_COMPONENT_TYPE_RTCP;
cdes.addr = &raddr_rtcp;
cdes.addr = raddr_rtcp;
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands);
cdes.addr = &laddr_rtcp;
cdes.addr = laddr_rtcp;
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands);
g_main_loop_run (global_mainloop);
......
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