Commit f46eba9f authored by Youness Alaoui's avatar Youness Alaoui

Port libnice agent to the StunUsageTimerReturn API

parent 03dce9b3
...@@ -257,9 +257,8 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G ...@@ -257,9 +257,8 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G
p->state = NICE_CHECK_FAILED; p->state = NICE_CHECK_FAILED;
nice_debug ("Agent %p : pair %p state FAILED", agent, p); nice_debug ("Agent %p : pair %p state FAILED", agent, p);
} else if (priv_timer_expired (&p->next_tick, now)) { } else if (priv_timer_expired (&p->next_tick, now)) {
int timeout = stun_timer_refresh (&p->timer); switch (stun_timer_refresh (&p->timer)) {
switch (timeout) { case STUN_USAGE_TIMER_RETURN_TIMEOUT:
case -1:
/* case: error, abort processing */ /* case: error, abort processing */
nice_debug ("Agent %p : Retransmissions failed, giving up on connectivity check %p", agent, p); nice_debug ("Agent %p : Retransmissions failed, giving up on connectivity check %p", agent, p);
p->state = NICE_CHECK_FAILED; p->state = NICE_CHECK_FAILED;
...@@ -267,7 +266,7 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G ...@@ -267,7 +266,7 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G
p->stun_message.buffer = NULL; p->stun_message.buffer = NULL;
p->stun_message.buffer_len = 0; p->stun_message.buffer_len = 0;
break; break;
case 0: case STUN_USAGE_TIMER_RETURN_RETRANSMIT:
{ {
/* case: not ready, so schedule a new timeout */ /* case: not ready, so schedule a new timeout */
unsigned int timeout = stun_timer_remainder (&p->timer); unsigned int timeout = stun_timer_remainder (&p->timer);
...@@ -286,8 +285,10 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G ...@@ -286,8 +285,10 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G
keep_timer_going = TRUE; keep_timer_going = TRUE;
break; break;
} }
default: case STUN_USAGE_TIMER_RETURN_SUCCESS:
{ {
unsigned int timeout = stun_timer_remainder (&p->timer);
/* note: convert from milli to microseconds for g_time_val_add() */ /* note: convert from milli to microseconds for g_time_val_add() */
p->next_tick = *now; p->next_tick = *now;
g_time_val_add (&p->next_tick, timeout * 1000); g_time_val_add (&p->next_tick, timeout * 1000);
...@@ -522,13 +523,12 @@ static gboolean priv_turn_allocate_refresh_retransmissions_tick (gpointer pointe ...@@ -522,13 +523,12 @@ static gboolean priv_turn_allocate_refresh_retransmissions_tick (gpointer pointe
g_source_unref (cand->tick_source); g_source_unref (cand->tick_source);
cand->tick_source = NULL; cand->tick_source = NULL;
timeout = stun_timer_refresh (&cand->timer); switch (stun_timer_refresh (&cand->timer)) {
switch (timeout) { case STUN_USAGE_TIMER_RETURN_TIMEOUT:
case -1:
/* Time out */ /* Time out */
refresh_cancel (cand); refresh_cancel (cand);
break; break;
case 0: case STUN_USAGE_TIMER_RETURN_RETRANSMIT:
/* Retransmit */ /* Retransmit */
nice_socket_send (cand->nicesock, &cand->server, nice_socket_send (cand->nicesock, &cand->server,
stun_message_length (&cand->stun_message), (gchar *)cand->stun_buffer); stun_message_length (&cand->stun_message), (gchar *)cand->stun_buffer);
...@@ -537,7 +537,8 @@ static gboolean priv_turn_allocate_refresh_retransmissions_tick (gpointer pointe ...@@ -537,7 +537,8 @@ static gboolean priv_turn_allocate_refresh_retransmissions_tick (gpointer pointe
cand->tick_source = agent_timeout_add_with_context (cand->agent, timeout, cand->tick_source = agent_timeout_add_with_context (cand->agent, timeout,
priv_turn_allocate_refresh_retransmissions_tick, cand); priv_turn_allocate_refresh_retransmissions_tick, cand);
break; break;
default: case STUN_USAGE_TIMER_RETURN_SUCCESS:
timeout = stun_timer_remainder (&cand->timer);
cand->tick_source = agent_timeout_add_with_context (cand->agent, timeout, cand->tick_source = agent_timeout_add_with_context (cand->agent, timeout,
priv_turn_allocate_refresh_retransmissions_tick, cand); priv_turn_allocate_refresh_retransmissions_tick, cand);
break; break;
......
...@@ -885,16 +885,15 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer) ...@@ -885,16 +885,15 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
cand->done = TRUE; cand->done = TRUE;
} }
else if (priv_timer_expired (&cand->next_tick, &now)) { else if (priv_timer_expired (&cand->next_tick, &now)) {
int timeout = stun_timer_refresh (&cand->timer); switch (stun_timer_refresh (&cand->timer)) {
switch (timeout) { case STUN_USAGE_TIMER_RETURN_TIMEOUT:
case -1:
/* case: error, abort processing */ /* case: error, abort processing */
cand->done = TRUE; cand->done = TRUE;
cand->stun_message.buffer = NULL; cand->stun_message.buffer = NULL;
cand->stun_message.buffer_len = 0; cand->stun_message.buffer_len = 0;
nice_debug ("Agent %p : bind discovery timed out, aborting discovery item.", agent); nice_debug ("Agent %p : bind discovery timed out, aborting discovery item.", agent);
break; break;
case 0: case STUN_USAGE_TIMER_RETURN_RETRANSMIT:
{ {
/* case: not ready complete, so schedule next timeout */ /* case: not ready complete, so schedule next timeout */
unsigned int timeout = stun_timer_remainder (&cand->timer); unsigned int timeout = stun_timer_remainder (&cand->timer);
...@@ -914,8 +913,10 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer) ...@@ -914,8 +913,10 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
++not_done; /* note: retry later */ ++not_done; /* note: retry later */
break; break;
} }
default: case STUN_USAGE_TIMER_RETURN_SUCCESS:
{ {
unsigned int timeout = stun_timer_remainder (&cand->timer);
cand->next_tick = now; cand->next_tick = now;
g_time_val_add (&cand->next_tick, timeout * 1000); g_time_val_add (&cand->next_tick, timeout * 1000);
......
...@@ -509,9 +509,8 @@ static gboolean ...@@ -509,9 +509,8 @@ static gboolean
priv_retransmissions_tick_unlocked (TurnPriv *priv) priv_retransmissions_tick_unlocked (TurnPriv *priv)
{ {
if (priv->current_binding_msg) { if (priv->current_binding_msg) {
guint timeout = stun_timer_refresh (&priv->current_binding_msg->timer); switch (stun_timer_refresh (&priv->current_binding_msg->timer)) {
switch (timeout) { case STUN_USAGE_TIMER_RETURN_TIMEOUT:
case -1:
/* Time out */ /* Time out */
g_free (priv->current_binding); g_free (priv->current_binding);
priv->current_binding = NULL; priv->current_binding = NULL;
...@@ -519,13 +518,13 @@ priv_retransmissions_tick_unlocked (TurnPriv *priv) ...@@ -519,13 +518,13 @@ priv_retransmissions_tick_unlocked (TurnPriv *priv)
priv->current_binding_msg = NULL; priv->current_binding_msg = NULL;
priv_process_pending_bindings (priv); priv_process_pending_bindings (priv);
break; break;
case 0: case STUN_USAGE_TIMER_RETURN_RETRANSMIT:
/* Retransmit */ /* Retransmit */
nice_socket_send (priv->base_socket, &priv->server_addr, nice_socket_send (priv->base_socket, &priv->server_addr,
stun_message_length (&priv->current_binding_msg->message), stun_message_length (&priv->current_binding_msg->message),
(gchar *)priv->current_binding_msg->buffer); (gchar *)priv->current_binding_msg->buffer);
break; break;
default: case STUN_USAGE_TIMER_RETURN_SUCCESS:
break; break;
} }
} }
......
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