From e829fa6e222f37de9c26e4e82f0227078f4b6629 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 19 Oct 2012 11:41:03 +0200 Subject: [PATCH] add int linphone_core_decline_call(LinphoneCore *lc, LinphoneCall * call, LinphoneReason reason) --- coreapi/linphonecall.c | 1 + coreapi/linphonecore.c | 33 +++++++++++++++++++++++++++++++-- coreapi/linphonecore.h | 5 ++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 32dc9d59..70395841 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -2096,6 +2096,7 @@ bool_t linphone_call_is_in_conference(const LinphoneCall *call) { /** * Perform a zoom of the video displayed during a call. + * @param call the call. * @param zoom_factor a floating point number describing the zoom factor. A value 1.0 corresponds to no zoom applied. * @param cx a floating point number pointing the horizontal center of the zoom to be applied. This value should be between 0.0 and 1.0. * @param cy a floating point number pointing the vertical center of the zoom to be applied. This value should be between 0.0 and 1.0. diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index d96a1905..c0738050 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2917,6 +2917,7 @@ static void terminate_call(LinphoneCore *lc, LinphoneCall *call){ linphone_call_stop_media_streams(call); if (lc->vtable.display_status!=NULL) lc->vtable.display_status(lc,_("Call ended") ); + linphone_call_set_state(call,LinphoneCallEnd,"Call terminated"); } int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char *redirect_uri){ @@ -2924,7 +2925,6 @@ int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char sal_call_decline(call->op,SalReasonRedirect,redirect_uri); call->reason=LinphoneReasonDeclined; terminate_call(lc,call); - linphone_call_set_state(call,LinphoneCallEnd,"Call terminated"); }else{ ms_error("Bad state for call redirection."); return -1; @@ -2958,8 +2958,35 @@ int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *the_call) } sal_call_terminate(call->op); terminate_call(lc,call); + return 0; +} - linphone_call_set_state(call,LinphoneCallEnd,"Call terminated"); +/** + * Decline a pending incoming call, with a reason. + * @param lc the linphone core + * @param call the LinphoneCall, must be in the IncomingReceived state. + * @param reason the reason for rejecting the call: LinphoneReasonDeclined or LinphoneReasonBusy +**/ +int linphone_core_decline_call(LinphoneCore *lc, LinphoneCall * call, LinphoneReason reason){ + SalReason sal_reason=SalReasonUnknown; + if (call->state!=LinphoneCallIncomingReceived && call->state!=LinphoneCallIncomingEarlyMedia){ + ms_error("linphone_core_decline_call(): Cannot decline a call that is in state %s",linphone_call_state_to_string(call->state)); + return -1; + } + switch(reason){ + case LinphoneReasonDeclined: + sal_reason=SalReasonDeclined; + break; + case LinphoneReasonBusy: + sal_reason=SalReasonBusy; + break; + default: + ms_error("linphone_core_decline_call(): unsupported reason %s",linphone_reason_to_string(reason)); + return -1; + break; + } + sal_call_decline(call->op,sal_reason,NULL); + terminate_call(lc,call); return 0; } @@ -4975,6 +5002,8 @@ const char *linphone_reason_to_string(LinphoneReason err){ return "User not found"; case LinphoneReasonNotAnswered: return "Not answered"; + case LinphoneReasonBusy: + return "Busy"; } return "unknown error"; } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index ad52c559..d0ecc11a 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -222,7 +222,8 @@ enum _LinphoneReason{ LinphoneReasonBadCredentials, /**