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
5d3c509b
Commit
5d3c509b
authored
Jan 19, 2011
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a nice_agent_set_port_range API to allow forcing the listening port on local host candidates
parent
99595a96
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
2 deletions
+60
-2
agent/agent.c
agent/agent.c
+30
-2
agent/agent.h
agent/agent.h
+27
-0
agent/component.h
agent/component.h
+2
-0
docs/reference/libnice/libnice-sections.txt
docs/reference/libnice/libnice-sections.txt
+1
-0
No files found.
agent/agent.c
View file @
5d3c509b
...
...
@@ -1780,6 +1780,7 @@ nice_agent_gather_candidates (
for
(
n
=
0
;
n
<
stream
->
n_components
;
n
++
)
{
Component
*
component
=
stream_find_component_by_id
(
stream
,
n
+
1
);
guint
current_port
=
component
->
min_port
;
if
(
agent
->
reliable
&&
component
->
tcp
==
NULL
)
{
nice_debug
(
"Agent %p: not gathering candidates for s%d:%d because "
...
...
@@ -1788,14 +1789,25 @@ nice_agent_gather_candidates (
continue
;
}
host_candidate
=
NULL
;
while
(
host_candidate
==
NULL
)
{
nice_debug
(
"Agent %p: Trying to create host candidate on port %d"
,
agent
,
current_port
);
nice_address_set_port
(
addr
,
current_port
);
host_candidate
=
discovery_add_local_host_candidate
(
agent
,
stream
->
id
,
n
+
1
,
addr
);
if
(
current_port
>
0
)
current_port
++
;
if
(
current_port
==
0
||
current_port
>
component
->
max_port
)
break
;
}
nice_address_set_port
(
addr
,
0
);
if
(
!
host_candidate
)
{
gchar
ip
[
NICE_ADDRESS_STRING_LEN
];
nice_address_to_string
(
addr
,
ip
);
nice_debug
(
"Agent %p: Unable to add local host candidate %s for s%d:%d"
". Invalid interface?"
,
agent
,
ip
,
stream
->
id
,
component
->
id
);
ret
=
FALSE
;
goto
error
;
}
...
...
@@ -1930,6 +1942,22 @@ nice_agent_remove_stream (
agent_unlock
();
}
NICEAPI_EXPORT
void
nice_agent_set_port_range
(
NiceAgent
*
agent
,
guint
stream_id
,
guint
component_id
,
guint
min_port
,
guint
max_port
)
{
Component
*
component
;
agent_lock
();
if
(
agent_find_component
(
agent
,
stream_id
,
component_id
,
NULL
,
&
component
))
{
component
->
min_port
=
min_port
;
component
->
max_port
=
max_port
;
}
agent_unlock
();
}
NICEAPI_EXPORT
gboolean
nice_agent_add_local_address
(
NiceAgent
*
agent
,
NiceAddress
*
addr
)
{
...
...
agent/agent.h
View file @
5d3c509b
...
...
@@ -355,6 +355,33 @@ nice_agent_remove_stream (
NiceAgent
*
agent
,
guint
stream_id
);
/**
* nice_agent_set_port_range:
* @agent: The #NiceAgent Object
* @stream_id: The ID of the stream
* @component_id: The ID of the component
* @min_port: The minimum port to use
* @max_port: The maximum port to use
*
* Sets a preferred port range for allocating host candidates.
* <para>
* If a local host candidate cannot be created on that port
* range, then the nice_agent_gather_candidates() call will fail.
* </para>
* <para>
* This MUST be called before nice_agent_gather_candidates()
* </para>
*
*/
void
nice_agent_set_port_range
(
NiceAgent
*
agent
,
guint
stream_id
,
guint
component_id
,
guint
min_port
,
guint
max_port
);
/**
* nice_agent_set_relay_info:
* @agent: The #NiceAgent Object
...
...
agent/component.h
View file @
5d3c509b
...
...
@@ -123,6 +123,8 @@ struct _Component
GSource
*
tcp_clock
;
TcpUserData
*
tcp_data
;
gboolean
tcp_readable
;
guint
min_port
;
guint
max_port
;
};
Component
*
...
...
docs/reference/libnice/libnice-sections.txt
View file @
5d3c509b
...
...
@@ -11,6 +11,7 @@ NICE_AGENT_MAX_REMOTE_CANDIDATES
nice_agent_new
nice_agent_new_reliable
nice_agent_add_local_address
nice_agent_set_port_range
nice_agent_add_stream
nice_agent_remove_stream
nice_agent_set_relay_info
...
...
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