Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
mediastreamer2
Commits
b970cdf9
Commit
b970cdf9
authored
Mar 04, 2016
by
Simon Morlat
Browse files
allow to change the default candidate choice in the IceSession
parent
b25ef7dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
10 deletions
+25
-10
include/mediastreamer2/ice.h
include/mediastreamer2/ice.h
+12
-1
src/voip/ice.c
src/voip/ice.c
+13
-9
No files found.
include/mediastreamer2/ice.h
View file @
b970cdf9
...
...
@@ -54,10 +54,12 @@ typedef enum {
* See the terminology in paragraph 3 of the RFC 5245 for more details.
*/
typedef
enum
{
ICT_CandidateInvalid
=
-
1
,
ICT_HostCandidate
,
ICT_ServerReflexiveCandidate
,
ICT_PeerReflexiveCandidate
,
ICT_RelayedCandidate
ICT_RelayedCandidate
,
ICT_CandidateTypeMax
}
IceCandidateType
;
/**
...
...
@@ -115,6 +117,7 @@ typedef struct _IceSession {
socklen_t
ss_len
;
/**< Length of the STUN server address to use for the candidates gathering process */
MSTimeSpec
gathering_start_ts
;
MSTimeSpec
gathering_end_ts
;
IceCandidateType
default_types
[
ICT_CandidateTypeMax
];
bool_t
check_message_integrity
;
/*set to false for backward compatibility only*/
bool_t
send_event
;
/**< Boolean value telling whether an event must be sent or not */
uint8_t
max_connectivity_checks
;
/**< Configuration parameter to limit the number of connectivity checks performed by the agent (default is 100) */
...
...
@@ -249,6 +252,14 @@ extern "C"{
*/
MS2_PUBLIC
IceSession
*
ice_session_new
(
void
);
/**
* Set the prefered type for default candidates, as defined in rfc5245#section-4.1.4.
* The type table can be terminated by the ICT_CandidateInvalid element, may it contain less elements
* than the number of types available.
**/
MS2_PUBLIC
void
ice_session_set_default_candidates_types
(
IceSession
*
session
,
const
IceCandidateType
types
[
ICT_CandidateTypeMax
]);
/**
* Destroy a previously allocated ICE session.
*
...
...
src/voip/ice.c
View file @
b970cdf9
...
...
@@ -216,6 +216,10 @@ static void ice_session_init(IceSession *session)
session
->
gathering_start_ts
.
tv_sec
=
session
->
gathering_start_ts
.
tv_nsec
=
-
1
;
session
->
gathering_end_ts
.
tv_sec
=
session
->
gathering_end_ts
.
tv_nsec
=
-
1
;
session
->
check_message_integrity
=
TRUE
;
session
->
default_types
[
0
]
=
ICT_RelayedCandidate
;
session
->
default_types
[
1
]
=
ICT_ServerReflexiveCandidate
;
session
->
default_types
[
2
]
=
ICT_HostCandidate
;
session
->
default_types
[
2
]
=
ICT_CandidateInvalid
;
}
IceSession
*
ice_session_new
(
void
)
...
...
@@ -247,6 +251,10 @@ void ice_session_destroy(IceSession *session)
}
}
void
ice_session_set_default_candidates_types
(
IceSession
*
session
,
const
IceCandidateType
types
[
ICT_CandidateTypeMax
]){
memcpy
(
session
->
default_types
,
types
,
sizeof
(
session
->
default_types
));
}
void
ice_session_enable_message_integrity_check
(
IceSession
*
session
,
bool_t
enable
)
{
session
->
check_message_integrity
=
enable
;
}
...
...
@@ -2554,20 +2562,16 @@ static void ice_choose_local_or_remote_default_candidates(IceCheckList *cl, MSLi
{
Type_ComponentID
tc
;
MSList
*
l
;
int
i
;
int
i
,
k
;
/* Choose the default candidate for each componentID as defined in 4.1.4. */
for
(
i
=
ICE_MIN_COMPONENTID
;
i
<=
ICE_MAX_COMPONENTID
;
i
++
)
{
tc
.
componentID
=
i
;
tc
.
type
=
ICT_RelayedCandidate
;
l
=
ms_list_find_custom
(
list
,
(
MSCompareFunc
)
ice_find_candidate_from_type_and_componentID
,
&
tc
);
if
(
l
==
NULL
)
{
tc
.
type
=
ICT_ServerReflexiveCandidate
;
l
=
ms_list_find_custom
(
list
,
(
MSCompareFunc
)
ice_find_candidate_from_type_and_componentID
,
&
tc
);
}
if
(
l
==
NULL
)
{
tc
.
type
=
ICT_HostCandidate
;
l
=
NULL
;
for
(
k
=
0
;
k
<
ICT_CandidateTypeMax
&&
cl
->
session
->
default_types
[
k
]
!=
ICT_CandidateInvalid
;
++
k
){
tc
.
type
=
cl
->
session
->
default_types
[
k
];
l
=
ms_list_find_custom
(
list
,
(
MSCompareFunc
)
ice_find_candidate_from_type_and_componentID
,
&
tc
);
if
(
l
)
break
;
}
if
(
l
!=
NULL
)
{
IceCandidate
*
candidate
=
(
IceCandidate
*
)
l
->
data
;
...
...
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