From be90cd896ecf81fe6f57f5baa8129ca0a33b4731 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 14 Jun 2011 13:03:16 +0200 Subject: [PATCH] support for adaptive rate control --- coreapi/linphonecall.c | 16 ++++++++++++---- coreapi/linphonecore.c | 20 ++++++++++++++++++++ coreapi/linphonecore.h | 7 +++++-- mediastreamer2 | 2 +- 4 files changed, 38 insertions(+), 7 deletions(-) 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 d179d8104..7f0e8c727 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/mediastreamer2 b/mediastreamer2 index 79cbc5277..fd74240c2 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 79cbc5277d3fae8a70ae42a4e958042484ca2725 +Subproject commit fd74240c297e33c7e96d14dc5f7ed5d3dbdb8dc0