From 85a7e928dedf5720e8240d6fded9e22a2c4101a2 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 22 Apr 2011 10:21:31 +0200 Subject: [PATCH 1/4] fix unexpected "no response" message after failed calls --- coreapi/sal_eXosip2.c | 1 + mediastreamer2 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 16999e15c..0c644d284 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -1269,6 +1269,7 @@ static bool_t call_failure(Sal *sal, eXosip_event_t *ev){ sr=SalReasonUnknown; }else error=SalErrorNoResponse; } + op->terminated=TRUE; sal->callbacks.call_failure(op,error,sr,reason,code); if (computedReason != NULL){ ms_free(computedReason); diff --git a/mediastreamer2 b/mediastreamer2 index c9f3208df..3564b6ff2 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit c9f3208dfa0657a5d97870b80d1e2e5d9b080acc +Subproject commit 3564b6ff2ca81094706348ce7be621a5c08c336a From 9fe0c5b8d222e2aaf2ce3af08ab623209e26138a Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 22 Apr 2011 14:23:35 +0200 Subject: [PATCH 2/4] display MSTicker's load each second --- coreapi/linphonecall.c | 58 ++++++++++++++++++++++++++++++++++++++++++ coreapi/linphonecore.c | 49 +---------------------------------- coreapi/private.h | 2 ++ mediastreamer2 | 2 +- 4 files changed, 62 insertions(+), 49 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 8c480fbb9..be0cc7cad 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1121,3 +1121,61 @@ float linphone_call_get_record_volume(LinphoneCall *call){ return LINPHONE_VOLUME_DB_LOWEST; } + +static void display_bandwidth(RtpSession *as, RtpSession *vs){ + ms_message("bandwidth usage: audio=[d=%.1f,u=%.1f] video=[d=%.1f,u=%.1f] kbit/sec", + (as!=NULL) ? (rtp_session_compute_recv_bandwidth(as)*1e-3) : 0, + (as!=NULL) ? (rtp_session_compute_send_bandwidth(as)*1e-3) : 0, + (vs!=NULL) ? (rtp_session_compute_recv_bandwidth(vs)*1e-3) : 0, + (vs!=NULL) ? (rtp_session_compute_send_bandwidth(vs)*1e-3) : 0); +} + +static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){ + char temp[256]; + char *from=NULL; + 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,temp); + linphone_core_terminate_call(lc,call); +} + +void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapsed){ + int disconnect_timeout = linphone_core_get_nortp_timeout(call->core); + bool_t disconnected=FALSE; + + if (call->state==LinphoneCallStreamsRunning && one_second_elapsed){ + RtpSession *as=NULL,*vs=NULL; + float audio_load=0, video_load=0; + if (call->audiostream!=NULL){ + as=call->audiostream->session; + if (call->audiostream->ticker) + audio_load=ms_ticker_get_average_load(call->audiostream->ticker); + } + if (call->videostream!=NULL){ + if (call->videostream->ticker) + video_load=ms_ticker_get_average_load(call->videostream->ticker); + vs=call->videostream->session; + } + display_bandwidth(as,vs); + ms_message("Thread processing load: audio=%f\tvideo=%f",audio_load,video_load); + } +#ifdef VIDEO_ENABLED + if (call->videostream!=NULL) + video_stream_iterate(call->videostream); +#endif + if (one_second_elapsed && call->audiostream!=NULL && disconnect_timeout>0 ) + disconnected=!audio_stream_alive(call->audiostream,disconnect_timeout); + if (disconnected) + linphone_core_disconnected(call->core,call); +} + diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index ee6bdc7e2..873a3da79 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1487,32 +1487,6 @@ void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val){ } } -static void display_bandwidth(RtpSession *as, RtpSession *vs){ - ms_message("bandwidth usage: audio=[d=%.1f,u=%.1f] video=[d=%.1f,u=%.1f] kbit/sec", - (as!=NULL) ? (rtp_session_compute_recv_bandwidth(as)*1e-3) : 0, - (as!=NULL) ? (rtp_session_compute_send_bandwidth(as)*1e-3) : 0, - (vs!=NULL) ? (rtp_session_compute_recv_bandwidth(vs)*1e-3) : 0, - (vs!=NULL) ? (rtp_session_compute_send_bandwidth(vs)*1e-3) : 0); -} - -static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){ - char temp[256]; - char *from=NULL; - 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,temp); - linphone_core_terminate_call(lc,call); -} static void monitor_network_state(LinphoneCore *lc, time_t curtime){ static time_t last_check=0; @@ -1639,11 +1613,9 @@ static void linphone_core_do_plugin_tasks(LinphoneCore *lc){ void linphone_core_iterate(LinphoneCore *lc){ MSList *calls; LinphoneCall *call; - int disconnect_timeout = linphone_core_get_nortp_timeout(lc); time_t curtime=time(NULL); int elapsed; bool_t one_second_elapsed=FALSE; - bool_t disconnected=FALSE; if (curtime-lc->prevtime>=1){ lc->prevtime=curtime; @@ -1706,24 +1678,7 @@ void linphone_core_iterate(LinphoneCore *lc){ } call = linphone_core_get_current_call(lc); if(call) - { - if (call->state==LinphoneCallStreamsRunning && one_second_elapsed) - { - RtpSession *as=NULL,*vs=NULL; - lc->prevtime=curtime; - if (call->audiostream!=NULL) - as=call->audiostream->session; - if (call->videostream!=NULL) - vs=call->videostream->session; - display_bandwidth(as,vs); - } -#ifdef VIDEO_ENABLED - if (call->videostream!=NULL) - video_stream_iterate(call->videostream); -#endif - if (call->audiostream!=NULL && disconnect_timeout>0) - disconnected=!audio_stream_alive(call->audiostream,disconnect_timeout); - } + linphone_call_background_tasks(call,one_second_elapsed); if (linphone_core_video_preview_enabled(lc)){ if (lc->previewstream==NULL && lc->calls==NULL) toggle_video_preview(lc,TRUE); @@ -1734,8 +1689,6 @@ void linphone_core_iterate(LinphoneCore *lc){ if (lc->previewstream!=NULL) toggle_video_preview(lc,FALSE); } - if (disconnected) - linphone_core_disconnected(lc,call); linphone_core_run_hooks(lc); linphone_core_do_plugin_tasks(lc); diff --git a/coreapi/private.h b/coreapi/private.h index 4fc4db22d..df086213c 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -480,6 +480,8 @@ LinphoneEcCalibratorStatus ec_calibrator_get_status(EcCalibrator *ecc); void ec_calibrator_destroy(EcCalibrator *ecc); +void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapsed); + #define HOLD_OFF (0) #define HOLD_ON (1) diff --git a/mediastreamer2 b/mediastreamer2 index 3564b6ff2..bbde91a40 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 3564b6ff2ca81094706348ce7be621a5c08c336a +Subproject commit bbde91a403ae91f115058ff0ed9de90137d0b6f9 From 6cf6ce675dd84b10e019759bfe2b181513e95f7d Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 22 Apr 2011 21:05:08 +0200 Subject: [PATCH 3/4] fix stack overflow with linphonec without readline, asking for password --- console/linphonec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/console/linphonec.c b/console/linphonec.c index de3ce9e44..38cf24f28 100644 --- a/console/linphonec.c +++ b/console/linphonec.c @@ -794,11 +794,17 @@ linphonec_finish(int exit_status) int linphonec_prompt_for_auth_final(LinphoneCore *lc) { + static int reentrancy=0; char *input, *iptr; char auth_prompt[256]; #ifdef HAVE_READLINE rl_hook_func_t *old_event_hook; #endif + + if (reentrancy!=0) return 0; + + reentrancy++; + LinphoneAuthInfo *pending_auth=auth_stack.elem[auth_stack.nitems-1]; snprintf(auth_prompt, 256, "Password for %s on %s: ", From b18c4f3e3fd3348c6d0525b5e0f8e6beeebb44c4 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 4 May 2011 18:59:28 +0200 Subject: [PATCH 4/4] add an option to write logs into a file supplied from command line (--logfile) --- configure.ac | 3 +- gtk/linphone.h | 4 ++ gtk/logging.c | 118 +++++++++++++++++++++++-------------------------- gtk/main.c | 9 ++++ mediastreamer2 | 2 +- 5 files changed, 72 insertions(+), 64 deletions(-) diff --git a/configure.ac b/configure.ac index 06303cc27..562ba97e0 100644 --- a/configure.ac +++ b/configure.ac @@ -384,8 +384,9 @@ AC_ARG_ENABLE(strict, strictness="${enableval}"],[strictness=yes] ) +STRICT_OPTIONS="-Wall " + if test "$GCC$strictness" = "yesyes" ; then - STRICT_OPTIONS="-Wall " STRICT_OPTIONS="$STRICT_OPTIONS -Werror" CFLAGS="$CFLAGS -fno-strict-aliasing" fi diff --git a/gtk/linphone.h b/gtk/linphone.h index d726c0db1..f76f1b6a8 100644 --- a/gtk/linphone.h +++ b/gtk/linphone.h @@ -108,3 +108,7 @@ void linphone_gtk_enable_transfer_button(LinphoneCore *lc, gboolean value); void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg); void linphone_gtk_exit_login_frame(void); void linphone_gtk_set_ui_config(const char *key, const char *value); + +void linphone_gtk_log_uninit(); + + diff --git a/gtk/logging.c b/gtk/logging.c index 522308068..ebadeedfc 100644 --- a/gtk/logging.c +++ b/gtk/logging.c @@ -24,10 +24,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #endif +extern gchar *linphone_logfile; static GtkWidget *log_window=NULL; static GStaticMutex log_mutex=G_STATIC_MUTEX_INIT; static GList *log_queue=NULL; +static const char *dateformat="%Y%m%d-%H:%M:%S"; #define LOG_MAX_CHARS 1000000 /*1 mega bytes of traces*/ @@ -54,7 +56,7 @@ static FILE *_logfile = NULL; /* Called on exit, print out the marker, close the file and avoid to continue logging. */ -static void linphone_gtk_log_uninit() +void linphone_gtk_log_uninit() { if (_logfile != NULL) { fprintf(_logfile, "%s\n", LOGFILE_MARKER_STOP); @@ -72,10 +74,13 @@ static FILE *linphone_gtk_log_init() static char _logdir[1024]; static char _logfname[1024]; static gboolean _log_init = FALSE; - const char *dst_fname; + const char *dst_fname=NULL; if (!_log_init) { - dst_fname = linphone_gtk_get_ui_config("logfile",NULL); + if (linphone_gtk_get_core()!=NULL){ + dst_fname = linphone_gtk_get_ui_config("logfile",NULL); + dateformat=linphone_gtk_get_ui_config("logfile_date_format",dateformat); + } /* For anything to happen, we need a logfile configuration variable, this is our trigger */ if (dst_fname) { @@ -101,51 +106,55 @@ static FILE *linphone_gtk_log_init() } #define PATH_SEPARATOR '/' #endif - /* We have a directory, fix the path to the log file in it and - open the file so that we will be appending to it. */ if (_logdir[0] != '\0') { - snprintf(_logfname, sizeof(_logfname), "%s%c%s", - _logdir, PATH_SEPARATOR, dst_fname); - /* If the constant LOGFILE_ROTATION is greater than zero, then - we kick away a simple rotation that will ensure that there - are never more than LOGFILE_ROTATION+1 old copies of the - log file on the disk. The oldest file is always rotated - "away" as expected. Rotated files have the same name as - the main log file, though with a number 0..LOGFILE_ROTATION - at the end, where the greater the number is, the older the - file is. */ - if (ortp_file_exist(_logfname)==0 && LOGFILE_ROTATION > 0) { - int i; - char old_fname[1024]; - char new_fname[1024]; - - /* Rotate away existing files. We make sure to remove the - old files otherwise rename() would not work properly. We - have to loop in reverse here. */ - for (i=LOGFILE_ROTATION-1;i>=0;i--) { - snprintf(old_fname, sizeof(old_fname), "%s%c%s.%d", - _logdir, PATH_SEPARATOR, dst_fname, i); - snprintf(new_fname, sizeof(new_fname), "%s%c%s.%d", - _logdir, PATH_SEPARATOR, dst_fname, i+1); - if (ortp_file_exist(old_fname)==0) { - if (ortp_file_exist(new_fname)==0) - unlink(new_fname); - rename(old_fname, new_fname); - } - } - /* Move current log file as the first of the rotation. Make - sure to remove the old .0 also, since otherwise rename() - would not work as expected. */ - snprintf(new_fname, sizeof(new_fname), "%s%c%s.%d", - _logdir, PATH_SEPARATOR, dst_fname, 0); - if (ortp_file_exist(new_fname)==0) - unlink(new_fname); - rename(_logfname, new_fname); - } - /* Start a new log file and mark that we have now initialised */ - _logfile = fopen(_logfname, "w"); - fprintf(_logfile, "%s\n", LOGFILE_MARKER_START); + /* We have a directory, fix the path to the log file in it and + open the file so that we will be appending to it. */ + snprintf(_logfname, sizeof(_logfname), "%s%c%s",_logdir, PATH_SEPARATOR, dst_fname); } + }else if (linphone_logfile!=NULL){ + snprintf(_logfname,sizeof(_logfname),"%s",linphone_logfile); + } + + if (_logfname[0]!='\0'){ + /* If the constant LOGFILE_ROTATION is greater than zero, then + we kick away a simple rotation that will ensure that there + are never more than LOGFILE_ROTATION+1 old copies of the + log file on the disk. The oldest file is always rotated + "away" as expected. Rotated files have the same name as + the main log file, though with a number 0..LOGFILE_ROTATION + at the end, where the greater the number is, the older the + file is. */ + if (ortp_file_exist(_logfname)==0 && LOGFILE_ROTATION > 0) { + int i; + char old_fname[1024]; + char new_fname[1024]; + + /* Rotate away existing files. We make sure to remove the + old files otherwise rename() would not work properly. We + have to loop in reverse here. */ + for (i=LOGFILE_ROTATION-1;i>=0;i--) { + snprintf(old_fname, sizeof(old_fname), "%s%c%s.%d", + _logdir, PATH_SEPARATOR, dst_fname, i); + snprintf(new_fname, sizeof(new_fname), "%s%c%s.%d", + _logdir, PATH_SEPARATOR, dst_fname, i+1); + if (ortp_file_exist(old_fname)==0) { + if (ortp_file_exist(new_fname)==0) + unlink(new_fname); + rename(old_fname, new_fname); + } + } + /* Move current log file as the first of the rotation. Make + sure to remove the old .0 also, since otherwise rename() + would not work as expected. */ + snprintf(new_fname, sizeof(new_fname), "%s%c%s.%d", + _logdir, PATH_SEPARATOR, dst_fname, 0); + if (ortp_file_exist(new_fname)==0) + unlink(new_fname); + rename(_logfname, new_fname); + } + /* Start a new log file and mark that we have now initialised */ + _logfile = fopen(_logfname, "w"); + fprintf(_logfile, "%s\n", LOGFILE_MARKER_START); } _log_init = TRUE; } @@ -154,33 +163,18 @@ static FILE *linphone_gtk_log_init() static void linphone_gtk_log_file(OrtpLogLevel lev, const char *msg) { - LinphoneCore *lc; time_t now; FILE *outlog; - lc = linphone_gtk_get_core(); - /* Nothing to do until the core has initialised */ - if (lc == NULL) - return; - - /* lc->config will turn NULL at exit, close the file to flush and - return to stop logging */ - if (linphone_core_get_config(lc) == NULL) { - linphone_gtk_log_uninit(); - return; - } - outlog = linphone_gtk_log_init(); if (outlog != NULL) { /* We have an opened file and we have initialised properly, it's time to write all these log messages. We convert the log level from oRTP into something readable and timestamp each log - message. The format of the timestamp can be controlled by + message. The format of the time stamp can be controlled by logfile_date_format in the GtkUi section of the config file, but it defaults to something compact, but yet readable. */ const char *lname="undef"; - const char *dateformat=linphone_gtk_get_ui_config("logfile_date_format", - "%Y%m%d-%H:%M:%S"); char date[256]; /* Convert level constant to text */ diff --git a/gtk/main.c b/gtk/main.c index 9adec52e8..622feca0d 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -64,6 +64,7 @@ static gchar * addr_to_call = NULL; static gboolean iconified=FALSE; static gchar *workingdir=NULL; static char *progpath=NULL; +gchar *linphone_logfile=NULL; static GOptionEntry linphone_options[]={ { @@ -73,6 +74,13 @@ static GOptionEntry linphone_options[]={ .arg_data= (gpointer)&verbose, .description=N_("log to stdout some debug information while running.") }, + { + .long_name = "logfile", + .short_name = 'l', + .arg = G_OPTION_ARG_STRING, + .arg_data = &linphone_logfile, + .description = N_("path to a file to write logs into.") + }, { .long_name="iconified", .short_name= '\0', @@ -1492,6 +1500,7 @@ int main(int argc, char *argv[]){ gdk_threads_leave(); linphone_gtk_destroy_log_window(); linphone_core_destroy(the_core); + linphone_gtk_log_uninit(); #ifndef HAVE_GTK_OSX /*workaround a bug on win32 that makes status icon still present in the systray even after program exit.*/ gtk_status_icon_set_visible(icon,FALSE); diff --git a/mediastreamer2 b/mediastreamer2 index bbde91a40..c73bc0d25 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit bbde91a403ae91f115058ff0ed9de90137d0b6f9 +Subproject commit c73bc0d25b29ee535c687869d7c98a69d805d1f0