Use echo canceller.

This commit is contained in:
Ghislain MARY 2012-10-17 09:52:36 +02:00
parent b4576a0036
commit ce4ec82a7d
7 changed files with 38 additions and 68 deletions

View file

@ -29,9 +29,9 @@ video_jitt_comp=60
nortp_timeout=30 nortp_timeout=30
[sound] [sound]
playback_dev_id=ANDROID SND: Android Sound card playback_dev_id=
ringer_dev_id=ANDROID SND: Android Sound card ringer_dev_id=
capture_dev_id=ANDROID SND: Android Sound card capture_dev_id=
remote_ring=/data/data/org.linphone/files/ringback.wav remote_ring=/data/data/org.linphone/files/ringback.wav
local_ring=/data/data/org.linphone/files/oldphone_mono.wav local_ring=/data/data/org.linphone/files/oldphone_mono.wav
ec_tail_len=120 ec_tail_len=120

View file

@ -33,7 +33,6 @@
<string name="pref_transport_use_standard_ports_key">pref_transport_use_standard_ports_key</string> <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_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_prefix_key">pref_prefix_key</string>
<string name="pref_proxy_key">pref_proxy_key</string> <string name="pref_proxy_key">pref_proxy_key</string>
<string name="pref_domain_key">pref_domain_key</string> <string name="pref_domain_key">pref_domain_key</string>

View file

@ -120,7 +120,6 @@
<string name="pref_delete_account">Delete this account</string> <string name="pref_delete_account">Delete this account</string>
<string name="pref_default_account_title">Use as default</string> <string name="pref_default_account_title">Use as default</string>
<string name="pref_echo_canceller_calibration">Echo canceller calibration</string> <string name="pref_echo_canceller_calibration">Echo canceller 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_use_front_camera_title">Use front camera</string>
<string name="pref_video">Video</string> <string name="pref_video">Video</string>
<string name="pref_preferences">Preferences</string> <string name="pref_preferences">Preferences</string>
@ -211,11 +210,11 @@
<string name="error_cannot_invite_address">Cannot invite destination address [%s]</string> <string name="error_cannot_invite_address">Cannot invite destination address [%s]</string>
<string name="notification_started">started</string> <string name="notification_started">started</string>
<string name="pref_echo_cancellation_summary">Removes the echo heard by other end (not recommended)</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="pref_stun_server">Stun server</string>
<string name="ec_calibrating">Calibrating...</string> <string name="ec_calibrating">Calibrating...</string>
<string name="ec_calibrated">Calibrated [%s ms]</string> <string name="ec_calibrated">Calibrated [%s ms]</string>
<string name="no_echo">No echo</string>
<string name="failed">failed</string> <string name="failed">failed</string>
<string name="first_login_explanation">Enter your username and password to connect to the service.</string> <string name="first_login_explanation">Enter your username and password to connect to the service.</string>
<string name="first_login_username">Username</string> <string name="first_login_username">Username</string>

View file

@ -56,13 +56,10 @@
<PreferenceCategory android:title="@string/pref_audio"> <PreferenceCategory android:title="@string/pref_audio">
<CheckBoxPreference android:key="@string/pref_echo_limiter_key"
android:title="@string/pref_echo_limiter" android:summary="@string/pref_echo_limiter_summary"/>
<CheckBoxPreference android:key="@string/pref_echo_cancellation_key" android:defaultValue="false" <CheckBoxPreference android:key="@string/pref_echo_cancellation_key" android:defaultValue="false"
android:title="@string/pref_echo_cancellation" android:summary="@string/pref_echo_cancellation_summary"></CheckBoxPreference> android:title="@string/pref_echo_cancellation" android:summary="@string/pref_echo_cancellation_summary"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_echo_canceller_calibration_key" <Preference android:key="@string/pref_echo_canceller_calibration_key"
android:title="@string/pref_echo_canceller_calibration" /> android:title="@string/pref_echo_canceller_calibration" />
<PreferenceScreen android:title="@string/pref_codecs" android:key="@string/pref_codecs_key"> <PreferenceScreen android:title="@string/pref_codecs" android:key="@string/pref_codecs_key">

View file

