From 4d500e84fe12bd0348e4da4129e7f71c3962f095 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 5 Oct 2016 22:40:29 +0200 Subject: [PATCH] Fix tests around ICE and video that were not testing what they should do. Add a big error to help understanding a common misuse of the library. --- coreapi/linphonecore.c | 4 ++++ coreapi/linphonecore.h | 2 +- tester/call_video_tester.c | 43 ++++++++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index df44c3529..028d0a62e 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -7435,6 +7435,10 @@ void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m) { void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *params) { params->has_audio = TRUE; params->has_video=linphone_core_video_enabled(lc) && lc->video_policy.automatically_initiate; + if (!linphone_core_video_enabled(lc) && lc->video_policy.automatically_initiate){ + ms_error("LinphoneCore has video disabled for both capture and display, but video policy is to start the call with video. " + "This is a possible mis-use of the API. In this case, video is disabled in default LinphoneCallParams"); + } params->media_encryption=linphone_core_get_media_encryption(lc); params->in_conference=FALSE; params->realtimetext_enabled = linphone_core_realtime_text_enabled(lc); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 1e3f9a8c7..d81056acf 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -189,7 +189,7 @@ enum _LinphoneReason{ LinphoneReasonIOError, /**lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, TRUE); linphone_core_set_video_policy(pauline->lc, &caller_policy); linphone_core_set_video_policy(marie->lc, &callee_policy); linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + /* This is to activate media relay on Flexisip server. + * Indeed, we want to test ICE with relay candidates as well, even though + * they will not be used at the end.*/ + linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); + linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL); + linphone_core_set_audio_port(marie->lc, -1); linphone_core_set_video_port(marie->lc, -1); linphone_core_set_audio_port(pauline->lc, -1); linphone_core_set_video_port(pauline->lc, -1); - BC_ASSERT_TRUE(call_ok = call(pauline, marie)); - if (!call_ok) goto end; - + + linphone_core_invite_address(pauline->lc, marie->identity); + if (!BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end; + marie_remote_params = linphone_call_get_remote_params(linphone_core_get_current_call(marie->lc)); + BC_ASSERT_PTR_NOT_NULL(marie_remote_params); + if (marie_remote_params){ + BC_ASSERT_TRUE(linphone_call_params_video_enabled(marie_remote_params) == caller_policy.automatically_initiate); + } + + linphone_core_accept_call(marie->lc, linphone_core_get_current_call(marie->lc)); + BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1) + && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1)); + + pauline_current_params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)); + BC_ASSERT_PTR_NOT_NULL(pauline_current_params); + if (pauline_current_params){ + BC_ASSERT_TRUE(linphone_call_params_video_enabled(pauline_current_params) == + (caller_policy.automatically_initiate && callee_policy.automatically_accept)); + } + /* Wait for ICE reINVITEs to complete. */ BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2) && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); @@ -954,6 +982,12 @@ static void call_with_ice_video_added_with_video_policies_to_false(void) { _call_with_ice_video(vpol, vpol, FALSE, TRUE, FALSE, FALSE); } +static void call_with_ice_video_declined_then_added_by_callee(void) { + LinphoneVideoPolicy caller_policy = { TRUE, TRUE }; + LinphoneVideoPolicy callee_policy = { FALSE, FALSE }; + _call_with_ice_video(caller_policy, callee_policy, FALSE, TRUE, FALSE, FALSE); +} + static void call_with_ice_video_and_rtt(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -1747,6 +1781,7 @@ test_t call_video_tests[] = { TEST_ONE_TAG("Call with ICE and video added 3", call_with_ice_video_added_3, "ICE"), TEST_ONE_TAG("Call with ICE and video added and refused", call_with_ice_video_added_and_refused, "ICE"), TEST_ONE_TAG("Call with ICE and video added with video policies to false", call_with_ice_video_added_with_video_policies_to_false, "ICE"), + TEST_ONE_TAG("Call with ICE and video declined then added by callee", call_with_ice_video_declined_then_added_by_callee, "ICE"), TEST_ONE_TAG("Call with ICE, video and realtime text", call_with_ice_video_and_rtt, "ICE"), TEST_ONE_TAG("Video call with ICE accepted using call params", video_call_ice_params, "ICE"), TEST_ONE_TAG("Audio call with ICE paused with caller video policy enabled", audio_call_with_ice_with_video_policy_enabled, "ICE"),