Ensure STUN server resolution is finished before starting calls in the testers.

This commit is contained in:
Ghislain MARY 2016-06-24 16:09:09 +02:00
parent 01506f4fca
commit 5c4edb7c60
3 changed files with 16 additions and 11 deletions

View file

@ -260,6 +260,10 @@ bool_t call_with_params2(LinphoneCoreManager* caller_mgr
LinphoneCall *callee_call=NULL;
LinphoneCall *caller_call=NULL;
/* TODO: This should be handled correctly inside the liblinphone library but meanwhile handle this here. */
linphone_core_manager_wait_for_stun_resolution(caller_mgr);
linphone_core_manager_wait_for_stun_resolution(callee_mgr);
setup_sdp_handling(caller_test_params, caller_mgr);
setup_sdp_handling(callee_test_params, callee_mgr);

View file

@ -286,6 +286,7 @@ LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_f
LinphoneCoreManager* linphone_core_manager_new(const char* rc_file);
void linphone_core_manager_stop(LinphoneCoreManager *mgr);
void linphone_core_manager_uninit(LinphoneCoreManager *mgr);
void linphone_core_manager_wait_for_stun_resolution(LinphoneCoreManager *mgr);
void linphone_core_manager_destroy(LinphoneCoreManager* mgr);
void reset_counters( stats* counters);

View file

@ -354,7 +354,6 @@ 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(bctbx_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count, int, "%d");*/
@ -386,16 +385,7 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies
linphone_address_clean(mgr->identity);
}
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*/
const char **tags = bc_tester_current_test_tags();
int ice_test = (tags && ((tags[0] && !strcmp(tags[0], "ICE")) || (tags[1] && !strcmp(tags[1], "ICE"))));
if (ice_test) {
BC_ASSERT_TRUE(wait_for_stun_resolution(mgr));
}
}
linphone_core_manager_wait_for_stun_resolution(mgr);
if (!check_for_proxies){
/*now that stun server resolution is done, we can start registering*/
linphone_core_set_network_reachable(mgr->lc, TRUE);
@ -448,6 +438,16 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) {
manager_count--;
}
void linphone_core_manager_wait_for_stun_resolution(LinphoneCoreManager *mgr) {
LinphoneNatPolicy *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)) &&
(linphone_nat_policy_ice_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));
}
}
void linphone_core_manager_destroy(LinphoneCoreManager* mgr) {
linphone_core_manager_uninit(mgr);
ms_free(mgr);