diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 272b2eb84..9052f71c7 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1325,7 +1325,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const break; case LinphoneCallConnected: call->log->status=LinphoneCallSuccess; - call->log->connected_date_time=time(NULL); + call->log->connected_date_time = ms_time(NULL); break; case LinphoneCallReleased: #ifdef ANDROID @@ -1726,7 +1726,7 @@ bool_t linphone_call_has_transfer_pending(const LinphoneCall *call){ **/ int linphone_call_get_duration(const LinphoneCall *call){ if (call->log->connected_date_time==0) return 0; - return time(NULL)-call->log->connected_date_time; + return ms_time(NULL)-call->log->connected_date_time; } /** @@ -3638,18 +3638,17 @@ static void report_bandwidth(LinphoneCall *call, MediaStream *as, MediaStream *v call->stats[LINPHONE_CALL_STATS_AUDIO].rtcp_upload_bandwidth=(as_active) ? (media_stream_get_rtcp_up_bw(as)*1e-3) : 0; call->stats[LINPHONE_CALL_STATS_VIDEO].rtcp_download_bandwidth=(vs_active) ? (media_stream_get_rtcp_down_bw(vs)*1e-3) : 0; call->stats[LINPHONE_CALL_STATS_VIDEO].rtcp_upload_bandwidth=(vs_active) ? (media_stream_get_rtcp_up_bw(vs)*1e-3) : 0; - if (as_active) { - call->stats[LINPHONE_CALL_STATS_AUDIO].updated|=LINPHONE_CALL_STATS_PERIODICAL_UPDATE; - linphone_core_notify_call_stats_updated(call->core, call, &call->stats[LINPHONE_CALL_STATS_AUDIO]); - call->stats[LINPHONE_CALL_STATS_AUDIO].updated=0; - update_local_stats(&call->stats[LINPHONE_CALL_STATS_AUDIO], as); - } - if (vs_active) { - call->stats[LINPHONE_CALL_STATS_VIDEO].updated|=LINPHONE_CALL_STATS_PERIODICAL_UPDATE; - linphone_core_notify_call_stats_updated(call->core, call, &call->stats[LINPHONE_CALL_STATS_VIDEO]); - call->stats[LINPHONE_CALL_STATS_VIDEO].updated=0; - update_local_stats(&call->stats[LINPHONE_CALL_STATS_VIDEO], vs); - } + + call->stats[LINPHONE_CALL_STATS_AUDIO].updated|=LINPHONE_CALL_STATS_PERIODICAL_UPDATE; + linphone_core_notify_call_stats_updated(call->core, call, &call->stats[LINPHONE_CALL_STATS_AUDIO]); + call->stats[LINPHONE_CALL_STATS_AUDIO].updated=0; + update_local_stats(&call->stats[LINPHONE_CALL_STATS_AUDIO], as); + + call->stats[LINPHONE_CALL_STATS_VIDEO].updated|=LINPHONE_CALL_STATS_PERIODICAL_UPDATE; + linphone_core_notify_call_stats_updated(call->core, call, &call->stats[LINPHONE_CALL_STATS_VIDEO]); + call->stats[LINPHONE_CALL_STATS_VIDEO].updated=0; + update_local_stats(&call->stats[LINPHONE_CALL_STATS_VIDEO], vs); + ms_message( "Bandwidth usage for call [%p]:\n" "\tRTP audio=[d=%5.1f,u=%5.1f], video=[d=%5.1f,u=%5.1f] kbits/sec\n" diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 057e27388..0133d2056 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2397,10 +2397,12 @@ static void linphone_core_do_plugin_tasks(LinphoneCore *lc){ void linphone_core_iterate(LinphoneCore *lc){ MSList *calls; LinphoneCall *call; - time_t curtime=time(NULL); + uint64_t curtime_ms = ms_get_cur_time_ms(); /*monotonic time*/ int elapsed; + time_t current_real_time = ms_time(NULL); bool_t one_second_elapsed=FALSE; const char *remote_provisioning_uri = NULL; + if (lc->network_reachable_to_be_notified) { lc->network_reachable_to_be_notified=FALSE; linphone_core_notify_network_reachable(lc,lc->network_reachable); @@ -2423,9 +2425,11 @@ void linphone_core_iterate(LinphoneCore *lc){ } } // else linphone_configuring_terminated has already been called in linphone_core_init } - - if (curtime-lc->prevtime>=1){ - lc->prevtime=curtime; + if (lc->prevtime_ms == 0){ + lc->prevtime_ms = curtime_ms; + } + if (curtime_ms-lc->prevtime_ms >= 1000){ + lc->prevtime_ms += 1000; one_second_elapsed=TRUE; } @@ -2457,7 +2461,7 @@ void linphone_core_iterate(LinphoneCore *lc){ } if (lc->ringstream && lc->ringstream_autorelease && lc->dmfs_playing_start_time!=0 - && (curtime-lc->dmfs_playing_start_time)>5){ + && (curtime_ms/1000 - lc->dmfs_playing_start_time)>5){ MSPlayerState state; bool_t stop=TRUE; if (lc->ringstream->source && ms_filter_call_method(lc->ringstream->source,MS_PLAYER_GET_STATE,&state)==0){ @@ -2471,15 +2475,15 @@ void linphone_core_iterate(LinphoneCore *lc){ sal_iterate(lc->sal); if (lc->msevq) ms_event_queue_pump(lc->msevq); - if (lc->auto_net_state_mon) monitor_network_state(lc,curtime); + if (lc->auto_net_state_mon) monitor_network_state(lc, current_real_time); proxy_update(lc); //we have to iterate for each call - calls= lc->calls; + calls = lc->calls; while(calls!= NULL){ call = (LinphoneCall *)calls->data; - elapsed = curtime-call->log->start_date_time; + elapsed = current_real_time - call->log->start_date_time; /* get immediately a reference to next one in case the one we are going to examine is destroy and removed during linphone_core_start_invite() */ @@ -2514,7 +2518,7 @@ void linphone_core_iterate(LinphoneCore *lc){ } if ( (lc->sip_conf.in_call_timeout > 0) && (call->log->connected_date_time != 0) - && ((curtime - call->log->connected_date_time) > lc->sip_conf.in_call_timeout)) + && ((current_real_time - call->log->connected_date_time) > lc->sip_conf.in_call_timeout)) { ms_message("in call timeout (%i)",lc->sip_conf.in_call_timeout); linphone_core_terminate_call(lc,call); @@ -2535,7 +2539,7 @@ void linphone_core_iterate(LinphoneCore *lc){ linphone_core_run_hooks(lc); linphone_core_do_plugin_tasks(lc); - if (lc->network_reachable && lc->netup_time!=0 && (curtime-lc->netup_time)>3){ + if (lc->network_reachable && lc->netup_time!=0 && (current_real_time-lc->netup_time)>3){ /*not do that immediately, take your time.*/ linphone_core_send_initial_subscribes(lc); } @@ -5760,11 +5764,11 @@ static MSFilter *get_audio_resource(LinphoneCore *lc, LinphoneAudioResourceType ringstream=lc->ringstream=ring_start(NULL,0,ringcard); ms_filter_call_method(lc->ringstream->gendtmf,MS_DTMF_GEN_SET_DEFAULT_AMPLITUDE,&); - lc->dmfs_playing_start_time=time(NULL); + lc->dmfs_playing_start_time = ms_get_cur_time_ms()/1000; }else{ ringstream=lc->ringstream; if (lc->dmfs_playing_start_time!=0) - lc->dmfs_playing_start_time=time(NULL); + lc->dmfs_playing_start_time = ms_get_cur_time_ms()/1000; } if (rtype==LinphoneToneGenerator) return ringstream->gendtmf; if (rtype==LinphoneLocalPlayer) return ringstream->source; diff --git a/coreapi/private.h b/coreapi/private.h index 3766edb4d..142e2c3cc 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -811,7 +811,7 @@ struct _LinphoneCore void *data; char *play_file; char *rec_file; - time_t prevtime; + uint64_t prevtime_ms; int audio_bw; /*IP bw consumed by audio codec, set as soon as used codec is known, its purpose is to know the remaining bw for video*/ LinphoneCoreWaitingCallback wait_cb; void *wait_ctx; diff --git a/tester/call_tester.c b/tester/call_tester.c index 8bb779436..229aa14fc 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -3332,9 +3332,10 @@ void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, MSList* switch (audio_dir) { case LinphoneMediaDirectionInactive: BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_up_bw(mgr), 5, int, "%i"); + BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_down_bw(mgr), 5, int, "%i"); + break; case LinphoneMediaDirectionSendOnly: - BC_ASSERT_LOWER(linphone_call_get_video_stats(call)->download_bandwidth, 5, int, "%i"); - BC_ASSERT_TRUE(wait_for_list(lcs,mgr->stat.current_audio_upload_bandwidth,70,4000)); + BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_up_bw(mgr), 70, int, "%i"); break; case LinphoneMediaDirectionRecvOnly: BC_ASSERT_LOWER(linphone_core_manager_get_mean_audio_up_bw(mgr), 5, int, "%i");