nice_candidate_ice_priority (const NiceCandidate *candidate,
gboolean reliable, gboolean nat_assisted);
+guint32
+nice_candidate_ms_ice_priority (const NiceCandidate *candidate,
+ gboolean reliable, gboolean nat_assisted);
+
guint64
nice_candidate_pair_priority (guint32 o_prio, guint32 a_prio);
}
static guint32
-nice_candidate_ice_local_priority_full (guint direction_preference,
+nice_candidate_ice_local_preference_full (guint direction_preference,
guint other_preference)
{
return (0x2000 * direction_preference +
}
static guint16
-nice_candidate_ice_local_priority (const NiceCandidate *candidate)
+nice_candidate_ice_local_preference (const NiceCandidate *candidate)
{
guint direction_preference;
break;
}
- return nice_candidate_ice_local_priority_full (direction_preference, 1);
+ return nice_candidate_ice_local_preference_full (direction_preference, 1);
}
-guint32
-nice_candidate_ice_priority (const NiceCandidate *candidate,
+static guint32
+nice_candidate_ms_ice_local_preference_full (guint transport_preference,
+ guint direction_preference, guint other_preference)
+{
+ return 0x1000 * transport_preference +
+ 0x200 * direction_preference +
+ 0x1 * other_preference;
+}
+
+static guint32
+nice_candidate_ms_ice_local_preference (const NiceCandidate *candidate)
+{
+ guint8 transport_preference = 0;
+ guint8 direction_preference = 0;
+
+ switch (candidate->transport)
+ {
+ case NICE_CANDIDATE_TRANSPORT_TCP_SO:
+ case NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE:
+ transport_preference = NICE_CANDIDATE_TRANSPORT_MS_PREF_TCP;
+ direction_preference = NICE_CANDIDATE_DIRECTION_MS_PREF_ACTIVE;
+ break;
+ case NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE:
+ transport_preference = NICE_CANDIDATE_TRANSPORT_MS_PREF_TCP;
+ direction_preference = NICE_CANDIDATE_DIRECTION_MS_PREF_PASSIVE;
+ break;
+ case NICE_CANDIDATE_TRANSPORT_UDP:
+ default:
+ transport_preference = NICE_CANDIDATE_TRANSPORT_MS_PREF_UDP;
+ break;
+ }
+
+ return nice_candidate_ms_ice_local_preference_full(transport_preference,
+ direction_preference, 0);
+}
+
+static guint8
+nice_candidate_ice_type_preference (const NiceCandidate *candidate,
gboolean reliable, gboolean nat_assisted)
{
guint8 type_preference;
- guint16 local_preference;
switch (candidate->type)
{
(!reliable && candidate->transport != NICE_CANDIDATE_TRANSPORT_UDP)) {
type_preference = type_preference / 2;
}
- local_preference = nice_candidate_ice_local_priority (candidate);
+
+ return type_preference;
+}
+
+guint32
+nice_candidate_ice_priority (const NiceCandidate *candidate,
+ gboolean reliable, gboolean nat_assisted)
+{
+ guint8 type_preference;
+ guint16 local_preference;
+
+ type_preference = nice_candidate_ice_type_preference (candidate, reliable,
+ nat_assisted);
+ local_preference = nice_candidate_ice_local_preference (candidate);
+
+ return nice_candidate_ice_priority_full (type_preference, local_preference,
+ candidate->component_id);
+}
+
+guint32
+nice_candidate_ms_ice_priority (const NiceCandidate *candidate,
+ gboolean reliable, gboolean nat_assisted)
+{
+ guint8 type_preference;
+ guint16 local_preference;
+
+ type_preference = nice_candidate_ice_type_preference (candidate, reliable,
+ nat_assisted);
+ local_preference = nice_candidate_ms_ice_local_preference (candidate);
return nice_candidate_ice_priority_full (type_preference, local_preference,
candidate->component_id);
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_UDP_TUNNELED 75
#define NICE_CANDIDATE_TYPE_PREF_RELAYED 10
+/* 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 */
/**
* NICE_CANDIDATE_MAX_FOUNDATION:
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
priority = nice_candidate_jingle_priority (candidate_priority);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
- agent->compatibility == NICE_COMPATIBILITY_OC2007) {
+ agent->compatibility == NICE_COMPATIBILITY_OC2007) {
priority = nice_candidate_msn_priority (candidate_priority);
+ } else if (agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
+ priority = nice_candidate_ms_ice_priority (candidate_priority,
+ agent->reliable, FALSE);
} else {
priority = nice_candidate_ice_priority (candidate_priority,
agent->reliable, FALSE);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
candidate->priority = nice_candidate_msn_priority (candidate);
+ } else if (agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
+ candidate->priority = nice_candidate_ms_ice_priority (candidate,
+ agent->reliable, FALSE);
} else {
candidate->priority = nice_candidate_ice_priority (candidate,
agent->reliable, FALSE);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
candidate->priority = nice_candidate_msn_priority (candidate);
+ } else if (agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
+ candidate->priority = nice_candidate_ms_ice_priority (candidate,
+ agent->reliable, nat_assisted);
} else {
candidate->priority = nice_candidate_ice_priority (candidate,
agent->reliable, nat_assisted);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
candidate->priority = nice_candidate_msn_priority (candidate);
+ } else if (agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
+ candidate->priority = nice_candidate_ms_ice_priority (candidate,
+ agent->reliable, FALSE);
} else {
candidate->priority = nice_candidate_ice_priority (candidate,
agent->reliable, FALSE);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
candidate->priority = nice_candidate_msn_priority (candidate);
+ } else if (agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
+ candidate->priority = nice_candidate_ms_ice_priority (candidate,
+ agent->reliable, FALSE);
} else {
candidate->priority = nice_candidate_ice_priority (candidate,
agent->reliable, FALSE);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
candidate->priority = nice_candidate_msn_priority (candidate);
+ } else if (agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
+ candidate->priority = nice_candidate_ms_ice_priority (candidate,
+ agent->reliable, FALSE);
} else {
candidate->priority = nice_candidate_ice_priority (candidate,
agent->reliable, FALSE);