From 9fe0c5b8d222e2aaf2ce3af08ab623209e26138a Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 22 Apr 2011 14:23:35 +0200 Subject: [PATCH] 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