Commit 29a33974 authored by Youness Alaoui's avatar Youness Alaoui

Change msn/jingle priority into a guint32 instead of a float that we * 1000 later

parent e3d8fbf9
......@@ -83,30 +83,30 @@ nice_candidate_free (NiceCandidate *candidate)
}
NICEAPI_EXPORT gfloat
guint32
nice_candidate_jingle_priority (NiceCandidate *candidate)
{
switch (candidate->type)
{
case NICE_CANDIDATE_TYPE_HOST: return 1.0;
case NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE: return 0.9;
case NICE_CANDIDATE_TYPE_PEER_REFLEXIVE: return 0.9;
case NICE_CANDIDATE_TYPE_RELAYED: return 0.5;
case NICE_CANDIDATE_TYPE_HOST: return 1000;
case NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE: return 900;
case NICE_CANDIDATE_TYPE_PEER_REFLEXIVE: return 900;
case NICE_CANDIDATE_TYPE_RELAYED: return 500;
}
/* appease GCC */
return 0;
}
NICEAPI_EXPORT gfloat
guint32
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;
case NICE_CANDIDATE_TYPE_HOST: return 830;
case NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE: return 550;
case NICE_CANDIDATE_TYPE_PEER_REFLEXIVE: return 550;
case NICE_CANDIDATE_TYPE_RELAYED: return 450;
}
/* appease GCC */
......@@ -118,8 +118,7 @@ nice_candidate_msn_priority (NiceCandidate *candidate)
* ICE 4.1.2.1. "Recommended Formula" (ID-19):
* returns number between 1 and 0x7effffff
*/
G_GNUC_CONST
NICEAPI_EXPORT guint32
guint32
nice_candidate_ice_priority_full (
// must be ∈ (0, 126) (max 2^7 - 2)
guint type_preference,
......@@ -135,8 +134,7 @@ nice_candidate_ice_priority_full (
}
G_GNUC_CONST
NICEAPI_EXPORT guint32
guint32
nice_candidate_ice_priority (const NiceCandidate *candidate)
{
guint8 type_preference = 0;
......@@ -161,7 +159,7 @@ nice_candidate_ice_priority (const NiceCandidate *candidate)
* Calculates the pair priority as specified in ICE
* sect 5.7.2. "Computing Pair Priority and Ordering Pairs" (ID-19).
*/
NICEAPI_EXPORT guint64
guint64
nice_candidate_pair_priority (guint32 o_prio, guint32 a_prio)
{
guint32 max = o_prio > a_prio ? o_prio : a_prio;
......
......@@ -212,10 +212,10 @@ NiceCandidate *
nice_candidate_copy (const NiceCandidate *candidate);
gfloat
guint32
nice_candidate_jingle_priority (NiceCandidate *candidate);
gfloat
guint32
nice_candidate_msn_priority (NiceCandidate *candidate);
guint32
......
......@@ -398,9 +398,9 @@ NiceCandidate *discovery_add_local_host_candidate (
candidate->addr = *address;
candidate->base_addr = *address;
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
candidate->priority = nice_candidate_jingle_priority (candidate) * 1000;
candidate->priority = nice_candidate_jingle_priority (candidate);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
candidate->priority = nice_candidate_msn_priority (candidate) * 1000;
candidate->priority = nice_candidate_msn_priority (candidate);
} else {
candidate->priority = nice_candidate_ice_priority (candidate);
}
......@@ -478,9 +478,9 @@ discovery_add_server_reflexive_candidate (
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE);
if (candidate) {
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
candidate->priority = nice_candidate_jingle_priority (candidate) * 1000;
candidate->priority = nice_candidate_jingle_priority (candidate);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
candidate->priority = nice_candidate_msn_priority (candidate) * 1000;
candidate->priority = nice_candidate_msn_priority (candidate);
} else {
candidate->priority = nice_candidate_ice_priority_full
(NICE_CANDIDATE_TYPE_PREF_SERVER_REFLEXIVE, 0, component_id);
......@@ -538,9 +538,9 @@ discovery_add_relay_candidate (
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_RELAYED);
if (candidate) {
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
candidate->priority = nice_candidate_jingle_priority (candidate) * 1000;
candidate->priority = nice_candidate_jingle_priority (candidate);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
candidate->priority = nice_candidate_msn_priority (candidate) * 1000;
candidate->priority = nice_candidate_msn_priority (candidate);
} else {
candidate->priority = nice_candidate_ice_priority_full
(NICE_CANDIDATE_TYPE_PREF_RELAYED, 0, component_id);
......@@ -624,9 +624,9 @@ discovery_add_peer_reflexive_candidate (
candidate->transport = NICE_CANDIDATE_TRANSPORT_UDP;
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
candidate->priority = nice_candidate_jingle_priority (candidate) * 1000;
candidate->priority = nice_candidate_jingle_priority (candidate);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
candidate->priority = nice_candidate_msn_priority (candidate) * 1000;
candidate->priority = nice_candidate_msn_priority (candidate);
} else {
candidate->priority = nice_candidate_ice_priority_full
(NICE_CANDIDATE_TYPE_PREF_PEER_REFLEXIVE, 0, component_id);
......@@ -706,7 +706,7 @@ NiceCandidate *discovery_learn_remote_peer_reflexive_candidate (
NiceAgent *agent,
Stream *stream,
Component *component,
guint32 priority,
guint32 priority,
const NiceAddress *remote_address,
NiceSocket *udp_socket,
NiceCandidate *local,
......
......@@ -48,7 +48,7 @@ main (void)
/* test 1 */
candidate = nice_candidate_new (NICE_CANDIDATE_TYPE_HOST);
g_assert (nice_candidate_ice_priority (candidate) == 0x78000200);
g_assert (nice_candidate_jingle_priority (candidate) == 1.0);
g_assert (nice_candidate_jingle_priority (candidate) == 1000);
nice_candidate_free (candidate);
/* test 2 */
......
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