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
cb84aa95
Commit
cb84aa95
authored
Aug 07, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding support for turn settings per component
parent
c62438bb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
25 deletions
+86
-25
agent/agent.c
agent/agent.c
+68
-25
agent/agent.h
agent/agent.h
+10
-0
agent/component.c
agent/component.c
+5
-0
agent/component.h
agent/component.h
+3
-0
No files found.
agent/agent.c
View file @
cb84aa95
...
@@ -638,7 +638,10 @@ agent_candidate_pair_priority (NiceAgent *agent, NiceCandidate *local, NiceCandi
...
@@ -638,7 +638,10 @@ agent_candidate_pair_priority (NiceAgent *agent, NiceCandidate *local, NiceCandi
}
}
static
gboolean
static
gboolean
priv_add_srv_rfx_candidate_discovery
(
NiceAgent
*
agent
,
NiceCandidate
*
host_candidate
,
const
gchar
*
stun_server_ip
,
const
guint
stun_server_port
,
Stream
*
stream
,
guint
component_id
,
NiceAddress
*
addr
,
NiceCandidateType
type
)
priv_add_new_candidate_discovery
(
NiceAgent
*
agent
,
NiceCandidate
*
host_candidate
,
NiceAddress
server
,
Stream
*
stream
,
guint
component_id
,
NiceAddress
*
addr
,
NiceCandidateType
type
)
{
{
CandidateDiscovery
*
cdisco
;
CandidateDiscovery
*
cdisco
;
GSList
*
modified_list
;
GSList
*
modified_list
;
...
@@ -654,8 +657,7 @@ priv_add_srv_rfx_candidate_discovery (NiceAgent *agent, NiceCandidate *host_cand
...
@@ -654,8 +657,7 @@ priv_add_srv_rfx_candidate_discovery (NiceAgent *agent, NiceCandidate *host_cand
cdisco
->
type
=
type
;
cdisco
->
type
=
type
;
cdisco
->
socket
=
host_candidate
->
sockptr
->
fileno
;
cdisco
->
socket
=
host_candidate
->
sockptr
->
fileno
;
cdisco
->
nicesock
=
host_candidate
->
sockptr
;
cdisco
->
nicesock
=
host_candidate
->
sockptr
;
cdisco
->
server_addr
=
stun_server_ip
;
cdisco
->
server
=
server
;
cdisco
->
server_port
=
stun_server_port
;
cdisco
->
interface
=
addr
;
cdisco
->
interface
=
addr
;
cdisco
->
stream
=
stream
;
cdisco
->
stream
=
stream
;
cdisco
->
component
=
stream_find_component_by_id
(
stream
,
component_id
);
cdisco
->
component
=
stream_find_component_by_id
(
stream
,
component_id
);
...
@@ -721,6 +723,33 @@ nice_agent_add_stream (
...
@@ -721,6 +723,33 @@ nice_agent_add_stream (
}
}
NICEAPI_EXPORT
void
nice_agent_set_relay_info
(
NiceAgent
*
agent
,
guint
stream_id
,
guint
component_id
,
const
gchar
*
server_ip
,
guint
server_port
,
const
gchar
*
username
,
const
gchar
*
password
)
{
Component
*
component
=
NULL
;
g_static_rec_mutex_lock
(
&
agent
->
mutex
);
if
(
agent_find_component
(
agent
,
stream_id
,
component_id
,
NULL
,
&
component
))
{
nice_address_init
(
&
component
->
turn_server
);
if
(
nice_address_set_from_string
(
&
component
->
turn_server
,
server_ip
))
{
nice_address_set_port
(
&
component
->
turn_server
,
server_port
);
}
g_free
(
component
->
turn_username
);
component
->
turn_username
=
g_strdup
(
username
);
g_free
(
component
->
turn_password
);
component
->
turn_password
=
g_strdup
(
password
);
}
g_static_rec_mutex_unlock
(
&
agent
->
mutex
);
}
/**
/**
* nice_agent_gather_candidates:
* nice_agent_gather_candidates:
*
*
...
@@ -753,6 +782,7 @@ nice_agent_gather_candidates (
...
@@ -753,6 +782,7 @@ nice_agent_gather_candidates (
NiceCandidate
*
host_candidate
;
NiceCandidate
*
host_candidate
;
for
(
n
=
0
;
n
<
stream
->
n_components
;
n
++
)
{
for
(
n
=
0
;
n
<
stream
->
n_components
;
n
++
)
{
Component
*
component
=
stream_find_component_by_id
(
stream
,
n
+
1
);
host_candidate
=
discovery_add_local_host_candidate
(
agent
,
stream
->
id
,
host_candidate
=
discovery_add_local_host_candidate
(
agent
,
stream
->
id
,
n
+
1
,
addr
);
n
+
1
,
addr
);
...
@@ -763,12 +793,14 @@ nice_agent_gather_candidates (
...
@@ -763,12 +793,14 @@ nice_agent_gather_candidates (
if
(
agent
->
full_mode
&&
if
(
agent
->
full_mode
&&
agent
->
stun_server_ip
)
{
agent
->
stun_server_ip
)
{
NiceAddress
stun_server
;
if
(
nice_address_set_from_string
(
&
stun_server
,
agent
->
stun_server_ip
))
{
nice_address_set_port
(
&
stun_server
,
agent
->
stun_server_port
);
gboolean
res
=
gboolean
res
=
priv_add_srv_rfx
_candidate_discovery
(
agent
,
priv_add_new
_candidate_discovery
(
agent
,
host_candidate
,
host_candidate
,
agent
->
stun_server_ip
,
stun_server
,
agent
->
stun_server_port
,
stream
,
stream
,
n
+
1
/* component-id */
,
n
+
1
/* component-id */
,
addr
,
addr
,
...
@@ -779,14 +811,14 @@ nice_agent_gather_candidates (
...
@@ -779,14 +811,14 @@ nice_agent_gather_candidates (
g_error
(
"Memory allocation failure?"
);
g_error
(
"Memory allocation failure?"
);
}
}
}
}
}
if
(
agent
->
full_mode
&&
if
(
agent
->
full_mode
&&
agent
->
turn_server_ip
)
{
component
&&
nice_address_is_valid
(
&
component
->
turn_server
)
)
{
gboolean
res
=
gboolean
res
=
priv_add_
srv_rfx
_candidate_discovery
(
agent
,
priv_add_
new
_candidate_discovery
(
agent
,
host_candidate
,
host_candidate
,
agent
->
turn_server_ip
,
component
->
turn_server
,
agent
->
turn_server_port
,
stream
,
stream
,
n
+
1
/* component-id */
,
n
+
1
/* component-id */
,
addr
,
addr
,
...
@@ -1239,6 +1271,17 @@ _nice_agent_recv (
...
@@ -1239,6 +1271,17 @@ _nice_agent_recv (
return
0
;
return
0
;
}
}
if
(
nice_address_equal
(
&
from
,
&
component
->
turn_server
))
{
GSList
*
i
=
NULL
;
g_debug
(
"Agent %p : Packet received from TURN server candidate."
,
agent
);
for
(
i
=
component
->
local_candidates
;
i
;
i
=
i
->
next
)
{
NiceCandidate
*
cand
=
i
->
data
;
if
(
cand
->
type
==
NICE_CANDIDATE_TYPE_RELAYED
)
{
len
=
nice_udp_turn_socket_parse_recv
(
cand
->
sockptr
,
&
from
,
len
,
buf
,
&
from
,
buf
,
len
);
}
}
}
if
(
stun_message_validate_buffer_length
((
uint8_t
*
)
buf
,
(
size_t
)
len
)
==
len
)
{
if
(
stun_message_validate_buffer_length
((
uint8_t
*
)
buf
,
(
size_t
)
len
)
==
len
)
{
/* If the retval is no 0, its not a valid stun packet, probably data */
/* If the retval is no 0, its not a valid stun packet, probably data */
if
(
conn_check_handle_inbound_stun
(
agent
,
stream
,
component
,
udp_socket
,
if
(
conn_check_handle_inbound_stun
(
agent
,
stream
,
component
,
udp_socket
,
...
...
agent/agent.h
View file @
cb84aa95
...
@@ -138,6 +138,16 @@ nice_agent_remove_stream (
...
@@ -138,6 +138,16 @@ nice_agent_remove_stream (
NiceAgent
*
agent
,
NiceAgent
*
agent
,
guint
stream_id
);
guint
stream_id
);
void
nice_agent_set_relay_info
(
NiceAgent
*
agent
,
guint
stream_id
,
guint
component_id
,
const
gchar
*
server_ip
,
guint
server_port
,
const
gchar
*
username
,
const
gchar
*
password
);
void
void
nice_agent_gather_candidates
(
nice_agent_gather_candidates
(
NiceAgent
*
agent
,
NiceAgent
*
agent
,
...
...
agent/component.c
View file @
cb84aa95
...
@@ -105,6 +105,11 @@ component_free (Component *cmp)
...
@@ -105,6 +105,11 @@ component_free (Component *cmp)
g_slist_free
(
cmp
->
sockets
);
g_slist_free
(
cmp
->
sockets
);
g_slist_free
(
cmp
->
gsources
),
cmp
->
gsources
=
NULL
;
g_slist_free
(
cmp
->
gsources
),
cmp
->
gsources
=
NULL
;
g_slist_free
(
cmp
->
incoming_checks
);
g_slist_free
(
cmp
->
incoming_checks
);
nice_address_init
(
&
cmp
->
turn_server
);
g_free
(
cmp
->
turn_username
);
g_free
(
cmp
->
turn_password
);
g_slice_free
(
Component
,
cmp
);
g_slice_free
(
Component
,
cmp
);
}
}
...
...
agent/component.h
View file @
cb84aa95
...
@@ -82,6 +82,9 @@ struct _Component
...
@@ -82,6 +82,9 @@ struct _Component
GSList
*
sockets
;
/**< list of NiceUDPSocket objs */
GSList
*
sockets
;
/**< list of NiceUDPSocket objs */
GSList
*
gsources
;
/**< list of GSource objs */
GSList
*
gsources
;
/**< list of GSource objs */
GSList
*
incoming_checks
;
/**< list of IncomingCheck objs */
GSList
*
incoming_checks
;
/**< list of IncomingCheck objs */
NiceAddress
turn_server
;
/**< TURN server address */
gchar
*
turn_username
;
/**< TURN username */
gchar
*
turn_password
;
/**< TURN password */
CandidatePair
selected_pair
;
/**< independent from checklists,
CandidatePair
selected_pair
;
/**< independent from checklists,
see ICE 11.1. "Sending Media" (ID-19) */
see ICE 11.1. "Sending Media" (ID-19) */
gboolean
media_after_tick
;
/**< true if media received since last
gboolean
media_after_tick
;
/**< true if media received since last
...
...
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