@ -21,14 +21,18 @@ package org.linphone;
import static android.content.Intent.ACTION_MAIN; import static android.content.Intent.ACTION_MAIN;
import org.linphone.LinphoneManager.EcCalibrationListener;
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener; import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
import org.linphone.compatibility.Compatibility; import org.linphone.compatibility.Compatibility;
import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State; import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
import org.linphone.core.LinphoneCore.RegistrationState; import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.Log; import org.linphone.core.Log;
import org.linphone.mediastream.Version; import org.linphone.mediastream.Version;
import org.linphone.mediastream.video.capture.hwconf.Hacks;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.TabActivity; import android.app.TabActivity;
@ -148,19 +152,25 @@ public class LinphoneActivity extends TabActivity implements ContactPicked
switch (requestCode) { switch (requestCode) {
case FIRST_LOGIN_ACTIVITY: case FIRST_LOGIN_ACTIVITY:
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
// Toast.makeText(this, getString(R.string.ec_calibration_launch_message), Toast.LENGTH_LONG).show(); if (!Hacks.hasBuiltInEchoCanceller()) {
// try { Toast.makeText(this, getString(R.string.ec_calibration_launch_message), Toast.LENGTH_LONG).show();
// LinphoneManager.getInstance().startEcCalibration(new EcCalibrationListener() { try {
// public void onEcCalibrationStatus(EcCalibratorStatus status, int delayMs) { LinphoneManager.getInstance().startEcCalibration(new EcCalibrationListener() {
// PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.this) public void onEcCalibrationStatus(EcCalibratorStatus status, int delayMs) {
// .edit().putBoolean( SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.this);
// getString(R.string.pref_echo_canceller_calibration_key), SharedPreferences.Editor editor = prefs.edit();
// status == EcCalibratorStatus.Done).commit(); if (status == EcCalibratorStatus.DoneNoEcho) {
// } editor.putBoolean(getString(R.string.pref_echo_cancellation_key), false);
// }); } else if ((status == EcCalibratorStatus.Done) || (status == EcCalibratorStatus.Failed)) {
// } catch (LinphoneCoreException e) { editor.putBoolean(getString(R.string.pref_echo_cancellation_key), true);
// Log.e(e, "Unable to calibrate EC"); }
// } editor.commit();
}
});
} catch (LinphoneCoreException e) {
Log.e(e, "Unable to calibrate EC");
}
}
fillTabHost(); fillTabHost();
} else { } else {
finish(); finish();

View file

@ -605,9 +605,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
} }
boolean useEC = getPrefBoolean(R.string.pref_echo_cancellation_key, false); boolean useEC = getPrefBoolean(R.string.pref_echo_cancellation_key, false);
boolean useEL = getPrefBoolean(R.string.pref_echo_limiter_key, false);
mLc.enableEchoCancellation(useEC); mLc.enableEchoCancellation(useEC);
mLc.enableEchoLimiter(useEL);
} catch (LinphoneCoreException e) { } catch (LinphoneCoreException e) {
throw new LinphoneConfigException(getString(R.string.wrong_settings),e); throw new LinphoneConfigException(getString(R.string.wrong_settings),e);
} }

View file

@ -26,7 +26,6 @@ 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_codec_speex16_key;
import static org.linphone.R.string.pref_echo_cancellation_key; import static org.linphone.R.string.pref_echo_cancellation_key;
import static org.linphone.R.string.pref_echo_canceller_calibration_key; import static org.linphone.R.string.pref_echo_canceller_calibration_key;
import static org.linphone.R.string.pref_echo_limiter_key;
import static org.linphone.R.string.pref_media_encryption_key; import static org.linphone.R.string.pref_media_encryption_key;
import static org.linphone.R.string.pref_video_enable_key; import static org.linphone.R.string.pref_video_enable_key;
@ -76,8 +75,7 @@ import de.timroes.axmlrpc.XMLRPCServerException;
public class LinphonePreferencesActivity extends PreferenceActivity implements EcCalibrationListener { public class LinphonePreferencesActivity extends PreferenceActivity implements EcCalibrationListener {
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private CheckBoxPreference ecCalibratePref; private Preference ecCalibratePref;
private CheckBoxPreference elPref;
private CheckBoxPreference ecPref; private CheckBoxPreference ecPref;
private ListPreference mencPref; private ListPreference mencPref;
private int nbAccounts = 1; private int nbAccounts = 1;
@ -597,7 +595,7 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
addTransportChecboxesListener(); addTransportChecboxesListener();
ecCalibratePref = (CheckBoxPreference) findPreference(pref_echo_canceller_calibration_key); ecCalibratePref = findPreference(pref_echo_canceller_calibration_key);
ecCalibratePref.setOnPreferenceClickListener(new OnPreferenceClickListener() { ecCalibratePref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
startEcCalibration(); startEcCalibration();
@ -605,7 +603,6 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
} }
}); });
ecPref = (CheckBoxPreference) findPreference(pref_echo_cancellation_key); ecPref = (CheckBoxPreference) findPreference(pref_echo_cancellation_key);
elPref = (CheckBoxPreference) findPreference(pref_echo_limiter_key);
mencPref = (ListPreference) findPreference(pref_media_encryption_key); mencPref = (ListPreference) findPreference(pref_media_encryption_key);
boolean fastCpu = Version.isArmv7(); boolean fastCpu = Version.isArmv7();
@ -614,7 +611,6 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
findPreference(pref_codec_speex16_key).setEnabled(true); findPreference(pref_codec_speex16_key).setEnabled(true);
//findPreference(pref_codec_speex32_key)).setEnabled(enableIlbc); //findPreference(pref_codec_speex32_key)).setEnabled(enableIlbc);
} }
findPreference(pref_echo_limiter_key).setEnabled(true);
initializeMediaEncryptionPreferences(); initializeMediaEncryptionPreferences();
@ -637,9 +633,8 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
doOnFirstLaunch(); doOnFirstLaunch();
} }
if (Hacks.hasBuiltInEchoCanceller()) { if (Hacks.hasBuiltInEchoCanceller()) {
uncheckDisableAndHideCheckbox(R.string.pref_echo_limiter_key);
uncheckDisableAndHideCheckbox(R.string.pref_echo_cancellation_key); uncheckDisableAndHideCheckbox(R.string.pref_echo_cancellation_key);
uncheckDisableAndHideCheckbox(R.string.pref_echo_canceller_calibration_key); findPreference(R.string.pref_echo_canceller_calibration_key).setLayoutResource(R.layout.hidden);
} }
@ -651,10 +646,6 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
findPreference(R.string.pref_video_codec_h264_key).setDefaultValue(false); findPreference(R.string.pref_video_codec_h264_key).setDefaultValue(false);
} }
addEchoPrefsListener();
if (Hacks.needSoftvolume()) checkAndDisableCheckbox(R.string.pref_audio_soft_volume_key);
if (!LinphoneManager.getLc().isTunnelAvailable()){ if (!LinphoneManager.getLc().isTunnelAvailable()){
hidePreferenceCategory(R.string.pref_tunnel_key); hidePreferenceCategory(R.string.pref_tunnel_key);
} }
@ -677,7 +668,6 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
} }
private void doOnFirstLaunch() { private void doOnFirstLaunch() {
manageCheckbox(R.string.pref_echo_limiter_key, !Hacks.hasBuiltInEchoCanceller(), true, false);
prefs().edit().putBoolean(LinphoneActivity.PREF_FIRST_LAUNCH, false).commit(); prefs().edit().putBoolean(LinphoneActivity.PREF_FIRST_LAUNCH, false).commit();
} }
@ -711,29 +701,6 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
} }
} }
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() { private void addTransportChecboxesListener() {
final List<CheckBoxPreference> checkboxes = Arrays.asList( final List<CheckBoxPreference> checkboxes = Arrays.asList(
@ -801,15 +768,15 @@ public class LinphonePreferencesActivity extends PreferenceActivity implements E
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
if (status == EcCalibratorStatus.Done) { if (status == EcCalibratorStatus.DoneNoEcho) {
ecCalibratePref.setSummary(R.string.no_echo);
ecPref.setChecked(false);
} else if (status == EcCalibratorStatus.Done) {
ecCalibratePref.setSummary(String.format(getString(R.string.ec_calibrated), delayMs)); ecCalibratePref.setSummary(String.format(getString(R.string.ec_calibrated), delayMs));
ecCalibratePref.setChecked(true); ecPref.setChecked(true);
} else if (status == EcCalibratorStatus.Failed) { } else if (status == EcCalibratorStatus.Failed) {
ecCalibratePref.setSummary(R.string.failed); ecCalibratePref.setSummary(R.string.failed);
ecCalibratePref.setChecked(false); ecPref.setChecked(true);
elPref.setChecked(true);
ecPref.setChecked(false);
} }
} }
}); });