From ddff1d846004ac4373d00458cd10f6c2dbabedc8 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 10 Jun 2011 16:01:08 +0200 Subject: [PATCH] display average quality in call logs --- coreapi/linphonecall.c | 1 + coreapi/linphonecore.c | 2 ++ coreapi/linphonecore.h | 1 + coreapi/lpconfig.c | 9 +++++++-- coreapi/lpconfig.h | 6 ++++++ gtk/calllogs.c | 10 ++++++++-- 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index fdcca58d1..8649c4c45 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1015,6 +1015,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut static void linphone_call_log_fill_stats(LinphoneCallLog *log, AudioStream *st){ audio_stream_get_local_rtp_stats (st,&log->local_stats); + log->quality=audio_stream_get_average_quality_rating(st); } void linphone_call_stop_media_streams(LinphoneCall *call){ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 7504749ea..d179d8104 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -124,6 +124,7 @@ void call_logs_write_to_config_file(LinphoneCore *lc){ lp_config_set_string(cfg,logsection,"start_date",cl->start_date); lp_config_set_int(cfg,logsection,"duration",cl->duration); if (cl->refkey) lp_config_set_string(cfg,logsection,"refkey",cl->refkey); + lp_config_set_float(cfg,logsection,"quality",cl->quality); } for(;imax_call_logs;++i){ snprintf(logsection,sizeof(logsection),"call_log_%i",i); @@ -151,6 +152,7 @@ static void call_logs_read_from_config_file(LinphoneCore *lc){ cl->duration=lp_config_get_int(cfg,logsection,"duration",0); tmp=lp_config_get_string(cfg,logsection,"refkey",NULL); if (tmp) cl->refkey=ms_strdup(tmp); + cl->quality=lp_config_get_float(cfg,logsection,"quality",-1); lc->call_logs=ms_list_append(lc->call_logs,cl); }else break; } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index cd57b926d..02c4c607a 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -152,6 +152,7 @@ typedef struct _LinphoneCallLog{ void *user_pointer; rtp_stats_t local_stats; rtp_stats_t remote_stats; + float quality; struct _LinphoneCore *lc; } LinphoneCallLog; diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index ce093cbaf..0de019e57 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -307,9 +307,14 @@ void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *ke void lp_config_set_int(LpConfig *lpconfig,const char *section, const char *key, int value){ char tmp[30]; - snprintf(tmp,30,"%i",value); + snprintf(tmp,sizeof(tmp),"%i",value); + lp_config_set_string(lpconfig,section,key,tmp); +} + +void lp_config_set_float(LpConfig *lpconfig,const char *section, const char *key, float value){ + char tmp[30]; + snprintf(tmp,sizeof(tmp),"%f",value); lp_config_set_string(lpconfig,section,key,tmp); - lpconfig->modified++; } void lp_item_write(LpItem *item, FILE *file){ diff --git a/coreapi/lpconfig.h b/coreapi/lpconfig.h index bb731acbc..ed7a66b1e 100644 --- a/coreapi/lpconfig.h +++ b/coreapi/lpconfig.h @@ -86,6 +86,12 @@ void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *ke * @ingroup misc **/ void lp_config_set_int(LpConfig *lpconfig,const char *section, const char *key, int value); +/** + * Sets a float config item + * + * @ingroup misc +**/ +void lp_config_set_float(LpConfig *lpconfig,const char *section, const char *key, float value); /** * Writes the config file to disk. * diff --git a/gtk/calllogs.c b/gtk/calllogs.c index c196c2c41..f336992d7 100644 --- a/gtk/calllogs.c +++ b/gtk/calllogs.c @@ -40,14 +40,20 @@ void linphone_gtk_call_log_update(GtkWidget *w){ char *addr= linphone_address_as_string_uri_only (la); const char *display; gchar *logtxt; + gchar quality[20]; + display=linphone_address_get_display_name (la); if (display==NULL){ display=linphone_address_get_username (la); if (display==NULL) display=linphone_address_get_domain (la); } - logtxt=g_markup_printf_escaped("%s\t%s\n" - "%s\t%i minutes %i seconds",display, addr, cl->start_date, + if (cl->quality!=-1){ + snprintf(quality,sizeof(quality),"%.1f",cl->quality); + } + logtxt=g_markup_printf_escaped("%s\t%s\tQuality: %s\n" + "%s\t%i minutes %i seconds\t",display, addr, cl->quality!=-1 ? quality : _("n/a"), + cl->start_date, cl->duration/60,cl->duration%60); gtk_list_store_append (store,&iter); gtk_list_store_set (store,&iter,