Commit b5b4325f authored by Youness Alaoui's avatar Youness Alaoui

Port nice agent to the new API of NiceSocket

parent 7f8ff6c2
...@@ -68,8 +68,6 @@ struct _NiceAgent ...@@ -68,8 +68,6 @@ struct _NiceAgent
GObject parent; /**< gobject pointer */ GObject parent; /**< gobject pointer */
gboolean full_mode; /**< property: full-mode */ gboolean full_mode; /**< property: full-mode */
NiceSocketFactory *udp_socket_factory; /**< property: socket factory */
NiceSocketFactory *relay_socket_factory; /**< property: socket factory */
GTimeVal next_check_tv; /**< property: next conncheck timestamp */ GTimeVal next_check_tv; /**< property: next conncheck timestamp */
gchar *stun_server_ip; /**< property: STUN server IP */ gchar *stun_server_ip; /**< property: STUN server IP */
guint stun_server_port; /**< property: STUN server port */ guint stun_server_port; /**< property: STUN server port */
......
...@@ -376,11 +376,6 @@ nice_agent_init (NiceAgent *agent) ...@@ -376,11 +376,6 @@ nice_agent_init (NiceAgent *agent)
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS | STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
STUN_AGENT_USAGE_USE_FINGERPRINT); STUN_AGENT_USAGE_USE_FINGERPRINT);
agent->udp_socket_factory =
nice_socket_factory_new (NICE_SOCKET_FACTORY_UDP_BSD);
agent->relay_socket_factory =
nice_socket_factory_new (NICE_SOCKET_FACTORY_UDP_RELAY);
agent->rng = nice_rng_new (); agent->rng = nice_rng_new ();
priv_generate_tie_breaker (agent); priv_generate_tie_breaker (agent);
...@@ -1802,11 +1797,6 @@ nice_agent_dispose (GObject *object) ...@@ -1802,11 +1797,6 @@ nice_agent_dispose (GObject *object)
if (G_OBJECT_CLASS (nice_agent_parent_class)->dispose) if (G_OBJECT_CLASS (nice_agent_parent_class)->dispose)
G_OBJECT_CLASS (nice_agent_parent_class)->dispose (object); G_OBJECT_CLASS (nice_agent_parent_class)->dispose (object);
nice_socket_factory_free (agent->udp_socket_factory);
agent->udp_socket_factory = NULL;
nice_socket_factory_free (agent->relay_socket_factory);
agent->relay_socket_factory = NULL;
g_static_rec_mutex_free (&agent->mutex); g_static_rec_mutex_free (&agent->mutex);
} }
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
#include "discovery.h" #include "discovery.h"
#include "stun/usages/bind.h" #include "stun/usages/bind.h"
#include "stun/usages/turn.h" #include "stun/usages/turn.h"
#include "udp-turn.h" #include "socket.h"
static inline int priv_timer_expired (GTimeVal *restrict timer, GTimeVal *restrict now) static inline int priv_timer_expired (GTimeVal *restrict timer, GTimeVal *restrict now)
{ {
...@@ -306,7 +306,7 @@ NiceCandidate *discovery_add_local_host_candidate ( ...@@ -306,7 +306,7 @@ NiceCandidate *discovery_add_local_host_candidate (
/* note: candidate username and password are left NULL as stream /* note: candidate username and password are left NULL as stream
level ufrag/password are used */ level ufrag/password are used */
udp_socket = nice_socket_new (agent->udp_socket_factory, address); udp_socket = nice_udp_bsd_socket_new (address);
if (udp_socket) { if (udp_socket) {
gboolean result; gboolean result;
...@@ -431,7 +431,6 @@ discovery_add_relay_candidate ( ...@@ -431,7 +431,6 @@ discovery_add_relay_candidate (
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_RELAYED); candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_RELAYED);
if (candidate) { if (candidate) {
relay_socket = g_slice_new0 (NiceSocket);
if (relay_socket) { if (relay_socket) {
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) { if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
candidate->priority = nice_candidate_jingle_priority (candidate) * 1000; candidate->priority = nice_candidate_jingle_priority (candidate) * 1000;
...@@ -446,10 +445,11 @@ discovery_add_relay_candidate ( ...@@ -446,10 +445,11 @@ discovery_add_relay_candidate (
candidate->addr = *address; candidate->addr = *address;
/* step: link to the base candidate+socket */ /* step: link to the base candidate+socket */
if (nice_udp_turn_create_socket_full (agent->relay_socket_factory, relay_socket = nice_udp_turn_socket_new (address,
relay_socket, address, base_socket, &component->turn_server, base_socket, &component->turn_server,
component->turn_username, component->turn_password, component->turn_username, component->turn_password,
priv_agent_to_udp_turn_compatibility (agent))) { priv_agent_to_udp_turn_compatibility (agent), &agent->mutex);
if (relay_socket) {
candidate->sockptr = relay_socket; candidate->sockptr = relay_socket;
candidate->base_addr = base_socket->addr; candidate->base_addr = base_socket->addr;
...@@ -466,20 +466,26 @@ discovery_add_relay_candidate ( ...@@ -466,20 +466,26 @@ discovery_add_relay_candidate (
result = priv_add_local_candidate_pruned (component, candidate); result = priv_add_local_candidate_pruned (component, candidate);
if (result) { if (result) {
agent_signal_new_candidate (agent, candidate); agent_signal_new_candidate (agent, candidate);
} else /* error: memory allocation, or duplicate candidate */ } else {
/* error: memory allocation, or duplicate candidate */
errors = TRUE; errors = TRUE;
} else /* error: socket factory make */ }
} else {
/* error: socket factory make */
errors = TRUE; errors = TRUE;
} else /* error: udp socket memory allocation */ }
} else {
/* error: udp socket memory allocation */
errors = TRUE; errors = TRUE;
} }
}
/* clean up after errors */ /* clean up after errors */
if (errors) { if (errors) {
if (candidate) if (candidate)
nice_candidate_free (candidate), candidate = NULL; nice_candidate_free (candidate), candidate = NULL;
if (relay_socket) if (relay_socket)
g_slice_free (NiceSocket, relay_socket); nice_socket_free (relay_socket);
} }
return candidate; return candidate;
} }
......
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