Commit 6dda75c7 authored by Youness Alaoui's avatar Youness Alaoui

Merge remote-tracking branch 'shadeslayer/dribble_mode'

parents 428f7028 ebc7313f
...@@ -130,6 +130,7 @@ tests/test-priority ...@@ -130,6 +130,7 @@ tests/test-priority
tests/test-pseudotcp tests/test-pseudotcp
tests/test-restart tests/test-restart
tests/test-thread tests/test-thread
tests/test-new-dribble
docs/reference/libnice/libnice*.txt docs/reference/libnice/libnice*.txt
docs/reference/libnice/libnice.args docs/reference/libnice/libnice.args
......
...@@ -2220,12 +2220,6 @@ nice_agent_set_remote_candidates (NiceAgent *agent, guint stream_id, guint compo ...@@ -2220,12 +2220,6 @@ nice_agent_set_remote_candidates (NiceAgent *agent, guint stream_id, guint compo
goto done; goto done;
} }
if (stream->gathering) {
nice_debug ("Agent %p: Remote candidates refused for stream %d because "
"we are still gathering our own candidates", agent, stream_id);
added = -1;
goto done;
}
if (agent->reliable && component->tcp == NULL) { if (agent->reliable && component->tcp == NULL) {
nice_debug ("Agent %p: not setting remote candidate for s%d:%d because " nice_debug ("Agent %p: not setting remote candidate for s%d:%d because "
......
...@@ -505,6 +505,12 @@ nice_agent_get_local_credentials ( ...@@ -505,6 +505,12 @@ nice_agent_get_local_credentials (
#NiceAgent::candidate-gathering-done signale before #NiceAgent::candidate-gathering-done signale before
calling nice_agent_set_remote_candidates() calling nice_agent_set_remote_candidates()
</para> </para>
<para>
Since 0.1.3, there is no need to wait for the candidate-gathering-done signal.
Remote candidates can be set even while gathering local candidates.
Newly discovered local candidates will automatically be paired with
existing remote candidates.
</para>
</note> </note>
* *
* Returns: The number of candidates added, negative on errors (memory allocation * Returns: The number of candidates added, negative on errors (memory allocation
......
...@@ -1286,6 +1286,40 @@ static void priv_add_new_check_pair (NiceAgent *agent, guint stream_id, Componen ...@@ -1286,6 +1286,40 @@ static void priv_add_new_check_pair (NiceAgent *agent, guint stream_id, Componen
} }
} }
static gboolean priv_conn_check_add_for_candidate_pair (NiceAgent *agent, guint stream_id, Component *component, NiceCandidate *local, NiceCandidate *remote)
{
gboolean ret = FALSE;
/* note: do not create pairs where the local candidate is
* a srv-reflexive (ICE 5.7.3. "Pruning the pairs" ID-9) */
if ((agent->compatibility == NICE_COMPATIBILITY_RFC5245 ||
agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
local->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE) {
return FALSE;
}
/* note: match pairs only if transport and address family are the same */
if (local->transport == remote->transport &&
local->addr.s.addr.sa_family == remote->addr.s.addr.sa_family) {
priv_add_new_check_pair (agent, stream_id, component, local, remote, NICE_CHECK_FROZEN, FALSE);
ret = TRUE;
if (component->state < NICE_COMPONENT_STATE_CONNECTED) {
agent_signal_component_state_change (agent,
stream_id,
component->id,
NICE_COMPONENT_STATE_CONNECTING);
} else {
agent_signal_component_state_change (agent,
stream_id,
component->id,
NICE_COMPONENT_STATE_CONNECTED);
}
}
return ret;
}
/* /*
* Forms new candidate pairs by matching the new remote candidate * Forms new candidate pairs by matching the new remote candidate
* 'remote_cand' with all existing local candidates of 'component'. * 'remote_cand' with all existing local candidates of 'component'.
...@@ -1302,36 +1336,44 @@ int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, Component * ...@@ -1302,36 +1336,44 @@ int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, Component *
{ {
GSList *i; GSList *i;
int added = 0; int added = 0;
int ret = 0;
for (i = component->local_candidates; i ; i = i->next) { for (i = component->local_candidates; i ; i = i->next) {
NiceCandidate *local = i->data; NiceCandidate *local = i->data;
ret = priv_conn_check_add_for_candidate_pair (agent, stream_id, component, local, remote);
/* note: match pairs only if transport and address family are the same */ if (ret) {
if (local->transport == remote->transport && ++added;
local->addr.s.addr.sa_family == remote->addr.s.addr.sa_family) { }
}
/* note: do not create pairs where local candidate is return added;
* a srv-reflexive (ICE 5.7.3. "Pruning the Pairs" ID-19) */ }
if ((agent->compatibility == NICE_COMPATIBILITY_RFC5245 ||
agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
local->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE)
continue;
priv_add_new_check_pair (agent, stream_id, component, local, remote, NICE_CHECK_FROZEN, FALSE); /*
* Forms new candidate pairs by matching the new local candidate
* 'local_cand' with all existing remote candidates of 'component'.
*
* @param agent context
* @param component pointer to the component
* @param local local candidate to match with
*
* @return number of checks added, negative on fatal errors
*/
int conn_check_add_for_local_candidate (NiceAgent *agent, guint stream_id, Component *component, NiceCandidate *local)
{
GSList *i;
int added = 0;
int ret = 0;
for (i = component->remote_candidates; i ; i = i->next) {
NiceCandidate *remote = i->data;
ret = priv_conn_check_add_for_candidate_pair (agent, stream_id, component, local, remote);
if (ret) {
++added; ++added;
if (component->state < NICE_COMPONENT_STATE_CONNECTED) {
agent_signal_component_state_change (agent,
stream_id,
component->id,
NICE_COMPONENT_STATE_CONNECTING);
} else {
agent_signal_component_state_change (agent,
stream_id,
component->id,
NICE_COMPONENT_STATE_CONNECTED);
}
} }
} }
......
...@@ -82,6 +82,7 @@ struct _CandidateCheckPair ...@@ -82,6 +82,7 @@ struct _CandidateCheckPair
}; };
int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, Component *component, NiceCandidate *remote); int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, Component *component, NiceCandidate *remote);
int conn_check_add_for_local_candidate (NiceAgent *agent, guint stream_id, Component *component, NiceCandidate *local);
void conn_check_free_item (gpointer data, gpointer user_data); void conn_check_free_item (gpointer data, gpointer user_data);
void conn_check_free (NiceAgent *agent); void conn_check_free (NiceAgent *agent);
gboolean conn_check_schedule_next (NiceAgent *agent); gboolean conn_check_schedule_next (NiceAgent *agent);
......
...@@ -247,7 +247,7 @@ void refresh_cancel (CandidateRefresh *refresh) ...@@ -247,7 +247,7 @@ void refresh_cancel (CandidateRefresh *refresh)
* defined in ICE spec section 4.1.3 "Eliminating Redundant * defined in ICE spec section 4.1.3 "Eliminating Redundant
* Candidates" (ID-19). * Candidates" (ID-19).
*/ */
static gboolean priv_add_local_candidate_pruned (Component *component, NiceCandidate *candidate) static gboolean priv_add_local_candidate_pruned (NiceAgent *agent, guint stream_id, Component *component, NiceCandidate *candidate)
{ {
GSList *i; GSList *i;
...@@ -263,6 +263,7 @@ static gboolean priv_add_local_candidate_pruned (Component *component, NiceCandi ...@@ -263,6 +263,7 @@ static gboolean priv_add_local_candidate_pruned (Component *component, NiceCandi
component->local_candidates = g_slist_append (component->local_candidates, component->local_candidates = g_slist_append (component->local_candidates,
candidate); candidate);
conn_check_add_for_local_candidate(agent, stream_id, component, candidate);
return TRUE; return TRUE;
} }
...@@ -489,7 +490,7 @@ NiceCandidate *discovery_add_local_host_candidate ( ...@@ -489,7 +490,7 @@ NiceCandidate *discovery_add_local_host_candidate (
candidate->addr = udp_socket->addr; candidate->addr = udp_socket->addr;
candidate->base_addr = udp_socket->addr; candidate->base_addr = udp_socket->addr;
if (!priv_add_local_candidate_pruned (component, candidate)) if (!priv_add_local_candidate_pruned (agent, stream_id, component, candidate))
goto errors; goto errors;
component->sockets = g_slist_append (component->sockets, udp_socket); component->sockets = g_slist_append (component->sockets, udp_socket);
...@@ -547,7 +548,7 @@ discovery_add_server_reflexive_candidate ( ...@@ -547,7 +548,7 @@ discovery_add_server_reflexive_candidate (
priv_generate_candidate_credentials (agent, candidate); priv_generate_candidate_credentials (agent, candidate);
priv_assign_foundation (agent, candidate); priv_assign_foundation (agent, candidate);
result = priv_add_local_candidate_pruned (component, candidate); result = priv_add_local_candidate_pruned (agent, stream_id, component, candidate);
if (result) { if (result) {
agent_signal_new_candidate (agent, candidate); agent_signal_new_candidate (agent, candidate);
} }
...@@ -620,7 +621,7 @@ discovery_add_relay_candidate ( ...@@ -620,7 +621,7 @@ discovery_add_relay_candidate (
priv_assign_foundation (agent, candidate); priv_assign_foundation (agent, candidate);
if (!priv_add_local_candidate_pruned (component, candidate)) if (!priv_add_local_candidate_pruned (agent, stream_id, component, candidate))
goto errors; goto errors;
component->sockets = g_slist_append (component->sockets, relay_socket); component->sockets = g_slist_append (component->sockets, relay_socket);
...@@ -715,9 +716,9 @@ discovery_add_peer_reflexive_candidate ( ...@@ -715,9 +716,9 @@ discovery_add_peer_reflexive_candidate (
candidate->sockptr = base_socket; candidate->sockptr = base_socket;
candidate->base_addr = base_socket->addr; candidate->base_addr = base_socket->addr;
result = priv_add_local_candidate_pruned (component, candidate); result = priv_add_local_candidate_pruned (agent, stream_id, component, candidate);
if (result != TRUE) { if (result != TRUE) {
/* error: memory allocation, or duplicate candidatet */ /* error: memory allocation, or duplicate candidate */
nice_candidate_free (candidate), candidate = NULL; nice_candidate_free (candidate), candidate = NULL;
} }
......
...@@ -368,7 +368,7 @@ static void test_attribute (void) ...@@ -368,7 +368,7 @@ static void test_attribute (void)
StunMessage msg; StunMessage msg;
uint16_t known_attributes[] = {STUN_ATTRIBUTE_MESSAGE_INTEGRITY, STUN_ATTRIBUTE_USERNAME, 0}; uint16_t known_attributes[] = {STUN_ATTRIBUTE_MESSAGE_INTEGRITY, STUN_ATTRIBUTE_USERNAME, 0};
printf ("Attribute test message length: %u\n", sizeof (acme)); printf ("Attribute test message length: %lu\n", sizeof (acme));
stun_agent_init (&agent, known_attributes, stun_agent_init (&agent, known_attributes,
STUN_COMPATIBILITY_RFC5389, STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS); STUN_COMPATIBILITY_RFC5389, STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS);
......
...@@ -32,7 +32,8 @@ check_PROGRAMS = \ ...@@ -32,7 +32,8 @@ check_PROGRAMS = \
test-restart \ test-restart \
test-fallback \ test-fallback \
test-thread \ test-thread \
test-dribble test-dribble \
test-new-dribble
dist_check_SCRIPTS = \ dist_check_SCRIPTS = \
check-test-fullmode-with-stun.sh \ check-test-fullmode-with-stun.sh \
...@@ -64,6 +65,8 @@ test_fallback_LDADD = $(COMMON_LDADD) ...@@ -64,6 +65,8 @@ test_fallback_LDADD = $(COMMON_LDADD)
test_dribble_LDADD = $(COMMON_LDADD) test_dribble_LDADD = $(COMMON_LDADD)
test_new_dribble_LDADD = $(COMMON_LDADD)
all-local: all-local:
chmod a+x $(srcdir)/check-test-fullmode-with-stun.sh chmod a+x $(srcdir)/check-test-fullmode-with-stun.sh
chmod a+x $(srcdir)/test-pseudotcp-random.sh chmod a+x $(srcdir)/test-pseudotcp-random.sh
...@@ -381,7 +381,7 @@ int main (void) ...@@ -381,7 +381,7 @@ int main (void)
nice_agent_remove_stream (ragent, rs_id); nice_agent_remove_stream (ragent, rs_id);
priv_print_global_status (); priv_print_global_status ();
g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY); g_assert (global_lagent_state == NICE_COMPONENT_STATE_READY);
g_assert (global_ragent_state == NICE_COMPONENT_STATE_READY); g_assert (global_ragent_state >= NICE_COMPONENT_STATE_CONNECTED);
/* note: verify that correct number of local candidates were reported */ /* note: verify that correct number of local candidates were reported */
g_assert (global_lagent_cands == 1); g_assert (global_lagent_cands == 1);
g_assert (global_ragent_cands == 1); g_assert (global_ragent_cands == 1);
......
This diff is collapsed.
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