diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 49450e0a8..6feb1ddc6 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -3438,6 +3438,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/include/linphone/api/c-call-stats.h b/include/linphone/api/c-call-stats.h index fb00a6174..9192fdd4c 100644 --- a/include/linphone/api/c-call-stats.h +++ b/include/linphone/api/c-call-stats.h @@ -191,6 +191,13 @@ LINPHONE_PUBLIC float linphone_call_stats_get_jitter_buffer_size_ms (const Linph */ LINPHONE_PUBLIC float linphone_call_stats_get_round_trip_delay (const LinphoneCallStats *stats); +/** + * Get the estimated bandwidth measurement of the received stream, expressed in kbit/s, including IP/UDP/RTP headers. + * @param[in] stats LinphoneCallStats object + * @return The estimated bandwidth measurement of the received stream in kbit/s. + */ +LINPHONE_PUBLIC float linphone_call_stats_get_estimated_download_bandwidth(const LinphoneCallStats *stats); + /** * @} */ diff --git a/java/common/org/linphone/core/LinphoneCallStats.java b/java/common/org/linphone/core/LinphoneCallStats.java index dbb23406d..9210b8002 100644 --- a/java/common/org/linphone/core/LinphoneCallStats.java +++ b/java/common/org/linphone/core/LinphoneCallStats.java @@ -139,6 +139,12 @@ public interface LinphoneCallStats { * @return The upload bandwidth */ public float getUploadBandwidth(); + + /** + * Get the estimated download bandwidth in kbit/s + * @return The estimated download bandwidth + */ + public float getEstimatedDownloadBandwidth(); /** * Get the local loss rate since last report diff --git a/java/impl/org/linphone/core/LinphoneCallStatsImpl.java b/java/impl/org/linphone/core/LinphoneCallStatsImpl.java index 00859f61c..a88b051b6 100644 --- a/java/impl/org/linphone/core/LinphoneCallStatsImpl.java +++ b/java/impl/org/linphone/core/LinphoneCallStatsImpl.java @@ -24,6 +24,7 @@ class LinphoneCallStatsImpl implements LinphoneCallStats { private int iceState; private float downloadBandwidth; private float uploadBandwidth; + private float estimatedDownloadBandwidth; private float senderLossRate; private float receiverLossRate; private float senderInterarrivalJitter; @@ -39,6 +40,7 @@ class LinphoneCallStatsImpl implements LinphoneCallStats { private native int getIceState(long nativeStatsPtr); private native float getDownloadBandwidth(long nativeStatsPtr); private native float getUploadBandwidth(long nativeStatsPtr); + private native float getEstimatedDownloadBandwidth(long nativeStatsptr); private native float getSenderLossRate(long nativeStatsPtr); private native float getReceiverLossRate(long nativeStatsPtr); private native float getSenderInterarrivalJitter(long nativeStatsPtr); @@ -57,6 +59,7 @@ class LinphoneCallStatsImpl implements LinphoneCallStats { iceState = getIceState(nativeStatsPtr); downloadBandwidth = getDownloadBandwidth(nativeStatsPtr); uploadBandwidth = getUploadBandwidth(nativeStatsPtr); + estimatedDownloadBandwidth = getEstimatedDownloadBandwidth(nativeStatsPtr); senderLossRate = getSenderLossRate(nativeStatsPtr); receiverLossRate = getReceiverLossRate(nativeStatsPtr); senderInterarrivalJitter = getSenderInterarrivalJitter(nativeStatsPtr); @@ -81,6 +84,10 @@ class LinphoneCallStatsImpl implements LinphoneCallStats { public float getUploadBandwidth() { return uploadBandwidth; } + + public float getEstimatedDownloadBandwidth() { + return estimatedDownloadBandwidth; + } public float getSenderLossRate() { return senderLossRate; diff --git a/src/c-wrapper/api/c-call-stats.cpp b/src/c-wrapper/api/c-call-stats.cpp index 2ee7bec13..c8fa47375 100644 --- a/src/c-wrapper/api/c-call-stats.cpp +++ b/src/c-wrapper/api/c-call-stats.cpp @@ -54,6 +54,7 @@ struct _LinphoneCallStats { int rtp_remote_family; /**< Ip adress family of the remote destination */ int clockrate; /*RTP clockrate of the stream, provided here for easily converting timestamp units expressed in RTCP packets in milliseconds*/ bool_t rtcp_received_via_mux; /*private flag, for non-regression test only*/ + float estimated_download_bandwidth; /**round_trip_delay; } + +float linphone_call_stats_get_estimated_download_bandwidth(const LinphoneCallStats *stats) { + return stats->estimated_download_bandwidth; +} diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index f91dd6b89..1446f0404 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -2297,7 +2297,9 @@ void MediaSessionPrivate::handleStreamEvents (int streamIndex) { telephoneEventReceived(evd->info.telephone_event); } else if (evt == ORTP_EVENT_NEW_VIDEO_BANDWIDTH_ESTIMATION_AVAILABLE) { lInfo() << "Video bandwidth estimation is " << (int)(evd->info.video_bandwidth_available / 1000.) << " kbit/s"; - // 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); } @@ -3426,7 +3428,7 @@ void MediaSessionPrivate::reportBandwidth () { lInfo() << "Bandwidth usage for CallSession [" << q << "]:\n" << fixed << setprecision(2) << "\tRTP audio=[d=" << linphone_call_stats_get_download_bandwidth(audioStats) << ",u=" << linphone_call_stats_get_upload_bandwidth(audioStats) << - "], video=[d=" << linphone_call_stats_get_download_bandwidth(videoStats) << ",u=" << linphone_call_stats_get_upload_bandwidth(videoStats) << + "], video=[d=" << linphone_call_stats_get_download_bandwidth(videoStats) << ",u=" << linphone_call_stats_get_upload_bandwidth(videoStats) << ",ed=" << linphone_call_stats_get_estimated_download_bandwidth(videoStats) << "], text=[d=" << linphone_call_stats_get_download_bandwidth(textStats) << ",u=" << linphone_call_stats_get_upload_bandwidth(textStats) << "] kbits/sec\n" << "\tRTCP audio=[d=" << linphone_call_stats_get_rtcp_download_bandwidth(audioStats) << ",u=" << linphone_call_stats_get_rtcp_upload_bandwidth(audioStats) << "], video=[d=" << linphone_call_stats_get_rtcp_download_bandwidth(videoStats) << ",u=" << linphone_call_stats_get_rtcp_upload_bandwidth(videoStats) <<