mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-23 14:18:07 +00:00
tuning of echo limiter
git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@358 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
This commit is contained in:
parent
0f94518313
commit
d9f3e1c8cf
6 changed files with 68 additions and 20 deletions
|
|
@ -704,6 +704,11 @@ int linphone_accept_video_offer(sdp_context_t *ctx,sdp_payload_t *payload)
|
|||
|
||||
if (!linphone_core_video_enabled(lc)) return -1;
|
||||
|
||||
if (payload->remoteport==0) {
|
||||
ms_message("Video stream refused by remote.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
params=&call->video_params;
|
||||
remote_profile=call->profile;
|
||||
/* see if this codec is supported in our local rtp profile*/
|
||||
|
|
|
|||
|
|
@ -1436,7 +1436,7 @@ static void post_configure_audio_streams(LinphoneCore *lc){
|
|||
float speed=lp_config_get_float(lc->config,"sound","el_speed",-1);
|
||||
float thres=lp_config_get_float(lc->config,"sound","el_thres",-1);
|
||||
if (speed!=-1)
|
||||
ms_filter_call_method(st->volsend,MS_VOLUME_SET_EA_SPEED,&speed);
|
||||
ms_filter_call_method(st->volrecv,MS_VOLUME_SET_EA_SPEED,&speed);
|
||||
if (thres!=-1)
|
||||
ms_filter_call_method(st->volrecv,MS_VOLUME_SET_EA_THRESHOLD,&thres);
|
||||
}
|
||||
|
|
@ -2406,6 +2406,18 @@ LpConfig *linphone_core_get_config(LinphoneCore *lc){
|
|||
|
||||
void linphone_core_uninit(LinphoneCore *lc)
|
||||
{
|
||||
if (lc->call){
|
||||
int i;
|
||||
linphone_core_terminate_call(lc,NULL);
|
||||
for(i=0;i<10;++i){
|
||||
#ifndef WIN32
|
||||
usleep(50000);
|
||||
#else
|
||||
Sleep(50);
|
||||
#endif
|
||||
linphone_core_iterate(lc);
|
||||
}
|
||||
}
|
||||
gstate_new_state(lc, GSTATE_POWER_SHUTDOWN, NULL);
|
||||
#ifdef VIDEO_ENABLED
|
||||
if (lc->previewstream!=NULL){
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ int lp_config_get_int(LpConfig *lpconfig,const char *section, const char *key, i
|
|||
|
||||
float lp_config_get_float(LpConfig *lpconfig,const char *section, const char *key, float default_value){
|
||||
const char *str=lp_config_get_string(lpconfig,section,key,NULL);
|
||||
float ret;
|
||||
float ret=default_value;
|
||||
if (str==NULL) return default_value;
|
||||
sscanf(str,"%f",&ret);
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,14 @@ Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org)
|
|||
#include "lpconfig.h"
|
||||
#include "private.h"
|
||||
|
||||
void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc){
|
||||
MSList *elem;
|
||||
int i;
|
||||
for(elem=lc->sip_conf.proxies,i=0;elem!=NULL;elem=ms_list_next(elem),i++){
|
||||
LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data;
|
||||
linphone_proxy_config_write_to_config_file(lc->config,cfg,i);
|
||||
}
|
||||
}
|
||||
|
||||
void linphone_proxy_config_init(LinphoneProxyConfig *obj){
|
||||
memset(obj,0,sizeof(LinphoneProxyConfig));
|
||||
|
|
@ -231,13 +239,10 @@ void linphone_proxy_config_apply(LinphoneProxyConfig *obj,LinphoneCore *lc)
|
|||
linphone_proxy_config_done(obj);
|
||||
}
|
||||
|
||||
int linphone_proxy_config_done(LinphoneProxyConfig *obj)
|
||||
{
|
||||
static void linphone_proxy_config_register(LinphoneProxyConfig *obj){
|
||||
const char *id_str;
|
||||
if (!linphone_proxy_config_check(obj->lc,obj)) return -1;
|
||||
if (obj->reg_identity!=NULL) id_str=obj->reg_identity;
|
||||
else id_str=linphone_core_get_primary_contact(obj->lc);
|
||||
obj->frozen=FALSE;
|
||||
if (obj->reg_sendregister){
|
||||
char *ct=NULL;
|
||||
osip_message_t *msg=NULL;
|
||||
|
|
@ -245,6 +250,14 @@ int linphone_proxy_config_done(LinphoneProxyConfig *obj)
|
|||
eXosip_register_send_register(obj->rid,msg);
|
||||
if (ct!=NULL) osip_free(ct);
|
||||
}
|
||||
}
|
||||
|
||||
int linphone_proxy_config_done(LinphoneProxyConfig *obj)
|
||||
{
|
||||
if (!linphone_proxy_config_check(obj->lc,obj)) return -1;
|
||||
obj->frozen=FALSE;
|
||||
linphone_proxy_config_register(obj);
|
||||
linphone_proxy_config_write_all_to_config_file(obj->lc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -502,15 +515,14 @@ const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc){
|
|||
void linphone_proxy_config_process_authentication_failure(LinphoneCore *lc, eXosip_event_t *ev){
|
||||
LinphoneProxyConfig *cfg=linphone_core_get_proxy_config_from_rid(lc, ev->rid);
|
||||
if (cfg){
|
||||
cfg->auth_failures++;
|
||||
/*restart a new register */
|
||||
if (cfg->auth_failures==1){
|
||||
linphone_proxy_config_done(cfg);
|
||||
}
|
||||
cfg->auth_failures++;
|
||||
/*restart a new register */
|
||||
if (cfg->auth_failures==1){
|
||||
linphone_proxy_config_register(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyConfig *obj, int index)
|
||||
{
|
||||
char key[50];
|
||||
|
|
@ -537,6 +549,8 @@ void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyC
|
|||
lp_config_set_int(config,key,"publish",obj->publish);
|
||||
}
|
||||
|
||||
|
||||
|
||||
LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config, int index)
|
||||
{
|
||||
const char *tmp;
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ static int ice_sound_send_stun_request(RtpSession *session, struct IceCheckList
|
|||
|
||||
/* prepare ONCE tie-break value */
|
||||
if (checklist->tiebreak_value==0) {
|
||||
checklist->tiebreak_value = random() * (0x7fffffffffffffff/0x7fff);
|
||||
checklist->tiebreak_value = random() * (0x7fffffffffffffffLL /0x7fff);
|
||||
}
|
||||
|
||||
cand_pair=NULL;
|
||||
|
|
@ -513,7 +513,7 @@ static int ice_process_stun_message(RtpSession *session, struct IceCheckList *ch
|
|||
|
||||
/* prepare ONCE tie-break value */
|
||||
if (checklist->tiebreak_value==0) {
|
||||
checklist->tiebreak_value = random() * (0x7fffffffffffffff/0x7fff);
|
||||
checklist->tiebreak_value = random() * (0x7fffffffffffffffLL/0x7fff);
|
||||
}
|
||||
|
||||
memset (src6host, 0, sizeof (src6host));
|
||||
|
|
@ -947,7 +947,7 @@ static int ice_process_stun_message(RtpSession *session, struct IceCheckList *ch
|
|||
{
|
||||
struct in_addr inaddr;
|
||||
char mapped_addr[64];
|
||||
struct CandidatePair *cand_pair;
|
||||
struct CandidatePair *cand_pair=NULL;
|
||||
int pos;
|
||||
inaddr.s_addr = htonl (mappedAddr.addr);
|
||||
snprintf(mapped_addr, sizeof(mapped_addr),
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
static const float max_e=32767*32767;
|
||||
static const float coef=0.1;
|
||||
static const float gain_k=0.2;
|
||||
|
||||
static const float gain_k=0.03;
|
||||
static const float en_weight=4.0;
|
||||
static const float noise_thres=0.1;
|
||||
|
||||
|
||||
|
|
@ -46,6 +46,7 @@ static void volume_init(MSFilter *f){
|
|||
v->ea_active=FALSE;
|
||||
v->gain_k=gain_k;
|
||||
v->thres=noise_thres;
|
||||
v->peer=NULL;
|
||||
f->data=v;
|
||||
}
|
||||
|
||||
|
|
@ -67,14 +68,22 @@ static int volume_get_linear(MSFilter *f, void *arg){
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline float compute_gain(float static_gain, float energy, float weight){
|
||||
float ret=static_gain*(1 - (energy*weight));
|
||||
if (ret<0) ret=0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void volume_echo_avoider_process(Volume *v){
|
||||
float peer_e;
|
||||
float gain;
|
||||
float gain_k2;
|
||||
ms_filter_call_method(v->peer,MS_VOLUME_GET_LINEAR,&peer_e);
|
||||
peer_e=sqrt(peer_e);
|
||||
if (v->ea_active){
|
||||
if (peer_e>v->thres){
|
||||
/*lower our output*/
|
||||
gain=v->static_gain*(1-peer_e);
|
||||
gain=compute_gain(v->static_gain,peer_e,en_weight);
|
||||
}else {
|
||||
gain=v->static_gain;
|
||||
v->ea_active=FALSE;
|
||||
|
|
@ -84,11 +93,15 @@ 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=v->static_gain*(1-peer_e);
|
||||
gain=compute_gain(v->static_gain,peer_e,en_weight);
|
||||
v->ea_active=TRUE;
|
||||
}else gain=v->static_gain;
|
||||
}
|
||||
v->gain=(v->gain*(1-v->gain_k)) + (v->gain_k*v->gain);
|
||||
if (v->ea_active){
|
||||
gain_k2=5*v->gain_k;
|
||||
}else gain_k2=v->gain_k;
|
||||
v->gain=(v->gain*(1-gain_k2)) + (gain_k2*gain);
|
||||
ms_message("ea_active=%i, peer_e=%f gain=%f gain_k=%f",v->ea_active,peer_e,v->gain, v->gain_k);
|
||||
}
|
||||
|
||||
static int volume_set_gain(MSFilter *f, void *arg){
|
||||
|
|
@ -208,3 +221,7 @@ MSFilterDesc ms_volume_desc={
|
|||
methods
|
||||
};
|
||||
#endif
|
||||
|
||||
MS_FILTER_DESC_EXPORT(ms_volume_desc)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue