Commit 16d51b09 authored by Olivier Crête's avatar Olivier Crête

agent: Remove explicit parent pointers

Remove all pointers that don't include have a reference except to agents
parent da41258a
......@@ -1582,7 +1582,7 @@ static void
g_cancellable_cancel (component->tcp_writable_cancellable);
agent_queue_signal (agent, signals[SIGNAL_RELIABLE_TRANSPORT_WRITABLE],
component->stream->id, component->id);
component->stream_id, component->id);
}
static void
......@@ -1600,8 +1600,7 @@ pseudo_tcp_socket_create (NiceAgent *agent, NiceStream *stream, NiceComponent *c
agent, component->id);
}
static void priv_pseudo_tcp_error (NiceAgent *agent, NiceStream *stream,
NiceComponent *component)
static void priv_pseudo_tcp_error (NiceAgent *agent, NiceComponent *component)
{
if (component->tcp_writable_cancellable) {
g_cancellable_cancel (component->tcp_writable_cancellable);
......@@ -1609,7 +1608,7 @@ static void priv_pseudo_tcp_error (NiceAgent *agent, NiceStream *stream,
}
if (component->tcp) {
agent_signal_component_state_change (agent, stream->id,
agent_signal_component_state_change (agent, component->stream_id,
component->id, NICE_COMPONENT_STATE_FAILED);
nice_component_detach_all_sockets (component);
pseudo_tcp_socket_close (component->tcp, TRUE);
......@@ -1627,10 +1626,9 @@ pseudo_tcp_socket_opened (PseudoTcpSocket *sock, gpointer user_data)
{
NiceComponent *component = user_data;
NiceAgent *agent = component->agent;
NiceStream *stream = component->stream;
nice_debug ("Agent %p: s%d:%d pseudo Tcp socket Opened", agent,
stream->id, component->id);
component->stream_id, component->id);
agent_signal_socket_writable (agent, component);
}
......@@ -1787,15 +1785,21 @@ pseudo_tcp_socket_readable (PseudoTcpSocket *sock, gpointer user_data)
{
NiceComponent *component = user_data;
NiceAgent *agent = component->agent;
NiceStream *stream = component->stream;
gboolean has_io_callback;
guint stream_id = stream->id;
NiceStream *stream = NULL;
guint stream_id = component->stream_id;
guint component_id = component->id;
g_object_ref (agent);
if (!agent_find_component (agent, stream_id, component_id,
&stream, &component)) {
g_object_unref (agent);
goto out;
}
nice_debug_verbose ("Agent %p: s%d:%d pseudo Tcp socket readable", agent,
stream->id, component->id);
stream_id, component->id);
component->tcp_readable = TRUE;
......@@ -1826,7 +1830,7 @@ pseudo_tcp_socket_readable (PseudoTcpSocket *sock, gpointer user_data)
/* Handle errors. */
if (pseudo_tcp_socket_get_error (sock) != EWOULDBLOCK) {
nice_debug ("%s: calling priv_pseudo_tcp_error()", G_STRFUNC);
priv_pseudo_tcp_error (agent, stream, component);
priv_pseudo_tcp_error (agent, component);
}
if (component->recv_buf_error != NULL) {
......@@ -1889,7 +1893,7 @@ pseudo_tcp_socket_readable (PseudoTcpSocket *sock, gpointer user_data)
component->tcp_readable = FALSE;
} else if (n_valid_messages < 0) {
nice_debug ("%s: calling priv_pseudo_tcp_error()", G_STRFUNC);
priv_pseudo_tcp_error (agent, stream, component);
priv_pseudo_tcp_error (agent, component);
} else if (n_valid_messages == 0) {
/* Reached EOS. */
component->tcp_readable = FALSE;
......@@ -1912,10 +1916,9 @@ pseudo_tcp_socket_writable (PseudoTcpSocket *sock, gpointer user_data)
{
NiceComponent *component = user_data;
NiceAgent *agent = component->agent;
NiceStream *stream = component->stream;
nice_debug_verbose ("Agent %p: s%d:%d pseudo Tcp socket writable", agent,
stream->id, component->id);
component->stream_id, component->id);
agent_signal_socket_writable (agent, component);
}
......@@ -1926,11 +1929,11 @@ pseudo_tcp_socket_closed (PseudoTcpSocket *sock, guint32 err,
{
NiceComponent *component = user_data;
NiceAgent *agent = component->agent;
NiceStream *stream = component->stream;
nice_debug ("Agent %p: s%d:%d pseudo Tcp socket closed. "
"Calling priv_pseudo_tcp_error().", agent, stream->id, component->id);
priv_pseudo_tcp_error (agent, stream, component);
"Calling priv_pseudo_tcp_error().", agent, component->stream_id,
component->id);
priv_pseudo_tcp_error (agent, component);
}
......@@ -1953,7 +1956,7 @@ pseudo_tcp_socket_write_packet (PseudoTcpSocket *psocket,
nice_debug_verbose (
"Agent %p : s%d:%d: sending %d bytes on socket %p (FD %d) to [%s]:%d",
component->agent, component->stream->id, component->id, len,
component->agent, component->stream_id, component->id, len,
sock->fileno, g_socket_get_fd (sock->fileno), tmpbuf,
nice_address_get_port (addr));
}
......@@ -1983,7 +1986,9 @@ notify_pseudo_tcp_socket_clock_agent_locked (NiceAgent *agent,
NiceComponent *component = user_data;
NiceStream *stream;
stream = component->stream;
stream = agent_find_stream (agent, component->stream_id);
if (!stream)
return G_SOURCE_REMOVE;
pseudo_tcp_socket_notify_clock (component->tcp);
adjust_tcp_clock (agent, stream, component);
......@@ -2018,7 +2023,7 @@ adjust_tcp_clock (NiceAgent *agent, NiceStream *stream, NiceComponent *component
nice_debug ("Agent %p: component %d pseudo-TCP socket should be "
"destroyed. Calling priv_pseudo_tcp_error().",
agent, component->id);
priv_pseudo_tcp_error (agent, stream, component);
priv_pseudo_tcp_error (agent, component);
}
}
}
......@@ -2028,7 +2033,6 @@ _tcp_sock_is_writable (NiceSocket *sock, gpointer user_data)
{
NiceComponent *component = user_data;
NiceAgent *agent = component->agent;
NiceStream *stream = component->stream;
agent_lock (agent);
......@@ -2041,7 +2045,7 @@ _tcp_sock_is_writable (NiceSocket *sock, gpointer user_data)
}
nice_debug ("Agent %p: s%d:%d Tcp socket writable", agent,
stream->id, component->id);
component->stream_id, component->id);
agent_signal_socket_writable (agent, component);
agent_unlock_and_emit (agent);
......@@ -2413,9 +2417,8 @@ priv_add_new_candidate_discovery_stun (NiceAgent *agent,
cdisco->type = NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE;
cdisco->nicesock = nicesock;
cdisco->server = server;
cdisco->stream = stream;
cdisco->component = nice_stream_find_component_by_id (stream, component_id);
cdisco->agent = agent;
cdisco->stream_id = stream->id;
cdisco->component_id = component_id;
stun_agent_init (&cdisco->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC3489,
(agent->compatibility == NICE_COMPATIBILITY_OC2007 ||
......@@ -2556,9 +2559,8 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent,
cdisco->turn = turn_server_ref (turn);
cdisco->server = turn->server;
cdisco->stream = stream;
cdisco->component = nice_stream_find_component_by_id (stream, component_id);
cdisco->agent = agent;
cdisco->stream_id = stream->id;
cdisco->component_id = component_id;
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
stun_agent_init (&cdisco->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
......@@ -2603,10 +2605,9 @@ nice_agent_add_stream (
g_return_val_if_fail (n_components >= 1, 0);
agent_lock (agent);
stream = nice_stream_new (n_components, agent);
stream = nice_stream_new (agent->next_stream_id++, n_components, agent);
agent->streams = g_slist_append (agent->streams, stream);
stream->id = agent->next_stream_id++;
nice_debug ("Agent %p : allocating stream id %u (%p)", agent, stream->id, stream);
if (agent->reliable) {
nice_debug ("Agent %p : reliable stream", agent);
......@@ -4722,7 +4723,7 @@ nice_agent_send_messages_nonblocking_internal (
if (n_sent < 0 && !g_error_matches (child_error, G_IO_ERROR,
G_IO_ERROR_WOULD_BLOCK)) {
/* Signal errors */
priv_pseudo_tcp_error (agent, stream, component);
priv_pseudo_tcp_error (agent, component);
}
} else {
g_set_error (&child_error, G_IO_ERROR, G_IO_ERROR_FAILED,
......@@ -5133,10 +5134,18 @@ component_io_cb (GSocket *gsocket, GIOCondition condition, gpointer user_data)
component = socket_source->component;
agent = component->agent;
stream = component->stream;
agent_lock (agent);
stream = agent_find_stream (agent, component->stream_id);
if (stream == NULL) {
nice_debug ("%s: stream %d destroyed", G_STRFUNC, component->stream_id);
agent_unlock (agent);
return G_SOURCE_REMOVE;
}
if (g_source_is_destroyed (g_main_current_source ())) {
/* Silently return FALSE. */
nice_debug ("%s: source %p destroyed", G_STRFUNC, g_main_current_source ());
......@@ -5160,7 +5169,7 @@ component_io_cb (GSocket *gsocket, GIOCondition condition, gpointer user_data)
stream->id, component->id, NICE_COMPONENT_STATE_FAILED);
}
nice_component_remove_socket (component, socket_source->socket);
nice_component_remove_socket (agent, component, socket_source->socket);
agent_unlock (agent);
g_object_unref (agent);
return G_SOURCE_REMOVE;
......@@ -5326,7 +5335,7 @@ component_io_cb (GSocket *gsocket, GIOCondition condition, gpointer user_data)
done:
if (remove_source)
nice_component_remove_socket (component, socket_source->socket);
nice_component_remove_socket (agent, component, socket_source->socket);
/* If we’re in the middle of a read, don’t emit any signals, or we could cause
* re-entrancy by (e.g.) emitting component-state-changed and having the
......@@ -6476,7 +6485,7 @@ nice_agent_forget_relays (NiceAgent *agent, guint stream_id, guint component_id)
goto done;
}
nice_component_clean_turn_servers (component);
nice_component_clean_turn_servers (agent, component);
done:
agent_unlock_and_emit (agent);
......
......@@ -164,9 +164,13 @@ nice_component_new (guint id, NiceAgent *agent, NiceStream *stream)
}
void
nice_component_remove_socket (NiceComponent *cmp, NiceSocket *nsocket)
nice_component_remove_socket (NiceAgent *agent, NiceComponent *cmp,
NiceSocket *nsocket)
{
GSList *i;
NiceStream *stream;
stream = agent_find_stream (agent, cmp->stream_id);
for (i = cmp->local_candidates; i;) {
NiceCandidate *candidate = i->data;
......@@ -179,14 +183,14 @@ nice_component_remove_socket (NiceComponent *cmp, NiceSocket *nsocket)
if (candidate == cmp->selected_pair.local) {
nice_component_clear_selected_pair (cmp);
agent_signal_component_state_change (cmp->agent, cmp->stream->id,
agent_signal_component_state_change (cmp->agent, cmp->stream_id,
cmp->id, NICE_COMPONENT_STATE_FAILED);
}
refresh_prune_candidate (cmp->agent, candidate);
if (candidate->sockptr != nsocket) {
if (candidate->sockptr != nsocket && stream) {
discovery_prune_socket (cmp->agent, candidate->sockptr);
conn_check_prune_socket (cmp->agent, cmp->stream, cmp,
conn_check_prune_socket (cmp->agent, stream, cmp,
candidate->sockptr);
nice_component_detach_socket (cmp, candidate->sockptr);
}
......@@ -198,14 +202,18 @@ nice_component_remove_socket (NiceComponent *cmp, NiceSocket *nsocket)
}
discovery_prune_socket (cmp->agent, nsocket);
conn_check_prune_socket (cmp->agent, cmp->stream, cmp, nsocket);
if (stream)
conn_check_prune_socket (cmp->agent, stream, cmp, nsocket);
nice_component_detach_socket (cmp, nsocket);
}
void
nice_component_clean_turn_servers (NiceComponent *cmp)
nice_component_clean_turn_servers (NiceAgent *agent, NiceComponent *cmp)
{
GSList *i;
NiceStream *stream;
stream = agent_find_stream (agent, cmp->stream_id);
g_list_free_full (cmp->turn_servers, (GDestroyNotify) turn_server_unref);
cmp->turn_servers = NULL;
......@@ -232,8 +240,9 @@ nice_component_clean_turn_servers (NiceComponent *cmp)
if (cmp->turn_candidate) {
refresh_prune_candidate (cmp->agent, cmp->turn_candidate);
discovery_prune_socket (cmp->agent, cmp->turn_candidate->sockptr);
conn_check_prune_socket (cmp->agent, cmp->stream, cmp,
cmp->turn_candidate->sockptr);
if (stream)
conn_check_prune_socket (cmp->agent, stream, cmp,
cmp->turn_candidate->sockptr);
nice_component_detach_socket (cmp, cmp->turn_candidate->sockptr);
nice_candidate_free (cmp->turn_candidate);
}
......@@ -245,8 +254,9 @@ nice_component_clean_turn_servers (NiceComponent *cmp)
} else {
refresh_prune_candidate (cmp->agent, candidate);
discovery_prune_socket (cmp->agent, candidate->sockptr);
conn_check_prune_socket (cmp->agent, cmp->stream, cmp,
candidate->sockptr);
if (stream)
conn_check_prune_socket (cmp->agent, stream, cmp,
candidate->sockptr);
nice_component_detach_socket (cmp, candidate->sockptr);
agent_remove_local_candidate (cmp->agent, candidate);
nice_candidate_free (candidate);
......@@ -313,7 +323,7 @@ nice_component_close (NiceComponent *cmp)
(GDestroyNotify) incoming_check_free);
cmp->incoming_checks = NULL;
nice_component_clean_turn_servers (cmp);
nice_component_clean_turn_servers (cmp->agent, cmp);
if (cmp->tcp_clock) {
g_source_destroy (cmp->tcp_clock);
......@@ -418,8 +428,13 @@ nice_component_restart (NiceComponent *cmp)
void
nice_component_update_selected_pair (NiceComponent *component, const CandidatePair *pair)
{
NiceStream *stream;
g_assert (component);
g_assert (pair);
stream = agent_find_stream (component->agent, component->stream_id);
nice_debug ("setting SELECTED PAIR for component %u: %s:%s (prio:%"
G_GUINT64_FORMAT ").", component->id, pair->local->foundation,
pair->remote->foundation, pair->priority);
......@@ -429,8 +444,9 @@ nice_component_update_selected_pair (NiceComponent *component, const CandidatePa
refresh_prune_candidate (component->agent, component->turn_candidate);
discovery_prune_socket (component->agent,
component->turn_candidate->sockptr);
conn_check_prune_socket (component->agent, component->stream, component,
component->turn_candidate->sockptr);
if (stream)
conn_check_prune_socket (component->agent, stream, component,
component->turn_candidate->sockptr);
nice_component_detach_socket (component, component->turn_candidate->sockptr);
nice_candidate_free (component->turn_candidate);
component->turn_candidate = NULL;
......@@ -575,7 +591,7 @@ nice_component_attach_socket (NiceComponent *component, NiceSocket *nicesock)
/* Create and attach a source */
nice_debug ("Component %p (agent %p): Attach source (stream %u).",
component, component->agent, component->stream->id);
component, component->agent, component->stream_id);
socket_source_attach (socket_source, component->ctx);
}
......@@ -797,7 +813,7 @@ emit_io_callback_cb (gpointer user_data)
g_object_ref (agent);
stream_id = component->stream->id;
stream_id = component->stream_id;
component_id = component->id;
g_mutex_lock (&component->io_mutex);
......@@ -869,7 +885,7 @@ nice_component_emit_io_callback (NiceComponent *component,
g_assert (buf_len > 0);
agent = component->agent;
stream_id = component->stream->id;
stream_id = component->stream_id;
component_id = component->id;
g_mutex_lock (&component->io_mutex);
......@@ -1029,7 +1045,6 @@ nice_component_init (NiceComponent *component)
component->restart_candidate = NULL;
component->tcp = NULL;
component->agent = NULL;
component->stream = NULL;
g_mutex_init (&component->io_mutex);
g_queue_init (&component->pending_io_messages);
......@@ -1084,9 +1099,12 @@ nice_component_get_property (GObject *obj,
break;
case PROP_STREAM:
g_value_set_object (value, component->stream);
break;
{
NiceStream *stream = agent_find_stream (component->agent,
component->stream_id);
g_value_set_object (value, stream);
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
}
......@@ -1111,7 +1129,10 @@ nice_component_set_property (GObject *obj,
break;
case PROP_STREAM:
component->stream = g_value_get_object (value);
{
NiceStream *stream = g_value_get_object (value);
component->stream_id = stream->id;
}
break;
default:
......
......@@ -69,7 +69,6 @@ typedef struct _IncomingCheck IncomingCheck;
struct _CandidatePairKeepalive
{
NiceAgent *agent;
GSource *tick_source;
guint stream_id;
guint component_id;
......@@ -202,8 +201,7 @@ struct _NiceComponent {
NiceAgent *agent; /* unowned, immutable: can be accessed without holding the
* agent lock */
NiceStream *stream; /* unowned, immutable: can be accessed without holding
* the agent lock */
guint stream_id;
StunAgent stun_agent; /* This stun agent is used to validate all stun requests */
......@@ -263,7 +261,8 @@ void
nice_component_attach_socket (NiceComponent *component, NiceSocket *nsocket);
void
nice_component_remove_socket (NiceComponent *component, NiceSocket *nsocket);
nice_component_remove_socket (NiceAgent *agent, NiceComponent *component,
NiceSocket *nsocket);
void
nice_component_detach_all_sockets (NiceComponent *component);
......@@ -290,7 +289,7 @@ nice_component_emit_io_callback (NiceComponent *component,
gboolean
nice_component_has_io_callback (NiceComponent *component);
void
nice_component_clean_turn_servers (NiceComponent *component);
nice_component_clean_turn_servers (NiceAgent *agent, NiceComponent *component);
TurnServer *
......
......@@ -1180,7 +1180,7 @@ static gboolean priv_conn_keepalive_retransmissions_tick_agent_locked (
stun_agent_forget_transaction (&component->stun_agent, id);
pair->keepalive.stun_message.buffer = NULL;
if (pair->keepalive.agent->media_after_tick) {
if (agent->media_after_tick) {
nice_debug ("Agent %p : Keepalive conncheck timed out!! "
"but media was received. Suspecting keepalive lost because of "
"network bottleneck", agent);
......@@ -1369,9 +1369,8 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
p->keepalive.stream_id = stream->id;
p->keepalive.component_id = component->id;
p->keepalive.agent = agent;
agent_timeout_add_with_context (p->keepalive.agent,
agent_timeout_add_with_context (agent,
&p->keepalive.tick_source, "Pair keepalive",
stun_timer_remainder (&p->keepalive.timer),
priv_conn_keepalive_retransmissions_tick_agent_locked, p);
......@@ -1490,7 +1489,7 @@ static gboolean priv_turn_allocate_refresh_retransmissions_tick_agent_locked (
stun_message_id (&cand->stun_message, id);
stun_agent_forget_transaction (&cand->stun_agent, id);
refresh_cancel (cand);
refresh_cancel (agent, cand);
break;
}
case STUN_USAGE_TIMER_RETURN_RETRANSMIT:
......@@ -1775,7 +1774,7 @@ static void priv_update_check_list_failed_components (NiceAgent *agent, NiceStre
/* There is still discovery ogoing for this stream,
* so don't fail any of it's candidates.
*/
if (d->stream == stream && !d->done)
if (d->stream_id == stream->id && !d->done)
return;
}
if (agent->discovery_list != NULL)
......@@ -1939,7 +1938,8 @@ static void priv_mark_pair_nominated (NiceAgent *agent, NiceStream *stream, Nice
}
guint32
ensure_unique_priority (NiceComponent *component, guint32 priority)
ensure_unique_priority (NiceStream *stream, NiceComponent *component,
guint32 priority)
{
GSList *item;
......@@ -1956,7 +1956,7 @@ ensure_unique_priority (NiceComponent *component, guint32 priority)
}
}
for (item = component->stream->conncheck_list; item; item = item->next) {
for (item = stream->conncheck_list; item; item = item->next) {
CandidateCheckPair *p = item->data;
if (p->component_id == component->id &&
......@@ -2013,7 +2013,7 @@ static CandidateCheckPair *priv_add_new_check_pair (NiceAgent *agent,
tmpbuf1, nice_address_get_port (&pair->local->addr),
tmpbuf2, nice_address_get_port (&pair->remote->addr));
}
pair->prflx_priority = ensure_unique_priority (component,
pair->prflx_priority = ensure_unique_priority (stream, component,
peer_reflexive_candidate_priority (agent, local));
stream->conncheck_list = g_slist_insert_sorted (stream->conncheck_list, pair,
......@@ -2936,7 +2936,7 @@ static CandidateCheckPair *priv_add_peer_reflexive_pair (NiceAgent *agent, guint
pair->priority = nice_candidate_pair_priority (pair->remote->priority,
pair->local->priority);
pair->nominated = FALSE;
pair->prflx_priority = ensure_unique_priority (component,
pair->prflx_priority = ensure_unique_priority (stream, component,
peer_reflexive_candidate_priority (agent, local_cand));
nice_debug ("Agent %p : added a new peer-discovered pair with "
"foundation '%s'.", agent, pair->foundation);
......@@ -3349,18 +3349,18 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
nice_address_set_from_sockaddr (&niceaddr, &sockaddr.addr);
discovery_add_server_reflexive_candidate (
d->agent,
d->stream->id,
d->component->id,
agent,
d->stream_id,
d->component_id,
&niceaddr,
NICE_CANDIDATE_TRANSPORT_UDP,
d->nicesock,
FALSE);
if (d->agent->use_ice_tcp)
if (agent->use_ice_tcp)
discovery_discover_tcp_server_reflexive_candidates (
d->agent,
d->stream->id,
d->component->id,
agent,
d->stream_id,
d->component_id,
&niceaddr,
d->nicesock);
}
......@@ -3384,11 +3384,10 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
static CandidateRefresh *
priv_add_new_turn_refresh (CandidateDiscovery *cdisco, NiceCandidate *relay_cand,
guint lifetime)
priv_add_new_turn_refresh (NiceAgent *agent, CandidateDiscovery *cdisco,
NiceCandidate *relay_cand, guint lifetime)
{
CandidateRefresh *cand;
NiceAgent *agent = cdisco->agent;
cand = g_slice_new0 (CandidateRefresh);
agent->refresh_list = g_slist_append (agent->refresh_list, cand);
......@@ -3396,9 +3395,8 @@ priv_add_new_turn_refresh (CandidateDiscovery *cdisco, NiceCandidate *relay_cand
cand->candidate = relay_cand;
cand->nicesock = cdisco->nicesock;
cand->server = cdisco->server;
cand->stream = cdisco->stream;
cand->component = cdisco->component;
cand->agent = cdisco->agent;
cand->stream_id = cdisco->stream_id;
cand->component_id = cdisco->component_id;
memcpy (&cand->stun_agent, &cdisco->stun_agent, sizeof(StunAgent));
/* Use previous stun response for authentication credentials */
......@@ -3412,7 +3410,7 @@ priv_add_new_turn_refresh (CandidateDiscovery *cdisco, NiceCandidate *relay_cand
}
nice_debug ("Agent %p : Adding new refresh candidate %p with timeout %d",
agent, cand, (lifetime - 60) * 1000);
agent, cand, lifetime - 60);
/* step: also start the refresh timer */
/* refresh should be sent 1 minute before it expires */
......@@ -3441,7 +3439,7 @@ static void priv_handle_turn_alternate_server (NiceAgent *agent,
if (!d->done &&
d->type == disco->type &&
d->stream == disco->stream &&
d->stream_id == disco->stream_id &&
d->turn->type == disco->turn->type &&
nice_address_equal (&d->server, &server)) {
gchar ip[INET6_ADDRSTRLEN];
......@@ -3539,15 +3537,15 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
if (d->turn->type == NICE_RELAY_TYPE_TURN_UDP &&
!agent->force_relay) {
discovery_add_server_reflexive_candidate (
d->agent,
d->stream->id,
d->component->id,
agent,
d->stream_id,
d->component_id,
&mappedniceaddr,
NICE_CANDIDATE_TRANSPORT_UDP,
d->nicesock,
FALSE);
}
if (d->agent->use_ice_tcp) {
if (agent->use_ice_tcp) {
if ((agent->compatibility == NICE_COMPATIBILITY_OC2007 ||
agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
!nice_address_equal_no_port (&niceaddr, &d->turn->server)) {
......@@ -3555,9 +3553,9 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
"ignoring bogus srflx address");
} else {
discovery_discover_tcp_server_reflexive_candidates (
d->agent,
d->stream->id,
d->component->id,
agent,
d->stream_id,
d->component_id,
&mappedniceaddr,
d->nicesock);
}
......@@ -3566,9 +3564,9 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
if (nice_socket_is_reliable (d->nicesock)) {
relay_cand = discovery_add_relay_candidate (
d->agent,
d->stream->id,
d->component->id,
agent,
d->stream_id,
d->component_id,
&niceaddr,
NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE,
d->nicesock,
......@@ -3582,23 +3580,23 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
nice_udp_turn_socket_set_ms_connection_id(relay_cand->sockptr,
resp);
} else {
priv_add_new_turn_refresh (d, relay_cand, lifetime);
priv_add_new_turn_refresh (agent, d, relay_cand, lifetime);
}
}
relay_cand = discovery_add_relay_candidate (
d->agent,
d->stream->id,
d->component->id,
agent,
d->stream_id,
d->component_id,
&niceaddr,
NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE,
d->nicesock,
d->turn);
} else {
relay_cand = discovery_add_relay_candidate (
d->agent,
d->stream->id,
d->component->id,
agent,
d->stream_id,
d->component_id