diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 8649c4c45..2aaad1444 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -669,6 +669,7 @@ void linphone_call_init_media_streams(LinphoneCall *call){ int enabled=lp_config_get_int(lc->config,"sound","noisegate",0); audio_stream_enable_noise_gate(audiostream,enabled); } + if (lc->a_rtp) rtp_session_set_transports(audiostream->session,lc->a_rtp,lc->a_rtcp); @@ -853,6 +854,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut const SalStreamDescription *vstream=sal_media_description_find_stream(call->resultdesc, SalProtoRtpAvp,SalVideo); #endif + bool_t use_arc=linphone_core_adaptive_rate_control_enabled(lc); if(call->audiostream == NULL) { @@ -876,7 +878,7 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut const char *playfile=lc->play_file; const char *recfile=lc->rec_file; call->audio_profile=make_profile(call,call->resultdesc,stream,&used_pt); - bool_t use_ec; + bool_t use_ec,use_arc_audio=use_arc; if (used_pt!=-1){ if (playcard==NULL) { @@ -907,11 +909,17 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut playcard=NULL; } use_ec=captcard==NULL ? FALSE : linphone_core_echo_cancellation_enabled(lc); -#if defined(VIDEO_ENABLED) && defined(ANDROID) - /*On android we have to disable the echo canceller to preserve CPU for video codecs */ - if (vstream && vstream->dir!=SalStreamInactive && vstream->payloads!=NULL) +#if defined(VIDEO_ENABLED) + if (vstream && vstream->dir!=SalStreamInactive && vstream->payloads!=NULL){ + /*when video is used, do not make adaptive rate control on audio, it is stupid.*/ + use_arc_audio=FALSE; + #if defined(ANDROID) + /*On android we have to disable the echo canceller to preserve CPU for video codecs */ use_ec=FALSE; + #endif + } #endif + audio_stream_enable_adaptive_bitrate_control(call->audiostream,use_arc_audio); audio_stream_start_full( call->audiostream, call->audio_profile, diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index aa88a263e..0036694c8 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -782,6 +782,26 @@ static void autoreplier_config_init(LinphoneCore *lc) } */ +/** + * Enable adaptive rate control (experimental feature, audio-only). + * + * Adaptive rate control consists in using RTCP feedback provided information to dynamically + * control the output bitrate of the encoders, so that we can adapt to the network conditions and + * available bandwidth. +**/ +void linphone_core_enable_adaptive_rate_control(LinphoneCore *lc, bool_t enabled){ + lp_config_set_int(lc->config,"net","adaptive_rate_control",(int)enabled); +} + +/** + * Returns whether adaptive rate control is enabled. + * + * See linphone_core_enable_adaptive_rate_control(). +**/ +bool_t linphone_core_adaptive_rate_control_enabled(const LinphoneCore *lc){ + return lp_config_get_int(lc->config,"net","adaptive_rate_control",FALSE); +} + /** * Sets maximum available download bandwidth * diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 02c4c607a..8a298332f 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -705,14 +705,17 @@ void linphone_core_set_upload_bandwidth(LinphoneCore *lc, int bw); int linphone_core_get_download_bandwidth(const LinphoneCore *lc); int linphone_core_get_upload_bandwidth(const LinphoneCore *lc); + +void linphone_core_enable_adaptive_rate_control(LinphoneCore *lc, bool_t enabled); +bool_t linphone_core_adaptive_rate_control_enabled(const LinphoneCore *lc); /** - * set audio packetization time linphone expect to received from peer + * set audio packetization time linphone expect to receive from peer * @ingroup media_parameters * */ void linphone_core_set_download_ptime(LinphoneCore *lc, int ptime); /** - * get audio packetization time linphone expect to received from peer, 0 means unspecified + * get audio packetization time linphone expect to receive from peer, 0 means unspecified * @ingroup media_parameters */ int linphone_core_get_download_ptime(LinphoneCore *lc); diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 4e201c845..2492e8f61 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1023,6 +1023,18 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv return (jlong)linphone_call_get_replaced_call((LinphoneCall*)ptr); } +extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env + ,jobject thiz + ,jlong ptr) { + return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr); +} + +extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env + ,jobject thiz + ,jlong ptr) { + return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr); +} + //LinphoneFriend extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env diff --git a/java/common/org/linphone/core/LinphoneCall.java b/java/common/org/linphone/core/LinphoneCall.java index 9f029b053..e0f7cde34 100644 --- a/java/common/org/linphone/core/LinphoneCall.java +++ b/java/common/org/linphone/core/LinphoneCall.java @@ -190,4 +190,28 @@ public interface LinphoneCall { * @return call duration computed from media start */ int getDuration(); + /** + * Obtain real-time quality rating of the call + * + * Based on local RTP statistics and RTCP feedback, a quality rating is computed and updated + * during all the duration of the call. This function returns its value at the time of the function call. + * It is expected that the rating is updated at least every 5 seconds or so. + * The rating is a floating point number comprised between 0 and 5. + * + * 4-5 = good quality
+ * 3-4 = average quality
+ * 2-3 = poor quality
+ * 1-2 = very poor quality
+ * 0-1 = can't be worse, mostly unusable
+ * + * @returns The function returns -1 if no quality measurement is available, for example if no + * active audio stream exist. Otherwise it returns the quality rating. + */ + float getCurrentQuality(); + /** + * Returns call quality averaged over all the duration of the call. + * + * See getCurrentQuality() for more details about quality measurement. + */ + float getAverageQuality(); } diff --git a/mediastreamer2 b/mediastreamer2 index 79cbc5277..fd74240c2 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 79cbc5277d3fae8a70ae42a4e958042484ca2725 +Subproject commit fd74240c297e33c7e96d14dc5f7ed5d3dbdb8dc0