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
16d51b09
Commit
16d51b09
authored
Oct 28, 2018
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
agent: Remove explicit parent pointers
Remove all pointers that don't include have a reference except to agents
parent
da41258a
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
172 additions
and
145 deletions
+172
-145
agent/agent.c
agent/agent.c
+43
-34
agent/component.c
agent/component.c
+42
-21
agent/component.h
agent/component.h
+4
-5
agent/conncheck.c
agent/conncheck.c
+49
-51
agent/conncheck.h
agent/conncheck.h
+2
-1
agent/discovery.c
agent/discovery.c
+23
-24
agent/discovery.h
agent/discovery.h
+5
-7
agent/stream.c
agent/stream.c
+3
-1
agent/stream.h
agent/stream.h
+1
-1
No files found.
agent/agent.c
View file @
16d51b09
...
@@ -1582,7 +1582,7 @@ static void
...
@@ -1582,7 +1582,7 @@ static void
g_cancellable_cancel
(
component
->
tcp_writable_cancellable
);
g_cancellable_cancel
(
component
->
tcp_writable_cancellable
);
agent_queue_signal
(
agent
,
signals
[
SIGNAL_RELIABLE_TRANSPORT_WRITABLE
],
agent_queue_signal
(
agent
,
signals
[
SIGNAL_RELIABLE_TRANSPORT_WRITABLE
],
component
->
stream
->
id
,
component
->
id
);
component
->
stream
_
id
,
component
->
id
);
}
}
static
void
static
void
...
@@ -1600,8 +1600,7 @@ pseudo_tcp_socket_create (NiceAgent *agent, NiceStream *stream, NiceComponent *c
...
@@ -1600,8 +1600,7 @@ pseudo_tcp_socket_create (NiceAgent *agent, NiceStream *stream, NiceComponent *c
agent
,
component
->
id
);
agent
,
component
->
id
);
}
}
static
void
priv_pseudo_tcp_error
(
NiceAgent
*
agent
,
NiceStream
*
stream
,
static
void
priv_pseudo_tcp_error
(
NiceAgent
*
agent
,
NiceComponent
*
component
)
NiceComponent
*
component
)
{
{
if
(
component
->
tcp_writable_cancellable
)
{
if
(
component
->
tcp_writable_cancellable
)
{
g_cancellable_cancel
(
component
->
tcp_writable_cancellable
);
g_cancellable_cancel
(
component
->
tcp_writable_cancellable
);
...
@@ -1609,7 +1608,7 @@ static void priv_pseudo_tcp_error (NiceAgent *agent, NiceStream *stream,
...
@@ -1609,7 +1608,7 @@ static void priv_pseudo_tcp_error (NiceAgent *agent, NiceStream *stream,
}
}
if
(
component
->
tcp
)
{
if
(
component
->
tcp
)
{
agent_signal_component_state_change
(
agent
,
stream
->
id
,
agent_signal_component_state_change
(
agent
,
component
->
stream_
id
,
component
->
id
,
NICE_COMPONENT_STATE_FAILED
);
component
->
id
,
NICE_COMPONENT_STATE_FAILED
);
nice_component_detach_all_sockets
(
component
);
nice_component_detach_all_sockets
(
component
);
pseudo_tcp_socket_close
(
component
->
tcp
,
TRUE
);
pseudo_tcp_socket_close
(
component
->
tcp
,
TRUE
);
...
@@ -1627,10 +1626,9 @@ pseudo_tcp_socket_opened (PseudoTcpSocket *sock, gpointer user_data)
...
@@ -1627,10 +1626,9 @@ pseudo_tcp_socket_opened (PseudoTcpSocket *sock, gpointer user_data)
{
{
NiceComponent
*
component
=
user_data
;
NiceComponent
*
component
=
user_data
;
NiceAgent
*
agent
=
component
->
agent
;
NiceAgent
*
agent
=
component
->
agent
;
NiceStream
*
stream
=
component
->
stream
;
nice_debug
(
"Agent %p: s%d:%d pseudo Tcp socket Opened"
,
agent
,
nice_debug
(
"Agent %p: s%d:%d pseudo Tcp socket Opened"
,
agent
,
stream
->
id
,
component
->
id
);
component
->
stream_
id
,
component
->
id
);
agent_signal_socket_writable
(
agent
,
component
);
agent_signal_socket_writable
(
agent
,
component
);
}
}
...
@@ -1787,15 +1785,21 @@ pseudo_tcp_socket_readable (PseudoTcpSocket *sock, gpointer user_data)
...
@@ -1787,15 +1785,21 @@ pseudo_tcp_socket_readable (PseudoTcpSocket *sock, gpointer user_data)
{
{
NiceComponent
*
component
=
user_data
;
NiceComponent
*
component
=
user_data
;
NiceAgent
*
agent
=
component
->
agent
;
NiceAgent
*
agent
=
component
->
agent
;
NiceStream
*
stream
=
component
->
stream
;
gboolean
has_io_callback
;
gboolean
has_io_callback
;
guint
stream_id
=
stream
->
id
;
NiceStream
*
stream
=
NULL
;
guint
stream_id
=
component
->
stream_id
;
guint
component_id
=
component
->
id
;
guint
component_id
=
component
->
id
;
g_object_ref
(
agent
);
g_object_ref
(
agent
);
if
(
!
agent_find_component
(
agent
,
stream_id
,
component_id
,
&
stream
,
&
component
))
{
g_object_unref
(
agent
);
goto
out
;
}
nice_debug_verbose
(
"Agent %p: s%d:%d pseudo Tcp socket readable"
,
agent
,
nice_debug_verbose
(
"Agent %p: s%d:%d pseudo Tcp socket readable"
,
agent
,
stream
->
id
,
component
->
id
);
stream
_
id
,
component
->
id
);
component
->
tcp_readable
=
TRUE
;
component
->
tcp_readable
=
TRUE
;
...
@@ -1826,7 +1830,7 @@ pseudo_tcp_socket_readable (PseudoTcpSocket *sock, gpointer user_data)
...
@@ -1826,7 +1830,7 @@ pseudo_tcp_socket_readable (PseudoTcpSocket *sock, gpointer user_data)
/* Handle errors. */
/* Handle errors. */
if
(
pseudo_tcp_socket_get_error
(
sock
)
!=
EWOULDBLOCK
)
{
if
(
pseudo_tcp_socket_get_error
(
sock
)
!=
EWOULDBLOCK
)
{
nice_debug
(
"%s: calling priv_pseudo_tcp_error()"
,
G_STRFUNC
);
nice_debug
(
"%s: calling priv_pseudo_tcp_error()"
,
G_STRFUNC
);
priv_pseudo_tcp_error
(
agent
,
stream
,
component
);
priv_pseudo_tcp_error
(
agent
,
component
);
}
}
if
(
component
->
recv_buf_error
!=
NULL
)
{
if
(
component
->
recv_buf_error
!=
NULL
)
{
...
@@ -1889,7 +1893,7 @@ pseudo_tcp_socket_readable (PseudoTcpSocket *sock, gpointer user_data)
...
@@ -1889,7 +1893,7 @@ pseudo_tcp_socket_readable (PseudoTcpSocket *sock, gpointer user_data)
component
->
tcp_readable
=
FALSE
;
component
->
tcp_readable
=
FALSE
;
}
else
if
(
n_valid_messages
<
0
)
{
}
else
if
(
n_valid_messages
<
0
)
{
nice_debug
(
"%s: calling priv_pseudo_tcp_error()"
,
G_STRFUNC
);
nice_debug
(
"%s: calling priv_pseudo_tcp_error()"
,
G_STRFUNC
);
priv_pseudo_tcp_error
(
agent
,
stream
,
component
);
priv_pseudo_tcp_error
(
agent
,
component
);
}
else
if
(
n_valid_messages
==
0
)
{
}
else
if
(
n_valid_messages
==
0
)
{
/* Reached EOS. */
/* Reached EOS. */
component
->
tcp_readable
=
FALSE
;
component
->
tcp_readable
=
FALSE
;
...
@@ -1912,10 +1916,9 @@ pseudo_tcp_socket_writable (PseudoTcpSocket *sock, gpointer user_data)
...
@@ -1912,10 +1916,9 @@ pseudo_tcp_socket_writable (PseudoTcpSocket *sock, gpointer user_data)
{
{
NiceComponent
*
component
=
user_data
;
NiceComponent
*
component
=
user_data
;
NiceAgent
*
agent
=
component
->
agent
;
NiceAgent
*
agent
=
component
->
agent
;
NiceStream
*
stream
=
component
->
stream
;
nice_debug_verbose
(
"Agent %p: s%d:%d pseudo Tcp socket writable"
,
agent
,
nice_debug_verbose
(
"Agent %p: s%d:%d pseudo Tcp socket writable"
,
agent
,
stream
->
id
,
component
->
id
);
component
->
stream_
id
,
component
->
id
);
agent_signal_socket_writable
(
agent
,
component
);
agent_signal_socket_writable
(
agent
,
component
);
}
}
...
@@ -1926,11 +1929,11 @@ pseudo_tcp_socket_closed (PseudoTcpSocket *sock, guint32 err,
...
@@ -1926,11 +1929,11 @@ pseudo_tcp_socket_closed (PseudoTcpSocket *sock, guint32 err,
{
{
NiceComponent
*
component
=
user_data
;
NiceComponent
*
component
=
user_data
;
NiceAgent
*
agent
=
component
->
agent
;
NiceAgent
*
agent
=
component
->
agent
;
NiceStream
*
stream
=
component
->
stream
;
nice_debug
(
"Agent %p: s%d:%d pseudo Tcp socket closed. "
nice_debug
(
"Agent %p: s%d:%d pseudo Tcp socket closed. "
"Calling priv_pseudo_tcp_error()."
,
agent
,
stream
->
id
,
component
->
id
);
"Calling priv_pseudo_tcp_error()."
,
agent
,
component
->
stream_id
,
priv_pseudo_tcp_error
(
agent
,
stream
,
component
);
component
->
id
);
priv_pseudo_tcp_error
(
agent
,
component
);
}
}
...
@@ -1953,7 +1956,7 @@ pseudo_tcp_socket_write_packet (PseudoTcpSocket *psocket,
...
@@ -1953,7 +1956,7 @@ pseudo_tcp_socket_write_packet (PseudoTcpSocket *psocket,
nice_debug_verbose
(
nice_debug_verbose
(
"Agent %p : s%d:%d: sending %d bytes on socket %p (FD %d) to [%s]:%d"
,
"Agent %p : s%d:%d: sending %d bytes on socket %p (FD %d) to [%s]:%d"
,
component
->
agent
,
component
->
stream
->
id
,
component
->
id
,
len
,
component
->
agent
,
component
->
stream
_
id
,
component
->
id
,
len
,
sock
->
fileno
,
g_socket_get_fd
(
sock
->
fileno
),
tmpbuf
,
sock
->
fileno
,
g_socket_get_fd
(
sock
->
fileno
),
tmpbuf
,
nice_address_get_port
(
addr
));
nice_address_get_port
(
addr
));
}
}
...
@@ -1983,7 +1986,9 @@ notify_pseudo_tcp_socket_clock_agent_locked (NiceAgent *agent,
...
@@ -1983,7 +1986,9 @@ notify_pseudo_tcp_socket_clock_agent_locked (NiceAgent *agent,
NiceComponent
*
component
=
user_data
;
NiceComponent
*
component
=
user_data
;
NiceStream
*
stream
;
NiceStream
*
stream
;
stream
=
component
->
stream
;
stream
=
agent_find_stream
(
agent
,
component
->
stream_id
);
if
(
!
stream
)
return
G_SOURCE_REMOVE
;
pseudo_tcp_socket_notify_clock
(
component
->
tcp
);
pseudo_tcp_socket_notify_clock
(
component
->
tcp
);
adjust_tcp_clock
(
agent
,
stream
,
component
);
adjust_tcp_clock
(
agent
,
stream
,
component
);
...
@@ -2018,7 +2023,7 @@ adjust_tcp_clock (NiceAgent *agent, NiceStream *stream, NiceComponent *component
...
@@ -2018,7 +2023,7 @@ adjust_tcp_clock (NiceAgent *agent, NiceStream *stream, NiceComponent *component
nice_debug
(
"Agent %p: component %d pseudo-TCP socket should be "
nice_debug
(
"Agent %p: component %d pseudo-TCP socket should be "
"destroyed. Calling priv_pseudo_tcp_error()."
,
"destroyed. Calling priv_pseudo_tcp_error()."
,
agent
,
component
->
id
);
agent
,
component
->
id
);
priv_pseudo_tcp_error
(
agent
,
stream
,
component
);
priv_pseudo_tcp_error
(
agent
,
component
);
}
}
}
}
}
}
...
@@ -2028,7 +2033,6 @@ _tcp_sock_is_writable (NiceSocket *sock, gpointer user_data)
...
@@ -2028,7 +2033,6 @@ _tcp_sock_is_writable (NiceSocket *sock, gpointer user_data)
{
{
NiceComponent
*
component
=
user_data
;
NiceComponent
*
component
=
user_data
;
NiceAgent
*
agent
=
component
->
agent
;
NiceAgent
*
agent
=
component
->
agent
;
NiceStream
*
stream
=
component
->
stream
;
agent_lock
(
agent
);
agent_lock
(
agent
);
...
@@ -2041,7 +2045,7 @@ _tcp_sock_is_writable (NiceSocket *sock, gpointer user_data)
...
@@ -2041,7 +2045,7 @@ _tcp_sock_is_writable (NiceSocket *sock, gpointer user_data)
}
}
nice_debug
(
"Agent %p: s%d:%d Tcp socket writable"
,
agent
,
nice_debug
(
"Agent %p: s%d:%d Tcp socket writable"
,
agent
,
stream
->
id
,
component
->
id
);
component
->
stream_
id
,
component
->
id
);
agent_signal_socket_writable
(
agent
,
component
);
agent_signal_socket_writable
(
agent
,
component
);
agent_unlock_and_emit
(
agent
);
agent_unlock_and_emit
(
agent
);
...
@@ -2413,9 +2417,8 @@ priv_add_new_candidate_discovery_stun (NiceAgent *agent,
...
@@ -2413,9 +2417,8 @@ priv_add_new_candidate_discovery_stun (NiceAgent *agent,
cdisco
->
type
=
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE
;
cdisco
->
type
=
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE
;
cdisco
->
nicesock
=
nicesock
;
cdisco
->
nicesock
=
nicesock
;
cdisco
->
server
=
server
;
cdisco
->
server
=
server
;
cdisco
->
stream
=
stream
;
cdisco
->
stream_id
=
stream
->
id
;
cdisco
->
component
=
nice_stream_find_component_by_id
(
stream
,
component_id
);
cdisco
->
component_id
=
component_id
;
cdisco
->
agent
=
agent
;
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
STUN_COMPATIBILITY_RFC3489
,
STUN_COMPATIBILITY_RFC3489
,
(
agent
->
compatibility
==
NICE_COMPATIBILITY_OC2007
||
(
agent
->
compatibility
==
NICE_COMPATIBILITY_OC2007
||
...
@@ -2556,9 +2559,8 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent,
...
@@ -2556,9 +2559,8 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent,
cdisco
->
turn
=
turn_server_ref
(
turn
);
cdisco
->
turn
=
turn_server_ref
(
turn
);
cdisco
->
server
=
turn
->
server
;
cdisco
->
server
=
turn
->
server
;
cdisco
->
stream
=
stream
;
cdisco
->
stream_id
=
stream
->
id
;
cdisco
->
component
=
nice_stream_find_component_by_id
(
stream
,
component_id
);
cdisco
->
component_id
=
component_id
;
cdisco
->
agent
=
agent
;
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_GOOGLE
)
{
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
stun_agent_init
(
&
cdisco
->
stun_agent
,
STUN_ALL_KNOWN_ATTRIBUTES
,
...
@@ -2603,10 +2605,9 @@ nice_agent_add_stream (
...
@@ -2603,10 +2605,9 @@ nice_agent_add_stream (
g_return_val_if_fail
(
n_components
>=
1
,
0
);
g_return_val_if_fail
(
n_components
>=
1
,
0
);
agent_lock
(
agent
);
agent_lock
(
agent
);
stream
=
nice_stream_new
(
n_components
,
agent
);
stream
=
nice_stream_new
(
agent
->
next_stream_id
++
,
n_components
,
agent
);
agent
->
streams
=
g_slist_append
(
agent
->
streams
,
stream
);
agent
->
streams
=
g_slist_append
(
agent
->
streams
,
stream
);
stream
->
id
=
agent
->
next_stream_id
++
;
nice_debug
(
"Agent %p : allocating stream id %u (%p)"
,
agent
,
stream
->
id
,
stream
);
nice_debug
(
"Agent %p : allocating stream id %u (%p)"
,
agent
,
stream
->
id
,
stream
);
if
(
agent
->
reliable
)
{
if
(
agent
->
reliable
)
{
nice_debug
(
"Agent %p : reliable stream"
,
agent
);
nice_debug
(
"Agent %p : reliable stream"
,
agent
);
...
@@ -4722,7 +4723,7 @@ nice_agent_send_messages_nonblocking_internal (
...
@@ -4722,7 +4723,7 @@ nice_agent_send_messages_nonblocking_internal (
if
(
n_sent
<
0
&&
!
g_error_matches
(
child_error
,
G_IO_ERROR
,
if
(
n_sent
<
0
&&
!
g_error_matches
(
child_error
,
G_IO_ERROR
,
G_IO_ERROR_WOULD_BLOCK
))
{
G_IO_ERROR_WOULD_BLOCK
))
{
/* Signal errors */
/* Signal errors */
priv_pseudo_tcp_error
(
agent
,
stream
,
component
);
priv_pseudo_tcp_error
(
agent
,
component
);
}
}
}
else
{
}
else
{
g_set_error
(
&
child_error
,
G_IO_ERROR
,
G_IO_ERROR_FAILED
,
g_set_error
(
&
child_error
,
G_IO_ERROR
,
G_IO_ERROR_FAILED
,
...
@@ -5133,10 +5134,18 @@ component_io_cb (GSocket *gsocket, GIOCondition condition, gpointer user_data)
...
@@ -5133,10 +5134,18 @@ component_io_cb (GSocket *gsocket, GIOCondition condition, gpointer user_data)
component
=
socket_source
->
component
;
component
=
socket_source
->
component
;
agent
=
component
->
agent
;
agent
=
component
->
agent
;
stream
=
component
->
stream
;
agent_lock
(
agent
);
agent_lock
(
agent
);
stream
=
agent_find_stream
(
agent
,
component
->
stream_id
);
if
(
stream
==
NULL
)
{
nice_debug
(
"%s: stream %d destroyed"
,
G_STRFUNC
,
component
->
stream_id
);
agent_unlock
(
agent
);
return
G_SOURCE_REMOVE
;
}
if
(
g_source_is_destroyed
(
g_main_current_source
()))
{
if
(
g_source_is_destroyed
(
g_main_current_source
()))
{
/* Silently return FALSE. */
/* Silently return FALSE. */
nice_debug
(
"%s: source %p destroyed"
,
G_STRFUNC
,
g_main_current_source
());
nice_debug
(
"%s: source %p destroyed"
,
G_STRFUNC
,
g_main_current_source
());
...
@@ -5160,7 +5169,7 @@ component_io_cb (GSocket *gsocket, GIOCondition condition, gpointer user_data)
...
@@ -5160,7 +5169,7 @@ component_io_cb (GSocket *gsocket, GIOCondition condition, gpointer user_data)
stream
->
id
,
component
->
id
,
NICE_COMPONENT_STATE_FAILED
);
stream
->
id
,
component
->
id
,
NICE_COMPONENT_STATE_FAILED
);
}
}
nice_component_remove_socket
(
component
,
socket_source
->
socket
);
nice_component_remove_socket
(
agent
,
component
,
socket_source
->
socket
);
agent_unlock
(
agent
);
agent_unlock
(
agent
);
g_object_unref
(
agent
);
g_object_unref
(
agent
);
return
G_SOURCE_REMOVE
;
return
G_SOURCE_REMOVE
;
...
@@ -5326,7 +5335,7 @@ component_io_cb (GSocket *gsocket, GIOCondition condition, gpointer user_data)
...
@@ -5326,7 +5335,7 @@ component_io_cb (GSocket *gsocket, GIOCondition condition, gpointer user_data)
done:
done:
if
(
remove_source
)
if
(
remove_source
)
nice_component_remove_socket
(
component
,
socket_source
->
socket
);
nice_component_remove_socket
(
agent
,
component
,
socket_source
->
socket
);
/* If we’re in the middle of a read, don’t emit any signals, or we could cause
/* If we’re in the middle of a read, don’t emit any signals, or we could cause
* re-entrancy by (e.g.) emitting component-state-changed and having the
* re-entrancy by (e.g.) emitting component-state-changed and having the
...
@@ -6476,7 +6485,7 @@ nice_agent_forget_relays (NiceAgent *agent, guint stream_id, guint component_id)
...
@@ -6476,7 +6485,7 @@ nice_agent_forget_relays (NiceAgent *agent, guint stream_id, guint component_id)
goto
done
;
goto
done
;
}
}
nice_component_clean_turn_servers
(
component
);
nice_component_clean_turn_servers
(
agent
,
component
);
done:
done:
agent_unlock_and_emit
(
agent
);
agent_unlock_and_emit
(
agent
);
...
...
agent/component.c
View file @
16d51b09
...
@@ -164,9 +164,13 @@ nice_component_new (guint id, NiceAgent *agent, NiceStream *stream)
...
@@ -164,9 +164,13 @@ nice_component_new (guint id, NiceAgent *agent, NiceStream *stream)
}
}
void
void
nice_component_remove_socket
(
NiceComponent
*
cmp
,
NiceSocket
*
nsocket
)
nice_component_remove_socket
(
NiceAgent
*
agent
,
NiceComponent
*
cmp
,
NiceSocket
*
nsocket
)
{
{
GSList
*
i
;
GSList
*
i
;
NiceStream
*
stream
;
stream
=
agent_find_stream
(
agent
,
cmp
->
stream_id
);
for
(
i
=
cmp
->
local_candidates
;
i
;)
{
for
(
i
=
cmp
->
local_candidates
;
i
;)
{
NiceCandidate
*
candidate
=
i
->
data
;
NiceCandidate
*
candidate
=
i
->
data
;
...
@@ -179,14 +183,14 @@ nice_component_remove_socket (NiceComponent *cmp, NiceSocket *nsocket)
...
@@ -179,14 +183,14 @@ nice_component_remove_socket (NiceComponent *cmp, NiceSocket *nsocket)
if
(
candidate
==
cmp
->
selected_pair
.
local
)
{
if
(
candidate
==
cmp
->
selected_pair
.
local
)
{
nice_component_clear_selected_pair
(
cmp
);
nice_component_clear_selected_pair
(
cmp
);
agent_signal_component_state_change
(
cmp
->
agent
,
cmp
->
stream
->
id
,
agent_signal_component_state_change
(
cmp
->
agent
,
cmp
->
stream
_
id
,
cmp
->
id
,
NICE_COMPONENT_STATE_FAILED
);
cmp
->
id
,
NICE_COMPONENT_STATE_FAILED
);
}
}
refresh_prune_candidate
(
cmp
->
agent
,
candidate
);
refresh_prune_candidate
(
cmp
->
agent
,
candidate
);
if
(
candidate
->
sockptr
!=
nsocket
)
{
if
(
candidate
->
sockptr
!=
nsocket
&&
stream
)
{
discovery_prune_socket
(
cmp
->
agent
,
candidate
->
sockptr
);
discovery_prune_socket
(
cmp
->
agent
,
candidate
->
sockptr
);
conn_check_prune_socket
(
cmp
->
agent
,
cmp
->
stream
,
cmp
,
conn_check_prune_socket
(
cmp
->
agent
,
stream
,
cmp
,
candidate
->
sockptr
);
candidate
->
sockptr
);
nice_component_detach_socket
(
cmp
,
candidate
->
sockptr
);
nice_component_detach_socket
(
cmp
,
candidate
->
sockptr
);
}
}
...
@@ -198,14 +202,18 @@ nice_component_remove_socket (NiceComponent *cmp, NiceSocket *nsocket)
...
@@ -198,14 +202,18 @@ nice_component_remove_socket (NiceComponent *cmp, NiceSocket *nsocket)
}
}
discovery_prune_socket
(
cmp
->
agent
,
nsocket
);
discovery_prune_socket
(
cmp
->
agent
,
nsocket
);
conn_check_prune_socket
(
cmp
->
agent
,
cmp
->
stream
,
cmp
,
nsocket
);
if
(
stream
)
conn_check_prune_socket
(
cmp
->
agent
,
stream
,
cmp
,
nsocket
);
nice_component_detach_socket
(
cmp
,
nsocket
);
nice_component_detach_socket
(
cmp
,
nsocket
);
}
}
void
void
nice_component_clean_turn_servers
(
NiceComponent
*
cmp
)
nice_component_clean_turn_servers
(
Nice
Agent
*
agent
,
Nice
Component
*
cmp
)
{
{
GSList
*
i
;
GSList
*
i
;
NiceStream
*
stream
;
stream
=
agent_find_stream
(
agent
,
cmp
->
stream_id
);
g_list_free_full
(
cmp
->
turn_servers
,
(
GDestroyNotify
)
turn_server_unref
);
g_list_free_full
(
cmp
->
turn_servers
,
(
GDestroyNotify
)
turn_server_unref
);
cmp
->
turn_servers
=
NULL
;
cmp
->
turn_servers
=
NULL
;
...
@@ -232,7 +240,8 @@ nice_component_clean_turn_servers (NiceComponent *cmp)
...
@@ -232,7 +240,8 @@ nice_component_clean_turn_servers (NiceComponent *cmp)
if
(
cmp
->
turn_candidate
)
{
if
(
cmp
->
turn_candidate
)
{
refresh_prune_candidate
(
cmp
->
agent
,
cmp
->
turn_candidate
);
refresh_prune_candidate
(
cmp
->
agent
,
cmp
->
turn_candidate
);
discovery_prune_socket
(
cmp
->
agent
,
cmp
->
turn_candidate
->
sockptr
);
discovery_prune_socket
(
cmp
->
agent
,
cmp
->
turn_candidate
->
sockptr
);
conn_check_prune_socket
(
cmp
->
agent
,
cmp
->
stream
,
cmp
,
if
(
stream
)
conn_check_prune_socket
(
cmp
->
agent
,
stream
,
cmp
,
cmp
->
turn_candidate
->
sockptr
);
cmp
->
turn_candidate
->
sockptr
);
nice_component_detach_socket
(
cmp
,
cmp
->
turn_candidate
->
sockptr
);
nice_component_detach_socket
(
cmp
,
cmp
->
turn_candidate
->
sockptr
);
nice_candidate_free
(
cmp
->
turn_candidate
);
nice_candidate_free
(
cmp
->
turn_candidate
);
...
@@ -245,7 +254,8 @@ nice_component_clean_turn_servers (NiceComponent *cmp)
...
@@ -245,7 +254,8 @@ nice_component_clean_turn_servers (NiceComponent *cmp)
}
else
{
}
else
{
refresh_prune_candidate
(
cmp
->
agent
,
candidate
);
refresh_prune_candidate
(
cmp
->
agent
,
candidate
);
discovery_prune_socket
(
cmp
->
agent
,
candidate
->
sockptr
);
discovery_prune_socket
(
cmp
->
agent
,
candidate
->
sockptr
);
conn_check_prune_socket
(
cmp
->
agent
,
cmp
->
stream
,
cmp
,
if
(
stream
)
conn_check_prune_socket
(
cmp
->
agent
,
stream
,
cmp
,
candidate
->
sockptr
);
candidate
->
sockptr
);
nice_component_detach_socket
(
cmp
,
candidate
->
sockptr
);
nice_component_detach_socket
(
cmp
,
candidate
->
sockptr
);
agent_remove_local_candidate
(
cmp
->
agent
,
candidate
);
agent_remove_local_candidate
(
cmp
->
agent
,
candidate
);
...
@@ -313,7 +323,7 @@ nice_component_close (NiceComponent *cmp)
...
@@ -313,7 +323,7 @@ nice_component_close (NiceComponent *cmp)
(
GDestroyNotify
)
incoming_check_free
);
(
GDestroyNotify
)
incoming_check_free
);
cmp
->
incoming_checks
=
NULL
;
cmp
->
incoming_checks
=
NULL
;
nice_component_clean_turn_servers
(
cmp
);
nice_component_clean_turn_servers
(
cmp
->
agent
,
cmp
);
if
(
cmp
->
tcp_clock
)
{
if
(
cmp
->
tcp_clock
)
{
g_source_destroy
(
cmp
->
tcp_clock
);
g_source_destroy
(
cmp
->
tcp_clock
);
...
@@ -418,8 +428,13 @@ nice_component_restart (NiceComponent *cmp)
...
@@ -418,8 +428,13 @@ nice_component_restart (NiceComponent *cmp)
void
void
nice_component_update_selected_pair
(
NiceComponent
*
component
,
const
CandidatePair
*
pair
)
nice_component_update_selected_pair
(
NiceComponent
*
component
,
const
CandidatePair
*
pair
)
{
{
NiceStream
*
stream
;
g_assert
(
component
);
g_assert
(
component
);
g_assert
(
pair
);
g_assert
(
pair
);
stream
=
agent_find_stream
(
component
->
agent
,
component
->
stream_id
);
nice_debug
(
"setting SELECTED PAIR for component %u: %s:%s (prio:%"
nice_debug
(
"setting SELECTED PAIR for component %u: %s:%s (prio:%"
G_GUINT64_FORMAT
")."
,
component
->
id
,
pair
->
local
->
foundation
,
G_GUINT64_FORMAT
")."
,
component
->
id
,
pair
->
local
->
foundation
,
pair
->
remote
->
foundation
,
pair
->
priority
);
pair
->
remote
->
foundation
,
pair
->
priority
);
...
@@ -429,7 +444,8 @@ nice_component_update_selected_pair (NiceComponent *component, const CandidatePa
...
@@ -429,7 +444,8 @@ nice_component_update_selected_pair (NiceComponent *component, const CandidatePa
refresh_prune_candidate
(
component
->
agent
,
component
->
turn_candidate
);
refresh_prune_candidate
(
component
->
agent
,
component
->
turn_candidate
);
discovery_prune_socket
(
component
->
agent
,
discovery_prune_socket
(
component
->
agent
,
component
->
turn_candidate
->
sockptr
);
component
->
turn_candidate
->
sockptr
);
conn_check_prune_socket
(
component
->
agent
,
component
->
stream
,
component
,
if
(
stream
)
conn_check_prune_socket
(
component
->
agent
,
stream
,
component
,
component
->
turn_candidate
->
sockptr
);
component
->
turn_candidate
->
sockptr
);
nice_component_detach_socket
(
component
,
component
->
turn_candidate
->
sockptr
);
nice_component_detach_socket
(
component
,
component
->
turn_candidate
->
sockptr
);
nice_candidate_free
(
component
->
turn_candidate
);
nice_candidate_free
(
component
->
turn_candidate
);
...
@@ -575,7 +591,7 @@ nice_component_attach_socket (NiceComponent *component, NiceSocket *nicesock)
...
@@ -575,7 +591,7 @@ nice_component_attach_socket (NiceComponent *component, NiceSocket *nicesock)
/* Create and attach a source */
/* Create and attach a source */
nice_debug
(
"Component %p (agent %p): Attach source (stream %u)."
,
nice_debug
(
"Component %p (agent %p): Attach source (stream %u)."
,
component
,
component
->
agent
,
component
->
stream
->
id
);
component
,
component
->
agent
,
component
->
stream
_
id
);
socket_source_attach
(
socket_source
,
component
->
ctx
);
socket_source_attach
(
socket_source
,
component
->
ctx
);
}
}
...
@@ -797,7 +813,7 @@ emit_io_callback_cb (gpointer user_data)
...
@@ -797,7 +813,7 @@ emit_io_callback_cb (gpointer user_data)
g_object_ref
(
agent
);
g_object_ref
(
agent
);
stream_id
=
component
->
stream
->
id
;
stream_id
=
component
->
stream
_
id
;
component_id
=
component
->
id
;
component_id
=
component
->
id
;
g_mutex_lock
(
&
component
->
io_mutex
);
g_mutex_lock
(
&
component
->
io_mutex
);
...
@@ -869,7 +885,7 @@ nice_component_emit_io_callback (NiceComponent *component,
...
@@ -869,7 +885,7 @@ nice_component_emit_io_callback (NiceComponent *component,
g_assert
(
buf_len
>
0
);
g_assert
(
buf_len
>
0
);
agent
=
component
->
agent
;
agent
=
component
->
agent
;
stream_id
=
component
->
stream
->
id
;
stream_id
=
component
->
stream
_
id
;
component_id
=
component
->
id
;
component_id
=
component
->
id
;
g_mutex_lock
(
&
component
->
io_mutex
);
g_mutex_lock
(
&
component
->
io_mutex
);
...
@@ -1029,7 +1045,6 @@ nice_component_init (NiceComponent *component)
...
@@ -1029,7 +1045,6 @@ nice_component_init (NiceComponent *component)
component
->
restart_candidate
=
NULL
;
component
->
restart_candidate
=
NULL
;
component
->
tcp
=
NULL
;
component
->
tcp
=
NULL
;
component
->
agent
=
NULL
;
component
->
agent
=
NULL
;
component
->
stream
=
NULL
;
g_mutex_init
(
&
component
->
io_mutex
);
g_mutex_init
(
&
component
->
io_mutex
);
g_queue_init
(
&
component
->
pending_io_messages
);
g_queue_init
(
&
component
->
pending_io_messages
);
...
@@ -1084,9 +1099,12 @@ nice_component_get_property (GObject *obj,
...
@@ -1084,9 +1099,12 @@ nice_component_get_property (GObject *obj,
break
;
break
;
case
PROP_STREAM
:
case
PROP_STREAM
:
g_value_set_object
(
value
,
component
->
stream
);
{
NiceStream
*
stream
=
agent_find_stream
(
component
->
agent
,
component
->
stream_id
);
g_value_set_object
(
value
,
stream
);
break
;
break
;
}
default:
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID
(
obj
,
property_id
,
pspec
);
G_OBJECT_WARN_INVALID_PROPERTY_ID
(
obj
,
property_id
,
pspec
);
}
}
...
@@ -1111,7 +1129,10 @@ nice_component_set_property (GObject *obj,
...
@@ -1111,7 +1129,10 @@ nice_component_set_property (GObject *obj,
break
;
break
;
case
PROP_STREAM
:
case
PROP_STREAM
:
component
->
stream
=
g_value_get_object
(
value
);
{
NiceStream
*
stream
=
g_value_get_object
(
value
);
component
->
stream_id
=
stream
->
id
;
}
break
;
break
;
default:
default:
...
...
agent/component.h
View file @
16d51b09
...
@@ -69,7 +69,6 @@ typedef struct _IncomingCheck IncomingCheck;
...
@@ -69,7 +69,6 @@ typedef struct _IncomingCheck IncomingCheck;
struct
_CandidatePairKeepalive
struct
_CandidatePairKeepalive
{
{
NiceAgent
*
agent
;
GSource
*
tick_source
;
GSource
*
tick_source
;
guint
stream_id
;
guint
stream_id
;
guint
component_id
;
guint
component_id
;
...
@@ -202,8 +201,7 @@ struct _NiceComponent {
...
@@ -202,8 +201,7 @@ struct _NiceComponent {
NiceAgent
*
agent
;
/* unowned, immutable: can be accessed without holding the
NiceAgent
*
agent
;
/* unowned, immutable: can be accessed without holding the
* agent lock */
* agent lock */
NiceStream
*
stream
;
/* unowned, immutable: can be accessed without holding
guint
stream_id
;
* the agent lock */
StunAgent
stun_agent
;
/* This stun agent is used to validate all stun requests */
StunAgent
stun_agent
;
/* This stun agent is used to validate all stun requests */
...
@@ -263,7 +261,8 @@ void
...
@@ -263,7 +261,8 @@ void
nice_component_attach_socket
(
NiceComponent
*
component
,
NiceSocket
*
nsocket
);
nice_component_attach_socket
(
NiceComponent
*
component
,
NiceSocket
*
nsocket
);
void
void
nice_component_remove_socket
(
NiceComponent
*
component
,
NiceSocket
*
nsocket
);
nice_component_remove_socket
(
NiceAgent
*
agent
,
NiceComponent
*
component
,
NiceSocket
*
nsocket
);
void
void
nice_component_detach_all_sockets
(
NiceComponent
*
component
);
nice_component_detach_all_sockets
(
NiceComponent
*
component
);
...
@@ -290,7 +289,7 @@ nice_component_emit_io_callback (NiceComponent *component,
...
@@ -290,7 +289,7 @@ nice_component_emit_io_callback (NiceComponent *component,
gboolean
gboolean
nice_component_has_io_callback
(
NiceComponent
*
component
);
nice_component_has_io_callback
(
NiceComponent
*
component
);
void
void
nice_component_clean_turn_servers
(
NiceComponent
*
component
);
nice_component_clean_turn_servers
(
Nice
Agent
*
agent
,
Nice
Component
*
component
);
TurnServer
*
TurnServer
*
...
...
agent/conncheck.c
View file @
16d51b09
...
@@ -1180,7 +1180,7 @@ static gboolean priv_conn_keepalive_retransmissions_tick_agent_locked (
...
@@ -1180,7 +1180,7 @@ static gboolean priv_conn_keepalive_retransmissions_tick_agent_locked (
stun_agent_forget_transaction
(
&
component
->
stun_agent
,
id
);
stun_agent_forget_transaction
(
&
component
->
stun_agent
,
id
);
pair
->
keepalive
.
stun_message
.
buffer
=
NULL
;
pair
->
keepalive
.
stun_message
.
buffer
=
NULL
;
if
(
pair
->
keepalive
.
agent
->
media_after_tick
)
{
if
(
agent
->
media_after_tick
)
{
nice_debug
(
"Agent %p : Keepalive conncheck timed out!! "
nice_debug
(
"Agent %p : Keepalive conncheck timed out!! "
"but media was received. Suspecting keepalive lost because of "
"but media was received. Suspecting keepalive lost because of "
"network bottleneck"
,
agent
);
"network bottleneck"
,
agent
);
...
@@ -1369,9 +1369,8 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
...
@@ -1369,9 +1369,8 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
p
->
keepalive
.
stream_id
=
stream
->
id
;
p
->
keepalive
.
stream_id
=
stream
->
id
;
p
->
keepalive
.
component_id
=
component
->
id
;
p
->
keepalive
.
component_id
=
component
->
id
;
p
->
keepalive
.
agent
=
agent
;
agent_timeout_add_with_context
(
p
->
keepalive
.
agent
,
agent_timeout_add_with_context
(
agent
,
&
p
->
keepalive
.
tick_source
,
"Pair keepalive"
,
&
p
->
keepalive
.
tick_source
,
"Pair keepalive"
,
stun_timer_remainder
(
&
p
->
keepalive
.
timer
),
stun_timer_remainder
(
&
p
->
keepalive
.
timer
),
priv_conn_keepalive_retransmissions_tick_agent_locked
,
p
);
priv_conn_keepalive_retransmissions_tick_agent_locked
,
p
);
...
@@ -1490,7 +1489,7 @@ static gboolean priv_turn_allocate_refresh_retransmissions_tick_agent_locked (
...
@@ -1490,7 +1489,7 @@ static gboolean priv_turn_allocate_refresh_retransmissions_tick_agent_locked (
stun_message_id
(
&
cand
->
stun_message
,
id
);
stun_message_id
(
&
cand
->
stun_message
,
id
);
stun_agent_forget_transaction
(
&
cand
->
stun_agent
,
id
);
stun_agent_forget_transaction
(
&
cand
->
stun_agent
,
id
);
refresh_cancel
(
cand
);
refresh_cancel
(
agent
,
cand
);
break
;
break
;
}
}
case
STUN_USAGE_TIMER_RETURN_RETRANSMIT
:
case
STUN_USAGE_TIMER_RETURN_RETRANSMIT
:
...
@@ -1775,7 +1774,7 @@ static void priv_update_check_list_failed_components (NiceAgent *agent, NiceStre
...
@@ -1775,7 +1774,7 @@ static void priv_update_check_list_failed_components (NiceAgent *agent, NiceStre
/* There is still discovery ogoing for this stream,
/* There is still discovery ogoing for this stream,
* so don't fail any of it's candidates.
* so don't fail any of it's candidates.
*/
*/
if
(
d
->
stream
==
stream
&&
!
d
->
done
)
if
(
d
->
stream
_id
==
stream
->
id
&&
!
d
->
done
)
return
;
return
;
}
}
if
(
agent
->
discovery_list
!=
NULL
)
if
(
agent
->
discovery_list
!=
NULL
)
...
@@ -1939,7 +1938,8 @@ static void priv_mark_pair_nominated (NiceAgent *agent, NiceStream *stream, Nice
...
@@ -1939,7 +1938,8 @@ static void priv_mark_pair_nominated (NiceAgent *agent, NiceStream *stream, Nice
}
}
guint32
guint32
ensure_unique_priority
(
NiceComponent
*
component
,
guint32
priority
)
ensure_unique_priority
(
NiceStream
*
stream
,
NiceComponent
*
component
,
guint32
priority
)
{
{
GSList
*
item
;
GSList
*
item
;
...
@@ -1956,7 +1956,7 @@ ensure_unique_priority (NiceComponent *component, guint32 priority)
...
@@ -1956,7 +1956,7 @@ ensure_unique_priority (NiceComponent *component, guint32 priority)
}
}
}
}
for
(
item
=
component
->
stream
->
conncheck_list
;
item
;
item
=
item
->
next
)
{
for
(
item
=
stream
->
conncheck_list
;
item
;
item
=
item
->
next
)
{
CandidateCheckPair
*
p
=
item
->
data
;
CandidateCheckPair
*
p
=
item
->
data
;
if
(
p
->
component_id
==
component
->
id
&&
if
(
p
->
component_id
==
component
->
id
&&
...
@@ -2013,7 +2013,7 @@ static CandidateCheckPair *priv_add_new_check_pair (NiceAgent *agent,
...
@@ -2013,7 +2013,7 @@ static CandidateCheckPair *priv_add_new_check_pair (NiceAgent *agent,
tmpbuf1
,
nice_address_get_port
(
&
pair
->
local
->
addr
),
tmpbuf1
,
nice_address_get_port
(
&
pair
->
local
->
addr
),
tmpbuf2
,
nice_address_get_port
(
&
pair
->
remote
->
addr
));
tmpbuf2
,
nice_address_get_port
(
&
pair
->
remote
->
addr
));
}
}
pair
->
prflx_priority
=
ensure_unique_priority
(
component
,
pair
->
prflx_priority
=
ensure_unique_priority
(
stream
,
component
,
peer_reflexive_candidate_priority
(
agent
,
local
));
peer_reflexive_candidate_priority
(
agent
,
local
));
stream
->
conncheck_list
=
g_slist_insert_sorted
(
stream
->
conncheck_list
,
pair
,
stream
->
conncheck_list
=
g_slist_insert_sorted
(
stream
->
conncheck_list
,
pair
,
...
@@ -2936,7 +2936,7 @@ static CandidateCheckPair *priv_add_peer_reflexive_pair (NiceAgent *agent, guint
...
@@ -2936,7 +2936,7 @@ static CandidateCheckPair *priv_add_peer_reflexive_pair (NiceAgent *agent, guint
pair
->
priority
=
nice_candidate_pair_priority
(
pair
->
remote
->
priority
,
pair
->
priority
=
nice_candidate_pair_priority
(
pair
->
remote
->
priority
,
pair
->
local
->
priority
);
pair
->
local
->
priority
);
pair
->
nominated
=
FALSE
;
pair
->
nominated
=
FALSE
;
pair
->
prflx_priority
=
ensure_unique_priority
(
component
,
pair
->
prflx_priority
=
ensure_unique_priority
(
stream
,
component
,
peer_reflexive_candidate_priority
(
agent
,
local_cand
));
peer_reflexive_candidate_priority
(
agent
,
local_cand
));
nice_debug
(
"Agent %p : added a new peer-discovered pair with "
nice_debug
(
"Agent %p : added a new peer-discovered pair with "
"foundation '%s'."
,
agent
,
pair
->
foundation
);
"foundation '%s'."
,
agent
,
pair
->
foundation
);
...
@@ -3349,18 +3349,18 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
...
@@ -3349,18 +3349,18 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
nice_address_set_from_sockaddr
(
&
niceaddr
,
&
sockaddr
.
addr
);
nice_address_set_from_sockaddr
(
&
niceaddr
,
&
sockaddr
.
addr
);
discovery_add_server_reflexive_candidate
(
discovery_add_server_reflexive_candidate
(
d
->
agent
,
agent
,
d
->
stream
->
id
,
d
->
stream
_
id
,
d
->
component
->
id
,
d
->
component
_
id
,
&
niceaddr
,
&
niceaddr
,
NICE_CANDIDATE_TRANSPORT_UDP
,
NICE_CANDIDATE_TRANSPORT_UDP
,
d
->
nicesock
,
d
->
nicesock
,
FALSE
);
FALSE
);
if
(
d
->
agent
->
use_ice_tcp
)
if
(
agent
->
use_ice_tcp
)
discovery_discover_tcp_server_reflexive_candidates
(
discovery_discover_tcp_server_reflexive_candidates
(
d
->
agent
,
agent
,
d
->
stream
->
id
,
d
->
stream
_
id
,
d
->
component
->
id
,
d
->
component
_
id
,
&
niceaddr
,
&
niceaddr
,
d
->
nicesock
);
d
->
nicesock
);
}
}
...
@@ -3384,11 +3384,10 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
...
@@ -3384,11 +3384,10 @@ static gboolean priv_map_reply_to_discovery_request (NiceAgent *agent, StunMessa
static
CandidateRefresh
*
static
CandidateRefresh
*
priv_add_new_turn_refresh
(
CandidateDiscovery
*
cdisco
,
NiceCandidate
*
relay_cand
,
priv_add_new_turn_refresh
(
NiceAgent
*
agent
,
CandidateDiscovery
*
cdisco
,
guint
lifetime
)
NiceCandidate
*
relay_cand
,
guint
lifetime
)
{
{
CandidateRefresh
*
cand
;
CandidateRefresh
*
cand
;
NiceAgent
*
agent
=
cdisco
->
agent
;
cand
=
g_slice_new0
(
CandidateRefresh
);
cand
=
g_slice_new0
(
CandidateRefresh
);
agent
->
refresh_list
=
g_slist_append
(
agent
->
refresh_list
,
cand
);
agent
->
refresh_list
=
g_slist_append
(
agent
->
refresh_list
,
cand
);
...
@@ -3396,9 +3395,8 @@ priv_add_new_turn_refresh (CandidateDiscovery *cdisco, NiceCandidate *relay_cand
...
@@ -3396,9 +3395,8 @@ priv_add_new_turn_refresh (CandidateDiscovery *cdisco, NiceCandidate *relay_cand
cand
->
candidate
=
relay_cand
;
cand
->
candidate
=
relay_cand
;
cand
->
nicesock
=
cdisco
->
nicesock
;
cand
->
nicesock
=
cdisco
->
nicesock
;
cand
->
server
=
cdisco
->
server
;
cand
->
server
=
cdisco
->
server
;
cand
->
stream
=
cdisco
->
stream
;
cand
->
stream_id
=
cdisco
->
stream_id
;
cand
->
component
=
cdisco
->
component
;
cand
->
component_id
=
cdisco
->
component_id
;
cand
->
agent
=
cdisco
->
agent
;
memcpy
(
&
cand
->
stun_agent
,
&
cdisco
->
stun_agent
,
sizeof
(
StunAgent
));
memcpy
(
&
cand
->
stun_agent
,
&
cdisco
->
stun_agent
,
sizeof
(
StunAgent
));
/* Use previous stun response for authentication credentials */
/* Use previous stun response for authentication credentials */
...
@@ -3412,7 +3410,7 @@ priv_add_new_turn_refresh (CandidateDiscovery *cdisco, NiceCandidate *relay_cand
...
@@ -3412,7 +3410,7 @@ priv_add_new_turn_refresh (CandidateDiscovery *cdisco, NiceCandidate *relay_cand
}
}
nice_debug
(
"Agent %p : Adding new refresh candidate %p with timeout %d"
,
nice_debug
(
"Agent %p : Adding new refresh candidate %p with timeout %d"
,
agent
,
cand
,
(
lifetime
-
60
)
*
100
0
);
agent
,
cand
,
lifetime
-
6
0
);
/* step: also start the refresh timer */
/* step: also start the refresh timer */
/* refresh should be sent 1 minute before it expires */
/* refresh should be sent 1 minute before it expires */
...
@@ -3441,7 +3439,7 @@ static void priv_handle_turn_alternate_server (NiceAgent *agent,
...
@@ -3441,7 +3439,7 @@ static void priv_handle_turn_alternate_server (NiceAgent *agent,
if
(
!
d
->
done
&&
if
(
!
d
->
done
&&
d
->
type
==
disco
->
type
&&
d
->
type
==
disco
->
type
&&
d
->
stream
==
disco
->
stream
&&
d
->
stream
_id
==
disco
->
stream_id
&&
d
->
turn
->
type
==
disco
->
turn
->
type
&&
d
->
turn
->
type
==
disco
->
turn
->
type
&&
nice_address_equal
(
&
d
->
server
,
&
server
))
{
nice_address_equal
(
&
d
->
server
,
&
server
))
{
gchar
ip
[
INET6_ADDRSTRLEN
];
gchar
ip
[
INET6_ADDRSTRLEN
];
...
@@ -3539,15 +3537,15 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
...
@@ -3539,15 +3537,15 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
if
(
d
->
turn
->
type
==
NICE_RELAY_TYPE_TURN_UDP
&&
if
(
d
->
turn
->
type
==
NICE_RELAY_TYPE_TURN_UDP
&&
!
agent
->
force_relay
)
{
!
agent
->
force_relay
)
{
discovery_add_server_reflexive_candidate
(
discovery_add_server_reflexive_candidate
(
d
->
agent
,
agent
,
d
->
stream
->
id
,
d
->
stream
_
id
,
d
->
component
->
id
,
d
->
component
_
id
,
&
mappedniceaddr
,
&
mappedniceaddr
,
NICE_CANDIDATE_TRANSPORT_UDP
,
NICE_CANDIDATE_TRANSPORT_UDP
,
d
->
nicesock
,
d
->
nicesock
,
FALSE
);
FALSE
);
}
}
if
(
d
->
agent
->
use_ice_tcp
)
{
if
(
agent
->
use_ice_tcp
)
{
if
((
agent
->
compatibility
==
NICE_COMPATIBILITY_OC2007
||
if
((
agent
->
compatibility
==
NICE_COMPATIBILITY_OC2007
||
agent
->
compatibility
==
NICE_COMPATIBILITY_OC2007R2
)
&&
agent
->
compatibility
==
NICE_COMPATIBILITY_OC2007R2
)
&&
!
nice_address_equal_no_port
(
&
niceaddr
,
&
d
->
turn
->
server
))
{
!
nice_address_equal_no_port
(
&
niceaddr
,
&
d
->
turn
->
server
))
{
...
@@ -3555,9 +3553,9 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
...
@@ -3555,9 +3553,9 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
"ignoring bogus srflx address"
);
"ignoring bogus srflx address"
);
}
else
{
}
else
{
discovery_discover_tcp_server_reflexive_candidates
(
discovery_discover_tcp_server_reflexive_candidates
(
d
->
agent
,
agent
,
d
->
stream
->
id
,
d
->
stream
_
id
,
d
->
component
->
id
,
d
->
component
_
id
,
&
mappedniceaddr
,
&
mappedniceaddr
,
d
->
nicesock
);
d
->
nicesock
);
}
}
...
@@ -3566,9 +3564,9 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
...
@@ -3566,9 +3564,9 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
if
(
nice_socket_is_reliable
(
d
->
nicesock
))
{
if
(
nice_socket_is_reliable
(
d
->
nicesock
))
{
relay_cand
=
discovery_add_relay_candidate
(
relay_cand
=
discovery_add_relay_candidate
(
d
->
agent
,
agent
,
d
->
stream
->
id
,
d
->
stream
_
id
,
d
->
component
->
id
,
d
->
component
_
id
,
&
niceaddr
,
&
niceaddr
,
NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE
,
NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE
,
d
->
nicesock
,
d
->
nicesock
,
...
@@ -3582,23 +3580,23 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
...
@@ -3582,23 +3580,23 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
nice_udp_turn_socket_set_ms_connection_id
(
relay_cand
->
sockptr
,
nice_udp_turn_socket_set_ms_connection_id
(
relay_cand
->
sockptr
,
resp
);
resp
);
}
else
{
}
else
{
priv_add_new_turn_refresh
(
d
,
relay_cand
,
lifetime
);
priv_add_new_turn_refresh
(
agent
,
d
,
relay_cand
,
lifetime
);
}
}
}
}
relay_cand
=
discovery_add_relay_candidate
(
relay_cand
=
discovery_add_relay_candidate
(
d
->
agent
,
agent
,
d
->
stream
->
id
,
d
->
stream
_
id
,
d
->
component
->
id
,
d
->
component
_
id
,
&
niceaddr
,
&
niceaddr
,
NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE
,
NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE
,
d
->
nicesock
,
d
->
nicesock
,
d
->
turn
);
d
->
turn
);
}
else
{
}
else
{
relay_cand
=
discovery_add_relay_candidate
(
relay_cand
=
discovery_add_relay_candidate
(
d
->
agent
,
agent
,
d
->
stream
->
id
,
d
->
stream
_
id
,
d
->
component
->
id
,
d
->
component
_
id
,
&
niceaddr
,
&
niceaddr
,
NICE_CANDIDATE_TRANSPORT_UDP
,
NICE_CANDIDATE_TRANSPORT_UDP
,
d
->
nicesock
,
d
->
nicesock
,
...
@@ -3622,7 +3620,7 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
...
@@ -3622,7 +3620,7 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
nice_udp_turn_socket_set_ms_connection_id
(
relay_cand
->
sockptr
,
nice_udp_turn_socket_set_ms_connection_id
(
relay_cand
->
sockptr
,
resp
);
resp
);
}
else
{
}
else
{
priv_add_new_turn_refresh
(
d
,
relay_cand
,
lifetime
);
priv_add_new_turn_refresh
(
agent
,
d
,
relay_cand
,
lifetime
);
}
}
/* In case a new candidate has been added */
/* In case a new candidate has been added */
...
@@ -3723,12 +3721,12 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
...
@@ -3723,12 +3721,12 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
if
(
memcmp
(
refresh_id
,
response_id
,
sizeof
(
StunTransactionId
))
==
0
)
{
if
(
memcmp
(
refresh_id
,
response_id
,
sizeof
(
StunTransactionId
))
==
0
)
{
res
=
stun_usage_turn_refresh_process
(
resp
,
res
=
stun_usage_turn_refresh_process
(
resp
,
&
lifetime
,
agent_to_turn_compatibility
(
cand
->
agent
));
&
lifetime
,
agent_to_turn_compatibility
(
agent
));
nice_debug
(
"Agent %p : stun_turn_refresh_process for %p res %d."
,
nice_debug
(
"Agent %p : stun_turn_refresh_process for %p res %d."
,
agent
,
cand
,
(
int
)
res
);
agent
,
cand
,
(
int
)
res
);
if
(
res
==
STUN_USAGE_TURN_RETURN_RELAY_SUCCESS
)
{
if
(
res
==
STUN_USAGE_TURN_RETURN_RELAY_SUCCESS
)
{
/* refresh should be sent 1 minute before it expires */
/* refresh should be sent 1 minute before it expires */
agent_timeout_add_seconds_with_context
(
cand
->
agent
,
agent_timeout_add_seconds_with_context
(
agent
,
&
cand
->
timer_source
,
&
cand
->
timer_source
,
"Candidate TURN refresh"
,
lifetime
-
60
,
"Candidate TURN refresh"
,
lifetime
-
60
,
priv_turn_allocate_refresh_tick_agent_locked
,
cand
);
priv_turn_allocate_refresh_tick_agent_locked
,
cand
);
...
@@ -3749,7 +3747,7 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
...
@@ -3749,7 +3747,7 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
STUN_ATTRIBUTE_REALM
,
&
recv_realm_len
);
STUN_ATTRIBUTE_REALM
,
&
recv_realm_len
);
/* check for unauthorized error response */
/* check for unauthorized error response */
if
(
cand
->
agent
->
compatibility
==
NICE_COMPATIBILITY_RFC5245
&&
if
(
agent
->
compatibility
==
NICE_COMPATIBILITY_RFC5245
&&
stun_message_get_class
(
resp
)
==
STUN_ERROR
&&
stun_message_get_class
(
resp
)
==
STUN_ERROR
&&
stun_message_find_error
(
resp
,
&
code
)
==
stun_message_find_error
(
resp
,
&
code
)
==
STUN_MESSAGE_RETURN_SUCCESS
&&
STUN_MESSAGE_RETURN_SUCCESS
&&
...
@@ -3768,11 +3766,11 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
...
@@ -3768,11 +3766,11 @@ static gboolean priv_map_reply_to_relay_refresh (NiceAgent *agent, StunMessage *
priv_turn_allocate_refresh_tick_unlocked
(
agent
,
cand
);
priv_turn_allocate_refresh_tick_unlocked
(
agent
,
cand
);
}
else
{
}
else
{
/* case: a real unauthorized error */
/* case: a real unauthorized error */
refresh_cancel
(
cand
);
refresh_cancel
(
agent
,
cand
);
}
}
}
else
{
}
else
{
/* case: STUN error, the check STUN context was freed */
/* case: STUN error, the check STUN context was freed */
refresh_cancel
(
cand
);
refresh_cancel
(
agent
,
cand
);
}
}
trans_found
=
TRUE
;
trans_found
=
TRUE
;
}
}
...
@@ -3958,7 +3956,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, NiceStream *stream,
...
@@ -3958,7 +3956,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, NiceStream *stream,
valid
==
STUN_VALIDATION_UNMATCHED_RESPONSE
)
{
valid
==
STUN_VALIDATION_UNMATCHED_RESPONSE
)
{
for
(
i
=
agent
->
discovery_list
;
i
;
i
=
i
->
next
)
{
for
(
i
=
agent
->
discovery_list
;
i
;
i
=
i
->
next
)
{
CandidateDiscovery
*
d
=
i
->
data
;
CandidateDiscovery
*
d
=
i
->
data
;
if
(
d
->
stream
==
stream
&&
d
->
component
==
component
&&
if
(
d
->
stream
_id
==
stream
->
id
&&
d
->
component_id
==
component
->
id
&&
d
->
nicesock
==
nicesock
)
{
d
->
nicesock
==
nicesock
)
{
valid
=
stun_agent_validate
(
&
d
->
stun_agent
,
&
req
,
valid
=
stun_agent_validate
(
&
d
->
stun_agent
,
&
req
,
(
uint8_t
*
)
buf
,
len
,
conncheck_stun_validater
,
&
validater_data
);
(
uint8_t
*
)
buf
,
len
,
conncheck_stun_validater
,
&
validater_data
);
...
@@ -3977,11 +3975,11 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, NiceStream *stream,
...
@@ -3977,11 +3975,11 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, NiceStream *stream,
for
(
i
=
agent
->
refresh_list
;
i
;
i
=
i
->
next
)
{
for
(
i
=
agent
->
refresh_list
;
i
;
i
=
i
->
next
)
{
CandidateRefresh
*
r
=
i
->
data
;
CandidateRefresh
*
r
=
i
->
data
;
nice_debug_verbose
(
"Comparing
%p to %p, %p to %p
and %p and %p to %p"
,
nice_debug_verbose
(
"Comparing
r.sid=%u to sid=%u, r.cid=%u to cid=%u
and %p and %p to %p"
,
r
->
stream
,
stream
,
r
->
component
,
component
,
r
->
nicesock
,
r
->
stream
_id
,
stream
->
id
,
r
->
component_id
,
component
->
id
,
r
->
nicesock
,
r
->
candidate
->
sockptr
,
nicesock
);
r
->
candidate
->
sockptr
,
nicesock
);
if
(
r
->
stream
==
stream
&&
r
->
component
==
component
&&
if
(
r
->
stream
_id
==
stream
->
id
&&
r
->
component_id
==
component
->
id
&&
(
r
->
nicesock
==
nicesock
||
r
->
candidate
->
sockptr
==
nicesock
))
{
(
r
->
nicesock
==
nicesock
||
r
->
candidate
->
sockptr
==
nicesock
))
{
valid
=
stun_agent_validate
(
&
r
->
stun_agent
,
&
req
,
valid
=
stun_agent_validate
(
&
r
->
stun_agent
,
&
req
,
(
uint8_t
*
)
buf
,
len
,
conncheck_stun_validater
,
&
validater_data
);
(
uint8_t
*
)
buf
,
len
,
conncheck_stun_validater
,
&
validater_data
);
...
...
agent/conncheck.h
View file @
16d51b09
...
@@ -117,7 +117,8 @@ void
...
@@ -117,7 +117,8 @@ void
conn_check_prune_socket
(
NiceAgent
*
agent
,
NiceStream
*
stream
,
NiceComponent
*
component
,
conn_check_prune_socket
(
NiceAgent
*
agent
,
NiceStream
*
stream
,
NiceComponent
*
component
,
NiceSocket
*
sock
);
NiceSocket
*
sock
);
guint32
ensure_unique_priority
(
NiceComponent
*
component
,
guint32
priority
);
guint32
ensure_unique_priority
(
NiceStream
*
stream
,
NiceComponent
*
component
,
guint32
priority
);
void
recalculate_pair_priorities
(
NiceAgent
*
agent
);
void
recalculate_pair_priorities
(
NiceAgent
*
agent
);
#endif
/*_NICE_CONNCHECK_H */
#endif
/*_NICE_CONNCHECK_H */
agent/discovery.c
View file @
16d51b09
...
@@ -111,7 +111,7 @@ void discovery_prune_stream (NiceAgent *agent, guint stream_id)
...
@@ -111,7 +111,7 @@ void discovery_prune_stream (NiceAgent *agent, guint stream_id)
CandidateDiscovery
*
cand
=
i
->
data
;
CandidateDiscovery
*
cand
=
i
->
data
;
GSList
*
next
=
i
->
next
;
GSList
*
next
=
i
->
next
;
if
(
cand
->
stream
->
id
==
stream_id
)
{
if
(
cand
->
stream
_
id
==
stream_id
)
{
agent
->
discovery_list
=
g_slist_remove
(
agent
->
discovery_list
,
cand
);
agent
->
discovery_list
=
g_slist_remove
(
agent
->
discovery_list
,
cand
);
discovery_free_item
(
cand
);
discovery_free_item
(
cand
);
}
}
...
@@ -156,9 +156,8 @@ void discovery_prune_socket (NiceAgent *agent, NiceSocket *sock)
...
@@ -156,9 +156,8 @@ void discovery_prune_socket (NiceAgent *agent, NiceSocket *sock)
* Frees the CandidateDiscovery structure pointed to
* Frees the CandidateDiscovery structure pointed to
* by 'user data'. Compatible with g_slist_free_full().
* by 'user data'. Compatible with g_slist_free_full().
*/
*/
static
void
refresh_free_item
(
CandidateRefresh
*
cand
)
static
void
refresh_free_item
(
NiceAgent
*
agent
,
CandidateRefresh
*
cand
)
{
{
NiceAgent
*
agent
=
cand
->
agent
;
uint8_t
*
username
;
uint8_t
*
username
;
gsize
username_len
;
gsize
username_len
;
uint8_t
*
password
;
uint8_t
*
password
;
...
@@ -166,6 +165,8 @@ static void refresh_free_item (CandidateRefresh *cand)
...
@@ -166,6 +165,8 @@ static void refresh_free_item (CandidateRefresh *cand)
size_t
buffer_len
=
0
;
size_t
buffer_len
=
0
;
StunUsageTurnCompatibility
turn_compat
=
agent_to_turn_compatibility
(
agent
);
StunUsageTurnCompatibility
turn_compat
=
agent_to_turn_compatibility
(
agent
);
agent
->
refresh_list
=
g_slist_remove
(
agent
->
refresh_list
,
cand
);
if
(
cand
->
timer_source
!=
NULL
)
{
if
(
cand
->
timer_source
!=
NULL
)
{
g_source_destroy
(
cand
->
timer_source
);
g_source_destroy
(
cand
->
timer_source
);
g_source_unref
(
cand
->
timer_source
);
g_source_unref
(
cand
->
timer_source
);
...
@@ -227,8 +228,8 @@ static void refresh_free_item (CandidateRefresh *cand)
...
@@ -227,8 +228,8 @@ static void refresh_free_item (CandidateRefresh *cand)
*/
*/
void
refresh_free
(
NiceAgent
*
agent
)
void
refresh_free
(
NiceAgent
*
agent
)
{
{
g_slist_free_full
(
agent
->
refresh_list
,
(
GDestroyNotify
)
refresh_free_item
);
while
(
agent
->
refresh_list
)
agent
->
refresh_list
=
NULL
;
refresh_free_item
(
agent
,
agent
->
refresh_list
->
data
)
;
}
}
/*
/*
...
@@ -248,9 +249,8 @@ void refresh_prune_stream (NiceAgent *agent, guint stream_id)
...
@@ -248,9 +249,8 @@ void refresh_prune_stream (NiceAgent *agent, guint stream_id)
/* Don't free the candidate refresh to the currently selected local candidate
/* Don't free the candidate refresh to the currently selected local candidate
* unless the whole pair is being destroyed.
* unless the whole pair is being destroyed.
*/
*/
if
(
cand
->
stream
->
id
==
stream_id
)
{
if
(
cand
->
stream_id
==
stream_id
)
{
agent
->
refresh_list
=
g_slist_delete_link
(
agent
->
refresh_list
,
i
);
refresh_free_item
(
agent
,
cand
);
refresh_free_item
(
cand
);
}
}
i
=
next
;
i
=
next
;
...
@@ -267,8 +267,7 @@ void refresh_prune_candidate (NiceAgent *agent, NiceCandidate *candidate)
...
@@ -267,8 +267,7 @@ void refresh_prune_candidate (NiceAgent *agent, NiceCandidate *candidate)
CandidateRefresh
*
refresh
=
i
->
data
;
CandidateRefresh
*
refresh
=
i
->
data
;
if
(
refresh
->
candidate
==
candidate
)
{
if
(
refresh
->
candidate
==
candidate
)
{
agent
->
refresh_list
=
g_slist_delete_link
(
agent
->
refresh_list
,
i
);
refresh_free_item
(
agent
,
refresh
);
refresh_free_item
(
refresh
);
}
}
i
=
next
;
i
=
next
;
...
@@ -284,19 +283,16 @@ void refresh_prune_socket (NiceAgent *agent, NiceSocket *sock)
...
@@ -284,19 +283,16 @@ void refresh_prune_socket (NiceAgent *agent, NiceSocket *sock)
CandidateRefresh
*
refresh
=
i
->
data
;
CandidateRefresh
*
refresh
=
i
->
data
;
if
(
refresh
->
nicesock
==
sock
)
{
if
(
refresh
->
nicesock
==
sock
)
{
agent
->
refresh_list
=
g_slist_delete_link
(
agent
->
refresh_list
,
i
);
refresh_free_item
(
agent
,
refresh
);
refresh_free_item
(
refresh
);
}
}
i
=
next
;
i
=
next
;
}
}
}
}
void
refresh_cancel
(
CandidateRefresh
*
refresh
)
void
refresh_cancel
(
NiceAgent
*
agent
,
CandidateRefresh
*
refresh
)
{
{
refresh
->
agent
->
refresh_list
=
g_slist_remove
(
refresh
->
agent
->
refresh_list
,
refresh_free_item
(
agent
,
refresh
);
refresh
);
refresh_free_item
(
refresh
);
}
}
...
@@ -549,7 +545,7 @@ HostCandidateResult discovery_add_local_host_candidate (
...
@@ -549,7 +545,7 @@ HostCandidateResult discovery_add_local_host_candidate (
agent
->
reliable
,
FALSE
);
agent
->
reliable
,
FALSE
);
}
}
candidate
->
priority
=
ensure_unique_priority
(
component
,
candidate
->
priority
=
ensure_unique_priority
(
stream
,
component
,
candidate
->
priority
);
candidate
->
priority
);
priv_generate_candidate_credentials
(
agent
,
candidate
);
priv_generate_candidate_credentials
(
agent
,
candidate
);
priv_assign_foundation
(
agent
,
candidate
);
priv_assign_foundation
(
agent
,
candidate
);
...
@@ -641,7 +637,7 @@ discovery_add_server_reflexive_candidate (
...
@@ -641,7 +637,7 @@ discovery_add_server_reflexive_candidate (
agent
->
reliable
,
nat_assisted
);
agent
->
reliable
,
nat_assisted
);
}
}
candidate
->
priority
=
ensure_unique_priority
(
component
,
candidate
->
priority
=
ensure_unique_priority
(
stream
,
component
,
candidate
->
priority
);
candidate
->
priority
);
priv_generate_candidate_credentials
(
agent
,
candidate
);
priv_generate_candidate_credentials
(
agent
,
candidate
);
priv_assign_foundation
(
agent
,
candidate
);
priv_assign_foundation
(
agent
,
candidate
);
...
@@ -760,7 +756,7 @@ discovery_add_relay_candidate (
...
@@ -760,7 +756,7 @@ discovery_add_relay_candidate (
agent
->
reliable
,
FALSE
);
agent
->
reliable
,
FALSE
);
}
}
candidate
->
priority
=
ensure_unique_priority
(
component
,
candidate
->
priority
=
ensure_unique_priority
(
stream
,
component
,
candidate
->
priority
);
candidate
->
priority
);
priv_generate_candidate_credentials
(
agent
,
candidate
);
priv_generate_candidate_credentials
(
agent
,
candidate
);
...
@@ -842,7 +838,7 @@ discovery_add_peer_reflexive_candidate (
...
@@ -842,7 +838,7 @@ discovery_add_peer_reflexive_candidate (
agent
->
reliable
,
FALSE
);
agent
->
reliable
,
FALSE
);
}
}
candidate
->
priority
=
ensure_unique_priority
(
component
,
candidate
->
priority
=
ensure_unique_priority
(
stream
,
component
,
candidate
->
priority
);
candidate
->
priority
);
priv_assign_foundation
(
agent
,
candidate
);
priv_assign_foundation
(
agent
,
candidate
);
...
@@ -1029,12 +1025,15 @@ static gboolean priv_discovery_tick_unlocked (NiceAgent *agent)
...
@@ -1029,12 +1025,15 @@ static gboolean priv_discovery_tick_unlocked (NiceAgent *agent)
if
(
nice_address_is_valid
(
&
cand
->
server
)
&&
if
(
nice_address_is_valid
(
&
cand
->
server
)
&&
(
cand
->
type
==
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE
||
(
cand
->
type
==
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE
||
cand
->
type
==
NICE_CANDIDATE_TYPE_RELAYED
))
{
cand
->
type
==
NICE_CANDIDATE_TYPE_RELAYED
))
{
NiceComponent
*
component
;
if
(
cand
->
component
->
state
==
NICE_COMPONENT_STATE_DISCONNECTED
||
if
(
agent_find_component
(
agent
,
cand
->
stream_id
,
cand
->
component
->
state
==
NICE_COMPONENT_STATE_FAILED
)
cand
->
component_id
,
NULL
,
&
component
)
&&
(
component
->
state
==
NICE_COMPONENT_STATE_DISCONNECTED
||
component
->
state
==
NICE_COMPONENT_STATE_FAILED
))
agent_signal_component_state_change
(
agent
,
agent_signal_component_state_change
(
agent
,
cand
->
stream
->
id
,
cand
->
stream
_
id
,
cand
->
component
->
id
,
cand
->
component
_
id
,
NICE_COMPONENT_STATE_GATHERING
);
NICE_COMPONENT_STATE_GATHERING
);
if
(
cand
->
type
==
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE
)
{
if
(
cand
->
type
==
NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE
)
{
...
...
agent/discovery.h
View file @
16d51b09
...
@@ -46,15 +46,14 @@
...
@@ -46,15 +46,14 @@
typedef
struct
typedef
struct
{
{
NiceAgent
*
agent
;
/* back pointer to owner */
NiceCandidateType
type
;
/* candidate type STUN or TURN */
NiceCandidateType
type
;
/* candidate type STUN or TURN */
NiceSocket
*
nicesock
;
/* XXX: should be taken from local cand: existing socket to use */
NiceSocket
*
nicesock
;
/* XXX: should be taken from local cand: existing socket to use */
NiceAddress
server
;
/* STUN/TURN server address */
NiceAddress
server
;
/* STUN/TURN server address */
GTimeVal
next_tick
;
/* next tick timestamp */
GTimeVal
next_tick
;
/* next tick timestamp */
gboolean
pending
;
/* is discovery in progress? */
gboolean
pending
;
/* is discovery in progress? */
gboolean
done
;
/* is discovery complete? */
gboolean
done
;
/* is discovery complete? */
NiceStream
*
stream
;
guint
stream_id
;
NiceComponent
*
component
;
guint
component_id
;
TurnServer
*
turn
;
TurnServer
*
turn
;
StunAgent
stun_agent
;
StunAgent
stun_agent
;
StunTimer
timer
;
StunTimer
timer
;
...
@@ -66,12 +65,11 @@ typedef struct
...
@@ -66,12 +65,11 @@ typedef struct
typedef
struct
typedef
struct
{
{
NiceAgent
*
agent
;
/* back pointer to owner */
NiceSocket
*
nicesock
;
/* existing socket to use */
NiceSocket
*
nicesock
;
/* existing socket to use */
NiceAddress
server
;
/* STUN/TURN server address */
NiceAddress
server
;
/* STUN/TURN server address */
NiceCandidate
*
candidate
;
/* candidate to refresh */
NiceCandidate
*
candidate
;
/* candidate to refresh */
NiceStream
*
stream
;
guint
stream_id
;
NiceComponent
*
component
;
guint
component_id
;
StunAgent
stun_agent
;
StunAgent
stun_agent
;
GSource
*
timer_source
;
GSource
*
timer_source
;
GSource
*
tick_source
;
GSource
*
tick_source
;
...
@@ -86,7 +84,7 @@ void refresh_free (NiceAgent *agent);
...
@@ -86,7 +84,7 @@ void refresh_free (NiceAgent *agent);
void
refresh_prune_stream
(
NiceAgent
*
agent
,
guint
stream_id
);
void
refresh_prune_stream
(
NiceAgent
*
agent
,
guint
stream_id
);
void
refresh_prune_candidate
(
NiceAgent
*
agent
,
NiceCandidate
*
candidate
);
void
refresh_prune_candidate
(
NiceAgent
*
agent
,
NiceCandidate
*
candidate
);
void
refresh_prune_socket
(
NiceAgent
*
agent
,
NiceSocket
*
sock
);
void
refresh_prune_socket
(
NiceAgent
*
agent
,
NiceSocket
*
sock
);
void
refresh_cancel
(
CandidateRefresh
*
refresh
);
void
refresh_cancel
(
NiceAgent
*
agent
,
CandidateRefresh
*
refresh
);
void
discovery_free
(
NiceAgent
*
agent
);
void
discovery_free
(
NiceAgent
*
agent
);
...
...
agent/stream.c
View file @
16d51b09
...
@@ -58,13 +58,15 @@ nice_stream_finalize (GObject *obj);
...
@@ -58,13 +58,15 @@ nice_stream_finalize (GObject *obj);
* @brief ICE stream functionality
* @brief ICE stream functionality
*/
*/
NiceStream
*
NiceStream
*
nice_stream_new
(
guint
n_components
,
NiceAgent
*
agent
)
nice_stream_new
(
guint
stream_id
,
guint
n_components
,
NiceAgent
*
agent
)
{
{
NiceStream
*
stream
=
NULL
;
NiceStream
*
stream
=
NULL
;
guint
n
;
guint
n
;
stream
=
g_object_new
(
NICE_TYPE_STREAM
,
NULL
);
stream
=
g_object_new
(
NICE_TYPE_STREAM
,
NULL
);
stream
->
id
=
stream_id
;
/* Create the components. */
/* Create the components. */
for
(
n
=
0
;
n
<
n_components
;
n
++
)
{
for
(
n
=
0
;
n
<
n_components
;
n
++
)
{
NiceComponent
*
component
=
NULL
;
NiceComponent
*
component
=
NULL
;
...
...
agent/stream.h
View file @
16d51b09
...
@@ -98,7 +98,7 @@ typedef struct {
...
@@ -98,7 +98,7 @@ typedef struct {
GType
nice_stream_get_type
(
void
);
GType
nice_stream_get_type
(
void
);
NiceStream
*
NiceStream
*
nice_stream_new
(
guint
n_components
,
NiceAgent
*
agent
);
nice_stream_new
(
guint
stream_id
,
guint
n_components
,
NiceAgent
*
agent
);
void
void
nice_stream_close
(
NiceStream
*
stream
);
nice_stream_close
(
NiceStream
*
stream
);
...
...
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