diff --git a/console/linphonec.c b/console/linphonec.c index 81218be..f203057 100644 --- a/console/linphonec.c +++ b/console/linphonec.c @@ -133,7 +133,7 @@ static void linphonec_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, const char *from, const char *msg); static void linphonec_display_status (LinphoneCore * lc, const char *something); static void linphonec_general_state (LinphoneCore * lc, LinphoneGeneralState *gstate, LinphoneGeneralStateContext gctx); -static void linphonec_dtmf_received(LinphoneCore *lc, int dtmf); +static void linphonec_dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf); static void print_prompt(LinphoneCore *opm); void linphonec_out(const char *fmt,...); /*************************************************************************** @@ -429,9 +429,11 @@ linphonec_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, } -static void linphonec_dtmf_received(LinphoneCore *lc, int dtmf){ - fprintf(stdout,"Receiving tone %c\n",dtmf); +static void linphonec_dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf){ + char *from=linphone_call_get_remote_address_as_string(call); + fprintf(stdout,"Receiving tone %c from %s\n",dtmf,from); fflush(stdout); + ms_free(from); } static void @@ -463,6 +465,9 @@ linphonec_general_state (LinphoneCore * lc, LinphoneGeneralState *gstate, Linpho case GSTATE_CALL_IDLE: printf("GSTATE_CALL_IDLE"); break; + case GSTATE_CALL_OUT_RINGING: + printf("GSTATE_CALL_OUT_RINGING"); + break; case GSTATE_CALL_OUT_INVITE: printf("GSTATE_CALL_OUT_INVITE"); break; diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index e37941f..48e2db0 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -100,8 +100,13 @@ static void call_received(SalOp *h){ return; } /* the call is acceptable so we can now add it to our list */ - linphone_core_add_call(lc,call); - + if(linphone_core_add_call(lc,call)!= 0) + { + ms_warning("we cannot handle anymore call\n"); + sal_call_decline(h,SalReasonMedia,NULL); + linphone_call_unref(call); + return; + } from_parsed=linphone_address_new(sal_op_get_from(h)); linphone_address_clean(from_parsed); tmp=linphone_address_as_string(from_parsed); @@ -227,7 +232,11 @@ static void call_accepted(SalOp *op){ }//if there is an accepted incoming call else { - linphone_core_set_as_current_call (lc,call); + /* + * Do not set the call as current here, + * because we can go through this function not only when an incoming call is accepted + */ + //linphone_core_set_as_current_call (lc,call); gstate_new_state(lc, GSTATE_CALL_OUT_CONNECTED, gctx, NULL); linphone_connect_incoming(lc,call); } @@ -496,8 +505,9 @@ static void vfu_request(SalOp *op){ static void dtmf_received(SalOp *op, char dtmf){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); + LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op); if (lc->vtable.dtmf_received != NULL) - lc->vtable.dtmf_received(lc, dtmf); + lc->vtable.dtmf_received(lc, call, dtmf); } static void refer_received(Sal *sal, SalOp *op, const char *referto){ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index c1922fe..fa2e081 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1479,7 +1479,7 @@ static void display_bandwidth(RtpSession *as, RtpSession *vs){ static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){ char temp[256]; - char *from; + char *from=NULL; if(call) from = linphone_call_get_remote_address_as_string(call); if(from) @@ -1493,7 +1493,9 @@ static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){ } if (lc->vtable.display_warning!=NULL) lc->vtable.display_warning(lc,temp); - linphone_core_terminate_call(lc,call);//TODO failure ?? + if(lc->vtable.failure_recv) + lc->vtable.failure_recv(lc,call, 480);//480 Temporarily Unavailable + linphone_core_terminate_call(lc,call); } static void monitor_network_state(LinphoneCore *lc, time_t curtime){ @@ -2128,7 +2130,7 @@ static void linphone_core_dtmf_received(RtpSession* s, int dtmf, void* user_data return; } if (lc->vtable.dtmf_received != NULL) - lc->vtable.dtmf_received(lc, dtmf_tab[dtmf]); + lc->vtable.dtmf_received(lc, linphone_core_get_current_call(lc), dtmf_tab[dtmf]); } static void parametrize_equalizer(LinphoneCore *lc, AudioStream *st){ diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 950be3a..703703a 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -464,7 +464,7 @@ typedef void (*TextMessageReceived)(struct _LinphoneCore *lc, LinphoneChatRoom * /** Callback prototype */ typedef void (*GeneralStateChange)(struct _LinphoneCore *lc, LinphoneGeneralState *gstate, LinphoneGeneralStateContext ctx); /** Callback prototype */ -typedef void (*DtmfReceived)(struct _LinphoneCore* lc, int dtmf); +typedef void (*DtmfReceived)(struct _LinphoneCore* lc, LinphoneCall *call, int dtmf); /** Callback prototype */ typedef void (*ReferReceived)(struct _LinphoneCore *lc, LinphoneCall *call, const char *refer_to); /** Callback prototype */