From cadf50578638dfa096856e483627cccddca134ce Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 24 Oct 2016 14:27:45 +0200 Subject: [PATCH] Add specific callback to perform action (in this case re-INVITE) on cancel response. --- coreapi/bellesip_sal/sal_op_call.c | 3 +-- coreapi/callbacks.c | 9 +++++++++ coreapi/linphonecall.c | 1 + coreapi/private.h | 1 + include/sal/sal.h | 2 ++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_call.c b/coreapi/bellesip_sal/sal_op_call.c index 8f7fa89ef..d393dc1af 100644 --- a/coreapi/bellesip_sal/sal_op_call.c +++ b/coreapi/bellesip_sal/sal_op_call.c @@ -344,8 +344,7 @@ static void call_process_response(void *op_base, const belle_sip_response_event_ }else if (strcmp("UPDATE",method)==0){ op->base.root->callbacks.call_accepted(op); /*INVITE*/ }else if (strcmp("CANCEL",method)==0){ - sal_op_set_error_info_from_response(op,response); - op->base.root->callbacks.call_failure(op); + op->base.root->callbacks.call_cancel_done(op); } break; case SalOpStateTerminating: diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index df5c1b374..9e6e359fb 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -1005,6 +1005,14 @@ static void call_released(SalOp *op){ } } +static void call_cancel_done(SalOp *op) { + LinphoneCall *call = (LinphoneCall *)sal_op_get_user_pointer(op); + if (call->reinvite_on_cancel_response_requested == TRUE) { + call->reinvite_on_cancel_response_requested = FALSE; + linphone_call_reinvite_to_recover_from_connection_loss(call); + } +} + static void auth_failure(SalOp *op, SalAuthInfo* info) { LinphoneCore *lc = (LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); LinphoneAuthInfo *ai = NULL; @@ -1470,6 +1478,7 @@ SalCallbacks linphone_sal_callbacks={ call_terminated, call_failure, call_released, + call_cancel_done, auth_failure, register_success, register_failure, diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index a245dfc2e..4838e89e6 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -5138,6 +5138,7 @@ void linphone_call_repair_if_broken(LinphoneCall *call){ if (sal_call_dialog_request_pending(call->op)) { /* Need to cancel first re-INVITE as described in section 5.5 of RFC 6141 */ sal_call_cancel_invite(call->op); + call->reinvite_on_cancel_response_requested = TRUE; } break; case LinphoneCallStreamsRunning: diff --git a/coreapi/private.h b/coreapi/private.h index 104d80d96..f8fe6cda6 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -371,6 +371,7 @@ struct _LinphoneCall{ bool_t broken; /*set to TRUE when the call is in broken state due to network disconnection or transport */ bool_t defer_notify_incoming; bool_t need_localip_refresh; + bool_t reinvite_on_cancel_response_requested; }; BELLE_SIP_DECLARE_VPTR(LinphoneCall); diff --git a/include/sal/sal.h b/include/sal/sal.h index 1a8d1b987..f9fd31e4a 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -491,6 +491,7 @@ typedef void (*SalOnCallUpdating)(SalOp *op, bool_t is_update);/*< Called when a typedef void (*SalOnCallTerminated)(SalOp *op, const char *from); typedef void (*SalOnCallFailure)(SalOp *op); typedef void (*SalOnCallReleased)(SalOp *salop); +typedef void (*SalOnCallCancelDone)(SalOp *salop); typedef void (*SalOnAuthRequestedLegacy)(SalOp *op, const char *realm, const char *username); typedef bool_t (*SalOnAuthRequested)(Sal *sal,SalAuthInfo* info); typedef void (*SalOnAuthFailure)(SalOp *op, SalAuthInfo* info); @@ -530,6 +531,7 @@ typedef struct SalCallbacks{ SalOnCallTerminated call_terminated; SalOnCallFailure call_failure; SalOnCallReleased call_released; + SalOnCallCancelDone call_cancel_done; SalOnAuthFailure auth_failure; SalOnRegisterSuccess register_success; SalOnRegisterFailure register_failure;