From cdb72ebf7d013a8119c39e0d897ce0aec664d538 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 2 Nov 2016 16:12:16 +0100 Subject: [PATCH] Fix call recovery testers that were failing when run one after an other. --- coreapi/linphonecall.c | 36 ++++++++++++++++++++++++++---------- tester/call_single_tester.c | 24 +++++++++++++++--------- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 4838e89e6..a657ec11e 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -5160,6 +5160,10 @@ void linphone_call_repair_if_broken(LinphoneCall *call){ case LinphoneCallOutgoingRinging: linphone_call_repair_by_invite_with_replaces(call); break; + case LinphoneCallIncomingEarlyMedia: + case LinphoneCallIncomingReceived: + /* Keep the call broken until a forked INVITE is received from the server. */ + break; default: ms_warning("linphone_call_repair_if_broken(): don't know what to do in state [%s]", linphone_call_state_to_string(call->state)); call->broken = FALSE; @@ -5178,16 +5182,8 @@ void linphone_call_refresh_sockets(LinphoneCall *call){ } void linphone_call_replace_op(LinphoneCall *call, SalOp *op) { - switch (linphone_call_get_state(call)) { - case LinphoneCallConnected: - case LinphoneCallStreamsRunning: - sal_call_terminate(call->op); - break; - default: - break; - } - sal_op_kill_dialog(call->op); - sal_op_release(call->op); + SalOp *oldop = call->op; + LinphoneCallState oldstate = linphone_call_get_state(call); call->op = op; sal_op_set_user_pointer(call->op, call); sal_call_set_local_media_description(call->op, call->localdesc); @@ -5204,4 +5200,24 @@ void linphone_call_replace_op(LinphoneCall *call, SalOp *op) { ms_warning("linphone_call_replace_op(): don't know what to do in state [%s]", linphone_call_state_to_string(call->state)); break; } + switch (oldstate) { + case LinphoneCallIncomingEarlyMedia: + case LinphoneCallIncomingReceived: + sal_op_set_user_pointer(oldop, NULL); /* To make the call does not get terminated by terminating this op. */ + /* Do not terminate a forked INVITE */ + if (sal_call_get_replaces(op)) { + sal_call_terminate(oldop); + } else { + sal_op_kill_dialog(oldop); + } + break; + case LinphoneCallConnected: + case LinphoneCallStreamsRunning: + sal_call_terminate(oldop); + sal_op_kill_dialog(oldop); + break; + default: + break; + } + sal_op_release(oldop); } diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 601b3ad34..116d00009 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -4159,6 +4159,7 @@ static void call_record_with_custom_rtp_modifier(void) { } static void recovered_call_on_network_switch_in_early_state_1(void) { + const LinphoneCallParams *remote_params; LinphoneCall *incoming_call; LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -4174,6 +4175,12 @@ static void recovered_call_on_network_switch_in_early_state_1(void) { BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 2)); incoming_call = linphone_core_get_current_call(pauline->lc); + remote_params = linphone_call_get_remote_params(incoming_call); + BC_ASSERT_PTR_NOT_NULL(remote_params); + if (remote_params != NULL) { + const char *replaces_header = linphone_call_params_get_custom_header(remote_params, "Replaces"); + BC_ASSERT_PTR_NOT_NULL(replaces_header); + } linphone_core_accept_call(pauline->lc, incoming_call); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1)); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1)); @@ -4198,7 +4205,6 @@ static void recovered_call_on_network_switch_in_early_state_2(void) { incoming_call = linphone_core_get_current_call(pauline->lc); linphone_core_accept_call(pauline->lc, incoming_call); - //linphone_core_iterate(pauline->lc); linphone_core_set_network_reachable(marie->lc, FALSE); wait_for(marie->lc, pauline->lc, &marie->stat.number_of_NetworkReachableFalse, 1); linphone_core_set_network_reachable(marie->lc, TRUE); @@ -5393,14 +5399,14 @@ test_t call_tests[] = { TEST_NO_TAG("Call record with custom RTP Modifier", call_record_with_custom_rtp_modifier), TEST_NO_TAG("Call with network switch", call_with_network_switch), TEST_NO_TAG("Call with network switch and no recovery possible", call_with_network_switch_no_recovery), - TEST_NO_TAG("Recovered call on network switch in early state 1", recovered_call_on_network_switch_in_early_state_1), - TEST_NO_TAG("Recovered call on network switch in early state 2", recovered_call_on_network_switch_in_early_state_2), - TEST_NO_TAG("Recovered call on network switch in early state 3", recovered_call_on_network_switch_in_early_state_3), - TEST_NO_TAG("Recovered call on network switch in early state 4", recovered_call_on_network_switch_in_early_state_4), - TEST_NO_TAG("Recovered call on network switch during re-invite 1", recovered_call_on_network_switch_during_reinvite_1), - TEST_NO_TAG("Recovered call on network switch during re-invite 2", recovered_call_on_network_switch_during_reinvite_2), - TEST_NO_TAG("Recovered call on network switch during re-invite 3", recovered_call_on_network_switch_during_reinvite_3), - TEST_NO_TAG("Recovered call on network switch during re-invite 4", recovered_call_on_network_switch_during_reinvite_4), + TEST_ONE_TAG("Recovered call on network switch in early state 1", recovered_call_on_network_switch_in_early_state_1, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch in early state 2", recovered_call_on_network_switch_in_early_state_2, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch in early state 3", recovered_call_on_network_switch_in_early_state_3, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch in early state 4", recovered_call_on_network_switch_in_early_state_4, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch during re-invite 1", recovered_call_on_network_switch_during_reinvite_1, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch during re-invite 2", recovered_call_on_network_switch_during_reinvite_2, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch during re-invite 3", recovered_call_on_network_switch_during_reinvite_3, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch during re-invite 4", recovered_call_on_network_switch_during_reinvite_4, "CallRecovery"), TEST_ONE_TAG("Call with network switch and ICE", call_with_network_switch_and_ice, "ICE"), TEST_ONE_TAG("Call with network switch, ICE and RTT", call_with_network_switch_ice_and_rtt, "ICE"), TEST_NO_TAG("Call with network switch with socket refresh", call_with_network_switch_and_socket_refresh),