Commit d61fe35f authored by Ghislain MARY's avatar Ghislain MARY

Add API to force the use of relay when using ICE (for tests purpose) + add...

Add API to force the use of relay when using ICE (for tests purpose) + add test that does just that.
parent 89e97799
...@@ -624,6 +624,10 @@ const struct addrinfo *linphone_core_get_stun_server_addrinfo(LinphoneCore *lc){ ...@@ -624,6 +624,10 @@ const struct addrinfo *linphone_core_get_stun_server_addrinfo(LinphoneCore *lc){
return lc->net_conf.stun_addrinfo; return lc->net_conf.stun_addrinfo;
} }
void linphone_core_enable_forced_ice_relay(LinphoneCore *lc, bool_t enable) {
lc->forced_ice_relay = enable;
}
int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call) int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call)
{ {
char local_addr[64]; char local_addr[64];
...@@ -650,6 +654,8 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call) ...@@ -650,6 +654,8 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call)
} }
linphone_core_notify_display_status(lc, _("ICE local candidates gathering in progress...")); linphone_core_notify_display_status(lc, _("ICE local candidates gathering in progress..."));
ice_session_enable_forced_relay(call->ice_session, lc->forced_ice_relay);
/* Gather local host candidates. */ /* Gather local host candidates. */
if (linphone_core_get_local_ip_for(AF_INET, NULL, local_addr) < 0) { if (linphone_core_get_local_ip_for(AF_INET, NULL, local_addr) < 0) {
ms_error("Fail to get local ip"); ms_error("Fail to get local ip");
......
...@@ -486,6 +486,7 @@ void linphone_core_resolve_stun_server(LinphoneCore *lc); ...@@ -486,6 +486,7 @@ void linphone_core_resolve_stun_server(LinphoneCore *lc);
LINPHONE_PUBLIC const struct addrinfo *linphone_core_get_stun_server_addrinfo(LinphoneCore *lc); LINPHONE_PUBLIC const struct addrinfo *linphone_core_get_stun_server_addrinfo(LinphoneCore *lc);
void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, LinphoneCallParams *params); void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, LinphoneCallParams *params);
int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call); int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call);
LINPHONE_PUBLIC void linphone_core_enable_forced_ice_relay(LinphoneCore *lc, bool_t enable);
void linphone_core_update_ice_state_in_call_stats(LinphoneCall *call); void linphone_core_update_ice_state_in_call_stats(LinphoneCall *call);
void linphone_call_stats_fill(LinphoneCallStats *stats, MediaStream *ms, OrtpEvent *ev); void linphone_call_stats_fill(LinphoneCallStats *stats, MediaStream *ms, OrtpEvent *ev);
void linphone_call_stop_ice_for_inactive_streams(LinphoneCall *call, SalMediaDescription *result); void linphone_call_stop_ice_for_inactive_streams(LinphoneCall *call, SalMediaDescription *result);
...@@ -937,7 +938,8 @@ struct _LinphoneCore ...@@ -937,7 +938,8 @@ struct _LinphoneCore
bool_t vtables_running; bool_t vtables_running;
bool_t send_call_stats_periodical_updates; bool_t send_call_stats_periodical_updates;
bool_t pad[2]; bool_t forced_ice_relay;
bool_t pad;
char localip[LINPHONE_IPADDR_SIZE]; char localip[LINPHONE_IPADDR_SIZE];
int device_rotation; int device_rotation;
int max_calls; int max_calls;
......
mediastreamer2 @ bc6574e8
Subproject commit dd5ad1b738989bc6964f889e17f275eea85e11c0 Subproject commit bc6574e8c7d5a385d89c2cb807e4fb9a6c20f612
...@@ -1110,7 +1110,10 @@ static void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManag ...@@ -1110,7 +1110,10 @@ static void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManag
} }
} }
static void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports) { static void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay) {
linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL);
linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL);
if (callee_with_ice){ if (callee_with_ice){
linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce);
} }
...@@ -1127,6 +1130,10 @@ static void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager ...@@ -1127,6 +1130,10 @@ static void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager
linphone_core_set_text_port(pauline->lc, -1); linphone_core_set_text_port(pauline->lc, -1);
} }
if (forced_relay == TRUE) {
linphone_core_enable_forced_ice_relay(marie->lc, TRUE);
linphone_core_enable_forced_ice_relay(pauline->lc, TRUE);
}
if (!BC_ASSERT_TRUE(call(pauline,marie))) if (!BC_ASSERT_TRUE(call(pauline,marie)))
return; return;
...@@ -1136,24 +1143,28 @@ static void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager ...@@ -1136,24 +1143,28 @@ static void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection)); if (forced_relay == TRUE) {
BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateRelayConnection));
} else {
BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
}
check_nb_media_starts(pauline, marie, 1, 1); check_nb_media_starts(pauline, marie, 1, 1);
} }
liblinphone_tester_check_rtcp(marie,pauline); liblinphone_tester_check_rtcp(marie,pauline);
/*then close the call*/ /*then close the call*/
end_call(pauline, marie); end_call(pauline, marie);
} }
static void _call_with_ice(bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports) {
static void _call_with_ice(bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
_call_with_ice_base(pauline,marie,caller_with_ice,callee_with_ice,random_ports); _call_with_ice_base(pauline,marie,caller_with_ice,callee_with_ice,random_ports,forced_relay);
linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(pauline);
} }
static void call_with_ice(void){ static void call_with_ice(void){
_call_with_ice(TRUE,TRUE,FALSE); _call_with_ice(TRUE,TRUE,FALSE,FALSE);
} }
/*ICE is not expected to work in this case, however this should not crash*/ /*ICE is not expected to work in this case, however this should not crash*/
...@@ -1177,15 +1188,19 @@ static void call_with_ice_no_sdp(void){ ...@@ -1177,15 +1188,19 @@ static void call_with_ice_no_sdp(void){
} }
static void call_with_ice_random_ports(void){ static void call_with_ice_random_ports(void){
_call_with_ice(TRUE,TRUE,TRUE); _call_with_ice(TRUE,TRUE,TRUE,FALSE);
}
static void call_with_ice_forced_relay(void) {
_call_with_ice(TRUE, TRUE, TRUE, TRUE);
} }
static void ice_to_not_ice(void){ static void ice_to_not_ice(void){
_call_with_ice(TRUE,FALSE,FALSE); _call_with_ice(TRUE,FALSE,FALSE,FALSE);
} }
static void not_ice_to_ice(void){ static void not_ice_to_ice(void){
_call_with_ice(FALSE,TRUE,FALSE); _call_with_ice(FALSE,TRUE,FALSE,FALSE);
} }
static void call_with_custom_headers(void) { static void call_with_custom_headers(void) {
...@@ -2426,7 +2441,7 @@ static void call_with_ice_video_to_novideo(void) { ...@@ -2426,7 +2441,7 @@ static void call_with_ice_video_to_novideo(void) {
linphone_core_set_video_policy(pauline->lc,&vpol); linphone_core_set_video_policy(pauline->lc,&vpol);
vpol.automatically_initiate=FALSE; vpol.automatically_initiate=FALSE;
linphone_core_set_video_policy(marie->lc,&vpol); linphone_core_set_video_policy(marie->lc,&vpol);
_call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE); _call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE,FALSE);
linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(pauline);
} }
...@@ -6072,6 +6087,7 @@ test_t call_tests[] = { ...@@ -6072,6 +6087,7 @@ test_t call_tests[] = {
TEST_ONE_TAG("Call with ICE", call_with_ice, "ICE"), TEST_ONE_TAG("Call with ICE", call_with_ice, "ICE"),
TEST_ONE_TAG("Call with ICE without SDP", call_with_ice_no_sdp, "ICE"), TEST_ONE_TAG("Call with ICE without SDP", call_with_ice_no_sdp, "ICE"),
TEST_ONE_TAG("Call with ICE (random ports)", call_with_ice_random_ports, "ICE"), TEST_ONE_TAG("Call with ICE (random ports)", call_with_ice_random_ports, "ICE"),
TEST_ONE_TAG("Call with ICE (forced relay)", call_with_ice_forced_relay, "ICE"),
TEST_ONE_TAG("Call from ICE to not ICE", ice_to_not_ice, "ICE"), TEST_ONE_TAG("Call from ICE to not ICE", ice_to_not_ice, "ICE"),
TEST_ONE_TAG("Call from not ICE to ICE", not_ice_to_ice, "ICE"), TEST_ONE_TAG("Call from not ICE to ICE", not_ice_to_ice, "ICE"),
TEST_NO_TAG("Call with custom headers", call_with_custom_headers), TEST_NO_TAG("Call with custom headers", call_with_custom_headers),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment