From a554ad1c911d598c9d27f066d2771cef3678aca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Mon, 11 Sep 2017 14:41:42 +0200 Subject: [PATCH] Add estimated download bandwith stat for video calls --- coreapi/linphonecall.c | 11 +++++++++-- coreapi/linphonecore_jni.cc | 4 ++++ coreapi/private.h | 1 + gtk/incall_view.c | 5 ++++- include/linphone/call_stats.h | 7 +++++++ java/common/org/linphone/core/LinphoneCallStats.java | 6 ++++++ .../impl/org/linphone/core/LinphoneCallStatsImpl.java | 7 +++++++ 7 files changed, 38 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 3d81d539b..d89414bba 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -4514,6 +4514,10 @@ float linphone_call_stats_get_upload_bandwidth(const LinphoneCallStats *stats) { return stats->upload_bandwidth; } +float linphone_call_stats_get_estimated_download_bandwidth(const LinphoneCallStats *stats) { + return stats->estimated_download_bandwidth; +} + LinphoneIceState linphone_call_stats_get_ice_state(const LinphoneCallStats *stats) { return stats->ice_state; } @@ -4586,13 +4590,14 @@ static void report_bandwidth(LinphoneCall *call, MediaStream *as, MediaStream *v report_bandwidth_for_stream(call, ts, LinphoneStreamTypeText); ms_message( "Bandwidth usage for call [%p]:\n" - "\tRTP audio=[d=%5.1f,u=%5.1f], video=[d=%5.1f,u=%5.1f], text=[d=%5.1f,u=%5.1f] kbits/sec\n" + "\tRTP audio=[d=%5.1f,u=%5.1f], video=[d=%5.1f,u=%5.1f, ed=%5.1f], text=[d=%5.1f,u=%5.1f] kbits/sec\n" "\tRTCP audio=[d=%5.1f,u=%5.1f], video=[d=%5.1f,u=%5.1f], text=[d=%5.1f,u=%5.1f] kbits/sec", call, call->audio_stats->download_bandwidth, call->audio_stats->upload_bandwidth, call->video_stats->download_bandwidth, call->video_stats->upload_bandwidth, + call->video_stats->estimated_download_bandwidth, call->text_stats->download_bandwidth, call->text_stats->upload_bandwidth, call->audio_stats->rtcp_download_bandwidth, @@ -4852,7 +4857,9 @@ void linphone_call_handle_stream_events(LinphoneCall *call, int stream_index){ linphone_core_dtmf_received(call,evd->info.telephone_event); } else if (evt == ORTP_EVENT_NEW_VIDEO_BANDWIDTH_ESTIMATION_AVAILABLE) { ms_message("Video bandwidth estimation is %i kbit/s", (int)evd->info.video_bandwidth_available / 1000); - //TODO + /* If this event happens then it should be a video stream */ + if (stream_index == call->main_video_stream_index) + stats->estimated_download_bandwidth = (float)(evd->info.video_bandwidth_available)*1e-3; } ortp_event_destroy(ev); } diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index c6f063c54..4fa7aada0 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -3447,6 +3447,10 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getUploadBandwidt LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; return (jfloat)linphone_call_stats_get_upload_bandwidth(stats); } +extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getEstimatedDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) { + LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; + return (jfloat)linphone_call_stats_get_estimated_download_bandwidth(stats); +} extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) { LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; return (jfloat) linphone_call_stats_get_sender_loss_rate(stats); diff --git a/coreapi/private.h b/coreapi/private.h index 8d4c02c1a..46c0d663f 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1819,6 +1819,7 @@ struct _LinphoneCallStats { LinphoneUpnpState upnp_state; /**< State of uPnP processing. */ float download_bandwidth; /**