Commit 23d589ce authored by Simon Morlat's avatar Simon Morlat

fix bugs in call status, write codecs config immediately

parent 3a4c17df
...@@ -484,9 +484,18 @@ static void call_terminated(SalOp *op, const char *from){ ...@@ -484,9 +484,18 @@ static void call_terminated(SalOp *op, const char *from){
if (call==NULL) return; if (call==NULL) return;
if (linphone_call_get_state(call)==LinphoneCallEnd || linphone_call_get_state(call)==LinphoneCallError){ switch(linphone_call_get_state(call)){
ms_warning("call_terminated: ignoring."); case LinphoneCallEnd:
return; case LinphoneCallError:
ms_warning("call_terminated: ignoring.");
return;
break;
case LinphoneCallIncomingReceived:
case LinphoneCallIncomingEarlyMedia:
call->reason=LinphoneReasonNotAnswered;
break;
default:
break;
} }
ms_message("Current call terminated..."); ms_message("Current call terminated...");
//we stop the call only if we have this current call or if we are in call //we stop the call only if we have this current call or if we are in call
......
...@@ -497,8 +497,14 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const ...@@ -497,8 +497,14 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
call->state=cstate; call->state=cstate;
} }
if (cstate==LinphoneCallEnd || cstate==LinphoneCallError){ if (cstate==LinphoneCallEnd || cstate==LinphoneCallError){
if (call->reason==LinphoneReasonDeclined){ switch(call->reason){
call->log->status=LinphoneCallDeclined; case LinphoneReasonDeclined:
call->log->status=LinphoneCallDeclined;
case LinphoneReasonNotAnswered:
call->log->status=LinphoneCallMissed;
break;
default:
break;
} }
linphone_call_set_terminated (call); linphone_call_set_terminated (call);
} }
......
...@@ -1319,6 +1319,7 @@ int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs) ...@@ -1319,6 +1319,7 @@ int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs)
{ {
if (lc->codecs_conf.audio_codecs!=NULL) ms_list_free(lc->codecs_conf.audio_codecs); if (lc->codecs_conf.audio_codecs!=NULL) ms_list_free(lc->codecs_conf.audio_codecs);
lc->codecs_conf.audio_codecs=codecs; lc->codecs_conf.audio_codecs=codecs;
_linphone_core_codec_config_write(lc);
return 0; return 0;
} }
...@@ -1333,6 +1334,7 @@ int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs) ...@@ -1333,6 +1334,7 @@ int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs)
{ {
if (lc->codecs_conf.video_codecs!=NULL) ms_list_free(lc->codecs_conf.video_codecs); if (lc->codecs_conf.video_codecs!=NULL) ms_list_free(lc->codecs_conf.video_codecs);
lc->codecs_conf.video_codecs=codecs; lc->codecs_conf.video_codecs=codecs;
_linphone_core_codec_config_write(lc);
return 0; return 0;
} }
...@@ -1827,6 +1829,7 @@ void linphone_core_iterate(LinphoneCore *lc){ ...@@ -1827,6 +1829,7 @@ void linphone_core_iterate(LinphoneCore *lc){
ms_message("incoming call ringing for %i seconds",elapsed); ms_message("incoming call ringing for %i seconds",elapsed);
if (elapsed>lc->sip_conf.inc_timeout){ if (elapsed>lc->sip_conf.inc_timeout){
call->log->status=LinphoneCallMissed; call->log->status=LinphoneCallMissed;
call->reason=LinphoneReasonNotAnswered;
linphone_core_terminate_call(lc,call); linphone_core_terminate_call(lc,call);
} }
} }
...@@ -2569,7 +2572,8 @@ int linphone_core_abort_call(LinphoneCore *lc, LinphoneCall *call, const char *e ...@@ -2569,7 +2572,8 @@ int linphone_core_abort_call(LinphoneCore *lc, LinphoneCall *call, const char *e
static void terminate_call(LinphoneCore *lc, LinphoneCall *call){ static void terminate_call(LinphoneCore *lc, LinphoneCall *call){
if (call->state==LinphoneCallIncomingReceived){ if (call->state==LinphoneCallIncomingReceived){
call->reason=LinphoneReasonDeclined; if (call->reason!=LinphoneReasonNotAnswered)
call->reason=LinphoneReasonDeclined;
} }
/*stop ringing*/ /*stop ringing*/
if (lc->ringstream!=NULL) { if (lc->ringstream!=NULL) {
...@@ -4261,38 +4265,43 @@ void video_config_uninit(LinphoneCore *lc) ...@@ -4261,38 +4265,43 @@ void video_config_uninit(LinphoneCore *lc)
ms_free(lc->video_conf.cams); ms_free(lc->video_conf.cams);
} }
void codecs_config_uninit(LinphoneCore *lc) void _linphone_core_codec_config_write(LinphoneCore *lc){
{ if (linphone_core_ready(lc)){
PayloadType *pt; PayloadType *pt;
codecs_config_t *config=&lc->codecs_conf; codecs_config_t *config=&lc->codecs_conf;
MSList *node; MSList *node;
char key[50]; char key[50];
int index; int index;
index=0; index=0;
for(node=config->audio_codecs;node!=NULL;node=ms_list_next(node)){ for(node=config->audio_codecs;node!=NULL;node=ms_list_next(node)){
pt=(PayloadType*)(node->data); pt=(PayloadType*)(node->data);
sprintf(key,"audio_codec_%i",index);
lp_config_set_string(lc->config,key,"mime",pt->mime_type);
lp_config_set_int(lc->config,key,"rate",pt->clock_rate);
lp_config_set_int(lc->config,key,"enabled",linphone_core_payload_type_enabled(lc,pt));
index++;
}
sprintf(key,"audio_codec_%i",index); sprintf(key,"audio_codec_%i",index);
lp_config_set_string(lc->config,key,"mime",pt->mime_type); lp_config_clean_section (lc->config,key);
lp_config_set_int(lc->config,key,"rate",pt->clock_rate);
lp_config_set_int(lc->config,key,"enabled",linphone_core_payload_type_enabled(lc,pt)); index=0;
index++; for(node=config->video_codecs;node!=NULL;node=ms_list_next(node)){
} pt=(PayloadType*)(node->data);
sprintf(key,"audio_codec_%i",index); sprintf(key,"video_codec_%i",index);
lp_config_clean_section (lc->config,key); lp_config_set_string(lc->config,key,"mime",pt->mime_type);
lp_config_set_int(lc->config,key,"rate",pt->clock_rate);
index=0; lp_config_set_int(lc->config,key,"enabled",linphone_core_payload_type_enabled(lc,pt));
for(node=config->video_codecs;node!=NULL;node=ms_list_next(node)){ lp_config_set_string(lc->config,key,"recv_fmtp",pt->recv_fmtp);
pt=(PayloadType*)(node->data); index++;
}
sprintf(key,"video_codec_%i",index); sprintf(key,"video_codec_%i",index);
lp_config_set_string(lc->config,key,"mime",pt->mime_type); lp_config_clean_section (lc->config,key);
lp_config_set_int(lc->config,key,"rate",pt->clock_rate);
lp_config_set_int(lc->config,key,"enabled",linphone_core_payload_type_enabled(lc,pt));
lp_config_set_string(lc->config,key,"recv_fmtp",pt->recv_fmtp);
index++;
} }
sprintf(key,"video_codec_%i",index); }
lp_config_clean_section (lc->config,key);
static void codecs_config_uninit(LinphoneCore *lc)
{
_linphone_core_codec_config_write(lc);
ms_list_free(lc->codecs_conf.audio_codecs); ms_list_free(lc->codecs_conf.audio_codecs);
ms_list_free(lc->codecs_conf.video_codecs); ms_list_free(lc->codecs_conf.video_codecs);
} }
...@@ -4584,6 +4593,8 @@ const char *linphone_reason_to_string(LinphoneReason err){ ...@@ -4584,6 +4593,8 @@ const char *linphone_reason_to_string(LinphoneReason err){
return "Call declined"; return "Call declined";
case LinphoneReasonNotFound: case LinphoneReasonNotFound:
return "User not found"; return "User not found";
case LinphoneReasonNotAnswered:
return "Not answered";
} }
return "unknown error"; return "unknown error";
} }
......
...@@ -205,7 +205,8 @@ enum _LinphoneReason{ ...@@ -205,7 +205,8 @@ enum _LinphoneReason{
LinphoneReasonNoResponse, /**<No response received from remote*/ LinphoneReasonNoResponse, /**<No response received from remote*/
LinphoneReasonBadCredentials, /**<Authentication failed due to bad or missing credentials*/ LinphoneReasonBadCredentials, /**<Authentication failed due to bad or missing credentials*/
LinphoneReasonDeclined, /**<The call has been declined*/ LinphoneReasonDeclined, /**<The call has been declined*/
LinphoneReasonNotFound, LinphoneReasonNotFound, /**<Destination of the calls was not found.*/
LinphoneReasonNotAnswered
}; };
typedef enum _LinphoneReason LinphoneReason; typedef enum _LinphoneReason LinphoneReason;
......
...@@ -196,6 +196,7 @@ bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const PayloadType *p ...@@ -196,6 +196,7 @@ bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const PayloadType *p
int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enabled){ int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enabled){
if (ms_list_find(lc->codecs_conf.audio_codecs,pt) || ms_list_find(lc->codecs_conf.video_codecs,pt)){ if (ms_list_find(lc->codecs_conf.audio_codecs,pt) || ms_list_find(lc->codecs_conf.video_codecs,pt)){
payload_type_set_enable(pt,enabled); payload_type_set_enable(pt,enabled);
_linphone_core_codec_config_write(lc);
return 0; return 0;
} }
ms_error("Enabling codec not in audio or video list of PayloadType !"); ms_error("Enabling codec not in audio or video list of PayloadType !");
......
...@@ -568,6 +568,7 @@ bool_t linphone_core_sound_resources_available(LinphoneCore *lc); ...@@ -568,6 +568,7 @@ bool_t linphone_core_sound_resources_available(LinphoneCore *lc);
void linphone_core_notify_refer_state(LinphoneCore *lc, LinphoneCall *referer, LinphoneCall *newcall); void linphone_core_notify_refer_state(LinphoneCore *lc, LinphoneCall *referer, LinphoneCall *newcall);
void __linphone_core_invalidate_registers(LinphoneCore* lc); void __linphone_core_invalidate_registers(LinphoneCore* lc);
void _linphone_core_codec_config_write(LinphoneCore *lc);
#define HOLD_OFF (0) #define HOLD_OFF (0)
#define HOLD_ON (1) #define HOLD_ON (1)
......
...@@ -57,6 +57,7 @@ void linphone_gtk_call_log_update(GtkWidget *w){ ...@@ -57,6 +57,7 @@ void linphone_gtk_call_log_update(GtkWidget *w){
const char *display; const char *display;
gchar *logtxt, *minutes, *seconds; gchar *logtxt, *minutes, *seconds;
gchar quality[20]; gchar quality[20];
const char *status=NULL;
display=linphone_address_get_display_name (la); display=linphone_address_get_display_name (la);
if (display==NULL){ if (display==NULL){
...@@ -67,17 +68,35 @@ void linphone_gtk_call_log_update(GtkWidget *w){ ...@@ -67,17 +68,35 @@ void linphone_gtk_call_log_update(GtkWidget *w){
if (cl->quality!=-1){ if (cl->quality!=-1){
snprintf(quality,sizeof(quality),"%.1f",cl->quality); snprintf(quality,sizeof(quality),"%.1f",cl->quality);
} }
switch(cl->status){
case LinphoneCallAborted:
status=_("Aborted");
break;
case LinphoneCallMissed:
status=_("Missed");
break;
case LinphoneCallDeclined:
status=_("Declined");
break;
default:
break;
}
minutes=g_markup_printf_escaped( minutes=g_markup_printf_escaped(
ngettext("%i minute", "%i minutes", cl->duration/60), ngettext("%i minute", "%i minutes", cl->duration/60),
cl->duration/60); cl->duration/60);
seconds=g_markup_printf_escaped( seconds=g_markup_printf_escaped(
ngettext("%i second", "%i seconds", cl->duration%60), ngettext("%i second", "%i seconds", cl->duration%60),
cl->duration%60); cl->duration%60);
logtxt=g_markup_printf_escaped( if (status==NULL) logtxt=g_markup_printf_escaped(
_("<big><b>%s</b></big>\t<small><i>%s</i>\t" _("<big><b>%s</b></big>\t<small><i>%s</i>\t"
"<i>Quality: %s</i></small>\n%s\t%s %s\t"), "<i>Quality: %s</i></small>\n%s\t%s %s\t"),
display, addr, cl->quality!=-1 ? quality : _("n/a"), display, addr, cl->quality!=-1 ? quality : _("n/a"),
cl->start_date, minutes, seconds); cl->start_date, minutes, seconds);
else logtxt=g_markup_printf_escaped(
_("<big><b>%s</b></big>\t<small><i>%s</i></small>\t"
"\n%s\t%s"),
display, addr,
cl->start_date, status);
g_free(minutes); g_free(minutes);
g_free(seconds); g_free(seconds);
gtk_list_store_append (store,&iter); gtk_list_store_append (store,&iter);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment