Adding possibility to download OpenH264 on 5.1 < device from the video
settings
This commit is contained in:
parent
db0a0cb46c
commit
d683537be7
2 changed files with 61 additions and 31 deletions
|
@ -289,10 +289,12 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
} else {
|
||||
progress.dismiss();
|
||||
progress = null;
|
||||
LinphoneManager.getLc().reloadMsPlugins(LinphoneManager.this.getContext().getApplicationInfo().nativeLibraryDir);
|
||||
if (ohcodec.getUserDataSize() > box && ohcodec.getUserData(box) != null) {
|
||||
((CheckBoxPreference) ohcodec.getUserData(box)).setSummary(mCodecDownloader.getLicenseMessage());
|
||||
((CheckBoxPreference) ohcodec.getUserData(box)).setTitle("OpenH264");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||
LinphoneManager.getLc().reloadMsPlugins(AssistantActivity.instance().getApplicationInfo().nativeLibraryDir);
|
||||
AssistantActivity.instance().endDownloadCodec();
|
||||
} else {
|
||||
// We need to restart due to bad android linker
|
||||
AssistantActivity.instance().restartApplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -679,57 +679,7 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
echoCancellerCalibration.setSummary(R.string.failed);
|
||||
}
|
||||
|
||||
private void initVideoSettings() {
|
||||
initializePreferredVideoSizePreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key)));
|
||||
initializePreferredVideoFpsPreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_fps_key)));
|
||||
EditTextPreference bandwidth = (EditTextPreference) findPreference(getString(R.string.pref_bandwidth_limit_key));
|
||||
bandwidth.setText(Integer.toString(mPrefs.getBandwidthLimit()));
|
||||
bandwidth.setSummary(bandwidth.getText());
|
||||
updateVideoPreferencesAccordingToPreset();
|
||||
|
||||
ListPreference videoPresetPref = (ListPreference) findPreference(getString(R.string.pref_video_preset_key));
|
||||
videoPresetPref.setSummary(mPrefs.getVideoPreset());
|
||||
videoPresetPref.setValue(mPrefs.getVideoPreset());
|
||||
|
||||
PreferenceCategory codecs = (PreferenceCategory) findPreference(getString(R.string.pref_video_codecs_key));
|
||||
codecs.removeAll();
|
||||
|
||||
final LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
||||
final OpenH264DownloadHelper mCodecDownloader = LinphoneManager.getInstance().getOpenH264DownloadHelper();
|
||||
|
||||
for (final PayloadType pt : lc.getVideoCodecs()) {
|
||||
final CheckBoxPreference codec = new CheckBoxPreference(getActivity());
|
||||
codec.setTitle(pt.getMime());
|
||||
|
||||
if (!pt.getMime().equals("VP8")) {
|
||||
if (getResources().getBoolean(R.bool.disable_all_patented_codecs_for_markets)) {
|
||||
continue;
|
||||
} else {
|
||||
if (!Version.hasFastCpuWithAsmOptim() && pt.getMime().equals("H264"))
|
||||
{
|
||||
// Android without neon doesn't support H264
|
||||
Log.w("CPU does not have asm optimisations available, disabling H264");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lc.downloadOpenH264Enabled()) {
|
||||
if (pt.getMime().equals("H264") && mCodecDownloader.isCodecFound()) {
|
||||
codec.setSummary(mCodecDownloader.getLicenseMessage());
|
||||
codec.setTitle("OpenH264");
|
||||
}
|
||||
}
|
||||
codec.setChecked(lc.isPayloadTypeEnabled(pt));
|
||||
|
||||
codec.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
boolean enable = (Boolean) newValue;
|
||||
try {
|
||||
if (lc.downloadOpenH264Enabled()) {
|
||||
if (enable && Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86")
|
||||
&& pt.getMime().equals("H264") && !mCodecDownloader.isCodecFound()) {
|
||||
private void initOpenH264AlertDialog(final OpenH264DownloadHelper mCodecDownloader, final CheckBoxPreference codec) {
|
||||
mCodecDownloader.setOpenH264HelperListener(LinphoneManager.getInstance().getOpenH264HelperListener());
|
||||
mCodecDownloader.setUserData(0, LinphoneManager.getInstance().getContext());
|
||||
mCodecDownloader.setUserData(1, codec);
|
||||
|
@ -748,10 +698,67 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == DialogInterface.BUTTON_NEGATIVE) {
|
||||
// Disable H264
|
||||
codec.setChecked(false);
|
||||
}
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
private void initVideoSettings() {
|
||||
initializePreferredVideoSizePreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key)));
|
||||
initializePreferredVideoFpsPreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_fps_key)));
|
||||
EditTextPreference bandwidth = (EditTextPreference) findPreference(getString(R.string.pref_bandwidth_limit_key));
|
||||
bandwidth.setText(Integer.toString(mPrefs.getBandwidthLimit()));
|
||||
bandwidth.setSummary(bandwidth.getText());
|
||||
updateVideoPreferencesAccordingToPreset();
|
||||
|
||||
ListPreference videoPresetPref = (ListPreference) findPreference(getString(R.string.pref_video_preset_key));
|
||||
videoPresetPref.setSummary(mPrefs.getVideoPreset());
|
||||
videoPresetPref.setValue(mPrefs.getVideoPreset());
|
||||
|
||||
PreferenceCategory codecs = (PreferenceCategory) findPreference(getString(R.string.pref_video_codecs_key));
|
||||
codecs.removeAll();
|
||||
|
||||
final LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
||||
final OpenH264DownloadHelper mCodecDownloader = LinphoneManager.getInstance().getOpenH264DownloadHelper();
|
||||
boolean h264IsHere = false;
|
||||
for (final PayloadType pt : lc.getVideoCodecs()) {
|
||||
final CheckBoxPreference codec = new CheckBoxPreference(getActivity());
|
||||
codec.setTitle(pt.getMime());
|
||||
|
||||
if (!pt.getMime().equals("VP8")) {
|
||||
if (getResources().getBoolean(R.bool.disable_all_patented_codecs_for_markets)) {
|
||||
continue;
|
||||
} else {
|
||||
if (!Version.hasFastCpuWithAsmOptim() && pt.getMime().equals("H264")) {
|
||||
// Android without neon doesn't support H264
|
||||
Log.w("CPU does not have asm optimisations available, disabling H264");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lc.downloadOpenH264Enabled()) {
|
||||
if (pt.getMime().equals("H264")) {
|
||||
h264IsHere = true;
|
||||
if (mCodecDownloader.isCodecFound()) {
|
||||
codec.setSummary(mCodecDownloader.getLicenseMessage());
|
||||
codec.setTitle("OpenH264");
|
||||
}
|
||||
}
|
||||
}
|
||||
codec.setChecked(lc.isPayloadTypeEnabled(pt));
|
||||
|
||||
codec.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
boolean enable = (Boolean) newValue;
|
||||
try {
|
||||
if (lc.downloadOpenH264Enabled()) {
|
||||
if (enable && Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86")
|
||||
&& pt.getMime().equals("H264") && !mCodecDownloader.isCodecFound()) {
|
||||
initOpenH264AlertDialog(mCodecDownloader, codec);
|
||||
}
|
||||
}
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().enablePayloadType(pt, enable);
|
||||
} catch (LinphoneCoreException e) {
|
||||
|
@ -763,6 +770,27 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
|
||||
codecs.addPreference(codec);
|
||||
}
|
||||
// Adding OpenH264 button on device < 5.1
|
||||
if (lc.downloadOpenH264Enabled() && !h264IsHere) {
|
||||
final CheckBoxPreference codec = new CheckBoxPreference(getActivity());
|
||||
codec.setTitle("OpenH264");
|
||||
codec.setSummary(mCodecDownloader.getLicenseMessage());
|
||||
//codec.setEnabled(false);
|
||||
codec.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
boolean enable = (Boolean) newValue;
|
||||
if (lc.downloadOpenH264Enabled()) {
|
||||
if (enable && Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86")
|
||||
&& !mCodecDownloader.isCodecFound()) {
|
||||
initOpenH264AlertDialog(mCodecDownloader, codec);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
codecs.addPreference(codec);
|
||||
}
|
||||
((CheckBoxPreference) findPreference(getString(R.string.pref_video_enable_key))).setChecked(mPrefs.isVideoEnabled());
|
||||
((CheckBoxPreference) findPreference(getString(R.string.pref_video_use_front_camera_key))).setChecked(mPrefs.useFrontCam());
|
||||
((CheckBoxPreference) findPreference(getString(R.string.pref_video_initiate_call_with_video_key))).setChecked(mPrefs.shouldInitiateVideoCall());
|
||||
|
|
Loading…
Reference in a new issue