Fix call recovery testers that were failing when run one after an other.

This commit is contained in:
Ghislain MARY 2016-11-02 16:12:16 +01:00
parent 3e91c26f8a
commit cdb72ebf7d
2 changed files with 41 additions and 19 deletions

View file

@ -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);
}

View file

@ -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),