diff --git a/linphone/console/commands.c b/linphone/console/commands.c index 1dd464f27..774f6134c 100644 --- a/linphone/console/commands.c +++ b/linphone/console/commands.c @@ -59,6 +59,8 @@ static int lpc_cmd_soundcard(LinphoneCore *, char *); static int lpc_cmd_play(LinphoneCore *, char *); static int lpc_cmd_record(LinphoneCore *, char *); static int lpc_cmd_register(LinphoneCore *, char *); +static int lpc_cmd_duration(LinphoneCore *lc, char *args); + /* Command handler helpers */ static void linphonec_proxy_add(LinphoneCore *lc); static void linphonec_proxy_display(LinphoneProxyConfig *lc); @@ -156,7 +158,8 @@ LPC_COMMAND commands[] = { "'record ' : record into wav file." }, { "quit", lpc_cmd_quit, "Exit linphonec", NULL }, - { "register", lpc_cmd_register, "register ", NULL }, + { "register", lpc_cmd_register, "Register in one line to a proxy" , "register "}, + { "duration", lpc_cmd_duration, "Print duration in seconds of the last call.", NULL }, { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL } }; @@ -1158,6 +1161,18 @@ static int lpc_cmd_register(LinphoneCore *lc, char *args){ return 1; } +int lpc_cmd_duration(LinphoneCore *lc, char *args){ + LinphoneCallLog *cl; + const MSList *elem=linphone_core_get_call_logs(lc); + for(;elem!=NULL;elem=elem->next){ + if (elem->next==NULL){ + cl=(LinphoneCallLog*)elem->data; + linphonec_out("%i seconds\n",cl->duration); + } + } + return 1; +} + /*************************************************************************** * * Command table management funx diff --git a/linphone/console/shell.c b/linphone/console/shell.c index 0b4f6282c..da972d6b7 100644 --- a/linphone/console/shell.c +++ b/linphone/console/shell.c @@ -203,6 +203,9 @@ int main(int argc, char *argv[]){ return register_execute(argc-argi-1,&argv[argi+1]); }else if (strcmp(argv[argi],"dial")==0){ return dial_execute(argc-argi-1,&argv[argi+1]); + }else if (strcmp(argv[argi],"hangup")==0){ + send_generic_command("terminate",FALSE); + send_generic_command("duration",TRUE); } } return 0; diff --git a/linphone/mediastreamer2/include/mediastreamer2/msticker.h b/linphone/mediastreamer2/include/mediastreamer2/msticker.h index d13bc2e30..ed523e426 100644 --- a/linphone/mediastreamer2/include/mediastreamer2/msticker.h +++ b/linphone/mediastreamer2/include/mediastreamer2/msticker.h @@ -60,6 +60,7 @@ struct _MSTicker uint64_t orig; /* a relative time to take in account difference between time base given by consecutive get_cur_time_ptr() functions.*/ MSTickerTimeFunc get_cur_time_ptr; void *get_cur_time_data; + char *name; bool_t run; /* flag to indicate whether the ticker must be run or not */ #ifdef WIN32_TIMERS HANDLE TimeEvent; @@ -86,6 +87,11 @@ extern "C"{ */ MSTicker *ms_ticker_new(void); +/** + * Set a name to the ticker (used for logging) +**/ +void ms_ticker_set_name(MSTicker *ticker, const char *name); + /** * Attach a chain of filters to a ticker. * The processing chain will be executed until ms_ticker_detach diff --git a/linphone/mediastreamer2/src/audiostream.c b/linphone/mediastreamer2/src/audiostream.c index 376e6c02c..473b0aff3 100644 --- a/linphone/mediastreamer2/src/audiostream.c +++ b/linphone/mediastreamer2/src/audiostream.c @@ -279,7 +279,7 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char /* create ticker */ stream->ticker=ms_ticker_new(); - + ms_ticker_set_name(stream->ticker,"Audio MSTicker"); ms_ticker_attach(stream->ticker,stream->soundread); ms_ticker_attach(stream->ticker,stream->rtprecv); @@ -423,6 +423,7 @@ RingStream * ring_start_with_cb(const char *file,int interval,MSSndCard *sndcard ms_filter_call_method(stream->source,MS_FILTER_GET_NCHANNELS,&tmp); ms_filter_call_method(stream->sndwrite,MS_FILTER_SET_NCHANNELS,&tmp); stream->ticker=ms_ticker_new(); + ms_ticker_set_name(stream->ticker,"Audio (ring) MSTicker"); ms_filter_link(stream->source,0,stream->sndwrite,0); ms_ticker_attach(stream->ticker,stream->source); return stream; diff --git a/linphone/mediastreamer2/src/msticker.c b/linphone/mediastreamer2/src/msticker.c index 55672bd87..83c15bb1a 100644 --- a/linphone/mediastreamer2/src/msticker.c +++ b/linphone/mediastreamer2/src/msticker.c @@ -45,6 +45,7 @@ void ms_ticker_init(MSTicker *ticker) #ifdef WIN32_TIMERS ticker->TimeEvent=NULL; #endif + ticker->name=ms_strdup("MSTicker"); ms_ticker_start(ticker); } @@ -61,10 +62,15 @@ void ms_ticker_stop(MSTicker *s){ ms_thread_join(s->thread,NULL); } +void ms_ticker_set_name(MSTicker *s, const char *name){ + if (s->name) ms_free(s->name); + s->name=ms_strdup(name); +} void ms_ticker_uninit(MSTicker *ticker) { ms_ticker_stop(ticker); + ms_free(ticker->name); ms_mutex_destroy(&ticker->lock); } @@ -349,7 +355,7 @@ void * ms_ticker_run(void *arg) }else{ late=-diff; if (late>s->interval*5 && late>lastlate){ - ms_warning("We are late of %d miliseconds.",late); + ms_warning("%s: We are late of %d miliseconds.",s->name,late); } lastlate=late; break; /*exit the while loop */ @@ -360,7 +366,7 @@ void * ms_ticker_run(void *arg) } ms_mutex_unlock(&s->lock); unset_high_prio(precision); - ms_message("MSTicker thread exiting"); + ms_message("%s thread exiting",s->name); ms_thread_exit(NULL); return NULL; diff --git a/linphone/mediastreamer2/src/videostream.c b/linphone/mediastreamer2/src/videostream.c index 82d7a4b7c..92faf54a9 100644 --- a/linphone/mediastreamer2/src/videostream.c +++ b/linphone/mediastreamer2/src/videostream.c @@ -306,7 +306,8 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re ms_filter_link(stream->tee,1,stream->output,1); /* create the ticker */ - stream->ticker = ms_ticker_new(); + stream->ticker = ms_ticker_new(); + ms_ticker_set_name(stream->ticker,"Video MSTicker"); /* attach it the graph */ ms_ticker_attach (stream->ticker, stream->source); return 0; @@ -390,7 +391,8 @@ VideoStream * video_preview_start(MSWebCam *device, MSVideoSize disp_size){ ms_filter_link(stream->pixconv, 0, stream->output, 0); /* create the ticker */ - stream->ticker = ms_ticker_new(); + stream->ticker = ms_ticker_new(); + ms_ticker_set_name(stream->ticker,"Video MSTicker"); ms_ticker_attach (stream->ticker, stream->source); return stream; }