lc->vtable.display_status(lc,barmesg);
/* play the ring */
- if (lc->sound_conf.ring_sndcard!=NULL){
- MSSndCard *ringcard=lc->sound_conf.lsd_card ? lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard;
- ms_message("Starting local ring...");
- lc->ringstream=ring_start(lc->sound_conf.local_ring,2000,ringcard);
+ if (lc->sound_conf.ring_sndcard!=NULL && !linphone_core_in_call(lc)){
- if(lc->ringstream==NULL)
- {
++ if(lc->ringstream==NULL){
++ MSSndCard *ringcard=lc->sound_conf.lsd_card ?lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard;
+ ms_message("Starting local ring...");
- lc->ringstream=ring_start(lc->sound_conf.local_ring,2000,lc->sound_conf.ring_sndcard);
++ lc->ringstream=ring_start(lc->sound_conf.local_ring,2000,ringcard);
+ }
+ else
+ {
+ ms_message("the local ring is already started");
+ }
}
- linphone_call_set_state(call,LCStateRinging);
+ call->state=LinphoneCallRinging;
sal_call_notify_ringing(h);
- linphone_core_init_media_streams(lc,lc->call);
- if (lc->vtable.inv_recv) lc->vtable.inv_recv(lc,tmp);
+ linphone_core_init_media_streams(lc,call);
+ if (lc->vtable.inv_recv) lc->vtable.inv_recv(lc,call);
ms_free(barmesg);
ms_free(tmp);
}
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."));
+ if (lc->vtable.show!=NULL)
+ lc->vtable.show(lc);
+ if (lc->vtable.display_status!=NULL)
+ lc->vtable.display_status(lc,_("Call terminated."));
+ linphone_call_set_terminated(call);
gstate_new_state(lc, GSTATE_CALL_END, NULL);
if (lc->vtable.bye_recv!=NULL){
LinphoneAddress *addr=linphone_address_new(from);
LinphoneCore *lc=call->core;
calllog->duration=time(NULL)-call->start_time;
- switch(call->state){
- case LCStateInit:
- case LCStatePreEstablishing:
- calllog->status=LinphoneCallAborted;
- break;
- case LCStateRinging:
- if (calllog->dir==LinphoneCallIncoming){
- char *info;
- calllog->status=LinphoneCallMissed;
- lc->missed_calls++;
- info=ortp_strdup_printf(ngettext("You have missed %i call.",
- "You have missed %i calls.", lc->missed_calls),
- lc->missed_calls);
+
+ if (status==LinphoneCallMissed){
+ char *info;
+ lc->missed_calls++;
+ info=ortp_strdup_printf(ngettext("You have missed %i call.",
+ "You have missed %i calls.", lc->missed_calls),
+ lc->missed_calls);
- lc->vtable.display_status(lc,info);
+ if (lc->vtable.display_status!=NULL)
+ lc->vtable.display_status(lc,info);
- ms_free(info);
- }
- else calllog->status=LinphoneCallAborted;
- break;
- case LCStateAVRunning:
- calllog->status=LinphoneCallSuccess;
- break;
- }
+ ms_free(info);
+ }else calllog->status=status;
lc->call_logs=ms_list_prepend(lc->call_logs,(void *)calllog);
if (ms_list_size(lc->call_logs)>lc->max_call_logs){
MSList *elem,*prevelem=NULL;
(vs!=NULL) ? (rtp_session_compute_send_bandwidth(vs)*1e-3) : 0);
}
-static void linphone_core_disconnected(LinphoneCore *lc){
+static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){
+ char temp[256];
+ char *from;
+ if(call)
+ from = linphone_call_get_remote_address_as_string(call);
+ if(from)
+ {
+ snprintf(temp,sizeof(temp),"Remote end %s seems to have disconnected, the call is going to be closed.",from);
+ free(from);
+ }
+ else
+ {
+ snprintf(temp,sizeof(temp),"Remote end seems to have disconnected, the call is going to be closed.");
+ }
+ if (lc->vtable.display_warning!=NULL)
- lc->vtable.display_warning(lc,_("Remote end seems to have disconnected, the call is going to be closed."));
- linphone_core_terminate_call(lc,NULL);
+ lc->vtable.display_warning(lc,temp);
+ linphone_core_terminate_call(lc,call);//TODO failure ??
}
static void monitor_network_state(LinphoneCore *lc, time_t curtime){
LinphoneAddress *uri;
if (is_enum(url,&enum_domain)){
- lc->vtable.display_status(lc,_("Looking for telephone number destination..."));
+ if (lc->vtable.display_status!=NULL)
+ lc->vtable.display_status(lc,_("Looking for telephone number destination..."));
if (enum_lookup(enum_domain,&enumres)<0){
- lc->vtable.display_status(lc,_("Could not resolve this number."));
+ if (lc->vtable.display_status!=NULL)
+ lc->vtable.display_status(lc,_("Could not resolve this number."));
+ if(lc->vtable.failure_recv)
+ lc->vtable.failure_recv(lc,NULL,400);
ms_free(enum_domain);
return NULL;
}
if (err<0){
ms_warning("Could not initiate call.");
- lc->vtable.display_status(lc,_("could not call"));
+ if (lc->vtable.display_status!=NULL)
+ lc->vtable.display_status(lc,_("could not call"));
- linphone_core_stop_media_streams(lc,call);
- linphone_call_destroy(call);
- lc->call=NULL;
+ if(call == linphone_core_get_current_call(lc))
+ linphone_core_stop_media_streams(lc,call);
+ linphone_call_unref(call);
}else gstate_new_state(lc, GSTATE_CALL_OUT_INVITE, real_url);
ms_free(real_url);
ms_free(from);
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") );
+ if (lc->vtable.display_status!=NULL)
+ lc->vtable.display_status(lc,_("Call ended") );
gstate_new_state(lc, GSTATE_CALL_END, NULL);
- linphone_call_destroy(call);
+ linphone_call_set_terminated(call);
+ linphone_call_unref(call);
return 0;
}