diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 5d158dcef..4e764243d 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -170,87 +170,6 @@ int liblinphone_tester_set_log_file(const char *filename) { return 0; } -bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, LinphoneIceState state) { - LinphoneCall *c1,*c2; - bool_t audio_success=FALSE; - bool_t video_success=FALSE; - bool_t text_success=FALSE; - bool_t video_enabled, realtime_text_enabled; - MSTimeSpec ts; - - c1=linphone_core_get_current_call(caller->lc); - c2=linphone_core_get_current_call(callee->lc); - - BC_ASSERT_PTR_NOT_NULL(c1); - BC_ASSERT_PTR_NOT_NULL(c2); - if (!c1 || !c2) return FALSE; - linphone_call_ref(c1); - linphone_call_ref(c2); - - BC_ASSERT_EQUAL(linphone_call_params_video_enabled(linphone_call_get_current_params(c1)),linphone_call_params_video_enabled(linphone_call_get_current_params(c2)), int, "%d"); - BC_ASSERT_EQUAL(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c1)),linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c2)), int, "%d"); - video_enabled=linphone_call_params_video_enabled(linphone_call_get_current_params(c1)); - realtime_text_enabled=linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c1)); - liblinphone_tester_clock_start(&ts); - do{ - if ((c1 != NULL) && (c2 != NULL)) { - if (linphone_call_get_audio_stats(c1)->ice_state==state && - linphone_call_get_audio_stats(c2)->ice_state==state ){ - audio_success=TRUE; - break; - } - linphone_core_iterate(caller->lc); - linphone_core_iterate(callee->lc); - } - ms_usleep(20000); - }while(!liblinphone_tester_clock_elapsed(&ts,10000)); - - if (video_enabled){ - liblinphone_tester_clock_start(&ts); - do{ - if ((c1 != NULL) && (c2 != NULL)) { - if (linphone_call_get_video_stats(c1)->ice_state==state && - linphone_call_get_video_stats(c2)->ice_state==state ){ - video_success=TRUE; - break; - } - linphone_core_iterate(caller->lc); - linphone_core_iterate(callee->lc); - } - ms_usleep(20000); - }while(!liblinphone_tester_clock_elapsed(&ts,10000)); - } - - if (realtime_text_enabled){ - liblinphone_tester_clock_start(&ts); - do{ - if ((c1 != NULL) && (c2 != NULL)) { - if (linphone_call_get_text_stats(c1)->ice_state==state && - linphone_call_get_text_stats(c2)->ice_state==state ){ - text_success=TRUE; - break; - } - linphone_core_iterate(caller->lc); - linphone_core_iterate(callee->lc); - } - ms_usleep(20000); - }while(!liblinphone_tester_clock_elapsed(&ts,10000)); - } - - /*make sure encryption mode are preserved*/ - if (c1) { - const LinphoneCallParams* call_param = linphone_call_get_current_params(c1); - BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); - } - if (c2) { - const LinphoneCallParams* call_param = linphone_call_get_current_params(c2); - BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(callee->lc), int, "%d"); - } - linphone_call_unref(c1); - linphone_call_unref(c2); - return video_enabled ? (realtime_text_enabled ? text_success && audio_success && video_success : audio_success && video_success) : realtime_text_enabled ? text_success && audio_success : audio_success; -} - #if !TARGET_OS_IPHONE && !(defined(LINPHONE_WINDOWS_PHONE) || defined(LINPHONE_WINDOWS_UNIVERSAL)) diff --git a/tester/tester.c b/tester/tester.c index 441983ef9..40e507cab 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -537,3 +537,86 @@ void liblinphone_tester_uninit(void) { } bc_tester_uninit(); } + +bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, LinphoneIceState state) { + LinphoneCall *c1,*c2; + bool_t audio_success=FALSE; + bool_t video_success=FALSE; + bool_t text_success=FALSE; + bool_t video_enabled, realtime_text_enabled; + MSTimeSpec ts; + + c1=linphone_core_get_current_call(caller->lc); + c2=linphone_core_get_current_call(callee->lc); + + BC_ASSERT_PTR_NOT_NULL(c1); + BC_ASSERT_PTR_NOT_NULL(c2); + if (!c1 || !c2) return FALSE; + linphone_call_ref(c1); + linphone_call_ref(c2); + + BC_ASSERT_EQUAL(linphone_call_params_video_enabled(linphone_call_get_current_params(c1)),linphone_call_params_video_enabled(linphone_call_get_current_params(c2)), int, "%d"); + BC_ASSERT_EQUAL(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c1)),linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c2)), int, "%d"); + video_enabled=linphone_call_params_video_enabled(linphone_call_get_current_params(c1)); + realtime_text_enabled=linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c1)); + liblinphone_tester_clock_start(&ts); + do{ + if ((c1 != NULL) && (c2 != NULL)) { + if (linphone_call_get_audio_stats(c1)->ice_state==state && + linphone_call_get_audio_stats(c2)->ice_state==state ){ + audio_success=TRUE; + break; + } + linphone_core_iterate(caller->lc); + linphone_core_iterate(callee->lc); + } + ms_usleep(20000); + }while(!liblinphone_tester_clock_elapsed(&ts,10000)); + + if (video_enabled){ + liblinphone_tester_clock_start(&ts); + do{ + if ((c1 != NULL) && (c2 != NULL)) { + if (linphone_call_get_video_stats(c1)->ice_state==state && + linphone_call_get_video_stats(c2)->ice_state==state ){ + video_success=TRUE; + break; + } + linphone_core_iterate(caller->lc); + linphone_core_iterate(callee->lc); + } + ms_usleep(20000); + }while(!liblinphone_tester_clock_elapsed(&ts,10000)); + } + + if (realtime_text_enabled){ + liblinphone_tester_clock_start(&ts); + do{ + if ((c1 != NULL) && (c2 != NULL)) { + if (linphone_call_get_text_stats(c1)->ice_state==state && + linphone_call_get_text_stats(c2)->ice_state==state ){ + text_success=TRUE; + break; + } + linphone_core_iterate(caller->lc); + linphone_core_iterate(callee->lc); + } + ms_usleep(20000); + }while(!liblinphone_tester_clock_elapsed(&ts,10000)); + } + + /*make sure encryption mode are preserved*/ + if (c1) { + const LinphoneCallParams* call_param = linphone_call_get_current_params(c1); + BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); + } + if (c2) { + const LinphoneCallParams* call_param = linphone_call_get_current_params(c2); + BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(callee->lc), int, "%d"); + } + linphone_call_unref(c1); + linphone_call_unref(c2); + return video_enabled ? (realtime_text_enabled ? text_success && audio_success && video_success : audio_success && video_success) : realtime_text_enabled ? text_success && audio_success : audio_success; +} + +