Binded audio settings and codecs
This commit is contained in:
parent
5c898ca323
commit
ed25573be2
3 changed files with 86 additions and 79 deletions
|
@ -54,63 +54,7 @@
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/pref_codecs"
|
android:title="@string/pref_codecs"
|
||||||
android:key="@string/pref_codecs_key">
|
android:key="@string/pref_codecs_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_opus"
|
|
||||||
android:key="@string/pref_codec_opus_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_speex16"
|
|
||||||
android:key="@string/pref_codec_speex16_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_speex8"
|
|
||||||
android:key="@string/pref_codec_speex8_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_ilbc"
|
|
||||||
android:key="@string/pref_codec_ilbc_key"
|
|
||||||
android:summary="@string/pref_ilbc_summary"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_amr"
|
|
||||||
android:key="@string/pref_codec_amr_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_g729"
|
|
||||||
android:key="@string/pref_codec_g729_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_amrwb"
|
|
||||||
android:key="@string/pref_codec_amrwb_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_gsm"
|
|
||||||
android:key="@string/pref_codec_gsm_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="@string/pref_codec_g722_key"
|
|
||||||
android:defaultValue="@bool/pref_codec_g722_default"
|
|
||||||
android:title="@string/pref_codec_g722"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_silk8"
|
|
||||||
android:key="@string/pref_codec_silk8_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_silk16"
|
|
||||||
android:key="@string/pref_codec_silk16_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_pcmu"
|
|
||||||
android:key="@string/pref_codec_pcmu_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_codec_pcma"
|
|
||||||
android:key="@string/pref_codec_pcma_key"/>
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
@ -153,26 +97,7 @@
|
||||||
android:title="@string/pref_video_codecs_title"
|
android:title="@string/pref_video_codecs_title"
|
||||||
android:key="@string/pref_video_codecs_key"
|
android:key="@string/pref_video_codecs_key"
|
||||||
android:dependency="@string/pref_video_enable_key"
|
android:dependency="@string/pref_video_enable_key"
|
||||||
android:shouldDisableView="true" >
|
android:shouldDisableView="true"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_video_codec_vp8_title"
|
|
||||||
android:key="@string/pref_video_codec_vp8_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_video_codec_h264_title"
|
|
||||||
android:key="@string/pref_video_codec_h264_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_video_codec_mpeg4_title"
|
|
||||||
android:key="@string/pref_video_codec_mpeg4_key"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:title="@string/pref_video_codec_h263_title"
|
|
||||||
android:key="@string/pref_video_codec_h263_key"
|
|
||||||
android:layout="@layout/hidden"/>
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
|
|
@ -322,7 +322,13 @@ public class LinphonePreferences {
|
||||||
// End of accounts settings
|
// End of accounts settings
|
||||||
|
|
||||||
// Audio settings
|
// Audio settings
|
||||||
|
public void setEchoCancellation(boolean enable) {
|
||||||
|
getLc().enableEchoCancellation(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEchoCancellationEnabled() {
|
||||||
|
return getLc().isEchoCancellationEnabled();
|
||||||
|
}
|
||||||
// End of audio settings
|
// End of audio settings
|
||||||
|
|
||||||
// Video settings
|
// Video settings
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
|
import org.linphone.core.PayloadType;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.mediastream.Version;
|
import org.linphone.mediastream.Version;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||||
|
@ -54,6 +55,7 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
||||||
private void initSettings() {
|
private void initSettings() {
|
||||||
//initAccounts(); Init accounts on Resume instead of on Create to update the account list when coming back from wizard
|
//initAccounts(); Init accounts on Resume instead of on Create to update the account list when coming back from wizard
|
||||||
|
|
||||||
|
initAudioSettings();
|
||||||
initNetworkSettings();
|
initNetworkSettings();
|
||||||
initializePreferredVideoSizePreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key)));
|
initializePreferredVideoSizePreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key)));
|
||||||
|
|
||||||
|
@ -100,6 +102,7 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
||||||
|
|
||||||
// Sets listener for each preference to update the matching value in linphonecore
|
// Sets listener for each preference to update the matching value in linphonecore
|
||||||
private void setListeners() {
|
private void setListeners() {
|
||||||
|
setAudioPreferencesListener();
|
||||||
setNetworkPreferencesListener();
|
setNetworkPreferencesListener();
|
||||||
setAdvancedPreferencesListener();
|
setAdvancedPreferencesListener();
|
||||||
}
|
}
|
||||||
|
@ -375,6 +378,63 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
||||||
pref.setEntryValues(contents);
|
pref.setEntryValues(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initAudioSettings() {
|
||||||
|
PreferenceCategory codecs = (PreferenceCategory) findPreference(getString(R.string.pref_codecs_key));
|
||||||
|
codecs.removeAll();
|
||||||
|
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
for(final PayloadType pt : lc.getAudioCodecs()) {
|
||||||
|
CheckBoxPreference codec = new CheckBoxPreference(LinphoneService.instance());
|
||||||
|
codec.setTitle(pt.getMime());
|
||||||
|
codec.setSummary(pt.getRate() + " Hz");
|
||||||
|
codec.setChecked(lc.isPayloadTypeEnabled(pt));
|
||||||
|
|
||||||
|
codec.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
boolean enable = (Boolean) newValue;
|
||||||
|
try {
|
||||||
|
LinphoneManager.getLcIfManagerNotDestroyedOrNull().enablePayloadType(pt, enable);
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
codecs.addPreference(codec);
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckBoxPreference echoCancellation = (CheckBoxPreference) findPreference(getString(R.string.pref_echo_cancellation_key));
|
||||||
|
echoCancellation.setChecked(mPrefs.isEchoCancellationEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAudioPreferencesListener() {
|
||||||
|
findPreference(getString(R.string.pref_echo_cancellation_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
boolean enabled = (Boolean) newValue;
|
||||||
|
mPrefs.setEchoCancellation(enabled);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
findPreference(getString(R.string.pref_echo_canceller_calibration_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
synchronized (SettingsFragment.this) {
|
||||||
|
try {
|
||||||
|
LinphoneManager.getInstance().startEcCalibration(SettingsFragment.this);
|
||||||
|
preference.setSummary(R.string.ec_calibrating);
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
Log.w(e, "Cannot calibrate EC");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void initNetworkSettings() {
|
private void initNetworkSettings() {
|
||||||
initMediaEncryptionPreference((ListPreference) findPreference(getString(R.string.pref_media_encryption_key)));
|
initMediaEncryptionPreference((ListPreference) findPreference(getString(R.string.pref_media_encryption_key)));
|
||||||
initializeTransportPreferences((ListPreference) findPreference(getString(R.string.pref_transport_key)));
|
initializeTransportPreferences((ListPreference) findPreference(getString(R.string.pref_transport_key)));
|
||||||
|
@ -609,8 +669,24 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEcCalibrationStatus(EcCalibratorStatus status, int delayMs) {
|
public void onEcCalibrationStatus(final EcCalibratorStatus status, final int delayMs) {
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
CheckBoxPreference echoCancellation = (CheckBoxPreference) findPreference(getString(R.string.pref_echo_cancellation_key));
|
||||||
|
Preference echoCancellerCalibration = findPreference(getString(R.string.pref_echo_canceller_calibration_key));
|
||||||
|
|
||||||
|
if (status == EcCalibratorStatus.DoneNoEcho) {
|
||||||
|
echoCancellerCalibration.setSummary(R.string.no_echo);
|
||||||
|
echoCancellation.setChecked(false);
|
||||||
|
} else if (status == EcCalibratorStatus.Done) {
|
||||||
|
echoCancellerCalibration.setSummary(String.format(getString(R.string.ec_calibrated), delayMs));
|
||||||
|
echoCancellation.setChecked(true);
|
||||||
|
} else if (status == EcCalibratorStatus.Failed) {
|
||||||
|
echoCancellerCalibration.setSummary(R.string.failed);
|
||||||
|
echoCancellation.setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue