diff --git a/linphone_before_patch_multi/console/commands.c b/linphone_after_patch_multi/console/commands.c index d52a0e8..1975e40 100644 --- a/linphone_before_patch_multi/console/commands.c +++ b/linphone_after_patch_multi/console/commands.c @@ -78,6 +78,7 @@ static int lpc_cmd_ports(LinphoneCore *lc, char *args); static int lpc_cmd_speak(LinphoneCore *lc, char *args); static int lpc_cmd_codec(LinphoneCore *lc, char *args); static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args); +static int lpc_cmd_hold(LinphoneCore *lc, char *args); /* Command handler helpers */ static void linphonec_proxy_add(LinphoneCore *lc); @@ -127,10 +128,14 @@ LPC_COMMAND commands[] = { "'chat \"message\"' " ": send a chat message \"message\" to the specified destination." }, - { "terminate", lpc_cmd_terminate, "Terminate the current call", - NULL }, + { "terminate", lpc_cmd_terminate, "Terminate a call", + "'terminate' : Terminate the current call\n" + "'terminate ' : Terminate the call with the cid \n" + "'terminate ' : Terminate all the current calls\n" + }, { "answer", lpc_cmd_answer, "Answer a call", - "Accept an incoming call." + "'answer' : Answer the current incoming call\n" + "'answer ' : Answer the call with the cid \n" }, { "autoanswer", lpc_cmd_autoanswer, "Show/set auto-answer mode", "'autoanswer' \t: show current autoanswer mode\n" @@ -223,6 +228,11 @@ LPC_COMMAND commands[] = { "'ec on [] [] []' : turn EC on with given delay, tail length and framesize\n" "'ec off' : turn echo cancellation (EC) off\n" "'ec show' : show EC status" }, + { "hold", lpc_cmd_hold, "Hold a call", + "'hold on' : hold on the current call\n" + "'hold off' : hold off the only call\n" + "'hold off ' : hold off the call with cid \n" + "'hold show' : show hold call status\n" }, { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL } }; @@ -375,9 +385,9 @@ lpc_cmd_call(LinphoneCore *lc, char *args) return 0; } - if ( lc->call != NULL ) + if ( linphone_core_in_call(lc) ) { - linphonec_out("Terminate current call first.\n"); + linphonec_out("Terminate or hold on the current call first.\n"); } else { @@ -448,21 +458,89 @@ lpc_cmd_refer(LinphoneCore *lc, char *args) static int lpc_cmd_terminate(LinphoneCore *lc, char *args) { - if ( -1 == linphone_core_terminate_call(lc, NULL) ) + char *arg1 = args; + char *arg2 = NULL; + char *ptr = args; + int the_cid,n; + + if (!args) { - linphonec_out("No active call.\n"); + if ( -1 == linphone_core_terminate_call(lc, NULL) ) + { + linphonec_out("No active call.\n"); + } + return 1; } - return 1; + + /* Isolate first and second arg */ + while(*ptr && !isspace(*ptr)) ++ptr; + if ( *ptr ) + { + *ptr='\0'; + arg2=ptr+1; + while(*arg2 && isspace(*arg2)) ++arg2; + } + if (arg1 != 0) + { + if(strcmp(arg1,"all")==0) + { + linphonec_out("We are going to stop all the calls.\n"); + return (linphone_core_terminate_calls(lc)==0)?1:0; + } + else + { + n = sscanf(arg1, "%d", &the_cid); + if (n == 1) + { + if ( -1 == linphone_core_terminate_call_by_cid(lc, &the_cid) ) + { + linphonec_out("Cannot stop the call with cid <%d>.\n",the_cid); + } + return 1; + } + } + } + return 0; } static int lpc_cmd_answer(LinphoneCore *lc, char *args) { - if ( -1 == linphone_core_accept_call(lc, NULL) ) + char *arg1 = args; + char *arg2 = NULL; + char *ptr = args; + int the_cid,n; + + if (!args) + { + if ( -1 == linphone_core_accept_call(lc, NULL) ) + { + linphonec_out("No incoming call.\n"); + } + return 1; + } + + /* Isolate first and second arg */ + while(*ptr && !isspace(*ptr)) ++ptr; + if ( *ptr ) { - linphonec_out("No incoming call.\n"); + *ptr='\0'; + arg2=ptr+1; + while(*arg2 && isspace(*arg2)) ++arg2; } - return 1; + if (arg1 != 0) + { + n = sscanf(arg1, "%d", &the_cid); + if (n == 1) + { + if ( -1 == linphone_core_accept_call(lc, &the_cid) ) + { + linphonec_out("Cannot answer the call with cid <%d>.\n",the_cid); + } + return 1; + } + } + return 0; } static int @@ -1063,7 +1141,72 @@ lpc_cmd_staticpic(LinphoneCore *lc, char *args) return 0; /* Syntax error */ } +static int lpc_cmd_hold(LinphoneCore *lc, char *args){ + char *arg1 = args; + char *arg2 = NULL; + char *ptr = args; + int the_cid,n; + + if (!args) return 0; + + /* Isolate first and second arg */ + while(*ptr && !isspace(*ptr)) ++ptr; + if ( *ptr ) + { + *ptr='\0'; + arg2=ptr+1; + while(*arg2 && isspace(*arg2)) ++arg2; + } + + if (strcmp(arg1,"on")==0){ + linphone_core_hold(lc,HOLD_ON,NULL); + } + else if (strcmp(arg1,"off")==0){ + if (arg2 != 0) { + n = sscanf(arg2, "%d", &the_cid); + if (n == 1) + { + linphone_core_hold(lc,HOLD_OFF,&the_cid); + } + } + else + { + if(linphone_core_hold(lc,HOLD_OFF,NULL) < 0 ) + { + linphonec_out("hold off is needed with a cid when you have multicall\n"); + } + } + } + else if (strcmp(arg1,"show")==0){ + if(linphone_core_get_calls_nb(lc)) + { + int i; + linphonec_out("\t\t\t\t\t\t\t\t\t\r\n"); + for(i = 0; i < linphone_core_get_calls_nb(lc); i++) + { + char *p_char = linphone_core_get_a_call_to_str(lc,i); + if(p_char) + { + linphonec_out("%s\n",p_char); + free(p_char); + } + else + { + linphonec_out("wrong number from linphone_core_get_calls_nb\r\n"); + } + } + } + else + { + linphonec_out("no call in process\r\n"); + } + } + else { + return 0; + } + return 1; +} /*************************************************************************** * diff --git a/linphone_before_patch_multi/console/linphonec.c b/linphone_after_patch_multi/console/linphonec.c index 2d1ce98..e37fc3c 100644 --- a/linphone_before_patch_multi/console/linphonec.c +++ b/linphone_after_patch_multi/console/linphonec.c @@ -769,7 +769,10 @@ linphonec_finish(int exit_status) printf("Terminating...\n"); /* Terminate any pending call */ - linphonec_parse_command_line(linphonec, "terminate"); + char buf[256]; + printf("Terminating...\n"); + snprintf (buf, sizeof(buf),"terminate all"); + linphonec_parse_command_line(linphonec, buf); linphonec_command_finished(); #ifdef HAVE_READLINE linphonec_finish_readline(); diff --git a/linphone_before_patch_multi/coreapi/callbacks.c b/linphone_after_patch_multi/coreapi/callbacks.c index cdb1804..4b0fec0 100644 --- a/linphone_before_patch_multi/coreapi/callbacks.c +++ b/linphone_after_patch_multi/coreapi/callbacks.c @@ -35,7 +35,8 @@ static void linphone_connect_incoming(LinphoneCore *lc, LinphoneCall *call){ ring_stop(lc->ringstream); lc->ringstream=NULL; } - linphone_core_start_media_streams(lc,call); + if(call == linphone_core_get_current_call(lc)) + linphone_core_start_media_streams(lc,call); } static void call_received(SalOp *h){ @@ -66,7 +67,7 @@ static void call_received(SalOp *h){ sal_op_release(h); return; } - if (lc->call!=NULL){/*busy*/ + if (!linphone_core_can_we_add_call(lc)){/*busy*/ sal_call_decline(h,SalReasonBusy,NULL); sal_op_release(h); return; @@ -75,7 +76,19 @@ static void call_received(SalOp *h){ to=sal_op_get_to(h); call=linphone_call_new_incoming(lc,linphone_address_new(from),linphone_address_new(to),h); - lc->call=call; + if(linphone_core_add_call(lc,call)!= 0) + { + ms_warning("we cannot have more calls\n"); + sal_call_decline(h,SalReasonMedia,NULL); + linphone_call_destroy(call); + return; + } + if(linphone_core_get_current_call(lc)!=NULL) //we are already in call just inform that an incoming call is going on + { + char temp[256]; + snprintf(temp,sizeof(temp),"A new incoming call with cid <%d> during call",sal_op_get_cid(h)); + lc->vtable.display_status(lc,temp); + } sal_call_set_local_media_description(h,call->localdesc); call->resultdesc=sal_call_get_final_media_description(h); if (call->resultdesc) @@ -83,7 +96,6 @@ static void call_received(SalOp *h){ if (call->resultdesc && sal_media_description_empty(call->resultdesc)){ sal_call_decline(h,SalReasonMedia,NULL); linphone_call_destroy(call); - lc->call=NULL; return; } @@ -92,20 +104,20 @@ static void call_received(SalOp *h){ tmp=linphone_address_as_string(from_parsed); linphone_address_destroy(from_parsed); gstate_new_state(lc, GSTATE_CALL_IN_INVITE, tmp); - barmesg=ortp_strdup_printf("%s %s%s",tmp,_("is contacting you"), + barmesg=ortp_strdup_printf("%s %s%s%s%s",tmp,_("is contacting you with cid <"),sal_op_get_cid(h),_(">"), (sal_call_autoanswer_asked(h)) ?_(" and asked autoanswer."):_(".")); if (lc->vtable.show) lc->vtable.show(lc); if (lc->vtable.display_status) lc->vtable.display_status(lc,barmesg); /* play the ring */ - if (lc->sound_conf.ring_sndcard!=NULL){ + if (lc->sound_conf.ring_sndcard!=NULL && !linphone_core_in_call(lc)){ ms_message("Starting local ring..."); lc->ringstream=ring_start(lc->sound_conf.local_ring,2000,lc->sound_conf.ring_sndcard); } linphone_call_set_state(call,LCStateRinging); sal_call_notify_ringing(h); - linphone_core_init_media_streams(lc,lc->call); +// linphone_core_init_media_streams(lc,lc->call); if (lc->vtable.inv_recv) lc->vtable.inv_recv(lc,tmp); ms_free(barmesg); ms_free(tmp); @@ -113,7 +125,7 @@ static void call_received(SalOp *h){ static void call_ringing(SalOp *h){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h)); - LinphoneCall *call=lc->call; + LinphoneCall *call=linphone_core_get_call_by_cid(lc,sal_op_get_cid(h)); SalMediaDescription *md; if (call==NULL) return; if (lc->vtable.display_status) @@ -143,7 +155,8 @@ static void call_ringing(SalOp *h){ lc->ringstream=NULL; } ms_message("Doing early media..."); - linphone_core_start_media_streams(lc,call); + if(call == linphone_core_get_current_call(lc)) + linphone_core_start_media_streams(lc,call); call->media_pending=TRUE; } call->state=LCStateRinging; @@ -151,22 +164,25 @@ static void call_ringing(SalOp *h){ static void call_accepted(SalOp *op){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); - LinphoneCall *call=lc->call; + LinphoneCall *call=linphone_core_get_call_by_cid(lc,sal_op_get_cid(op)); if (call==NULL){ ms_warning("No call to accept."); return ; } - if (sal_op_get_user_pointer(op)!=lc->call){ + if (sal_op_get_user_pointer(op)!=call){//TODO not sure here ms_warning("call_accepted: ignoring."); return; } if (call->state==LCStateAVRunning){ return ; /*already accepted*/ } - if (lc->audiostream->ticker!=NULL){ + if ((lc->audiostream!=NULL) && (lc->audiostream->ticker!=NULL)){ /*case where we accepted early media */ - linphone_core_stop_media_streams(lc,call); - linphone_core_init_media_streams(lc,call); + if(call == linphone_core_get_current_call(lc)) + { + linphone_core_stop_media_streams(lc,call); + linphone_core_init_media_streams(lc,call); + } } if (call->resultdesc) sal_media_description_unref(call->resultdesc); @@ -187,20 +203,23 @@ static void call_accepted(SalOp *op){ static void call_ack(SalOp *op){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); - LinphoneCall *call=lc->call; + LinphoneCall *call=linphone_core_get_call_by_cid(lc,sal_op_get_cid(op)); if (call==NULL){ ms_warning("No call to be ACK'd"); return ; } - if (sal_op_get_user_pointer(op)!=lc->call){ + if (sal_op_get_user_pointer(op)!=call){//TODO not sure here ms_warning("call_ack: ignoring."); return; } if (call->media_pending){ if (lc->audiostream->ticker!=NULL){ /*case where we accepted early media */ - linphone_core_stop_media_streams(lc,call); - linphone_core_init_media_streams(lc,call); + if(call == linphone_core_get_current_call(lc)) + { + linphone_core_stop_media_streams(lc,call); + linphone_core_init_media_streams(lc,call); + } } if (call->resultdesc) sal_media_description_unref(call->resultdesc); @@ -222,8 +241,11 @@ static void call_ack(SalOp *op){ static void call_updated(SalOp *op){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op); - linphone_core_stop_media_streams(lc,call); - linphone_core_init_media_streams(lc,call); + if(call == linphone_core_get_current_call(lc)) + { + linphone_core_stop_media_streams(lc,call); + linphone_core_init_media_streams(lc,call); + } if (call->resultdesc) sal_media_description_unref(call->resultdesc); call->resultdesc=sal_call_get_final_media_description(op); @@ -234,7 +256,8 @@ static void call_updated(SalOp *op){ static void call_terminated(SalOp *op, const char *from){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); - if (sal_op_get_user_pointer(op)!=lc->call){ + LinphoneCall *call = linphone_core_get_call_by_cid(lc,sal_op_get_cid(op)); + if (sal_op_get_user_pointer(op)!=call){ ms_warning("call_terminated: ignoring."); return; } @@ -243,7 +266,8 @@ static void call_terminated(SalOp *op, const char *from){ ring_stop(lc->ringstream); lc->ringstream=NULL; } - linphone_core_stop_media_streams(lc,lc->call); + if(call == linphone_core_get_current_call(lc)) + linphone_core_stop_media_streams(lc,call); lc->vtable.show(lc); lc->vtable.display_status(lc,_("Call terminated.")); gstate_new_state(lc, GSTATE_CALL_END, NULL); @@ -256,8 +280,7 @@ static void call_terminated(SalOp *op, const char *from){ ms_free(tmp); linphone_address_destroy(addr); } - linphone_call_destroy(lc->call); - lc->call=NULL; + linphone_call_destroy(call); } static void call_failure(SalOp *op, SalError error, SalReason sr, const char *details){ @@ -268,9 +291,9 @@ static void call_failure(SalOp *op, SalError error, SalReason sr, const char *de char *msg600=_("User does not want to be disturbed."); char *msg603=_("Call declined."); char *msg=NULL; - LinphoneCall *call=lc->call; + LinphoneCall *call=linphone_core_get_call_by_cid(lc,sal_op_get_cid(op)); - if (sal_op_get_user_pointer(op)!=lc->call){ + if (sal_op_get_user_pointer(op)!=call){ ms_warning("call_failure: ignoring."); return; } @@ -328,12 +351,12 @@ static void call_failure(SalOp *op, SalError error, SalReason sr, const char *de ring_stop(lc->ringstream); lc->ringstream=NULL; } - linphone_core_stop_media_streams(lc,call); + if(call == linphone_core_get_current_call(lc)) + linphone_core_stop_media_streams(lc,call); if (call!=NULL) { linphone_call_destroy(call); if (sr!=SalReasonDeclined) gstate_new_state(lc, GSTATE_CALL_ERROR, msg); else gstate_new_state(lc, GSTATE_CALL_END, NULL); - lc->call=NULL; } } diff --git a/linphone_before_patch_multi/coreapi/chat.c b/linphone_after_patch_multi/coreapi/chat.c index 73a5f7c..b1e3eb1 100644 --- a/linphone_before_patch_multi/coreapi/chat.c +++ b/linphone_after_patch_multi/coreapi/chat.c @@ -55,7 +55,7 @@ void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg){ if(linphone_core_is_in_communication_with(cr->lc,cr->peer)) { ms_message("send SIP message into the call\n"); - op = cr->lc->call->op; + op = linphone_call_get_sal_op(linphone_core_get_current_call(cr->lc)); } else { diff --git a/linphone_before_patch_multi/coreapi/linphonecore.c b/linphone_after_patch_multi/coreapi/linphonecore.c index 3307ee7..0e5d538 100644 --- a/linphone_before_patch_multi/coreapi/linphonecore.c +++ b/linphone_after_patch_multi/coreapi/linphonecore.c @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "mediastreamer2/mediastream.h" #include "mediastreamer2/msvolume.h" #include "mediastreamer2/msequalizer.h" +#include "mediastreamer2/mscommon.h" #include @@ -203,6 +204,15 @@ void linphone_call_destroy(LinphoneCall *obj) if (obj->ping_op) { sal_op_release(obj->ping_op); } + if(linphone_core_del_call(obj->core,obj) != 0) + { + ms_error("could not remove the call from the list !!!"); + } + if(obj == linphone_core_get_current_call(obj->core)) + { + ms_message("destroying the current call\n"); + linphone_core_unset_the_current_call(obj->core); + } ms_free(obj); } @@ -316,6 +326,7 @@ void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call){ } else calllog->status=LinphoneCallAborted; break; + case LCStateHolded://TODO case LCStateAVRunning: calllog->status=LinphoneCallSuccess; break; @@ -437,14 +448,14 @@ bool_t linphone_call_asked_to_autoanswer(LinphoneCall *call){ } int linphone_core_get_current_call_duration(const LinphoneCore *lc){ - LinphoneCall *call=lc->call; + LinphoneCall *call=linphone_core_get_current_call((LinphoneCore *)lc);//TODO const est un probleme ? if (call==NULL) return 0; if (call->media_start_time==0) return 0; return time(NULL)-call->media_start_time; } const LinphoneAddress *linphone_core_get_remote_uri(LinphoneCore *lc){ - LinphoneCall *call=lc->call; + LinphoneCall *call=linphone_core_get_current_call(lc); if (call==NULL) return 0; return call->dir==LinphoneCallIncoming ? call->log->from : call->log->to; } @@ -1650,8 +1661,8 @@ void linphone_core_iterate(LinphoneCore *lc){ proxy_update(lc); - if (lc->call!=NULL){ - LinphoneCall *call=lc->call; + LinphoneCall *call = linphone_core_get_current_call(lc); + if(call){ if (call->state==LCStatePreEstablishing && (curtime-call->start_time>=2)){ /*start the call even if the OPTIONS reply did not arrive*/ linphone_core_start_invite(lc,call,NULL); @@ -1851,7 +1862,6 @@ static char *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , LinphonePr if (call->op && sal_op_get_contact(call->op)!=NULL){ return NULL; } - /* if the ping OPTIONS request succeeded use the contact guessed from the received, rport*/ if (call->ping_op){ @@ -1861,7 +1871,7 @@ static char *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , LinphonePr return ms_strdup(guessed); } } - + /*if using a proxy, use the contact address as guessed with the REGISTERs*/ if (dest_proxy && dest_proxy->op){ const char *fixed_contact=sal_op_get_contact(dest_proxy->op); @@ -1870,7 +1880,7 @@ static char *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , LinphonePr return ms_strdup(fixed_contact); } } - + ctt=linphone_core_get_primary_contact_parsed(lc); if (ctt!=NULL){ @@ -1898,7 +1908,7 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphonePro ms_free(contact); } call->state=LCStateInit; - linphone_core_init_media_streams(lc,lc->call); + linphone_core_init_media_streams(lc,call); if (!lc->sip_conf.sdp_200_ack){ call->media_pending=TRUE; sal_call_set_local_media_description(call->op,call->localdesc); @@ -1918,9 +1928,10 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphonePro if (err<0){ ms_warning("Could not initiate call."); lc->vtable.display_status(lc,_("could not call")); - linphone_core_stop_media_streams(lc,call); + if(call == linphone_core_get_current_call(lc)) + linphone_core_stop_media_streams(lc,call); linphone_call_destroy(call); - lc->call=NULL; +// lc->call=NULL; }else gstate_new_state(lc, GSTATE_CALL_OUT_INVITE, real_url); ms_free(real_url); ms_free(from); @@ -1963,10 +1974,16 @@ int linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *real_p LinphoneProxyConfig *dest_proxy=NULL; LinphoneCall *call; - if (lc->call!=NULL){ - lc->vtable.display_warning(lc,_("Sorry, having multiple simultaneous calls is not supported yet !")); + if (linphone_core_in_call(lc)){ + //lc->vtable.display_warning(lc,_("Sorry, having multiple simultaneous calls is not supported yet !")); + lc->vtable.display_warning(lc,_("Sorry, you have to hold the current call first !")); return -1; } + if(!linphone_core_can_we_add_call(lc)) + { + lc->vtable.display_warning(lc,_("Sorry, we have reached the maximum number of simultaneous calls")); + return -2; + } linphone_core_get_default_proxy(lc,&proxy); route=linphone_core_get_route(lc); @@ -1992,7 +2009,14 @@ int linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *real_p call=linphone_call_new_outgoing(lc,parsed_url2,linphone_address_clone(real_parsed_url)); sal_op_set_route(call->op,route); - lc->call=call; + if(linphone_core_add_call(lc,call)!= 0) + { + ms_warning("we had a problem in adding the call into the invite ... weird\n"); + linphone_call_destroy(call); + return -3; + } + linphone_core_set_as_current_call(lc,call); + //lc->call=call; if (dest_proxy!=NULL || lc->sip_conf.ping_with_options==FALSE){ err=linphone_core_start_invite(lc,call,dest_proxy); }else{ @@ -2017,7 +2041,7 @@ int linphone_core_refer(LinphoneCore *lc, const char *url) /* bad url */ return -1; } - call=lc->call; + call=linphone_core_get_current_call(lc); if (call==NULL){ ms_warning("No established call to refer."); return -1; @@ -2030,13 +2054,16 @@ int linphone_core_refer(LinphoneCore *lc, const char *url) } /** - * Returns true if in incoming call is pending, ie waiting for being answered or declined. + * Returns true if an incoming call is pending, ie waiting for being answered or declined. * * @ingroup call_control **/ bool_t linphone_core_inc_invite_pending(LinphoneCore*lc){ - if (lc->call!=NULL && lc->call->dir==LinphoneCallIncoming){ - return TRUE; + LinphoneCall *call = linphone_core_get_current_call(lc); + if(call != NULL) + { + if(call->dir==LinphoneCallIncoming) + return TRUE; } return FALSE; } @@ -2291,7 +2318,7 @@ void linphone_core_start_media_streams(LinphoneCore *lc, LinphoneCall *call){ end: ms_free(cname); linphone_address_destroy(me); - lc->call->state=LCStateAVRunning; + call->state=LCStateAVRunning; } void linphone_core_stop_media_streams(LinphoneCore *lc, LinphoneCall *call){ @@ -2341,12 +2368,20 @@ void linphone_core_stop_media_streams(LinphoneCore *lc, LinphoneCall *call){ * however this feature is not supported yet. * Using NULL will accept the unique incoming call in progress. **/ -int linphone_core_accept_call(LinphoneCore *lc, const char *url) +int linphone_core_accept_call(LinphoneCore *lc, int *cid) { - LinphoneCall *call=lc->call; + LinphoneCall *call; LinphoneProxyConfig *cfg=NULL; const char *contact=NULL; + if(cid == NULL) + { + call=linphone_core_get_current_call(lc); + } + else + { + call=linphone_core_get_call_by_cid(lc,*cid); + } if (call==NULL){ return -1; } @@ -2363,7 +2398,11 @@ int linphone_core_accept_call(LinphoneCore *lc, const char *url) ms_message("ring stopped"); lc->ringstream=NULL; } - + if(linphone_core_set_as_current_call(lc,call)!=0) + { + ms_message("another call is already in process\n"); + } + linphone_core_get_default_proxy(lc,&cfg); /*try to be best-effort in giving real local or routable contact address*/ contact=get_fixed_contact(lc,call,cfg); @@ -2376,27 +2415,41 @@ int linphone_core_accept_call(LinphoneCore *lc, const char *url) call->resultdesc=sal_call_get_final_media_description(call->op); if (call->resultdesc){ sal_media_description_ref(call->resultdesc); - linphone_core_start_media_streams(lc, call); + if(call == linphone_core_get_current_call(lc)) + linphone_core_start_media_streams(lc, call); }else call->media_pending=TRUE; ms_message("call answered."); return 0; } +SalOp *linphone_call_get_sal_op(LinphoneCall *call) +{ + if(call != NULL && call->op != NULL) + return call->op; + return NULL; +} + /** - * Terminates a call. + * Terminates a call by its cid. * * @ingroup call_control * @param lc The LinphoneCore * @param url the destination of the call to be terminated, use NULL if there is * only one call (which is case in this version of liblinphone). **/ -int linphone_core_terminate_call(LinphoneCore *lc, const char *url) +int linphone_core_terminate_call_by_cid(LinphoneCore *lc, int *cid) { - LinphoneCall *call=lc->call; - if (call==NULL){ + LinphoneCall *call; + if(cid == NULL) + { return -1; } - lc->call=NULL; + call = linphone_core_get_call_by_cid(lc,*cid); + if(call == NULL) + { + lc->vtable.display_warning(lc,_("The Call asked to terminate was not in the list supposed to be the current one") ); + call = linphone_core_get_current_call(lc); + } sal_call_terminate(call->op); /*stop ringing*/ @@ -2404,7 +2457,8 @@ int linphone_core_terminate_call(LinphoneCore *lc, const char *url) ring_stop(lc->ringstream); lc->ringstream=NULL; } - linphone_core_stop_media_streams(lc,call); + if(call == linphone_core_get_current_call(lc)) + linphone_core_stop_media_streams(lc,call); lc->vtable.display_status(lc,_("Call ended") ); gstate_new_state(lc, GSTATE_CALL_END, NULL); linphone_call_destroy(call); @@ -2412,12 +2466,69 @@ int linphone_core_terminate_call(LinphoneCore *lc, const char *url) } /** + * Terminates a call. + * + * @ingroup call_control + * @param lc The LinphoneCore + * @param url the destination of the call to be terminated, use NULL if there is + * only one call (which is case in this version of liblinphone). +**/ +int linphone_core_terminate_call(LinphoneCore *lc, const char *url) +{ + LinphoneCall *call; + int cid; + if (!linphone_core_in_call(lc)) + { + lc->vtable.display_warning(lc,_("Could not terminate we are not in call") ); + return -1; + } + call = linphone_core_get_current_call(lc); + if(call == NULL) + { + ms_warning("%s could not find the current call\n"); + return -2; + } + cid = sal_op_get_cid(linphone_call_get_sal_op(call)); + if(cid <= 0) + { + ms_warning("%s could not find the cid of the current call\n"); + return -3; + } + return linphone_core_terminate_call_by_cid(lc,&cid); +} + +/** + * Returns the calls MSList + * + * @ingroup call_control +**/ +MSList *linphone_core_get_calls(LinphoneCore *lc) +{ + return lc->calls; +} + +/** + * Returns the calls MSList + * + * @ingroup call_control +**/ +int linphone_core_set_calls(LinphoneCore *lc,MSList *calls) +{ + lc->calls = calls; + return 0; +} + +/** * Returns TRUE if there is a call running or pending. * * @ingroup call_control **/ bool_t linphone_core_in_call(const LinphoneCore *lc){ +#if 0 return lc->call!=NULL; +#else + return linphone_core_get_current_call((LinphoneCore *)lc)!=NULL; +#endif } /** @@ -2425,14 +2536,23 @@ bool_t linphone_core_in_call(const LinphoneCore *lc){ * * @ingroup call_control **/ -struct _LinphoneCall *linphone_core_get_current_call(LinphoneCore *lc) +LinphoneCall *linphone_core_get_current_call(LinphoneCore *lc) { - if(linphone_core_in_call(lc)) - return lc->call; - else - return NULL; + if(lc->current_call != NULL) + return lc->current_call; + /* + MSList *allcalls = linphone_core_get_calls(lc); + while(allcalls!=NULL) + { + if(((LinphoneCall *)allcalls)->state == LCStateAVRunning) + return ((LinphoneCall *)allcalls); + allcalls=allcalls->next; + } + */ + return NULL; } + int linphone_core_send_publish(LinphoneCore *lc, LinphoneOnlineStatus presence_mode) { @@ -2904,7 +3024,7 @@ void linphone_core_send_dtmf(LinphoneCore *lc, char dtmf) } if (linphone_core_get_use_info_for_dtmf(lc)!=0){ /* Out of Band DTMF (use INFO method) */ - LinphoneCall *call=lc->call; + LinphoneCall *call=linphone_core_get_current_call(lc); if (call==NULL){ return; } @@ -3514,9 +3634,9 @@ LpConfig *linphone_core_get_config(LinphoneCore *lc){ static void linphone_core_uninit(LinphoneCore *lc) { - if (lc->call){ + if(linphone_core_get_calls_nb(lc)){ int i; - linphone_core_terminate_call(lc,NULL); + linphone_core_terminate_calls(lc); for(i=0;i<10;++i){ #ifndef WIN32 usleep(50000); @@ -3573,7 +3693,6 @@ static void set_network_reachable(LinphoneCore* lc,bool_t isReachable){ } lc->network_reachable=isReachable; } - void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t isReachable) { //first disable automatic mode if (lc->auto_net_state_mon) { @@ -3596,3 +3715,266 @@ void linphone_core_destroy(LinphoneCore *lc){ ms_free(lc); } + +/** + * Permits to hold on or hold off a call with the cid *cid or the current one if not specified + * + * @ingroup call_control +**/ +int linphone_core_hold(LinphoneCore *lc, int holdon, int *cid){ + char text[256]; + LinphoneCall *lcall; + + if(holdon == HOLD_ON) + { + if(cid == NULL) + { + if(!linphone_core_in_call(lc)) + { + lc->vtable.display_warning(lc,_("we are not in conversation cannot hold on")); + return -4; + } + } + else + { + lc->vtable.display_warning(lc,_("we do not have to specify a cid to hold on the call hold on")); + } + lcall = linphone_core_get_current_call(lc); + } + else + { //hold off + if(linphone_core_in_call(lc)) + { + lc->vtable.display_warning(lc,_("cannot hold off we are already in communication")); + return -3; + } + if(cid == NULL) + { + if(linphone_core_get_calls_nb(lc) == 1) + { + lcall = ((LinphoneCall *)linphone_core_get_calls(lc)->data); + } + else + { + lc->vtable.display_warning(lc,_("cannot hold a call without the cid specify")); + return -2; + } + } + else + { + lcall = linphone_core_get_call_by_cid(lc,*cid); + } + } + if(lcall == NULL) + { + if(cid == NULL) + snprintf(text,sizeof(text),"linphone could not hold the current call"); + else + snprintf(text,sizeof(text),"linphone could not hold the call with cid <%d>",*cid); + lc->vtable.display_status(lc,text); + return -1; + } + if(holdon==HOLD_ON) + { + if(cid == NULL) + snprintf(text,sizeof(text),"hold on the current call"); + else + snprintf(text,sizeof(text),"hold on the call with cid <%d>",*cid); + sal_call_hold(lcall->op,TRUE); + lcall->state = LCStateHolded; + linphone_core_unset_the_current_call(lc); + linphone_core_stop_media_streams(lc,lcall); + linphone_core_init_media_streams(lc,lcall); + } + else + { + if(cid == NULL) + snprintf(text,sizeof(text),"hold off the only call"); + else + snprintf(text,sizeof(text),"hold off the call with cid <%d>",*cid); + sal_call_hold(lcall->op,FALSE); + lcall->state = LCStateAVRunning; + linphone_core_set_as_current_call(lc,lcall); + linphone_core_start_media_streams(lc,lcall); + } + lc->vtable.display_status(lc,text); + return 0; +} + +/** + * Get the number of Call + * + * @ingroup call_control +**/ +int linphone_core_get_calls_nb(const LinphoneCore *lc) +{ + int returned; + if(linphone_core_get_calls((LinphoneCore *)lc) == NULL) + { + returned = 0; + } + else + { + returned = ms_list_size((const MSList *)linphone_core_get_calls((LinphoneCore *)lc)); + } + return returned; +} + +/** + * Compare the cid given in parameter with the one in the LinphoneCall return 0 if it is the same one + * + * @ingroup call_control +**/ +static int linphone_call_cid_compare(const void * a, const void * b) +{ + if(b == NULL || a ==NULL) + return 1; + int *cid = ((int *)b); + + if(sal_op_get_cid(linphone_call_get_sal_op(((LinphoneCall *)a))) == *cid ) + { + return 0; + } + return 1; +} + +/** + * Get the Call by its Call-ID + * + * @ingroup call_control +**/ +LinphoneCall *linphone_core_get_call_by_cid( LinphoneCore *lc,int cid) +{ + MSList *the_call = ms_list_find_custom(linphone_core_get_calls(lc),linphone_call_cid_compare,(void *)&cid); + if(the_call != NULL) + { + return ((LinphoneCall *)the_call->data); + } + return NULL; +} + +/** + * Check if we do not have exceed the number of simultaneous call + * + * @ingroup call_control +**/ +bool_t linphone_core_can_we_add_call(LinphoneCore *lc) +{ + if(linphone_core_get_calls_nb(lc) < NB_MAX_CALLS) + return TRUE; + return FALSE; +} + +/** + * Unset the current call + * + * @ingroup call_control +**/ +int linphone_core_unset_the_current_call(LinphoneCore *lc) +{ + if(lc->current_call == NULL) + return -1; + lc->current_call = NULL; + ms_message("Current call unset\n"); + return 0; +} + +/** + * Set the call in parameter as the new current call + * + * @ingroup call_control +**/ +int linphone_core_set_as_current_call(LinphoneCore *lc, LinphoneCall *call) +{ + if(lc->current_call != NULL) + return -1; + lc->current_call = call; + return 0; +} + +/** + * Add the call in the LinphoneCall list + * + * @ingroup call_control +**/ +int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call) +{ + if(linphone_core_can_we_add_call(lc)) + { + MSList *the_calls = linphone_core_get_calls(lc); + the_calls = ms_list_append(the_calls,(void *)call); + linphone_core_set_calls(lc,the_calls); + return 0; + } + return -1; +} + +/** + * Add the call in the LinphoneCall list + * + * @ingroup call_control +**/ +int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call) +{ + MSList *it; + + MSList *the_calls = linphone_core_get_calls(lc); + if(call == linphone_core_get_current_call(lc)) + { + linphone_core_unset_the_current_call(lc); + } + it=ms_list_find(the_calls,call); + if (it) + { + the_calls = ms_list_remove_link(the_calls,it); + } + else + { + ms_warning("could not find the call into the list\n"); + return -1; + } + linphone_core_set_calls(lc,the_calls); + return 0; +} + +/** + * Create a pointer that describe the call, the pointer have to be freed afterward + * + * @ingroup call_control +**/ +char *linphone_core_get_a_call_to_str(LinphoneCore *lc,int index) +{ + char *p_char; + LinphoneCall *call = ms_list_nth_data(linphone_core_get_calls(lc),index); + if(call == NULL) + return NULL; + p_char=malloc(sizeof(char)*1024); + snprintf(p_char,1024," %d\t%s\t%s\t\t%s\r\n", + sal_op_get_cid(linphone_call_get_sal_op(call)), + linphone_address_as_string(call->log->from), + linphone_address_as_string(call->log->to), + (call == linphone_core_get_current_call(lc))?"yes":"no"); + return p_char; +} + +/** + * Terminate all the calls of linphone + * + * @ingroup call_control +**/ +int linphone_core_terminate_calls(LinphoneCore *lc) +{ + MSList *calls; + int cid; + + while(linphone_core_get_calls_nb(lc)) + { + calls = linphone_core_get_calls(lc); + cid = sal_op_get_cid(linphone_call_get_sal_op( ((LinphoneCall *)calls->data) )); + if(cid > 0) + linphone_core_terminate_call_by_cid(lc, &cid); + else + return -1; + } + return 0; +} diff --git a/linphone_before_patch_multi/coreapi/linphonecore.h b/linphone_after_patch_multi/coreapi/linphonecore.h index 8ef28f9..a584388 100644 --- a/linphone_before_patch_multi/coreapi/linphonecore.h +++ b/linphone_after_patch_multi/coreapi/linphonecore.h @@ -489,11 +489,13 @@ int linphone_core_refer(LinphoneCore *lc, const char *url); bool_t linphone_core_inc_invite_pending(LinphoneCore*lc); +MSList *linphone_core_get_calls(LinphoneCore *lc); + bool_t linphone_core_in_call(const LinphoneCore *lc); LinphoneCall *linphone_core_get_current_call(LinphoneCore *lc); -int linphone_core_accept_call(LinphoneCore *lc, const char *url); +int linphone_core_accept_call(LinphoneCore *lc, int *cid); int linphone_core_terminate_call(LinphoneCore *lc, const char *url); @@ -781,6 +783,31 @@ void linphone_core_destroy(LinphoneCore *lc); /*for advanced users:*/ void linphone_core_set_audio_transports(LinphoneCore *lc, RtpTransport *rtp, RtpTransport *rtcp); +/*for multicall*/ +/* +#define LINPHONE_SESSION_ID_SIZE (15) +#define LINPHONE_IPADDR_SIZE (64) +#define LINPHONE_HOSTNAME_SIZE (128) +#define LINPHONE_CALL_ID_SIZE (255) +*/ +#define HOLD_OFF (0) +#define HOLD_ON (1) + +#ifndef NB_MAX_CALLS +#define NB_MAX_CALLS (2) +#endif + +int linphone_core_hold(LinphoneCore *lc, int holdon, int *cid); +int linphone_core_get_calls_nb(const LinphoneCore *lc); +LinphoneCall *linphone_core_get_call_by_cid( LinphoneCore *lc,int cid); +bool_t linphone_core_can_we_add_call(LinphoneCore *lc); +int linphone_core_set_as_current_call(LinphoneCore *lc, LinphoneCall *call); +int linphone_core_unset_the_current_call(LinphoneCore *lc); +int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call); +int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call); +char *linphone_core_get_a_call_to_str(LinphoneCore *lc,int index); +int linphone_core_terminate_call_by_cid(LinphoneCore *lc, int *cid); +int linphone_core_terminate_calls(LinphoneCore *lc); #ifdef __cplusplus } #endif diff --git a/linphone_before_patch_multi/coreapi/private.h b/linphone_after_patch_multi/coreapi/private.h index 4a3c1db..b5a28d2 100644 --- a/linphone_before_patch_multi/coreapi/private.h +++ b/linphone_after_patch_multi/coreapi/private.h @@ -58,7 +58,8 @@ typedef enum _LCState{ LCStateInit, LCStatePreEstablishing, LCStateRinging, - LCStateAVRunning + LCStateAVRunning, + LCStateHolded }LCState; @@ -178,12 +179,15 @@ void linphone_core_stop_media_streams(LinphoneCore *lc, struct _LinphoneCall *ca const char * linphone_core_get_identity(LinphoneCore *lc); const char * linphone_core_get_route(LinphoneCore *lc); bool_t linphone_core_is_in_communication_with(LinphoneCore *lc, const char *to); +SalOp *linphone_call_get_sal_op(LinphoneCall *call); void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose); void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progresses); void linphone_core_stop_waiting(LinphoneCore *lc); int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy); +int linphone_core_set_calls(LinphoneCore *lc,MSList *calls); + extern SalCallbacks linphone_sal_callbacks; @@ -360,7 +364,9 @@ struct _LinphoneCore MSList *auth_info; struct _RingStream *ringstream; LCCallbackObj preview_finished_cb; - struct _LinphoneCall *call; /* the current call, in the future it will be a list of calls (conferencing)*/ + MSList *calls; /* list of the calls in process */ + LinphoneCall *current_call; +// struct _LinphoneCall *call; /* the current call, in the future it will be a list of calls (conferencing)*/ MSList *queued_calls; /* used by the autoreplier */ MSList *call_logs; MSList *chatrooms; diff --git a/linphone_before_patch_multi/coreapi/sal.h b/linphone_after_patch_multi/coreapi/sal.h index 882761f..25f9ea0 100644 --- a/linphone_before_patch_multi/coreapi/sal.h +++ b/linphone_after_patch_multi/coreapi/sal.h @@ -98,6 +98,7 @@ typedef struct SalStreamDescription{ int bandwidth; int ptime; SalEndpointCandidate candidates[SAL_ENDPOINT_CANDIDATE_MAX]; + bool_t notsending; } SalStreamDescription; #define SAL_MEDIA_DESCRIPTION_MAX_STREAMS 4 @@ -109,6 +110,7 @@ typedef struct SalMediaDescription{ int nstreams; int bandwidth; SalStreamDescription streams[SAL_MEDIA_DESCRIPTION_MAX_STREAMS]; + bool_t notsending; } SalMediaDescription; SalMediaDescription *sal_media_description_new(); @@ -252,12 +254,15 @@ const char *sal_op_get_proxy(const SalOp *op); const char *sal_op_get_network_origin(const SalOp *op); void *sal_op_get_user_pointer(const SalOp *op); +int sal_op_get_cid(const SalOp *op); + /*Call API*/ int sal_call_set_local_media_description(SalOp *h, SalMediaDescription *desc); int sal_call(SalOp *h, const char *from, const char *to); int sal_call_notify_ringing(SalOp *h); int sal_call_accept(SalOp*h); int sal_call_decline(SalOp *h, SalReason reason, const char *redirection /*optional*/); +int sal_call_hold(SalOp *h, bool_t holdon); SalMediaDescription * sal_call_get_final_media_description(SalOp *h); int sal_refer(SalOp *h, const char *refer_to); int sal_refer_accept(SalOp *h); @@ -299,5 +304,4 @@ void __sal_op_init(SalOp *b, Sal *sal); void __sal_op_set_network_origin(SalOp *op, const char *origin /*a sip uri*/); void __sal_op_free(SalOp *b); - #endif diff --git a/linphone_before_patch_multi/coreapi/sal_eXosip2.c b/linphone_after_patch_multi/coreapi/sal_eXosip2.c index afbc4f8..07c39dc 100644 --- a/linphone_before_patch_multi/coreapi/sal_eXosip2.c +++ b/linphone_after_patch_multi/coreapi/sal_eXosip2.c @@ -329,6 +329,7 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i ms_fatal("SIP over TCP or TLS or DTLS is not supported yet."); return -1; } + err=eXosip_listen_addr(proto, addr, port, ipv6 ? PF_INET6 : PF_INET, 0); #ifdef HAVE_EXOSIP_GET_SOCKET ms_message("Exosip has socket number %i",eXosip_get_socket(proto)); @@ -392,6 +393,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) { @@ -1499,7 +1513,7 @@ static bool_t process_event(Sal *sal, eXosip_event_t *ev){ case EXOSIP_SUBSCRIPTION_GLOBALFAILURE: sal_exosip_subscription_closed(sal,ev); break; - case EXOSIP_REGISTRATION_FAILURE: + case EXOSIP_REGISTRATION_FAILURE: ms_message("REGISTRATION_FAILURE\n"); return registration_failure(sal,ev); break; @@ -1609,6 +1623,13 @@ const char *sal_address_get_domain(const SalAddress *addr){ return null_if_empty(u->url->host); } +int sal_op_get_cid(const SalOp *op) +{ + if(op != NULL) + return op->cid; + return -1; +} + void sal_address_set_display_name(SalAddress *addr, const char *display_name){ osip_from_t *u=(osip_from_t*)addr; if (u->displayname!=NULL){ @@ -1685,3 +1706,46 @@ void sal_address_destroy(SalAddress *u){ osip_from_free((osip_from_t*)u); } +/** + * 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; + eXosip_call_build_info(h->did,&reinvite); + if(reinvite == NULL) + { + ms_warning("could not get a build info to send INVITE, maybe no previous call established ?"); + return -1; + } + //change the sip_message to be an INVITE ... + osip_free(osip_message_get_method(reinvite)); + osip_message_set_method(reinvite,osip_strdup("INVITE")); + osip_free(osip_cseq_get_method(osip_message_get_cseq(reinvite))); + osip_cseq_set_method(osip_message_get_cseq(reinvite),osip_strdup("INVITE")); + //adding some features needed to be a correct INVITE + 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; +} + diff --git a/linphone_before_patch_multi/coreapi/sal_eXosip2_sdp.c b/linphone_after_patch_multi/coreapi/sal_eXosip2_sdp.c index 2165708..b5ad3f9 100644 --- a/linphone_before_patch_multi/coreapi/sal_eXosip2_sdp.c +++ b/linphone_after_patch_multi/coreapi/sal_eXosip2_sdp.c @@ -121,12 +121,21 @@ static sdp_message_t *create_generic_sdp(const SalMediaDescription *desc) osip_strdup ("IN"), inet6 ? osip_strdup("IP6") : osip_strdup ("IP4"), osip_strdup (desc->addr)); sdp_message_s_name_set (local, osip_strdup ("A conversation")); - sdp_message_c_connection_add (local, -1, + if(!desc->notsending) + { + sdp_message_c_connection_add (local, -1, osip_strdup ("IN"), inet6 ? osip_strdup ("IP6") : osip_strdup ("IP4"), osip_strdup (desc->addr), NULL, NULL); + } + else + { + sdp_message_c_connection_add (local, -1, + osip_strdup ("IN"), inet6 ? osip_strdup ("IP6") : osip_strdup ("IP4"), + inet6 ? osip_strdup ("0.0.0.0.0.0") : osip_strdup ("0.0.0.0"), NULL, NULL); + } sdp_message_t_time_descr_add (local, osip_strdup ("0"), osip_strdup ("0")); if (desc->bandwidth>0) sdp_message_b_bandwidth_add (local, -1, osip_strdup ("AS"), - int_2char(desc->bandwidth)); + int_2char(desc->bandwidth)); return local; } @@ -186,6 +195,10 @@ static void add_line(sdp_message_t *msg, int lineno, const SalStreamDescription for(elem=desc->payloads;elem!=NULL;elem=elem->next){ add_payload(msg, lineno, (PayloadType*)elem->data); } + if(desc->notsending)//to hold the distant SIP endpoint + sdp_message_a_attribute_add (msg, lineno, osip_strdup ("sendonly"),NULL); + else + sdp_message_a_attribute_add (msg, lineno, osip_strdup ("sendrecv"),NULL); } sdp_message_t *media_description_to_sdp(const SalMediaDescription *desc){ @@ -239,7 +252,6 @@ int sdp_to_media_description(sdp_message_t *msg, SalMediaDescription *desc){ for(j=0;(sbw=sdp_message_bandwidth_get(msg,-1,j))!=NULL;++j){ if (strcasecmp(sbw->b_bwtype,"AS")==0) desc->bandwidth=atoi(sbw->b_bandwidth); } - /* for each m= line */ for (i=0; !sdp_message_endof_media (msg, i) && iIn call holded with")); + if (image!=NULL) { + gtk_button_set_image(GTK_BUTTON(button),image); + gtk_widget_show(image); + } + }else{ + GtkWidget *image=create_pixmap("hold_on.png"); + gtk_button_set_label(GTK_BUTTON(button),_("HoldOn")); + gtk_label_set_markup(GTK_LABEL(status),_("In call with")); + if (image!=NULL) { + gtk_button_set_image(GTK_BUTTON(button),image); + gtk_widget_show(image); + } + } +} + +void linphone_gtk_hold_toggled(GtkToggleButton *button){ + gboolean active=gtk_toggle_button_get_active(button); + linphone_core_hold(linphone_gtk_get_core(),active,NULL); + linphone_gtk_draw_hold_button(button,active); +} + +void linphone_gtk_enable_hold_button(GtkToggleButton *button, gboolean sensitive){ + gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive); + linphone_gtk_draw_hold_button(button,FALSE); +} diff --git a/linphone_before_patch_multi/gtk-glade/linphone.h b/linphone_after_patch_multi/gtk-glade/linphone.h index b6dcd5d..8502771 100644 --- a/linphone_before_patch_multi/gtk-glade/linphone.h +++ b/linphone_after_patch_multi/gtk-glade/linphone.h @@ -92,6 +92,7 @@ void linphone_gtk_in_call_view_set_in_call(void); void linphone_gtk_in_call_view_update_duration(int duration); void linphone_gtk_in_call_view_terminate(const char *error_msg); void linphone_gtk_enable_mute_button(GtkToggleButton *button, gboolean sensitive); +void linphone_gtk_enable_hold_button(GtkToggleButton *button, gboolean sensitive); void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg); diff --git a/linphone_before_patch_multi/gtk-glade/main.c b/linphone_after_patch_multi/gtk-glade/main.c index 364accb..56069ba 100644 --- a/linphone_before_patch_multi/gtk-glade/main.c +++ b/linphone_after_patch_multi/gtk-glade/main.c @@ -559,6 +559,7 @@ void linphone_gtk_call_terminated(const char *error){ gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"terminate_call"),FALSE); gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"start_call"),TRUE); linphone_gtk_enable_mute_button(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(mw,"main_mute")),FALSE); + linphone_gtk_enable_hold_button(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(mw,"hold_call")),FALSE); if (linphone_gtk_use_in_call_view()) linphone_gtk_in_call_view_terminate(error); update_video_title(); @@ -614,6 +615,9 @@ static void _linphone_gtk_accept_call(){ linphone_gtk_enable_mute_button( GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"main_mute")) ,TRUE); + linphone_gtk_enable_hold_button( + GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"hold_call")) + ,TRUE); } void linphone_gtk_start_call(GtkWidget *w){ @@ -886,6 +890,9 @@ static void linphone_gtk_general_state(LinphoneCore *lc, LinphoneGeneralState *g linphone_gtk_enable_mute_button( GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"main_mute")), TRUE); + linphone_gtk_enable_hold_button( + GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"hold_call")), + TRUE); break; case GSTATE_CALL_ERROR: linphone_gtk_call_terminated(gstate->message); diff --git a/linphone_before_patch_multi/gtk-glade/main.glade b/linphone_after_patch_multi/gtk-glade/main.glade index b858892..67701fb 100644 --- a/linphone_before_patch_multi/gtk-glade/main.glade +++ b/linphone_after_patch_multi/gtk-glade/main.glade @@ -1190,6 +1190,7 @@ Fiber Channel True + spread Mute @@ -1205,6 +1206,21 @@ Fiber Channel 0 + + + HoldOn + True + False + True + True + + + + False + False + 1 + + False diff --git a/linphone_before_patch_multi/pixmaps/Makefile.am b/linphone_after_patch_multi/pixmaps/Makefile.am index 6247f4d..47d2f51 100644 --- a/linphone_before_patch_multi/pixmaps/Makefile.am +++ b/linphone_after_patch_multi/pixmaps/Makefile.am @@ -3,6 +3,7 @@ pixmapdir=$(datadir)/pixmaps/linphone pixmap_DATA= \ +hold_on.png hold_off.png \ mic_muted.png mic_active.png \ linphone-3-250x130.png linphone-3.png linphone2-57x57.png \ linphone.png linphone-banner.png \