GSList* soy_net_xmpp_agent_get_remote_candidates (soynetXMPPAgent* self, LmMessageNode* transport, guint stream_id) { GSList* result = NULL; GSList* rcands = NULL; LmMessageNode* candidate = NULL; LmMessageNode* _tmp0_ = NULL; LmMessageNode* _tmp1_ = NULL; LmMessageNode* _tmp2_ = NULL; LmMessageNode* _tmp3_ = NULL; GSList* _tmp45_ = NULL; GSList* _tmp46_ = NULL; #line 119 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" g_return_val_if_fail (self != NULL, NULL); #line 119 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" g_return_val_if_fail (transport != NULL, NULL); #line 120 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" rcands = NULL; #line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp0_ = transport; #line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp1_ = lm_message_node_get_child (_tmp0_, "candidate"); #line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp2_ = _lm_message_node_ref0 (_tmp1_); #line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" candidate = _tmp2_; #line 124 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp3_ = candidate; #line 124 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" if (_tmp3_ == NULL) { #line 125 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" result = rcands; #line 125 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _lm_message_node_unref0 (candidate); #line 125 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" return result; #line 584 "XMPPAgent.c" } #line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" while (TRUE) { #line 588 "XMPPAgent.c" LmMessageNode* _tmp4_ = NULL; NiceCandidate* rcand = NULL; GeeHashMap* _tmp5_ = NULL; LmMessageNode* _tmp6_ = NULL; const gchar* _tmp7_ = NULL; gpointer _tmp8_ = NULL; NiceCandidate* _tmp9_ = NULL; LmMessageNode* _tmp10_ = NULL; const gchar* _tmp11_ = NULL; LmMessageNode* _tmp12_ = NULL; const gchar* _tmp13_ = NULL; LmMessageNode* _tmp14_ = NULL; const gchar* _tmp15_ = NULL; LmMessageNode* _tmp16_ = NULL; const gchar* _tmp17_ = NULL; NiceCandidate* _tmp18_ = NULL; LmMessageNode* _tmp19_ = NULL; const gchar* _tmp20_ = NULL; NiceCandidate* _tmp21_ = NULL; LmMessageNode* _tmp22_ = NULL; const gchar* _tmp23_ = NULL; gint _tmp24_ = 0; NiceCandidate* _tmp25_ = NULL; NiceCandidate* _tmp26_ = NULL; LmMessageNode* _tmp27_ = NULL; const gchar* _tmp28_ = NULL; gint _tmp29_ = 0; NiceCandidate* _tmp30_ = NULL; LmMessageNode* _tmp31_ = NULL; const gchar* _tmp32_ = NULL; gint _tmp33_ = 0; NiceCandidate* _tmp34_ = NULL; guint _tmp35_ = 0U; NiceCandidate* _tmp36_ = NULL; gboolean _tmp37_ = FALSE; gchar* _tmp38_ = NULL; gchar* _tmp39_ = NULL; NiceCandidate* _tmp40_ = NULL; NiceCandidate* _tmp41_ = NULL; LmMessageNode* _tmp42_ = NULL; LmMessageNode* _tmp43_ = NULL; LmMessageNode* _tmp44_ = NULL; #line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp4_ = candidate; #line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" if (!(_tmp4_ != NULL)) { #line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" break; #line 637 "XMPPAgent.c" } #line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp5_ = soy_net_xmpp_agent_candidate_type_dict; #line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp6_ = candidate; #line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp7_ = lm_message_node_get_attribute (_tmp6_, "type"); #line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp8_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp5_, _tmp7_); #line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp9_ = nice_candidate_new ((guint) ((gint) ((gintptr) _tmp8_))); #line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" rcand = _tmp9_; #line 131 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" g_print ("Remote Candidate\n"); #line 132 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp10_ = candidate; #line 132 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp11_ = lm_message_node_get_attribute (_tmp10_, "ip"); #line 132 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" g_print ("%s\n", _tmp11_); #line 133 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp12_ = candidate; #line 133 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp13_ = lm_message_node_get_attribute (_tmp12_, "port"); #line 133 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" g_print ("port: %s\n", _tmp13_); #line 134 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp14_ = candidate; #line 134 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp15_ = lm_message_node_get_attribute (_tmp14_, "priority"); #line 134 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" g_print ("priority: %s\n", _tmp15_); #line 135 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp16_ = candidate; #line 135 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp17_ = lm_message_node_get_attribute (_tmp16_, "component"); #line 135 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" g_print ("component %s\n", _tmp17_); #line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp18_ = rcand; #line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp19_ = candidate; #line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp20_ = lm_message_node_get_attribute (_tmp19_, "ip"); #line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" nice_address_set_from_string (&_tmp18_->addr, _tmp20_); #line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp21_ = rcand; #line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp22_ = candidate; #line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp23_ = lm_message_node_get_attribute (_tmp22_, "port"); #line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp24_ = atoi (_tmp23_); #line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" nice_address_set_port (&_tmp21_->addr, (guint) _tmp24_); #line 140 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp25_ = rcand; #line 140 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp25_->transport = NICE_CANDIDATE_TRANSPORT_UDP; #line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp26_ = rcand; #line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp27_ = candidate; #line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp28_ = lm_message_node_get_attribute (_tmp27_, "priority"); #line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp29_ = atoi (_tmp28_); #line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp26_->priority = (guint32) _tmp29_; #line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp30_ = rcand; #line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp31_ = candidate; #line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp32_ = lm_message_node_get_attribute (_tmp31_, "component"); #line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp33_ = atoi (_tmp32_); #line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp30_->component_id = (guint) _tmp33_; #line 143 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp34_ = rcand; #line 143 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp35_ = stream_id; #line 143 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp34_->stream_id = _tmp35_; #line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp36_ = rcand; #line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp37_ = nice_address_is_valid (&_tmp36_->addr); #line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp38_ = bool_to_string (_tmp37_); #line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp39_ = _tmp38_; #line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" g_print ("%s\n", _tmp39_); #line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _g_free0 (_tmp39_); #line 146 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp40_ = rcand; #line 146 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp41_ = nice_candidate_copy (_tmp40_); #line 146 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" rcands = g_slist_append (rcands, _tmp41_); #line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp42_ = candidate; #line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp43_ = _tmp42_->next; #line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp44_ = _lm_message_node_ref0 (_tmp43_); #line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _lm_message_node_unref0 (candidate); #line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" candidate = _tmp44_; #line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _nice_candidate_free0 (rcand); #line 755 "XMPPAgent.c" } #line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp45_ = rcands; #line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _tmp46_ = g_slist_copy (_tmp45_); #line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" result = _tmp46_; #line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _lm_message_node_unref0 (candidate); #line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" _g_slist_free0 (rcands); #line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs" return result; #line 769 "XMPPAgent.c" }
/* * Timer callback that handles scheduling new candidate discovery * processes (paced by the Ta timer), and handles running of the * existing discovery processes. * * This function is designed for the g_timeout_add() interface. * * @return will return FALSE when no more pending timers. */ static gboolean priv_discovery_tick_unlocked (gpointer pointer) { CandidateDiscovery *cand; NiceAgent *agent = pointer; GSList *i; int not_done = 0; /* note: track whether to continue timer */ size_t buffer_len = 0; { static int tick_counter = 0; if (tick_counter++ % 50 == 0) nice_debug ("Agent %p : discovery tick #%d with list %p (1)", agent, tick_counter, agent->discovery_list); } for (i = agent->discovery_list; i ; i = i->next) { cand = i->data; if (cand->pending != TRUE) { cand->pending = TRUE; if (agent->discovery_unsched_items) --agent->discovery_unsched_items; if (nice_debug_is_enabled ()) { gchar tmpbuf[INET6_ADDRSTRLEN]; nice_address_to_string (&cand->server, tmpbuf); nice_debug ("Agent %p : discovery - scheduling cand type %u addr %s.", agent, cand->type, tmpbuf); } if (nice_address_is_valid (&cand->server) && (cand->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE || cand->type == NICE_CANDIDATE_TYPE_RELAYED)) { if (cand->component->state == NICE_COMPONENT_STATE_DISCONNECTED || cand->component->state == NICE_COMPONENT_STATE_FAILED) agent_signal_component_state_change (agent, cand->stream->id, cand->component->id, NICE_COMPONENT_STATE_GATHERING); if (cand->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE) { buffer_len = stun_usage_bind_create (&cand->stun_agent, &cand->stun_message, cand->stun_buffer, sizeof(cand->stun_buffer)); } else if (cand->type == NICE_CANDIDATE_TYPE_RELAYED) { uint8_t *username = (uint8_t *)cand->turn->username; gsize username_len = strlen (cand->turn->username); uint8_t *password = (uint8_t *)cand->turn->password; gsize password_len = strlen (cand->turn->password); StunUsageTurnCompatibility turn_compat = agent_to_turn_compatibility (agent); if (turn_compat == STUN_USAGE_TURN_COMPATIBILITY_MSN || turn_compat == STUN_USAGE_TURN_COMPATIBILITY_OC2007) { username = g_base64_decode ((gchar *)username, &username_len); password = g_base64_decode ((gchar *)password, &password_len); } buffer_len = stun_usage_turn_create (&cand->stun_agent, &cand->stun_message, cand->stun_buffer, sizeof(cand->stun_buffer), cand->stun_resp_msg.buffer == NULL ? NULL : &cand->stun_resp_msg, STUN_USAGE_TURN_REQUEST_PORT_NORMAL, -1, -1, username, username_len, password, password_len, turn_compat); if (turn_compat == STUN_USAGE_TURN_COMPATIBILITY_MSN || turn_compat == STUN_USAGE_TURN_COMPATIBILITY_OC2007) { g_free (username); g_free (password); } } if (buffer_len > 0) { if (nice_socket_is_reliable (cand->nicesock)) { stun_timer_start_reliable (&cand->timer, agent->stun_reliable_timeout); } else { stun_timer_start (&cand->timer, agent->stun_initial_timeout, agent->stun_max_retransmissions); } /* send the conncheck */ agent_socket_send (cand->nicesock, &cand->server, buffer_len, (gchar *)cand->stun_buffer); /* case: success, start waiting for the result */ g_get_current_time (&cand->next_tick); } else { /* case: error in starting discovery, start the next discovery */ cand->done = TRUE; cand->stun_message.buffer = NULL; cand->stun_message.buffer_len = 0; continue; } } else /* allocate relayed candidates */ g_assert_not_reached (); ++not_done; /* note: new discovery scheduled */ } if (cand->done != TRUE) { GTimeVal now; g_get_current_time (&now); if (cand->stun_message.buffer == NULL) { nice_debug ("Agent %p : STUN discovery was cancelled, marking discovery done.", agent); cand->done = TRUE; } else if (priv_timer_expired (&cand->next_tick, &now)) { switch (stun_timer_refresh (&cand->timer)) { case STUN_USAGE_TIMER_RETURN_TIMEOUT: { /* Time out */ /* case: error, abort processing */ StunTransactionId id; stun_message_id (&cand->stun_message, id); stun_agent_forget_transaction (&cand->stun_agent, id); 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 STUN_USAGE_TIMER_RETURN_RETRANSMIT: { /* case: not ready complete, so schedule next timeout */ unsigned int timeout = stun_timer_remainder (&cand->timer); stun_debug ("STUN transaction retransmitted (timeout %dms).", timeout); /* retransmit */ agent_socket_send (cand->nicesock, &cand->server, stun_message_length (&cand->stun_message), (gchar *)cand->stun_buffer); /* note: convert from milli to microseconds for g_time_val_add() */ cand->next_tick = now; g_time_val_add (&cand->next_tick, timeout * 1000); ++not_done; /* note: retry later */ break; } 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); ++not_done; /* note: retry later */ break; } default: /* Nothing to do. */ break; } } else { ++not_done; /* note: discovery not expired yet */ } } } if (not_done == 0) { nice_debug ("Agent %p : Candidate gathering FINISHED, stopping discovery timer.", agent); discovery_free (agent); agent_gathering_done (agent); /* note: no pending timers, return FALSE to stop timer */ return FALSE; } return TRUE; }