Commit 93ac1313 authored by Youness Alaoui's avatar Youness Alaoui

Adding compatibility mode and improvements on the main loop integration.

darcs-hash:20080422161414-4f0f6-388208b2ac7bb2a7ab06e48151e2152fc0621331.gz
parent 8d3f8b25
......@@ -80,10 +80,7 @@ struct _NiceAgent
GSList *local_addresses; /**< list of NiceAddresses for local
interfaces */
GSList *streams; /**< list of Stream objects */
gboolean main_context_set; /**< is the main context set */
GMainContext *main_context; /**< main context pointer */
NiceAgentRecvFunc read_func; /**< callback for media deliver */
gpointer read_func_data; /**< media delivery callback context */
guint next_candidate_id; /**< id of next created candidate */
guint next_stream_id; /**< id of next created candidate */
NiceRNG *rng; /**< random number generator */
......@@ -95,6 +92,7 @@ struct _NiceAgent
guint64 tie_breaker; /**< tie breaker (ICE sect 5.2
"Determining Role" ID-19) */
GMutex * mutex; /* Mutex used for thread-safe lib */
NiceCompatibility compatibility; /* property: Compatibility mode */
/* XXX: add pointer to internal data struct for ABI-safe extensions */
};
......
This diff is collapsed.
......@@ -96,6 +96,13 @@ typedef enum
NICE_COMPONENT_TYPE_RTCP = 2
} NiceComponentType;
typedef enum
{
NICE_COMPATIBILITY_ID19 = 1,
NICE_COMPATIBILITY_GOOGLE = 2,
NICE_COMPATIBILITY_MSN = 3
} NiceCompatibility;
typedef struct _NiceCandidateDesc NiceCandidateDesc;
struct _NiceCandidateDesc {
......@@ -125,7 +132,8 @@ struct _NiceAgentClass
GType nice_agent_get_type (void);
NiceAgent *
nice_agent_new (NiceUDPSocketFactory *factory);
nice_agent_new (NiceUDPSocketFactory *factory,
GMainContext *ctx, NiceCompatibility compat);
gboolean
nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr);
......@@ -218,8 +226,10 @@ nice_agent_restart (
NiceAgent *agent);
gboolean
nice_agent_main_context_attach (
nice_agent_attach_recv (
NiceAgent *agent,
guint stream_id,
guint component_id,
GMainContext *ctx,
NiceAgentRecvFunc func,
gpointer data);
......
......@@ -94,6 +94,21 @@ nice_candidate_jingle_priority (NiceCandidate *candidate)
return 0;
}
NICEAPI_EXPORT gfloat
nice_candidate_msn_priority (NiceCandidate *candidate)
{
switch (candidate->type)
{
case NICE_CANDIDATE_TYPE_HOST: return 0.830;
case NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE: return 0.550;
case NICE_CANDIDATE_TYPE_PEER_REFLEXIVE: return 0.550;
case NICE_CANDIDATE_TYPE_RELAYED: return 0.450;
}
/* appease GCC */
return 0;
}
/**
* ICE 4.1.2.1. "Recommended Formula" (ID-19):
......
......@@ -91,6 +91,9 @@ nice_candidate_free (NiceCandidate *candidate);
gfloat
nice_candidate_jingle_priority (NiceCandidate *candidate);
gfloat
nice_candidate_msn_priority (NiceCandidate *candidate);
guint32
nice_candidate_ice_priority_full (guint type_pref, guint local_pref, guint component_id);
......
......@@ -46,6 +46,7 @@
G_BEGIN_DECLS
/* (ICE §4.1.1.1, ID-19) ""For RTP-based media streams, the RTP itself has a component
* ID of 1, and RTCP a component ID of 2. If an agent is using RTCP it MUST
* obtain a candidate for it. If an agent is using both RTP and RTCP, it
......
......@@ -481,14 +481,20 @@ gboolean conn_check_schedule_next (NiceAgent *agent)
res = priv_conn_check_tick_unlocked ((gpointer) agent);
/* step: schedule timer if not running yet */
if (res && agent->conncheck_timer_id == 0)
agent->conncheck_timer_id =
g_timeout_add (agent->timer_ta, priv_conn_check_tick, agent);
if (res && agent->conncheck_timer_id == 0) {
GSource *source = g_timeout_source_new (agent->timer_ta);
g_source_set_callback (source, priv_conn_check_tick, agent, NULL);
agent->conncheck_timer_id = g_source_attach (source, agent->main_context);
g_source_unref (source);
}
/* step: also start the keepalive timer */
if (agent->keepalive_timer_id == 0)
agent->keepalive_timer_id =
g_timeout_add (NICE_AGENT_TIMER_TR_DEFAULT, priv_conn_keepalive_tick, agent);
if (agent->keepalive_timer_id == 0) {
GSource *source = g_timeout_source_new (NICE_AGENT_TIMER_TR_DEFAULT);
g_source_set_callback (source, priv_conn_keepalive_tick, agent, NULL);
agent->keepalive_timer_id = g_source_attach (source, agent->main_context);
g_source_unref (source);
}
}
......@@ -950,13 +956,17 @@ static gboolean priv_create_check_username (NiceAgent *agent, CandidateCheckPair
if (pair &&
pair->remote && pair->remote->username &&
pair->local && pair->local->username) {
g_snprintf (dest, dest_len, "%s:%s", pair->remote->username, pair->local->username);
g_snprintf (dest, dest_len, "%s%s%s", pair->remote->username,
agent->compatibility == NICE_COMPATIBILITY_ID19 ? ":" : "",
pair->local->username);
return TRUE;
}
stream = agent_find_stream (agent, pair->stream_id);
if (stream) {
g_snprintf (dest, dest_len, "%s:%s", stream->remote_ufrag, stream->local_ufrag);
g_snprintf (dest, dest_len, "%s%s%s", stream->remote_ufrag,
agent->compatibility == NICE_COMPATIBILITY_ID19 ? ":" : "",
stream->local_ufrag);
return TRUE;
}
......
......@@ -597,8 +597,10 @@ void discovery_schedule (NiceAgent *agent)
/* step: run first iteration immediately */
gboolean res = priv_discovery_tick_unlocked (agent);
if (res == TRUE) {
agent->discovery_timer_id =
g_timeout_add (agent->timer_ta, priv_discovery_tick, agent);
GSource *source = g_timeout_source_new (agent->timer_ta);
g_source_set_callback (source, priv_discovery_tick, agent, NULL);
agent->discovery_timer_id = g_source_attach (source, agent->main_context);
g_source_unref (source);
}
}
}
......
......@@ -14,11 +14,11 @@ nice_address_to_string
nice_agent_add_local_address
nice_agent_add_remote_candidate
nice_agent_add_stream
nice_agent_attach_recv
nice_agent_get_local_candidates
nice_agent_get_local_credentials
nice_agent_get_remote_candidates
nice_agent_get_type
nice_agent_main_context_attach
nice_agent_new
nice_agent_poll_read
nice_agent_recv
......
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