From 9d1568056134e4bb549d7c5074ed4691274f2b46 Mon Sep 17 00:00:00 2001 From: smorlat Date: Tue, 24 Mar 2009 20:36:22 +0000 Subject: [PATCH] add new force parameter. git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@361 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- linphone/coreapi/linphonecore.c | 3 +++ .../include/mediastreamer2/msvolume.h | 2 ++ linphone/mediastreamer2/src/msvolume.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/linphone/coreapi/linphonecore.c b/linphone/coreapi/linphonecore.c index cc44a9757..d183b956a 100644 --- a/linphone/coreapi/linphonecore.c +++ b/linphone/coreapi/linphonecore.c @@ -1439,6 +1439,7 @@ static void post_configure_audio_streams(LinphoneCore *lc){ if (st->volrecv && st->volsend){ float speed=lp_config_get_float(lc->config,"sound","el_speed",-1); float thres=lp_config_get_float(lc->config,"sound","el_thres",-1); + float force=lp_config_get_float(lc->config,"sound","el_force",-1); MSFilter *f; if (st->el_type==ELControlMic) f=st->volrecv; @@ -1447,6 +1448,8 @@ static void post_configure_audio_streams(LinphoneCore *lc){ ms_filter_call_method(f,MS_VOLUME_SET_EA_SPEED,&speed); if (thres!=-1) ms_filter_call_method(f,MS_VOLUME_SET_EA_THRESHOLD,&thres); + if (force!=-1) + ms_filter_call_method(f,MS_VOLUME_SET_EA_FORCE,&force); } if (lc->vtable.dtmf_received!=NULL){ /* replace by our default action*/ diff --git a/linphone/mediastreamer2/include/mediastreamer2/msvolume.h b/linphone/mediastreamer2/include/mediastreamer2/msvolume.h index 807934ea0..1bb208dc7 100644 --- a/linphone/mediastreamer2/include/mediastreamer2/msvolume.h +++ b/linphone/mediastreamer2/include/mediastreamer2/msvolume.h @@ -46,6 +46,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MS_VOLUME_SET_EA_SPEED MS_FILTER_METHOD(MS_VOLUME_ID,6,float) +#define MS_VOLUME_SET_EA_FORCE MS_FILTER_METHOD(MS_VOLUME_ID,7,float) + extern MSFilterDesc ms_volume_desc; #endif diff --git a/linphone/mediastreamer2/src/msvolume.c b/linphone/mediastreamer2/src/msvolume.c index fb39e4669..e64d537e7 100644 --- a/linphone/mediastreamer2/src/msvolume.c +++ b/linphone/mediastreamer2/src/msvolume.c @@ -34,6 +34,7 @@ typedef struct Volume{ float static_gain; float gain_k; float thres; + float force; MSFilter *peer; bool_t ea_active; }Volume; @@ -46,6 +47,7 @@ static void volume_init(MSFilter *f){ v->ea_active=FALSE; v->gain_k=gain_k; v->thres=noise_thres; + v->force=en_weight; v->peer=NULL; f->data=v; } @@ -83,7 +85,7 @@ static void volume_echo_avoider_process(Volume *v){ if (v->ea_active){ if (peer_e>v->thres){ /*lower our output*/ - gain=compute_gain(v->static_gain,peer_e,en_weight); + gain=compute_gain(v->static_gain,peer_e,v->force); }else { gain=v->static_gain; v->ea_active=FALSE; @@ -93,7 +95,7 @@ static void volume_echo_avoider_process(Volume *v){ ms_filter_call_method(v->peer,MS_VOLUME_GET_EA_STATE,&peer_active); if (peer_e>v->thres && ! peer_active){ /*lower our output*/ - gain=compute_gain(v->static_gain,peer_e,en_weight); + gain=compute_gain(v->static_gain,peer_e,v->force); v->ea_active=TRUE; }else gain=v->static_gain; } @@ -148,6 +150,13 @@ static int volume_set_ea_speed(MSFilter *f, void*arg){ return 0; } +static int volume_set_ea_force(MSFilter *f, void*arg){ + Volume *v=(Volume*)f->data; + float val=*(float*)arg; + v->force=val; + return 0; +} + static inline int16_t saturate(float val){ return (val>32767) ? 32767 : ( (val<-32767) ? -32767 : val); } @@ -188,6 +197,7 @@ static MSFilterMethod methods[]={ { MS_VOLUME_SET_PEER , volume_set_peer }, { MS_VOLUME_SET_EA_THRESHOLD , volume_set_ea_threshold }, { MS_VOLUME_SET_EA_SPEED , volume_set_ea_speed }, + { MS_VOLUME_SET_EA_FORCE , volume_set_ea_force }, { 0 , NULL } };