add option to enable echo limiter, and fallback to it when echo limiter failed

This commit is contained in:
Simon Morlat 2011-11-09 17:28:51 +01:00
parent 68f2df4abc
commit 119e7a29f5
9 changed files with 68 additions and 27 deletions

View file

@ -38,9 +38,9 @@ ec_tail_len=120
ec_framesize=128
el_type=mic
el_thres=0.05
el_thres=0.03
el_force=100000
el_sustain=600
el_sustain=400
el_transmit_thres=1.7
ng_floorgain=0.01

View file

@ -14,6 +14,7 @@
<string name="pref_transport_use_standard_ports_key">pref_transport_use_standard_ports_key</string>
<string name="pref_echo_canceller_calibration_key">pref_echo_canceller_calibration_key</string>
<string name="pref_echo_limiter_key">pref_echo_limiter_key</string>
<string name="pref_prefix_key">pref_prefix_key</string>
<string name="pref_proxy_key">pref_proxy_key</string>
<string name="pref_domain_key">pref_domain_key</string>

View file

@ -95,7 +95,8 @@
<string name="no_phone_numbers">No phone numbers found for %s</string>
<string name="filter_contacts">Filter contacts</string>
<string name="title_numbers_dialog">%s\'s phone numbers</string>
<string name="pref_echo_canceller_calibration">Echo calibration</string>
<string name="pref_echo_canceller_calibration">Echo canceler calibration</string>
<string name="pref_echo_limiter">Echo limiter</string>
<string name="pref_video_use_front_camera_title">Use front camera</string>
<string name="pref_video">Video</string>
<string name="pref_preferences">Preferences</string>
@ -183,6 +184,7 @@
<string name="notification_started">started</string>
<string name="pref_echo_cancellation_summary">Removes the echo heard by other end</string>
<string name="pref_echo_limiter_summary">Removes the echo heard by other end (brute force method)</string>
<string name="pref_stun_server">Stun server</string>
<string name="ec_calibrating">Calibrating...</string>
<string name="ec_calibrated">Calibrated [%s ms]</string>

View file

@ -46,6 +46,8 @@
<CheckBoxPreference android:key="@string/pref_echo_canceller_calibration_key"
android:title="@string/pref_echo_canceller_calibration" />
<CheckBoxPreference android:key="@string/pref_echo_limiter_key"
android:title="@string/pref_echo_limiter" android:summary="@string/pref_echo_limiter_summary"/>
<PreferenceScreen android:title="@string/pref_codecs" android:key="@string/pref_codecs_key">
<CheckBoxPreference android:key="@string/pref_codec_speex16_key"

View file

@ -236,17 +236,13 @@ public final class LinphoneManager implements LinphoneCoreListener {
*
*/
public void routeAudioToReceiver() {
routeAudioToSpeakerHelper(false);
if (mLc.isIncall()) {
//Restore default value
LinphoneCall call=mLc.getCurrentCall();
if (call!=null){
if (Version.isArmv7()){
call.enableEchoCancellation(mLc.isEchoCancellationEnabled());
call.enableEchoLimiter(false);
}else{
call.enableEchoCancellation(false);
call.enableEchoLimiter(mLc.isEchoCancellationEnabled());
}
call.enableEchoCancellation(mLc.isEchoCancellationEnabled());
call.enableEchoLimiter(mLc.isEchoLimiterEnabled());
}
}
}
@ -507,13 +503,10 @@ public final class LinphoneManager implements LinphoneCoreListener {
enableDisableVideoCodecs(videoCodec);
}
boolean use_ec=mPref.getBoolean(getString(R.string.pref_echo_cancellation_key),false);
if (Version.isArmv7()){
mLc.enableEchoCancellation(use_ec);
mLc.enableEchoLimiter(false);
}else{
mLc.enableEchoCancellation(false);
mLc.enableEchoLimiter(false);
}
boolean use_el=mPref.getBoolean(getString(R.string.pref_echo_limiter_key),false);
mLc.enableEchoCancellation(use_ec);
mLc.enableEchoLimiter(use_el);
} catch (LinphoneCoreException e) {
throw new LinphoneConfigException(getString(R.string.wrong_settings),e);
}

View file

