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