Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
30d592e8
Commit
30d592e8
authored
Feb 11, 2020
by
Fabrice Bellet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
agent: refactor conncheck update_selected_pair
parent
dec008ca
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
46 deletions
+46
-46
agent/agent-priv.h
agent/agent-priv.h
+0
-1
agent/agent.c
agent/agent.c
+32
-32
agent/conncheck.c
agent/conncheck.c
+11
-13
agent/conncheck.h
agent/conncheck.h
+3
-0
No files found.
agent/agent-priv.h
View file @
30d592e8
...
...
@@ -274,7 +274,6 @@ input_message_get_size (const NiceInputMessage *message);
gssize
agent_socket_send
(
NiceSocket
*
sock
,
const
NiceAddress
*
addr
,
gsize
len
,
const
gchar
*
buf
);
guint32
nice_candidate_jingle_priority
(
NiceCandidate
*
candidate
);
...
...
agent/agent.c
View file @
30d592e8
...
...
@@ -3474,7 +3474,8 @@ nice_agent_add_local_address (NiceAgent *agent, NiceAddress *addr)
}
/* Recompute foundations of all candidate pairs from a given stream
* having a specific remote candidate
* having a specific remote candidate, and eventually update the
* priority of the selected pair as well.
*/
static
void
priv_update_pair_foundations
(
NiceAgent
*
agent
,
guint
stream_id
,
guint
component_id
,
NiceCandidate
*
remote
)
...
...
@@ -3501,14 +3502,17 @@ static void priv_update_pair_foundations (NiceAgent *agent,
agent
,
pair
,
pair
->
foundation
);
if
(
component
->
selected_pair
.
local
==
pair
->
local
&&
component
->
selected_pair
.
remote
==
pair
->
remote
)
{
nice_debug
(
"Agent %p : updating SELECTED PAIR for component "
"%u: %s (prio:%"
G_GUINT64_FORMAT
")."
,
agent
,
component
->
id
,
foundation
,
pair
->
priority
);
/* the foundation update of the selected pair also implies
* an update of its priority. prflx_priority doesn't change
* because only the remote candidate foundation is modified.
*/
nice_debug
(
"Agent %p : pair %p is the selected pair, updating "
"its priority."
,
agent
,
pair
);
component
->
selected_pair
.
priority
=
pair
->
priority
;
nice_debug
(
"Agent %p : updating SELECTED PAIR for component "
"%u: %s (prio:%"
G_GUINT64_FORMAT
")."
,
agent
,
component
->
id
,
foundation
,
pair
->
priority
);
agent_signal_new_selected_pair
(
agent
,
pair
->
stream_id
,
component
->
id
,
pair
->
local
,
pair
->
remote
);
}
...
...
@@ -3518,47 +3522,27 @@ static void priv_update_pair_foundations (NiceAgent *agent,
}
}
/* Updated the component selected pair by the current highest
* priority nominated pair.
/* Returns the nominated pair with the highest priority.
*/
static
void
priv_update_selected_pair
(
NiceAgent
*
agent
,
guint
stream_id
,
guint
component_id
)
static
CandidateCheckPair
*
priv_get_highest_priority_nominated_pair
(
NiceAgent
*
agent
,
guint
stream_id
,
guint
component_id
)
{
NiceStream
*
stream
;
NiceComponent
*
component
;
CandidatePair
cpair
=
{
0
,
};
CandidateCheckPair
*
pair
;
gboolean
found
=
FALSE
;
GSList
*
i
;
if
(
agent_find_component
(
agent
,
stream_id
,
component_id
,
&
stream
,
&
component
))
{
GSList
*
i
;
for
(
i
=
stream
->
conncheck_list
;
i
;
i
=
i
->
next
)
{
pair
=
i
->
data
;
if
(
pair
->
component_id
==
component_id
&&
pair
->
nominated
)
{
found
=
TRUE
;
break
;
return
pair
;
}
}
if
(
found
&&
(
component
->
selected_pair
.
local
!=
pair
->
local
||
component
->
selected_pair
.
remote
!=
pair
->
remote
))
{
cpair
.
local
=
pair
->
local
;
cpair
.
remote
=
pair
->
remote
;
cpair
.
priority
=
pair
->
priority
;
cpair
.
prflx_priority
=
pair
->
prflx_priority
;
nice_debug
(
"Agent %p : Updating selected pair with higher "
"priority nominated pair %p."
,
agent
,
pair
);
nice_debug
(
"Agent %p : changing SELECTED PAIR for component %u: %s:%s "
"(prio:%"
G_GUINT64_FORMAT
")."
,
agent
,
component
->
id
,
pair
->
local
->
foundation
,
pair
->
remote
->
foundation
,
pair
->
priority
);
nice_component_update_selected_pair
(
agent
,
component
,
&
cpair
);
agent_signal_new_selected_pair
(
agent
,
pair
->
stream_id
,
component
->
id
,
pair
->
local
,
pair
->
remote
);
}
}
return
NULL
;
}
static
gboolean
priv_add_remote_candidate
(
...
...
@@ -3576,6 +3560,7 @@ static gboolean priv_add_remote_candidate (
{
NiceComponent
*
component
;
NiceCandidate
*
candidate
;
CandidateCheckPair
*
pair
;
if
(
transport
==
NICE_CANDIDATE_TRANSPORT_UDP
&&
!
agent
->
use_ice_udp
)
...
...
@@ -3652,11 +3637,26 @@ static gboolean priv_add_remote_candidate (
* to be recomputed...
*/
recalculate_pair_priorities
(
agent
);
priv_update_pair_foundations
(
agent
,
stream_id
,
component_id
,
candidate
);
/* ... and maybe we now have another nominated pair with a higher
* priority as the result of this priorities update.
*/
priv_update_selected_pair
(
agent
,
stream_id
,
component_id
);
priv_update_pair_foundations
(
agent
,
stream_id
,
component_id
,
candidate
);
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
))
{
/* 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*
* of the selected pair.
*/
g_assert
(
component
->
selected_pair
.
local
!=
NULL
);
g_assert
(
component
->
selected_pair
.
remote
!=
NULL
);
nice_debug
(
"Agent %p : Updating selected pair with higher "
"priority nominated pair %p."
,
agent
,
pair
);
conn_check_update_selected_pair
(
agent
,
component
,
pair
);
}
}
else
{
/* case 2: add a new candidate */
...
...
agent/conncheck.c
View file @
30d592e8
...
...
@@ -77,8 +77,6 @@ static void candidate_check_pair_free (NiceAgent *agent,
static
CandidateCheckPair
*
priv_conn_check_add_for_candidate_pair_matched
(
NiceAgent
*
agent
,
guint
stream_id
,
NiceComponent
*
component
,
NiceCandidate
*
local
,
NiceCandidate
*
remote
,
NiceCheckState
initial_state
);
static
gboolean
priv_update_selected_pair
(
NiceAgent
*
agent
,
NiceComponent
*
component
,
CandidateCheckPair
*
pair
);
static
gint64
priv_timer_remainder
(
gint64
timer
,
gint64
now
)
{
...
...
@@ -1228,7 +1226,7 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent)
nice_debug
(
"Agent %p : restarting check of pair %p as the "
"nominated pair."
,
agent
,
p
);
p
->
nominated
=
TRUE
;
priv
_update_selected_pair
(
agent
,
component
,
p
);
conn_check
_update_selected_pair
(
agent
,
component
,
p
);
priv_add_pair_to_triggered_check_queue
(
agent
,
p
);
keep_timer_going
=
TRUE
;
break
;
/* move to the next component */
...
...
@@ -2041,16 +2039,20 @@ static gboolean priv_limit_conn_check_list_size (NiceAgent *agent,
}
/*
* Changes the selected pair for the component if 'pair'
is nominated
*
and
has higher priority than the currently selected pair. See
*
ICE sect 11.1.1. "Procedures for Full Implementations" (ID-19).
* Changes the selected pair for the component if 'pair'
* has higher priority than the currently selected pair. See
*
RFC 8445 sect 8.1.1. "Nominating Pairs"
*/
static
gboolean
priv_update_selected_pair
(
NiceAgent
*
agent
,
NiceComponent
*
component
,
CandidateCheckPair
*
pair
)
void
conn_check_update_selected_pair
(
NiceAgent
*
agent
,
NiceComponent
*
component
,
CandidateCheckPair
*
pair
)
{
CandidatePair
cpair
=
{
0
,
};
g_assert
(
component
);
g_assert
(
pair
);
/* pair is expected to have the nominated flag */
g_assert
(
pair
->
nominated
);
if
(
pair
->
priority
>
component
->
selected_pair
.
priority
)
{
nice_debug
(
"Agent %p : changing SELECTED PAIR for component %u: %s:%s "
"(prio:%"
G_GUINT64_FORMAT
")."
,
agent
,
component
->
id
,
...
...
@@ -2060,7 +2062,6 @@ static gboolean priv_update_selected_pair (NiceAgent *agent, NiceComponent *comp
cpair
.
remote
=
pair
->
remote
;
cpair
.
priority
=
pair
->
priority
;
cpair
.
prflx_priority
=
pair
->
prflx_priority
;
/* cpair.keepalive is not used by nice_component_update_selected_pair() */
nice_component_update_selected_pair
(
agent
,
component
,
&
cpair
);
...
...
@@ -2068,10 +2069,7 @@ static gboolean priv_update_selected_pair (NiceAgent *agent, NiceComponent *comp
agent_signal_new_selected_pair
(
agent
,
pair
->
stream_id
,
component
->
id
,
pair
->
local
,
pair
->
remote
);
}
return
TRUE
;
}
/*
...
...
@@ -2253,7 +2251,7 @@ static void priv_mark_pair_nominated (NiceAgent *agent, NiceStream *stream, Nice
if
(
component
->
state
==
NICE_COMPONENT_STATE_FAILED
)
agent_signal_component_state_change
(
agent
,
stream
->
id
,
component
->
id
,
NICE_COMPONENT_STATE_CONNECTING
);
priv
_update_selected_pair
(
agent
,
component
,
pair
);
conn_check
_update_selected_pair
(
agent
,
component
,
pair
);
if
(
component
->
state
==
NICE_COMPONENT_STATE_CONNECTING
)
/* step: notify the client of a new component state (must be done
* before the possible check list state update step */
...
...
@@ -3638,7 +3636,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, NiceStre
}
if
(
ok_pair
->
nominated
==
TRUE
)
{
priv
_update_selected_pair
(
agent
,
component
,
ok_pair
);
conn_check
_update_selected_pair
(
agent
,
component
,
ok_pair
);
priv_print_conn_check_lists
(
agent
,
G_STRFUNC
,
", got a nominated pair"
);
...
...
agent/conncheck.h
View file @
30d592e8
...
...
@@ -121,5 +121,8 @@ conn_check_prune_socket (NiceAgent *agent, NiceStream *stream, NiceComponent *co
guint32
ensure_unique_priority
(
NiceStream
*
stream
,
NiceComponent
*
component
,
guint32
priority
);
void
recalculate_pair_priorities
(
NiceAgent
*
agent
);
void
conn_check_update_selected_pair
(
NiceAgent
*
agent
,
NiceComponent
*
component
,
CandidateCheckPair
*
pair
);
#endif
/*_NICE_CONNCHECK_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment