forked from mirrors/linphone-iphone
Add tests for ICE+TURN.
This commit is contained in:
parent
22900baaec
commit
7e47f0bb55
4 changed files with 70 additions and 9 deletions
|
|
@ -1173,7 +1173,7 @@ static void call_with_no_sdp_ack_without_sdp(void){
|
|||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
static void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *callee, unsigned int caller_nb_media_starts, unsigned int callee_nb_media_starts) {
|
||||
void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *callee, unsigned int caller_nb_media_starts, unsigned int callee_nb_media_starts) {
|
||||
LinphoneCall *c1 = linphone_core_get_current_call(caller->lc);
|
||||
LinphoneCall *c2 = linphone_core_get_current_call(callee->lc);
|
||||
BC_ASSERT_PTR_NOT_NULL(c1);
|
||||
|
|
|
|||
|
|
@ -367,6 +367,7 @@ void liblinphone_tester_init(void(*ftester_printf)(int level, const char *fmt, v
|
|||
void liblinphone_tester_uninit(void);
|
||||
int liblinphone_tester_set_log_file(const char *filename);
|
||||
bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, LinphoneIceState state);
|
||||
void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *callee, unsigned int caller_nb_media_starts, unsigned int callee_nb_media_starts);
|
||||
|
||||
LinphoneConferenceServer* linphone_conference_server_new(const char *rc_file, bool_t do_registration);
|
||||
void linphone_conference_server_destroy(LinphoneConferenceServer *conf_srv);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ static size_t test_stun_encode(char **buffer)
|
|||
return ms_stun_message_encode(req, buffer);
|
||||
}
|
||||
|
||||
|
||||
static void linphone_stun_test_encode(void)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
|
|
@ -46,7 +45,6 @@ static void linphone_stun_test_encode(void)
|
|||
ms_message("STUN message encoded in %i bytes", (int)len);
|
||||
}
|
||||
|
||||
|
||||
static void linphone_stun_test_grab_ip(void)
|
||||
{
|
||||
LinphoneCoreManager* lc_stun = linphone_core_manager_new2("stun_rc", FALSE);
|
||||
|
|
@ -90,10 +88,70 @@ static void linphone_stun_test_grab_ip(void)
|
|||
linphone_core_manager_destroy(lc_stun);
|
||||
}
|
||||
|
||||
static void configure_nat_policy(LinphoneCore *lc) {
|
||||
const char *username = "liblinphone-tester";
|
||||
const char *password = "retset-enohpnilbil";
|
||||
LinphoneAuthInfo *auth_info = linphone_core_create_auth_info(lc, username, NULL, password, NULL, "sip.linphone.org", NULL);
|
||||
LinphoneNatPolicy *nat_policy = linphone_core_create_nat_policy(lc);
|
||||
linphone_nat_policy_enable_ice(nat_policy, TRUE);
|
||||
linphone_nat_policy_enable_turn(nat_policy, TRUE);
|
||||
linphone_nat_policy_set_stun_server(nat_policy, "sip1.linphone.org:3479");
|
||||
linphone_nat_policy_set_stun_server_username(nat_policy, username);
|
||||
linphone_core_set_nat_policy(lc, nat_policy);
|
||||
linphone_core_add_auth_info(lc, auth_info);
|
||||
}
|
||||
|
||||
static void ice_turn_call_base(bool_t forced_relay) {
|
||||
LinphoneCoreManager *marie;
|
||||
LinphoneCoreManager *pauline;
|
||||
LinphoneIceState expected_ice_state = LinphoneIceStateHostConnection;
|
||||
MSList *lcs = NULL;
|
||||
|
||||
marie = linphone_core_manager_new("marie_rc");
|
||||
lcs = ms_list_append(lcs, marie->lc);
|
||||
pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
|
||||
lcs = ms_list_append(lcs, pauline->lc);
|
||||
|
||||
configure_nat_policy(marie->lc);
|
||||
configure_nat_policy(pauline->lc);
|
||||
if (forced_relay == TRUE) {
|
||||
linphone_core_enable_forced_ice_relay(marie->lc, TRUE);
|
||||
linphone_core_enable_forced_ice_relay(pauline->lc, TRUE);
|
||||
expected_ice_state = LinphoneIceStateRelayConnection;
|
||||
}
|
||||
|
||||
BC_ASSERT_TRUE(call(marie, pauline));
|
||||
|
||||
/* Wait for the ICE reINVITE to complete */
|
||||
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(check_ice(pauline, marie, expected_ice_state));
|
||||
check_nb_media_starts(pauline, marie, 1, 1);
|
||||
check_media_direction(marie, linphone_core_get_current_call(marie->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInactive);
|
||||
check_media_direction(pauline, linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInactive);
|
||||
liblinphone_tester_check_rtcp(marie, pauline);
|
||||
|
||||
end_call(marie, pauline);
|
||||
|
||||
linphone_core_manager_destroy(pauline);
|
||||
linphone_core_manager_destroy(marie);
|
||||
ms_list_free(lcs);
|
||||
}
|
||||
|
||||
static void basic_ice_turn_call(void) {
|
||||
ice_turn_call_base(FALSE);
|
||||
}
|
||||
|
||||
static void relayed_ice_turn_call(void) {
|
||||
ice_turn_call_base(TRUE);
|
||||
}
|
||||
|
||||
|
||||
test_t stun_tests[] = {
|
||||
TEST_NO_TAG("Basic Stun test (Ping/public IP)", linphone_stun_test_grab_ip),
|
||||
TEST_NO_TAG("STUN encode", linphone_stun_test_encode)
|
||||
TEST_ONE_TAG("Basic Stun test (Ping/public IP)", linphone_stun_test_grab_ip, "STUN"),
|
||||
TEST_ONE_TAG("STUN encode", linphone_stun_test_encode, "STUN"),
|
||||
TEST_TWO_TAGS("Basic ICE+TURN call", basic_ice_turn_call, "ICE", "TURN"),
|
||||
TEST_TWO_TAGS("Relayed ICE+TURN call", relayed_ice_turn_call, "ICE", "TURN")
|
||||
};
|
||||
|
||||
test_suite_t stun_test_suite = {"Stun", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
|
||||
|
|
|
|||
|
|
@ -215,13 +215,12 @@ bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) {
|
|||
bool_t wait_for_stun_resolution(LinphoneCoreManager *m) {
|
||||
MSTimeSpec start;
|
||||
int timeout_ms = 10000;
|
||||
|
||||
liblinphone_tester_clock_start(&start);
|
||||
while (m->lc->net_conf.stun_addrinfo == NULL && !liblinphone_tester_clock_elapsed(&start,timeout_ms)) {
|
||||
while (linphone_core_get_stun_server_addrinfo(m->lc) == NULL && !liblinphone_tester_clock_elapsed(&start,timeout_ms)) {
|
||||
linphone_core_iterate(m->lc);
|
||||
ms_usleep(20000);
|
||||
}
|
||||
return m->lc->net_conf.stun_addrinfo != NULL;
|
||||
return linphone_core_get_stun_server_addrinfo(m->lc) != NULL;
|
||||
}
|
||||
|
||||
static void set_codec_enable(LinphoneCore* lc,const char* type,int rate,bool_t enable) {
|
||||
|
|
@ -339,6 +338,7 @@ void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file) {
|
|||
|
||||
void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies) {
|
||||
LinphoneProxyConfig* proxy;
|
||||
LinphoneNatPolicy *nat_policy;
|
||||
int proxy_count;
|
||||
|
||||
/*BC_ASSERT_EQUAL(ms_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count, int, "%d");*/
|
||||
|
|
@ -370,7 +370,9 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies
|
|||
linphone_address_clean(mgr->identity);
|
||||
}
|
||||
|
||||
if (linphone_core_get_stun_server(mgr->lc) != NULL){
|
||||
nat_policy = linphone_core_get_nat_policy(mgr->lc);
|
||||
if ((nat_policy != NULL) && (linphone_nat_policy_get_stun_server(nat_policy) != NULL) &&
|
||||
(linphone_nat_policy_stun_enabled(nat_policy) || linphone_nat_policy_turn_enabled(nat_policy))) {
|
||||
/*before we go, ensure that the stun server is resolved, otherwise all ice related test will fail*/
|
||||
BC_ASSERT_TRUE(wait_for_stun_resolution(mgr));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue