]> sjero.net Git - linphone/blobdiff - coreapi/sal_eXosip2.c
Merge branch 'master' into dev_multicall
[linphone] / coreapi / sal_eXosip2.c
index bd3e7e664069bf47ef7ecec9e1762ea4ae136b8c..2a2c85516480425dfb747d8ce84918fc68514437 100644 (file)
@@ -421,6 +421,19 @@ static void set_sdp(osip_message_t *sip,sdp_message_t *msg){
        osip_free(sdp);
 }
 
+static void set_hold_status_to_desc(SalMediaDescription *desc, bool_t holdon)
+{
+       int i;
+       if(desc == NULL)
+               return;
+       desc->notsending = holdon;
+       for(i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++)
+       {
+               if(desc->streams != NULL)
+                       desc->streams[i].notsending = holdon;//Audio
+       }
+}
+
 static void set_sdp_from_desc(osip_message_t *sip, const SalMediaDescription *desc){
        sdp_message_t *msg=media_description_to_sdp(desc);
        if (msg==NULL) {
@@ -654,9 +667,13 @@ int sal_call_send_dtmf(SalOp *h, char dtmf){
 }
 
 int sal_call_terminate(SalOp *h){
+       int err;
        eXosip_lock();
-       eXosip_call_terminate(h->cid,h->did);
+       err=eXosip_call_terminate(h->cid,h->did);
        eXosip_unlock();
+       if (err!=0){
+               ms_warning("Exosip could not terminate the call: cid=%i did=%i", h->cid,h->did);
+       }
        sal_remove_call(h->base.root,h);
        h->cid=-1;
        return 0;
@@ -855,7 +872,8 @@ static int call_proceeding(Sal *sal, eXosip_event_t *ev){
                eXosip_unlock();
                return -1;
        }
-       op->did=ev->did;
+       if (ev->did>0)
+               op->did=ev->did;
        op->tid=ev->tid;
        
        /* update contact if received and rport are set by the server
@@ -889,6 +907,9 @@ static void call_accepted(Sal *sal, eXosip_event_t *ev){
                ms_error("A closed call is accepted ?");
                return;
        }
+       if (op->did==-1){
+               op->did=ev->did;
+       }
        sdp=eXosip_get_sdp_info(ev->response);
        if (sdp){
                op->base.remote_media=sal_media_description_new();
@@ -935,7 +956,7 @@ static void call_released(Sal *sal, eXosip_event_t *ev){
        }
        op->cid=-1;
        if (op->did==-1) 
-               sal->callbacks.call_failure(op,SalErrorNoResponse,SalReasonUnknown,NULL);
+               sal->callbacks.call_failure(op,SalErrorNoResponse,SalReasonUnknown,NULL, 487);
 }
 
 static int get_auth_data_from_response(osip_message_t *resp, const char **realm, const char **username){
@@ -1097,7 +1118,7 @@ static bool_t call_failure(Sal *sal, eXosip_event_t *ev){
                                sr=SalReasonUnknown;
                        }else error=SalErrorNoResponse;
        }
-       sal->callbacks.call_failure(op,error,sr,reason);
+       sal->callbacks.call_failure(op,error,sr,reason,code);
        if (computedReason != NULL){
                ms_free(computedReason);
        }
@@ -1461,6 +1482,9 @@ static void other_request_reply(Sal *sal,eXosip_event_t *ev){
 }
 
 static bool_t process_event(Sal *sal, eXosip_event_t *ev){
+#ifdef PRINTF_DEBUG
+       printf("EVENT (%d)\n",ev->type);
+#endif
        ms_message("linphone process event get a message %d\n",ev->type);
        switch(ev->type){
                case EXOSIP_CALL_ANSWERED:
@@ -1774,3 +1798,38 @@ int sal_address_get_port_int(const SalAddress *uri) {
        }
 }
 
+/**
+ * Send a re-Invite used to hold the current call
+ *
+ * @ingroup call_control
+ * @param lc the LinphoneCore object
+ * @param url the destination of the call (sip address).
+**/
+int sal_call_hold(SalOp *h, bool_t holdon)
+{
+       int err=0;
+
+       osip_message_t *reinvite;
+       if(eXosip_call_build_request(h->did,"INVITE",&reinvite) != OSIP_SUCCESS)
+               return -1;
+       if(reinvite==NULL)
+               return -2;
+       osip_message_set_subject(reinvite,osip_strdup("Phone Call Hold"));
+       osip_message_set_allow(reinvite, "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO");
+       if (h->base.root->session_expires!=0){
+               osip_message_set_header(reinvite, "Session-expires", "200");
+               osip_message_set_supported(reinvite, "timer");
+       }
+       //add something to say that the distant sip phone will be in sendonly/sendrecv mode
+       if (h->base.local_media){
+               h->sdp_offering=TRUE;
+               set_hold_status_to_desc(h->base.local_media,holdon);
+               set_sdp_from_desc(reinvite,h->base.local_media);
+       }else h->sdp_offering=FALSE;
+       eXosip_lock();
+       err = eXosip_call_send_request(h->did, reinvite);
+       eXosip_unlock();
+       
+       return err;
+}
+