]> sjero.net Git - linphone/commitdiff
display MSTicker's load each second
authorSimon Morlat <simon.morlat@linphone.org>
Fri, 22 Apr 2011 12:23:35 +0000 (14:23 +0200)
committerSimon Morlat <simon.morlat@linphone.org>
Fri, 22 Apr 2011 12:23:35 +0000 (14:23 +0200)
coreapi/linphonecall.c
coreapi/linphonecore.c
coreapi/private.h
mediastreamer2

index 8c480fbb9a188b8edaecaefc5c96fd1d9a1c8f5f..be0cc7cadc8b8bbc09c9c1e17aed0d1b0a7b6039 100644 (file)
@@ -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);
+}
+
index ee6bdc7e251cdd511e0c33bbd9dc50becee2d2ab..873a3da7935204daae2b6700babadc63c0bd82f9 100644 (file)
@@ -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);
index 4fc4db22d6e56e4fbc9238bdad51b0bb9dd454b5..df086213c1007b9ccea1fc29098b9ab1e5c08945 100644 (file)
@@ -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)
 
index 3564b6ff2ca81094706348ce7be621a5c08c336a..bbde91a403ae91f115058ff0ed9de90137d0b6f9 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 3564b6ff2ca81094706348ce7be621a5c08c336a
+Subproject commit bbde91a403ae91f115058ff0ed9de90137d0b6f9