@ -27,6 +27,9 @@ import static org.linphone.R.string.pref_codec_ilbc_key;
import static org.linphone.R.string.pref_codec_speex16_key;
import static org.linphone.R.string.pref_echo_canceller_calibration_key;
import static org.linphone.R.string.pref_video_enable_key;
import static org.linphone.R.string.pref_echo_limiter_key;
import static org.linphone.R.string.pref_echo_cancellation_key;
import java.util.Arrays;
import java.util.List;
@ -52,6 +55,8 @@ import android.widget.Toast;
public class LinphonePreferencesActivity extends PreferenceActivity implements EcCalibrationListener {
private Handler mHandler = new Handler();
private CheckBoxPreference ecCalibratePref;
private CheckBoxPreference elPref;
private CheckBoxPreference ecPref;
private SharedPreferences prefs() {
@ -84,19 +89,24 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
addTransportChecboxesListener();
ecPref = (CheckBoxPreference) findPreference(pref_echo_canceller_calibration_key);
ecPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
ecCalibratePref = (CheckBoxPreference) findPreference(pref_echo_canceller_calibration_key);
ecCalibratePref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
startEcCalibration();
return false;
}
});
ecPref = (CheckBoxPreference) findPreference(pref_echo_cancellation_key);
elPref = (CheckBoxPreference) findPreference(pref_echo_limiter_key);
boolean fastCpu = Version.isArmv7();
if (fastCpu) {
detectAudioCodec(pref_codec_ilbc_key, "iLBC", 8000, false);
findPreference(pref_codec_speex16_key).setEnabled(true);
//findPreference(pref_codec_speex32_key)).setEnabled(enableIlbc);
findPreference(pref_echo_cancellation_key).setEnabled(true);
}else{
findPreference(pref_echo_limiter_key).setEnabled(true);
}
detectAudioCodec(pref_codec_amr_key,"AMR",8000, false);
@ -122,11 +132,32 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
detectVideoCodec(R.string.pref_video_codec_h264_key, "H264");
addEchoPrefsListener();
if (Hacks.needSoftvolume()) checkAndDisableCheckbox(R.string.pref_audio_soft_volume_key);
}
private void addEchoPrefsListener(){
OnPreferenceChangeListener ec_listener=new OnPreferenceChangeListener(){
public boolean onPreferenceChange(Preference arg0, Object newValue) {
Boolean val=(Boolean)newValue;
if (val){
elPref.setChecked(!val);
}
return true;
}
};
OnPreferenceChangeListener el_listener=new OnPreferenceChangeListener(){
public boolean onPreferenceChange(Preference arg0, Object newValue) {
Boolean val=(Boolean)newValue;
if (val){
ecPref.setChecked(!val);
}
return true;
}
};
ecPref.setOnPreferenceChangeListener(ec_listener);
elPref.setOnPreferenceChangeListener(el_listener);
}
private void addTransportChecboxesListener() {
@ -184,8 +215,8 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
try {
LinphoneManager.getInstance().startEcCalibration(this);
ecPref.setSummary(ec_calibrating);
ecPref.getEditor().putBoolean(getString(pref_echo_canceller_calibration_key), false).commit();
ecCalibratePref.setSummary(ec_calibrating);
ecCalibratePref.getEditor().putBoolean(getString(pref_echo_canceller_calibration_key), false).commit();
} catch (LinphoneCoreException e) {
Log.w(e, "Cannot calibrate EC");
}
@ -196,11 +227,13 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
mHandler.post(new Runnable() {
public void run() {
if (status == EcCalibratorStatus.Done) {
ecPref.setSummary(String.format(getString(R.string.ec_calibrated), delayMs));
ecPref.setChecked(true);
ecCalibratePref.setSummary(String.format(getString(R.string.ec_calibrated), delayMs));
ecCalibratePref.setChecked(true);
} else if (status == EcCalibratorStatus.Failed) {
ecPref.setSummary(R.string.failed);
ecCalibratePref.setSummary(R.string.failed);
ecCalibratePref.setChecked(false);
elPref.setChecked(true);
ecPref.setChecked(false);
}
}

View file

@ -605,4 +605,9 @@ class LinphoneCoreImpl implements LinphoneCore {
public void setMaxCalls(int max) {
setMaxCalls(nativePtr, max);
}
private native boolean isEchoLimiterEnabled(long nativePtr);
@Override
public boolean isEchoLimiterEnabled() {
return isEchoLimiterEnabled(nativePtr);
}
}

@ -1 +1 @@
Subproject commit 23e177a1f349fe3ed83a43b5317b9662ede9276f
Subproject commit 91b606875d8ccbbf80191e189e2714a4e11a4763

View file

@ -358,6 +358,11 @@ public class TestConferenceActivity extends IncallActivity {
// TODO Auto-generated method stub
}
@Override
public boolean isEchoLimiterEnabled() {
// TODO Auto-generated method stub
return false;
}
}