]> sjero.net Git - linphone/commitdiff
add int linphone_core_decline_call(LinphoneCore *lc, LinphoneCall * call, LinphoneRea...
authorSimon Morlat <simon.morlat@linphone.org>
Fri, 19 Oct 2012 09:41:03 +0000 (11:41 +0200)
committerSimon Morlat <simon.morlat@linphone.org>
Fri, 19 Oct 2012 09:41:03 +0000 (11:41 +0200)
coreapi/linphonecall.c
coreapi/linphonecore.c
coreapi/linphonecore.h

index 32dc9d59c37a398208c554c8a7300a5046f7074e..70395841aa4c841a1838fa2cf32982e64de1b0a0 100644 (file)
@@ -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.
index d96a1905b50dfb23cdf7a874b2b03d960f1fb516..c073805021e5c72f4e2319a12fc17b512582be17 100644 (file)
@@ -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";
 }
index ad52c559f4955079f0276743ec6e1eb7b3daf843..d0ecc11a360713e7a41ecd40c1bfc75dd85c1744 100644 (file)
@@ -222,7 +222,8 @@ enum _LinphoneReason{
        LinphoneReasonBadCredentials, /**<Authentication failed due to bad or missing credentials*/
        LinphoneReasonDeclined, /**<The call has been declined*/
        LinphoneReasonNotFound, /**<Destination of the calls was not found.*/
-       LinphoneReasonNotAnswered
+       LinphoneReasonNotAnswered, /**<The call was not answered in time*/
+       LinphoneReasonBusy /**<Phone line was busy */
 };
 
 /**
@@ -964,6 +965,8 @@ int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call);
 
 int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char *redirect_uri);
 
+int linphone_core_decline_call(LinphoneCore *lc, LinphoneCall * call, LinphoneReason reason);
+
 int linphone_core_terminate_all_calls(LinphoneCore *lc);
 
 int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call);