This is slightly an API break, but it should never have been public.
#include "socket.h"
#include "stun/usages/turn.h"
-#include "candidate.h"
+#include "candidate-priv.h"
#include "component.h"
#include "conncheck.h"
#include "discovery.h"
NiceAddress *addr;
sock = component->selected_pair.local->sockptr;
- addr = &component->selected_pair.remote->addr;
+ addr = &component->selected_pair.remote->c.addr;
if (nice_debug_is_enabled ()) {
gchar tmpbuf[INET6_ADDRSTRLEN];
{
NiceComponent *component;
NiceStream *stream;
+ NiceCandidateImpl *lc = (NiceCandidateImpl *) lcandidate;
if (!agent_find_component (agent, stream_id, component_id,
&stream, &component))
return;
- if (((NiceSocket *)lcandidate->sockptr)->type == NICE_SOCKET_TYPE_UDP_TURN) {
- nice_udp_turn_socket_set_peer (lcandidate->sockptr, &rcandidate->addr);
+ if (((NiceSocket *)lc->sockptr)->type == NICE_SOCKET_TYPE_UDP_TURN) {
+ nice_udp_turn_socket_set_peer (lc->sockptr, &rcandidate->addr);
}
- if(agent->reliable && !nice_socket_is_reliable (lcandidate->sockptr)) {
+ if(agent->reliable && !nice_socket_is_reliable (lc->sockptr)) {
if (!component->tcp)
pseudo_tcp_socket_create (agent, stream, component);
process_queued_tcp_packets (agent, stream, component);
agent_queue_signal (agent, signals[SIGNAL_NEW_SELECTED_PAIR],
stream_id, component_id, lcandidate->foundation, rcandidate->foundation);
- if(agent->reliable && nice_socket_is_reliable (lcandidate->sockptr)) {
+ if(agent->reliable && nice_socket_is_reliable (lc->sockptr)) {
agent_signal_socket_writable (agent, component);
}
}
stream->gathering = TRUE;
for (i = component->local_candidates; i; i = i->next) {
- NiceCandidate *candidate = i->data;
+ NiceCandidateImpl *c = i->data;
- if (candidate->type == NICE_CANDIDATE_TYPE_HOST &&
- candidate->transport != NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE &&
- nice_address_ip_version (&candidate->addr) ==
+ if (c->c.type == NICE_CANDIDATE_TYPE_HOST &&
+ c->c.transport != NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE &&
+ nice_address_ip_version (&c->c.addr) ==
nice_address_ip_version (&turn->server))
priv_add_new_candidate_discovery_turn (agent,
- candidate->sockptr, turn, stream, component_id,
- candidate->transport != NICE_CANDIDATE_TRANSPORT_UDP);
+ c->sockptr, turn, stream, component_id,
+ c->c.transport != NICE_CANDIDATE_TRANSPORT_UDP);
}
if (agent->discovery_unsched_items)
for (j = stream->components; j; j = j->next) {
NiceComponent *component = j->data;
for (k = component->local_candidates; k; k = k->next) {
- NiceCandidate *local_candidate = k->data;
+ NiceCandidateImpl *local_candidate = k->data;
if (agent->force_relay &&
- local_candidate->type != NICE_CANDIDATE_TYPE_RELAYED)
+ local_candidate->c.type != NICE_CANDIDATE_TYPE_RELAYED)
continue;
- if (nice_address_equal (&localaddr, &local_candidate->base_addr)) {
+ if (nice_address_equal (&localaddr, &local_candidate->c.base_addr)) {
discovery_add_server_reflexive_candidate (
agent,
stream->id,
i && length < NICE_CANDIDATE_MAX_LOCAL_ADDRESSES;
i = i->next, length++) {
NiceAddress *addr = i->data;
- NiceCandidate *host_candidate;
+ NiceCandidateImpl *host_candidate;
#ifdef HAVE_GUPNP
gchar local_ip[NICE_ADDRESS_STRING_LEN];
#ifdef HAVE_GUPNP
if (agent->upnp_enabled && agent->upnp &&
transport != NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE) {
- NiceAddress *base_addr = nice_address_dup (&host_candidate->base_addr);
+ NiceAddress *base_addr = nice_address_dup (&host_candidate->c.base_addr);
nice_debug ("Agent %p: Adding UPnP port %s:%d", agent, local_ip,
nice_address_get_port (base_addr));
gupnp_simple_igd_add_port (GUPNP_SIMPLE_IGD (agent->upnp),
if (nice_address_set_from_string (&stun_server, agent->stun_server_ip)) {
nice_address_set_port (&stun_server, agent->stun_server_port);
- if (nice_address_ip_version (&host_candidate->addr) ==
+ if (nice_address_ip_version (&host_candidate->c.addr) ==
nice_address_ip_version (&stun_server))
priv_add_new_candidate_discovery_stun (agent,
host_candidate->sockptr,
if (agent->full_mode && component &&
transport != NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE) {
GList *item;
- int host_ip_version = nice_address_ip_version (&host_candidate->addr);
+ int host_ip_version = nice_address_ip_version (&host_candidate->c.addr);
for (item = component->turn_servers; item; item = item->next) {
TurnServer *turn = item->data;
turn,
stream,
cid,
- host_candidate->transport != NICE_CANDIDATE_TRANSPORT_UDP);
+ host_candidate->c.transport != NICE_CANDIDATE_TRANSPORT_UDP);
}
}
}
agent, pair, pair->foundation);
if (pair->state == NICE_CHECK_SUCCEEDED)
conn_check_unfreeze_related (agent, pair);
- if (component->selected_pair.local == pair->local &&
- component->selected_pair.remote == pair->remote) {
+ if ((NiceCandidate *) component->selected_pair.local == pair->local &&
+ (NiceCandidate *) component->selected_pair.remote == pair->remote) {
gchar priority[NICE_CANDIDATE_PAIR_PRIORITY_MAX_SIZE];
/* the foundation update of the selected pair also implies
NiceStream *stream;
NiceComponent *component;
NiceCandidate *candidate;
+ NiceCandidateImpl *c;
CandidateCheckPair *pair;
if (transport == NICE_CANDIDATE_TRANSPORT_UDP &&
/* step: check whether the candidate already exists */
candidate = nice_component_find_remote_candidate (component, addr, transport);
+ c = (NiceCandidateImpl *) candidate;
/* If it was a discovered remote peer reflexive candidate, then it should
* be updated according to RFC 5245 section 7.2.1.3 */
/* The updated candidate is no more peer reflexive, so its
* sockptr can be cleared
*/
- candidate->sockptr = NULL;
+ c->sockptr = NULL;
/* If it got there, the next one will also be ran, so the foundation
* will be set.
*/
pair = priv_get_highest_priority_nominated_pair (agent,
stream_id, component_id);
if (pair &&
- (pair->local != component->selected_pair.local ||
- pair->remote != component->selected_pair.remote)) {
+ (pair->local != (NiceCandidate *) component->selected_pair.local ||
+ pair->remote != (NiceCandidate *) component->selected_pair.remote)) {
/* If we have (at least) one pair with the nominated flag set, it
* implies that this pair (or another) is set as the selected pair
* for this component. In other words, this is really an *update*
* the socket we do the recv on to the topmost socket
*/
for (cand_i = component->local_candidates; cand_i; cand_i = cand_i->next) {
- NiceCandidate *cand = cand_i->data;
+ NiceCandidateImpl *cand = cand_i->data;
- if (cand->type == NICE_CANDIDATE_TYPE_RELAYED &&
- cand->stream_id == stream->id &&
- cand->component_id == component->id &&
+ if (cand->c.type == NICE_CANDIDATE_TYPE_RELAYED &&
+ cand->c.stream_id == stream->id &&
+ cand->c.component_id == component->id &&
nice_socket_is_based_on(cand->sockptr, nicesock)) {
nice_debug ("Agent %p : Packet received from a TURN socket.",
agent);
is_turn = TRUE;
for (i = component->local_candidates; i; i = i->next) {
- NiceCandidate *cand = i->data;
+ NiceCandidateImpl *cand = i->data;
- if (cand->type == NICE_CANDIDATE_TYPE_RELAYED &&
+ if (cand->c.type == NICE_CANDIDATE_TYPE_RELAYED &&
cand->turn == turn &&
- cand->stream_id == stream->id &&
+ cand->c.stream_id == stream->id &&
nice_socket_is_based_on (cand->sockptr, nicesock)) {
retval = nice_udp_turn_socket_parse_recv_message (cand->sockptr, &nicesock,
message);
if (component->selected_pair.local != NULL) {
if (nice_debug_is_enabled ()) {
gchar tmpbuf[INET6_ADDRSTRLEN];
- nice_address_to_string (&component->selected_pair.remote->addr, tmpbuf);
+ nice_address_to_string (&component->selected_pair.remote->c.addr, tmpbuf);
nice_debug_verbose ("Agent %p : s%d:%d: sending %u messages to "
"[%s]:%d", agent, stream_id, component_id, n_messages, tmpbuf,
- nice_address_get_port (&component->selected_pair.remote->addr));
+ nice_address_get_port (&component->selected_pair.remote->c.addr));
}
if(agent->reliable &&
NiceAddress *addr;
sock = component->selected_pair.local->sockptr;
- addr = &component->selected_pair.remote->addr;
+ addr = &component->selected_pair.remote->c.addr;
if (nice_socket_is_reliable (sock)) {
guint i;
/* step: set the selected pair */
nice_component_update_selected_pair (agent, component, &pair);
agent_signal_new_selected_pair (agent, stream_id, component_id,
- pair.local, pair.remote);
+ (NiceCandidate *) pair.local, (NiceCandidate *) pair.remote);
ret = TRUE;
goto done;
if (component->selected_pair.local && component->selected_pair.remote) {
- *local = component->selected_pair.local;
- *remote = component->selected_pair.remote;
+ *local = (NiceCandidate *) component->selected_pair.local;
+ *remote = (NiceCandidate *) component->selected_pair.remote;
ret = TRUE;
}
if (!component->selected_pair.local || !component->selected_pair.remote)
goto done;
- if (component->selected_pair.local->type == NICE_CANDIDATE_TYPE_RELAYED)
+ if (component->selected_pair.local->c.type == NICE_CANDIDATE_TYPE_RELAYED)
goto done;
/* ICE-TCP requires RFC4571 framing, even if unreliable */
- if (component->selected_pair.local->transport != NICE_CANDIDATE_TRANSPORT_UDP)
+ if (component->selected_pair.local->c.transport != NICE_CANDIDATE_TRANSPORT_UDP)
goto done;
nice_socket = (NiceSocket *)component->selected_pair.local->sockptr;
{
NiceComponent *component;
NiceStream *stream;
- NiceCandidate *lcandidate = NULL;
+ NiceCandidateImpl *lcandidate = NULL;
gboolean ret = FALSE;
- NiceCandidate *local = NULL, *remote = NULL;
+ NiceCandidateImpl *local = NULL, *remote = NULL;
guint64 priority;
g_return_val_if_fail (NICE_IS_AGENT (agent), FALSE);
stream->id, component->id);
/* Revert back to previous selected pair */
/* FIXME: by doing this, we lose the keepalive tick */
- component->selected_pair.local = local;
+ component->selected_pair.local = (NiceCandidateImpl *) local;
component->selected_pair.remote = remote;
component->selected_pair.priority = priority;
goto done;
NICE_COMPONENT_STATE_READY);
agent_signal_new_selected_pair (agent, stream_id, component_id,
- lcandidate, candidate);
+ (NiceCandidate *) lcandidate, candidate);
ret = TRUE;
NiceComponent *component = i->data;
for (j = component->local_candidates; j; j = j->next) {
- NiceCandidate *local_candidate = j->data;
+ NiceCandidateImpl *local_candidate = j->data;
_priv_set_socket_tos (agent, local_candidate->sockptr, tos);
}
--- /dev/null
+/*
+ * This file is part of the Nice GLib ICE library.
+ *
+ * (C) 2006-2020 Collabora Ltd.
+ * Contact: Youness Alaoui
+ * Contact: Olivier Crete
+ * (C) 2006-2009 Nokia Corporation. All rights reserved.
+ * Contact: Kai Vehmanen
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Nice GLib ICE library.
+ *
+ * The Initial Developers of the Original Code are Collabora Ltd and Nokia
+ * Corporation. All Rights Reserved.
+ *
+ * Contributors:
+ * Dafydd Harries, Collabora Ltd.
+ * Youness Alaoui, Collabora Ltd.
+ * Kai Vehmanen, Nokia
+ *
+ * Alternatively, the contents of this file may be used under the terms of the
+ * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
+ * case the provisions of LGPL are applicable instead of those above. If you
+ * wish to allow use of your version of this file only under the terms of the
+ * LGPL and not to allow others to use your version of this file under the
+ * MPL, indicate your decision by deleting the provisions above and replace
+ * them with the notice and other provisions required by the LGPL. If you do
+ * not delete the provisions above, a recipient may use your version of this
+ * file under either the MPL or the LGPL.
+ */
+
+#ifndef __LIBNICE_CANDIDATE_PRIV_H__
+#define __LIBNICE_CANDIDATE_PRIV_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "candidate.h"
+#include "socket/socket.h"
+
+G_BEGIN_DECLS
+
+
+/* Constants for determining candidate priorities */
+#define NICE_CANDIDATE_TYPE_PREF_HOST 120
+#define NICE_CANDIDATE_TYPE_PREF_PEER_REFLEXIVE 110
+#define NICE_CANDIDATE_TYPE_PREF_NAT_ASSISTED 105
+#define NICE_CANDIDATE_TYPE_PREF_SERVER_REFLEXIVE 100
+#define NICE_CANDIDATE_TYPE_PREF_RELAYED_UDP 30
+#define NICE_CANDIDATE_TYPE_PREF_RELAYED 20
+
+/* Priority preference constants for MS-ICE compatibility */
+#define NICE_CANDIDATE_TRANSPORT_MS_PREF_UDP 15
+#define NICE_CANDIDATE_TRANSPORT_MS_PREF_TCP 6
+#define NICE_CANDIDATE_DIRECTION_MS_PREF_PASSIVE 2
+#define NICE_CANDIDATE_DIRECTION_MS_PREF_ACTIVE 5
+
+typedef struct _NiceCandidateImpl NiceCandidateImpl;
+typedef struct _TurnServer TurnServer;
+
+/**
+ * TurnServer:
+ * @ref_count: Reference count for the structure.
+ * @server: The #NiceAddress of the TURN server
+ * @username: The TURN username
+ * @password: The TURN password
+ * @decoded_username: The base64 decoded TURN username
+ * @decoded_password: The base64 decoded TURN password
+ * @decoded_username_len: The length of @decoded_username
+ * @decoded_password_len: The length of @decoded_password
+ * @type: The #NiceRelayType of the server
+ * @preference: A unique identifier used to compute priority
+ *
+ * A structure to store the TURN relay settings
+ */
+struct _TurnServer
+{
+ gint ref_count;
+
+ NiceAddress server;
+ gchar *username;
+ gchar *password;
+ guint8 *decoded_username;
+ guint8 *decoded_password;
+ gsize decoded_username_len;
+ gsize decoded_password_len;
+ NiceRelayType type;
+ guint preference;
+};
+
+
+/**
+ * NiceCandidateImpl:
+ * @c: The #NiceCandidate
+ * @turn: The #TurnServer settings if the candidate is
+ * of type %NICE_CANDIDATE_TYPE_RELAYED
+ * @sockptr: The underlying socket
+ * @keepalive_next_tick: The timestamp for the next keepalive
+ *
+ * A structure to represent an ICE candidate
+ */
+struct _NiceCandidateImpl
+{
+ NiceCandidate c;
+ TurnServer *turn;
+ NiceSocket *sockptr;
+ guint64 keepalive_next_tick; /* next tick timestamp */
+};
+
+
+G_END_DECLS
+
+#endif /* __LIBNICE_CANDIDATE_H__ */
\ No newline at end of file
#include "agent.h"
#include "component.h"
#include "interfaces.h"
+#include "candidate-priv.h"
G_DEFINE_BOXED_TYPE (NiceCandidate, nice_candidate, nice_candidate_copy,
nice_candidate_free);
NICEAPI_EXPORT NiceCandidate *
nice_candidate_new (NiceCandidateType type)
{
- NiceCandidate *candidate;
+ NiceCandidateImpl *c;
- candidate = g_slice_new0 (NiceCandidate);
- candidate->type = type;
- return candidate;
+ c = g_slice_new0 (NiceCandidateImpl);
+ c->c.type = type;
+ return (NiceCandidate *) c;
}
-
NICEAPI_EXPORT void
nice_candidate_free (NiceCandidate *candidate)
{
+ NiceCandidateImpl *c = (NiceCandidateImpl *) candidate;
/* better way of checking if socket is allocated? */
if (candidate->username)
if (candidate->password)
g_free (candidate->password);
- if (candidate->turn)
- turn_server_unref (candidate->turn);
+ if (c->turn)
+ turn_server_unref (c->turn);
- g_slice_free (NiceCandidate, candidate);
+ g_slice_free (NiceCandidateImpl, c);
}
static guint16
nice_candidate_ice_local_preference (const NiceCandidate *candidate)
{
+ const NiceCandidateImpl *c = (NiceCandidateImpl *) candidate;
guint direction_preference = 0;
guint turn_preference = 0;
* creation time.
*/
if (candidate->type == NICE_CANDIDATE_TYPE_RELAYED) {
- g_assert (candidate->turn);
- turn_preference = candidate->turn->preference;
+ g_assert (c->turn);
+ turn_preference = c->turn->preference;
}
return nice_candidate_ice_local_preference_full (direction_preference,
static guint32
nice_candidate_ms_ice_local_preference (const NiceCandidate *candidate)
{
+ const NiceCandidateImpl *c = (NiceCandidateImpl *) candidate;
guint transport_preference = 0;
guint direction_preference = 0;
guint turn_preference = 0;
* creation time.
*/
if (candidate->type == NICE_CANDIDATE_TYPE_RELAYED) {
- g_assert (candidate->turn);
- turn_preference = candidate->turn->preference;
+ g_assert (c->turn);
+ turn_preference = c->turn->preference;
}
return nice_candidate_ms_ice_local_preference_full(transport_preference,
nice_candidate_ice_type_preference (const NiceCandidate *candidate,
gboolean reliable, gboolean nat_assisted)
{
+ const NiceCandidateImpl *c = (NiceCandidateImpl *) candidate;
guint8 type_preference;
switch (candidate->type)
type_preference = NICE_CANDIDATE_TYPE_PREF_SERVER_REFLEXIVE;
break;
case NICE_CANDIDATE_TYPE_RELAYED:
- if (candidate->turn->type == NICE_RELAY_TYPE_TURN_UDP)
+ if (c->turn->type == NICE_RELAY_TYPE_TURN_UDP)
type_preference = NICE_CANDIDATE_TYPE_PREF_RELAYED_UDP;
else
type_preference = NICE_CANDIDATE_TYPE_PREF_RELAYED;
NICEAPI_EXPORT NiceCandidate *
nice_candidate_copy (const NiceCandidate *candidate)
{
- NiceCandidate *copy;
+ const NiceCandidateImpl *c = (NiceCandidateImpl *)candidate;
+ NiceCandidateImpl *copy;
- g_return_val_if_fail (candidate != NULL, NULL);
+ g_return_val_if_fail (c != NULL, NULL);
- copy = nice_candidate_new (candidate->type);
- memcpy (copy, candidate, sizeof(NiceCandidate));
+ copy = (NiceCandidateImpl *) nice_candidate_new (candidate->type);
+ memcpy (copy, candidate, sizeof(NiceCandidateImpl));
copy->turn = NULL;
- copy->username = g_strdup (copy->username);
- copy->password = g_strdup (copy->password);
+ copy->c.username = g_strdup (copy->c.username);
+ copy->c.password = g_strdup (copy->c.password);
- return copy;
+ return (NiceCandidate *) copy;
}
NICEAPI_EXPORT gboolean
G_BEGIN_DECLS
-/* Constants for determining candidate priorities */
-#define NICE_CANDIDATE_TYPE_PREF_HOST 120
-#define NICE_CANDIDATE_TYPE_PREF_PEER_REFLEXIVE 110
-#define NICE_CANDIDATE_TYPE_PREF_NAT_ASSISTED 105
-#define NICE_CANDIDATE_TYPE_PREF_SERVER_REFLEXIVE 100
-#define NICE_CANDIDATE_TYPE_PREF_RELAYED_UDP 30
-#define NICE_CANDIDATE_TYPE_PREF_RELAYED 20
-
-/* Priority preference constants for MS-ICE compatibility */
-#define NICE_CANDIDATE_TRANSPORT_MS_PREF_UDP 15
-#define NICE_CANDIDATE_TRANSPORT_MS_PREF_TCP 6
-#define NICE_CANDIDATE_DIRECTION_MS_PREF_PASSIVE 2
-#define NICE_CANDIDATE_DIRECTION_MS_PREF_ACTIVE 5
/* Max foundation size '1*32ice-char' plus terminating NULL, ICE ID-19 */
/**
typedef struct _NiceCandidate NiceCandidate;
-typedef struct _TurnServer TurnServer;
-
-/**
- * TurnServer:
- * @ref_count: Reference count for the structure.
- * @server: The #NiceAddress of the TURN server
- * @username: The TURN username
- * @password: The TURN password
- * @decoded_username: The base64 decoded TURN username
- * @decoded_password: The base64 decoded TURN password
- * @decoded_username_len: The length of @decoded_username
- * @decoded_password_len: The length of @decoded_password
- * @type: The #NiceRelayType of the server
- * @preference: A unique identifier used to compute priority
- *
- * A structure to store the TURN relay settings
- */
-struct _TurnServer
-{
- gint ref_count;
-
- NiceAddress server;
- gchar *username;
- gchar *password;
- guint8 *decoded_username;
- guint8 *decoded_password;
- gsize decoded_username_len;
- gsize decoded_password_len;
- NiceRelayType type;
- guint preference;
-};
/**
* NiceCandidate:
* by nice_agent_set_local_credentials() or nice_agent_set_remote_credentials())
* @password: The candidate-specific password to use (overrides the one set
* by nice_agent_set_local_credentials() or nice_agent_set_remote_credentials())
- * @turn: The #TurnServer settings if the candidate is
- * of type %NICE_CANDIDATE_TYPE_RELAYED
- * @sockptr: The underlying socket
- * @keepalive_next_tick: The timestamp for the next keepalive
*
* A structure to represent an ICE candidate
<note>
gchar foundation[NICE_CANDIDATE_MAX_FOUNDATION];
gchar *username; /* pointer to a nul-terminated username string */
gchar *password; /* pointer to a nul-terminated password string */
- TurnServer *turn;
- gpointer sockptr;
- guint64 keepalive_next_tick; /* next tick timestamp */
};
/**
conn_check_prune_socket (agent, stream, cmp, nsocket);
for (i = cmp->local_candidates; i;) {
- NiceCandidate *candidate = i->data;
+ NiceCandidateImpl *candidate = (NiceCandidateImpl *) i->data;
GSList *next = i->next;
if (!nice_socket_is_based_on (candidate->sockptr, nsocket)) {
refresh_prune_candidate (agent, candidate);
if (candidate->sockptr != nsocket && stream) {
discovery_prune_socket (agent, candidate->sockptr);
- conn_check_prune_socket (agent, stream, cmp,
- candidate->sockptr);
+ conn_check_prune_socket (agent, stream, cmp, candidate->sockptr);
nice_component_detach_socket (cmp, candidate->sockptr);
}
- agent_remove_local_candidate (agent, candidate);
- nice_candidate_free (candidate);
+ agent_remove_local_candidate (agent, (NiceCandidate *) candidate);
+ nice_candidate_free ((NiceCandidate *) candidate);
cmp->local_candidates = g_slist_delete_link (cmp->local_candidates, i);
i = next;
* peer-reflexive remote candidate
*/
for (i = cmp->remote_candidates; i;) {
- NiceCandidate *candidate = i->data;
+ NiceCandidateImpl *candidate = i->data;
GSList *next = i->next;
if (candidate->sockptr != nsocket) {
if (stream)
conn_check_prune_socket (agent, stream, cmp, candidate->sockptr);
- nice_candidate_free (candidate);
+ nice_candidate_free ((NiceCandidate *) candidate);
cmp->remote_candidates = g_slist_delete_link (cmp->remote_candidates, i);
i = next;
}
static gboolean
-on_candidate_refreshes_pruned (NiceAgent *agent, NiceCandidate *candidate)
+on_candidate_refreshes_pruned (NiceAgent *agent, NiceCandidateImpl *candidate)
{
NiceComponent *component;
- if (agent_find_component (agent, candidate->stream_id,
- candidate->component_id, NULL, &component)) {
+ if (agent_find_component (agent, candidate->c.stream_id,
+ candidate->c.component_id, NULL, &component)) {
nice_component_detach_socket (component, candidate->sockptr);
}
- nice_candidate_free (candidate);
+ nice_candidate_free ((NiceCandidate *) candidate);
return G_SOURCE_REMOVE;
}
cmp->turn_servers = NULL;
for (i = cmp->local_candidates; i;) {
- NiceCandidate *candidate = i->data;
+ NiceCandidateImpl *candidate = i->data;
GSList *next = i->next;
- if (candidate->type != NICE_CANDIDATE_TYPE_RELAYED) {
+ if (candidate->c.type != NICE_CANDIDATE_TYPE_RELAYED) {
i = next;
continue;
}
cmp->selected_pair.priority = 0;
cmp->turn_candidate = candidate;
} else {
- agent_remove_local_candidate (agent, candidate);
+ agent_remove_local_candidate (agent, (NiceCandidate *) candidate);
relay_candidates = g_slist_append(relay_candidates, candidate);
}
cmp->local_candidates = g_slist_delete_link (cmp->local_candidates, i);
}
for (i = relay_candidates; i; i = i->next) {
- NiceCandidate * candidate = i->data;
+ NiceCandidateImpl * candidate = i->data;
discovery_prune_socket (agent, candidate->sockptr);
if (stream) {
cmp->restart_candidate = NULL;
if (cmp->turn_candidate)
- nice_candidate_free (cmp->turn_candidate),
+ nice_candidate_free ((NiceCandidate *) cmp->turn_candidate),
cmp->turn_candidate = NULL;
while (cmp->local_candidates) {
CandidatePair result = { 0, };
for (i = cmp->local_candidates; i; i = i->next) {
- NiceCandidate *candidate = i->data;
- if (strncmp (candidate->foundation, lfoundation, NICE_CANDIDATE_MAX_FOUNDATION) == 0) {
+ NiceCandidateImpl *candidate = i->data;
+ if (strncmp (candidate->c.foundation, lfoundation, NICE_CANDIDATE_MAX_FOUNDATION) == 0) {
result.local = candidate;
break;
}
}
for (i = cmp->remote_candidates; i; i = i->next) {
- NiceCandidate *candidate = i->data;
- if (strncmp (candidate->foundation, rfoundation, NICE_CANDIDATE_MAX_FOUNDATION) == 0) {
+ NiceCandidateImpl *candidate = i->data;
+ if (strncmp (candidate->c.foundation, rfoundation, NICE_CANDIDATE_MAX_FOUNDATION) == 0) {
result.remote = candidate;
break;
}
}
if (result.local && result.remote) {
- result.priority = agent_candidate_pair_priority (agent, result.local, result.remote);
+ result.priority = agent_candidate_pair_priority (agent,
+ (NiceCandidate *) result.local, (NiceCandidate *) result.remote);
if (pair)
*pair = result;
return TRUE;
/* note: do not remove the remote candidate that is
* currently part of the 'selected pair', see ICE
* 9.1.1.1. "ICE Restarts" (ID-19) */
- if (candidate == cmp->selected_pair.remote) {
+ if (candidate == (NiceCandidate *) cmp->selected_pair.remote) {
if (cmp->restart_candidate)
nice_candidate_free (cmp->restart_candidate);
cmp->restart_candidate = candidate;
nice_candidate_pair_priority_to_string (pair->priority, priority);
nice_debug ("setting SELECTED PAIR for component %u: %s:%s (prio:%s).",
- component->id, pair->local->foundation,
- pair->remote->foundation, priority);
+ component->id, pair->local->c.foundation,
+ pair->remote->c.foundation, priority);
if (component->selected_pair.local &&
component->selected_pair.local == component->turn_candidate) {
component->selected_pair.priority = pair->priority;
component->selected_pair.stun_priority = pair->stun_priority;
- nice_component_add_valid_candidate (agent, component, pair->remote);
+ nice_component_add_valid_candidate (agent, component,
+ (NiceCandidate *) pair->remote);
}
/*
* this candidate.
*/
-NiceCandidate *
+NiceCandidateImpl *
nice_component_set_selected_remote_candidate (NiceComponent *component,
NiceAgent *agent, NiceCandidate *candidate)
{
nice_component_clear_selected_pair (component);
- component->selected_pair.local = local;
- component->selected_pair.remote = remote;
+ component->selected_pair.local = (NiceCandidateImpl *) local;
+ component->selected_pair.remote = (NiceCandidateImpl *) remote;
component->selected_pair.priority = priority;
/* Get into fallback mode where packets from any source is accepted once
*/
component->fallback_mode = TRUE;
- return local;
+ return (NiceCandidateImpl *) local;
}
static gint
GSList *item;
for (item = component->local_candidates; item; item = item->next) {
- NiceCandidate *cand = item->data;
- NiceSocket *nicesock = cand->sockptr;
+ NiceCandidateImpl *c = item->data;
+ NiceSocket *nicesock = c->sockptr;
if (nicesock->fileno && !g_ptr_array_find (array, nicesock->fileno, NULL))
g_ptr_array_add (array, g_object_ref (nicesock->fileno));
#include "agent.h"
#include "agent-priv.h"
-#include "candidate.h"
+#include "candidate-priv.h"
#include "stun/stunagent.h"
#include "stun/usages/timer.h"
#include "pseudotcp.h"
struct _CandidatePair
{
- NiceCandidate *local;
- NiceCandidate *remote;
+ NiceCandidateImpl *local;
+ NiceCandidateImpl *remote;
guint64 priority; /* candidate pair priority */
guint32 stun_priority;
CandidatePairKeepalive keepalive;
see ICE 11.1. "Sending Media" (ID-19) */
gboolean fallback_mode; /* in this case, accepts packets from all, ignore candidate validation */
NiceCandidate *restart_candidate; /* for storing active remote candidate during a restart */
- NiceCandidate *turn_candidate; /* for storing active turn candidate if turn servers have been cleared */
+ NiceCandidateImpl *turn_candidate; /* for storing active turn candidate if turn servers have been cleared */
/* I/O handling. The main context must always be non-NULL, and is used for all
* socket recv() operations. All io_callback emissions are invoked in this
* context too.
nice_component_find_remote_candidate (NiceComponent *component,
const NiceAddress *addr, NiceCandidateTransport transport);
-NiceCandidate *
+NiceCandidateImpl *
nice_component_set_selected_remote_candidate (NiceComponent *component,
NiceAgent *agent, NiceCandidate *candidate);
}
case STUN_USAGE_TIMER_RETURN_RETRANSMIT:
/* Retransmit */
- agent_socket_send (pair->local->sockptr, &pair->remote->addr,
+ agent_socket_send (pair->local->sockptr, &pair->remote->c.addr,
stun_message_length (&pair->keepalive.stun_message),
(gchar *)pair->keepalive.stun_buffer);
CandidatePair *p = &component->selected_pair;
/* Disable keepalive checks on TCP candidates unless explicitly enabled */
- if (p->local->transport != NICE_CANDIDATE_TRANSPORT_UDP &&
+ if (p->local->c.transport != NICE_CANDIDATE_TRANSPORT_UDP &&
!agent->keepalive_conncheck)
continue;
uint8_t uname[NICE_STREAM_MAX_UNAME];
size_t uname_len =
priv_create_username (agent, agent_find_stream (agent, stream->id),
- component->id, p->remote, p->local, uname, sizeof (uname),
- FALSE);
+ component->id, (NiceCandidate *) p->remote,
+ (NiceCandidate *) p->local, uname, sizeof (uname), FALSE);
uint8_t *password = NULL;
size_t password_len = priv_get_password (agent,
- agent_find_stream (agent, stream->id), p->remote, &password);
+ agent_find_stream (agent, stream->id),
+ (NiceCandidate *) p->remote, &password);
if (p->keepalive.stun_message.buffer != NULL) {
nice_debug ("Agent %p: Keepalive for s%u:c%u still"
if (nice_debug_is_enabled ()) {
gchar tmpbuf[INET6_ADDRSTRLEN];
- nice_address_to_string (&p->remote->addr, tmpbuf);
+ nice_address_to_string (&p->remote->c.addr, tmpbuf);
nice_debug ("Agent %p : Keepalive STUN-CC REQ to '%s:%u', "
"(c-id:%u), username='%.*s' (%" G_GSIZE_FORMAT "), "
"password='%.*s' (%" G_GSIZE_FORMAT "), priority=%08x.",
- agent, tmpbuf, nice_address_get_port (&p->remote->addr),
+ agent, tmpbuf, nice_address_get_port (&p->remote->c.addr),
component->id, (int) uname_len, uname, uname_len,
(int) password_len, password, password_len,
p->stun_priority);
agent->media_after_tick = FALSE;
/* send the conncheck */
- agent_socket_send (p->local->sockptr, &p->remote->addr,
+ agent_socket_send (p->local->sockptr, &p->remote->c.addr,
buf_len, (gchar *)p->keepalive.stun_buffer);
p->keepalive.stream_id = stream->id;
sizeof(p->keepalive.stun_buffer));
if (buf_len > 0) {
- agent_socket_send (p->local->sockptr, &p->remote->addr, buf_len,
+ agent_socket_send (p->local->sockptr, &p->remote->c.addr, buf_len,
(gchar *)p->keepalive.stun_buffer);
p->keepalive.next_tick = now + 1000 * NICE_AGENT_TIMER_TR_DEFAULT;
if (agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
ms_ice2_legacy_conncheck_send (&p->keepalive.stun_message,
- p->local->sockptr, &p->remote->addr);
+ p->local->sockptr, &p->remote->c.addr);
}
if (nice_debug_is_enabled ()) {
gchar tmpbuf[INET6_ADDRSTRLEN];
- nice_address_to_string (&p->local->base_addr, tmpbuf);
+ nice_address_to_string (&p->local->c.base_addr, tmpbuf);
nice_debug ("Agent %p : resending STUN to keep the "
"selected base address %s:%u alive in s%d/c%d.", agent,
- tmpbuf, nice_address_get_port (&p->local->base_addr),
+ tmpbuf, nice_address_get_port (&p->local->c.base_addr),
stream->id, component->id);
}
&stun_message, stun_buffer, sizeof(stun_buffer));
for (k = component->local_candidates; k; k = k->next) {
- NiceCandidate *candidate = (NiceCandidate *) k->data;
- if (candidate->type == NICE_CANDIDATE_TYPE_HOST &&
- candidate->transport == NICE_CANDIDATE_TRANSPORT_UDP &&
- nice_address_ip_version (&candidate->addr) ==
+ NiceCandidateImpl *candidate = (NiceCandidateImpl *) k->data;
+ if (candidate->c.type == NICE_CANDIDATE_TYPE_HOST &&
+ candidate->c.transport == NICE_CANDIDATE_TRANSPORT_UDP &&
+ nice_address_ip_version (&candidate->c.addr) ==
nice_address_ip_version (&stun_server)) {
if (candidate->keepalive_next_tick) {
/* send the conncheck */
if (nice_debug_is_enabled ()) {
gchar tmpbuf[INET6_ADDRSTRLEN];
- nice_address_to_string (&candidate->addr, tmpbuf);
+ nice_address_to_string (&candidate->c.addr, tmpbuf);
nice_debug ("Agent %p : resending STUN to keep the local "
"candidate %s:%u alive in s%d/c%d.", agent,
- tmpbuf, nice_address_get_port (&candidate->addr),
+ tmpbuf, nice_address_get_port (&candidate->c.addr),
stream->id, component->id);
}
agent_socket_send (candidate->sockptr, &stun_server,
{
gboolean ret = TRUE;
NiceCandidateTransport transport;
+ NiceCandidateImpl *lc = (NiceCandidateImpl *) lcand;
g_assert (socket);
g_assert (lcand);
* socket is the tcp connect related socket */
if (ret && transport == NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE &&
nice_address_get_port (&lcand->addr) > 0)
- ret = (lcand->sockptr == socket);
+ ret = (lc->sockptr == socket);
} else if (socket->type == NICE_SOCKET_TYPE_UDP_TURN)
/* Socket of type udp-turn will match a unique local candidate
* by its sockptr value. An an udp-turn socket doesn't carry enough
* information when base socket is udp-turn-over-tcp to disambiguate
* between a tcp-act and a tcp-pass local candidate.
*/
- ret = (lcand->sockptr == socket);
+ ret = (lc->sockptr == socket);
return ret;
}
"(prio:%s).", agent, component->id,
pair->local->foundation, pair->remote->foundation, priority);
- cpair.local = pair->local;
- cpair.remote = pair->remote;
+ cpair.local = (NiceCandidateImpl *) pair->local;
+ cpair.remote = (NiceCandidateImpl *) pair->remote;
cpair.priority = pair->priority;
cpair.stun_priority = pair->stun_priority;
* the agent's list of checks.
*/
static CandidateCheckPair *priv_add_new_check_pair (NiceAgent *agent,
- guint stream_id, NiceComponent *component, NiceCandidate *local,
- NiceCandidate *remote, NiceCheckState initial_state)
+ guint stream_id, NiceComponent *component, NiceCandidateImpl *local,
+ NiceCandidateImpl *remote, NiceCheckState initial_state)
{
NiceStream *stream;
CandidateCheckPair *pair;
g_assert (local != NULL);
g_assert (remote != NULL);
- priority = agent_candidate_pair_priority (agent, local, remote);
+ priority = agent_candidate_pair_priority (agent, (NiceCandidate *) local,
+ (NiceCandidate *) remote);
if (component->selected_pair.priority &&
priority < component->selected_pair.priority) {
pair = g_slice_new0 (CandidateCheckPair);
pair->stream_id = stream_id;
- pair->component_id = component->id;;
- pair->local = local;
- pair->remote = remote;
+ pair->component_id = component->id;
+ pair->local = (NiceCandidate *) local;
+ pair->remote = (NiceCandidate *) remote;
/* note: we use the remote sockptr only in the case
* of TCP transport
*/
- if (local->transport == NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE &&
- remote->type == NICE_CANDIDATE_TYPE_PEER_REFLEXIVE)
- pair->sockptr = (NiceSocket *) remote->sockptr;
+ if (local->c.transport == NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE &&
+ remote->c.type == NICE_CANDIDATE_TYPE_PEER_REFLEXIVE)
+ pair->sockptr = remote->sockptr;
else
- pair->sockptr = (NiceSocket *) local->sockptr;
- g_snprintf (pair->foundation, NICE_CANDIDATE_PAIR_MAX_FOUNDATION, "%s:%s", local->foundation, remote->foundation);
+ pair->sockptr = local->sockptr;
+ g_snprintf (pair->foundation, NICE_CANDIDATE_PAIR_MAX_FOUNDATION, "%s:%s",
+ local->c.foundation, remote->c.foundation);
- pair->priority = agent_candidate_pair_priority (agent, local, remote);
+ pair->priority = agent_candidate_pair_priority (agent,
+ (NiceCandidate *) local, (NiceCandidate *) remote);
nice_debug ("Agent %p : creating a new pair", agent);
SET_PAIR_STATE (agent, pair, initial_state);
{
tmpbuf1, nice_address_get_port (&pair->local->addr),
tmpbuf2, nice_address_get_port (&pair->remote->addr));
}
- pair->stun_priority = stun_request_priority (agent, local);
+ pair->stun_priority = stun_request_priority (agent, (NiceCandidate *) local);
stream->conncheck_list = g_slist_insert_sorted (stream->conncheck_list, pair,
(GCompareFunc)conn_check_compare);
{
CandidateCheckPair *pair;
- pair = priv_add_new_check_pair (agent, stream_id, component, local, remote,
- initial_state);
+ pair = priv_add_new_check_pair (agent, stream_id, component,
+ (NiceCandidateImpl *) local, (NiceCandidateImpl *) remote, initial_state);
if (pair) {
if (component->state == NICE_COMPONENT_STATE_CONNECTED ||
component->state == NICE_COMPONENT_STATE_READY) {
}
for (i = component->local_candidates; i ; i = i->next) {
- local = i->data;
- if (local->sockptr == local_socket)
- break;
+ NiceCandidateImpl *lc = i->data;
+ local = i->data;
+ if (lc->sockptr == local_socket)
+ break;
}
if (i) {
*
* @return created pair, or NULL on fatal (memory allocation) errors
*/
-static CandidateCheckPair *priv_add_peer_reflexive_pair (NiceAgent *agent, guint stream_id, NiceComponent *component, NiceCandidate *local_cand, CandidateCheckPair *parent_pair)
+static CandidateCheckPair *priv_add_peer_reflexive_pair (NiceAgent *agent, guint stream_id, NiceComponent *component, NiceCandidateImpl *local_cand, CandidateCheckPair *parent_pair)
{
CandidateCheckPair *pair = g_slice_new0 (CandidateCheckPair);
NiceStream *stream = agent_find_stream (agent, stream_id);
pair->stream_id = stream_id;
pair->component_id = component->id;;
- pair->local = local_cand;
+ pair->local = (NiceCandidate *) local_cand;
pair->remote = parent_pair->remote;
pair->sockptr = local_cand->sockptr;
parent_pair->discovered_pair = pair;
tmpbuf2, nice_address_get_port (&pair->remote->addr));
}
g_snprintf (pair->foundation, NICE_CANDIDATE_PAIR_MAX_FOUNDATION, "%s:%s",
- local_cand->foundation, parent_pair->remote->foundation);
+ local_cand->c.foundation, parent_pair->remote->foundation);
if (agent->controlling_mode == TRUE)
pair->priority = nice_candidate_pair_priority (pair->local->priority,
"Constructing a Valid Pair") */
if (local_cand)
new_pair = priv_add_peer_reflexive_pair (agent, stream->id, component,
- local_cand, p);
+ (NiceCandidateImpl *) local_cand, p);
/* note: this is same as "adding to VALID LIST" in the spec
text */
if (new_pair)
static void
priv_add_new_turn_refresh (NiceAgent *agent, CandidateDiscovery *cdisco,
- NiceCandidate *relay_cand, guint lifetime)
+ NiceCandidateImpl *relay_cand, guint lifetime)
{
CandidateRefresh *cand;
res == STUN_USAGE_TURN_RETURN_MAPPED_SUCCESS) {
/* case: successful allocate, create a new local candidate */
NiceAddress niceaddr;
- NiceCandidate *relay_cand;
+ NiceCandidateImpl *relay_cand;
nice_address_set_from_sockaddr (&niceaddr, &relayaddr.addr);
* selected pair's priority so this pair gets SELECTED!
*/
if (component->selected_pair.priority &&
- component->selected_pair.remote && component->selected_pair.remote != remote_candidate &&
- component->selected_pair.local && component->selected_pair.local != local_candidate) {
+ component->selected_pair.remote && component->selected_pair.remote != (NiceCandidateImpl *) remote_candidate &&
+ component->selected_pair.local && component->selected_pair.local != (NiceCandidateImpl *) local_candidate) {
for (lst = stream->conncheck_list; lst; lst = lst->next) {
CandidateCheckPair *pair = lst->data;
if (pair->local == local_candidate && pair->remote == remote_candidate) {
CandidateCheckPair *p = l->data;
GSList *next = l->next;
- if ((p->local != NULL && p->local->sockptr == sock) ||
- (p->remote != NULL && p->remote->sockptr == sock) ||
+ if ((p->local != NULL && ((NiceCandidateImpl*) p->local)->sockptr == sock) ||
+ (p->remote != NULL && ((NiceCandidateImpl*)p->remote)->sockptr == sock) ||
(p->sockptr == sock)) {
nice_debug ("Agent %p : Retransmissions failed, giving up on pair %p",
agent, p);
gsize password_len;
size_t buffer_len = 0;
CandidateRefresh *cand = (CandidateRefresh *) pointer;
+ NiceCandidateImpl *c = (NiceCandidateImpl *) cand->candidate;
StunUsageTurnCompatibility turn_compat = agent_to_turn_compatibility (agent);
nice_debug ("Agent %p : Sending request to remove TURN allocation "
g_source_unref (cand->destroy_source);
cand->destroy_source = NULL;
- username = (uint8_t *)cand->candidate->turn->username;
- username_len = (size_t) strlen (cand->candidate->turn->username);
- password = (uint8_t *)cand->candidate->turn->password;
- password_len = (size_t) strlen (cand->candidate->turn->password);
+ username = (uint8_t *)c->turn->username;
+ username_len = (size_t) strlen (c->turn->username);
+ password = (uint8_t *)c->turn->password;
+ password_len = (size_t) strlen (c->turn->password);
if (turn_compat == STUN_USAGE_TURN_COMPATIBILITY_MSN ||
turn_compat == STUN_USAGE_TURN_COMPATIBILITY_OC2007) {
- username = cand->candidate->turn->decoded_username;
- password = cand->candidate->turn->decoded_password;
- username_len = cand->candidate->turn->decoded_username_len;
- password_len = cand->candidate->turn->decoded_password_len;
+ username = c->turn->decoded_username;
+ password = c->turn->decoded_password;
+ username_len = c->turn->decoded_username_len;
+ password_len = c->turn->decoded_password_len;
}
buffer_len = stun_usage_turn_create_refresh (&cand->stun_agent,
* situations when an error is detected in socket communication that prevents
* sending more requests to the server.
*/
-void refresh_prune_candidate (NiceAgent *agent, NiceCandidate *candidate)
+void refresh_prune_candidate (NiceAgent *agent, NiceCandidateImpl *candidate)
{
GSList *i;
* closes the associated port allocations on TURN server. Invokes 'function'
* when the process finishes.
*/
-void refresh_prune_candidate_async (NiceAgent *agent, NiceCandidate *candidate,
- NiceTimeoutLockedCallback function)
+void refresh_prune_candidate_async (NiceAgent *agent,
+ NiceCandidateImpl *candidate, NiceTimeoutLockedCallback function)
{
GSList *refreshes = NULL;
GSList *i;
static void priv_assign_foundation (NiceAgent *agent, NiceCandidate *candidate)
{
GSList *i, *j, *k;
+ NiceCandidateImpl *c = (NiceCandidateImpl *) candidate;
for (i = agent->streams; i; i = i->next) {
NiceStream *stream = i->data;
for (j = stream->components; j; j = j->next) {
NiceComponent *component = j->data;
for (k = component->local_candidates; k; k = k->next) {
- NiceCandidate *n = k->data;
+ NiceCandidateImpl *n = k->data;
- /* note: candidate must not on the local candidate list */
- g_assert (candidate != n);
+ /* note: candidate must not on the local candidate list */
+ g_assert (c != n);
- if (candidate->type == n->type &&
- candidate->transport == n->transport &&
- nice_address_equal_no_port (&candidate->base_addr, &n->base_addr) &&
+ if (candidate->type == n->c.type &&
+ candidate->transport == n->c.transport &&
+ nice_address_equal_no_port (&candidate->base_addr, &n->c.base_addr) &&
(candidate->type != NICE_CANDIDATE_TYPE_RELAYED ||
- priv_compare_turn_servers (candidate->turn, n->turn)) &&
+ priv_compare_turn_servers (c->turn, n->turn)) &&
!(agent->compatibility == NICE_COMPATIBILITY_GOOGLE &&
- n->type == NICE_CANDIDATE_TYPE_RELAYED)) {
+ n->c.type == NICE_CANDIDATE_TYPE_RELAYED)) {
/* note: currently only one STUN server per stream at a
* time is supported, so there is no need to check
* for candidates that would otherwise share the
* foundation, but have different STUN servers */
- g_strlcpy (candidate->foundation, n->foundation,
+ g_strlcpy (candidate->foundation, n->c.foundation,
NICE_CANDIDATE_MAX_FOUNDATION);
- if (n->username) {
+ if (n->c.username) {
g_free (candidate->username);
- candidate->username = g_strdup (n->username);
+ candidate->username = g_strdup (n->c.username);
}
- if (n->password) {
+ if (n->c.password) {
g_free (candidate->password);
- candidate->password = g_strdup (n->password);
+ candidate->password = g_strdup (n->c.password);
}
return;
}
NiceAddress *address,
NiceCandidateTransport transport,
gboolean accept_duplicate,
- NiceCandidate **outcandidate)
+ NiceCandidateImpl **outcandidate)
{
NiceCandidate *candidate;
+ NiceCandidateImpl *c;
NiceComponent *component;
NiceStream *stream;
NiceSocket *nicesock = NULL;
return res;
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_HOST);
+ c = (NiceCandidateImpl *) candidate;
candidate->transport = transport;
candidate->stream_id = stream_id;
candidate->component_id = component_id;
goto errors;
}
- candidate->sockptr = nicesock;
+ c->sockptr = nicesock;
candidate->addr = nicesock->addr;
candidate->base_addr = nicesock->addr;
_priv_set_socket_tos (agent, nicesock, stream->tos);
nice_component_attach_socket (component, nicesock);
- *outcandidate = candidate;
+ *outcandidate = c;
return HOST_CANDIDATE_SUCCESS;
gboolean nat_assisted)
{
NiceCandidate *candidate;
+ NiceCandidateImpl *c;
NiceComponent *component;
NiceStream *stream;
gboolean result = FALSE;
return NULL;
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE);
+ c = (NiceCandidateImpl *) candidate;
candidate->transport = transport;
candidate->stream_id = stream_id;
candidate->component_id = component_id;
candidate->addr = *address;
/* step: link to the base candidate+socket */
- candidate->sockptr = base_socket;
+ c->sockptr = base_socket;
candidate->base_addr = base_socket->addr;
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
component_id,
address,
c->transport,
- c->sockptr,
+ ((NiceCandidateImpl *) c)->sockptr,
FALSE);
}
}
*
* @return pointer to the created candidate, or NULL on error
*/
-NiceCandidate*
+NiceCandidateImpl *
discovery_add_relay_candidate (
NiceAgent *agent,
guint stream_id,
TurnServer *turn)
{
NiceCandidate *candidate;
+ NiceCandidateImpl *c;
NiceComponent *component;
NiceStream *stream;
NiceSocket *relay_socket = NULL;
return NULL;
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_RELAYED);
+ c = (NiceCandidateImpl *) candidate;
candidate->transport = transport;
candidate->stream_id = stream_id;
candidate->component_id = component_id;
candidate->addr = *address;
- candidate->turn = turn_server_ref (turn);
+ c->turn = turn_server_ref (turn);
/* step: link to the base candidate+socket */
relay_socket = nice_udp_turn_socket_new (agent->main_context, address,
if (!relay_socket)
goto errors;
- candidate->sockptr = relay_socket;
+ c->sockptr = relay_socket;
candidate->base_addr = base_socket->addr;
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
nice_component_attach_socket (component, relay_socket);
agent_signal_new_candidate (agent, candidate);
- return candidate;
+ return c;
errors:
nice_candidate_free (candidate);
NiceCandidate *remote)
{
NiceCandidate *candidate;
+ NiceCandidateImpl *c;
NiceComponent *component;
NiceStream *stream;
gboolean result;
return NULL;
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_PEER_REFLEXIVE);
+ c = (NiceCandidateImpl *) candidate;
if (local)
candidate->transport = local->transport;
else if (remote)
candidate->stream_id = stream_id;
candidate->component_id = component_id;
candidate->addr = *address;
- candidate->sockptr = base_socket;
+ c->sockptr = base_socket;
candidate->base_addr = base_socket->addr;
/* We don't ensure priority uniqueness in this case, since the
* discovered candidate receives the same priority than its
NiceCandidate *remote)
{
NiceCandidate *candidate;
+ NiceCandidateImpl *c;
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_PEER_REFLEXIVE);
+ c = (NiceCandidateImpl *) candidate;
candidate->addr = *remote_address;
candidate->base_addr = *remote_address;
else
candidate->transport = NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE;
}
- candidate->sockptr = nicesock;
+ c->sockptr = nicesock;
candidate->stream_id = stream->id;
candidate->component_id = component->id;
#include "stream.h"
#include "agent.h"
+#include "candidate-priv.h"
typedef struct
{
{
NiceSocket *nicesock; /* existing socket to use */
NiceAddress server; /* STUN/TURN server address */
- NiceCandidate *candidate; /* candidate to refresh */
+ NiceCandidateImpl *candidate; /* candidate to refresh */
guint stream_id;
guint component_id;
StunAgent stun_agent;
NiceTimeoutLockedCallback function, gpointer user_data);
void refresh_prune_stream_async (NiceAgent *agent, NiceStream *stream,
NiceTimeoutLockedCallback function);
-void refresh_prune_candidate (NiceAgent *agent, NiceCandidate *candidate);
-void refresh_prune_candidate_async (NiceAgent *agent, NiceCandidate *candidate,
+void refresh_prune_candidate (NiceAgent *agent, NiceCandidateImpl *candidate);
+void refresh_prune_candidate_async (NiceAgent *agent, NiceCandidateImpl *cand,
NiceTimeoutLockedCallback function);
NiceAddress *address,
NiceCandidateTransport transport,
gboolean accept_duplicate,
- NiceCandidate **candidate);
+ NiceCandidateImpl **candidate);
-NiceCandidate*
+NiceCandidateImpl*
discovery_add_relay_candidate (
NiceAgent *agent,
guint stream_id,
NiceCandidate
NiceCandidateType
NiceCandidateTransport
-TurnServer
NiceRelayType
NICE_CANDIDATE_MAX_FOUNDATION
NICE_CANDIDATE_MAX_TURN_SERVERS
NICE_CANDIDATE_DIRECTION_MS_PREF_PASSIVE
NICE_CANDIDATE_TRANSPORT_MS_PREF_TCP
NICE_CANDIDATE_TRANSPORT_MS_PREF_UDP
+TurnServer
</SECTION>
<SECTION>
'agent-priv.h',
'iostream.h',
'inputstream.h',
+ 'candidate-priv.h',
'outputstream.h',
'gstnice.h',
'gstnicesrc.h',
#endif
#include "agent.h"
+#include "candidate-priv.h"
#include "socket/socket.h"
*/
for (item1 = cands; item1; item1 = item1->next) {
- NiceCandidate *cand = item1->data;
+ NiceCandidateImpl *cand = item1->data;
NiceSocket *nicesock = cand->sockptr;
g_assert (nicesock);