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 {
|
} else {
|
||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
progress = null;
|
progress = null;
|
||||||
LinphoneManager.getLc().reloadMsPlugins(LinphoneManager.this.getContext().getApplicationInfo().nativeLibraryDir);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
if (ohcodec.getUserDataSize() > box && ohcodec.getUserData(box) != null) {
|
LinphoneManager.getLc().reloadMsPlugins(AssistantActivity.instance().getApplicationInfo().nativeLibraryDir);
|
||||||
((CheckBoxPreference) ohcodec.getUserData(box)).setSummary(mCodecDownloader.getLicenseMessage());
|
AssistantActivity.instance().endDownloadCodec();
|
||||||
((CheckBoxPreference) ohcodec.getUserData(box)).setTitle("OpenH264");
|
} else {
|
||||||
|
// We need to restart due to bad android linker
|
||||||
|
AssistantActivity.instance().restartApplication();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -679,6 +679,31 @@ public class SettingsFragment extends PreferencesListFragment {
|
||||||
echoCancellerCalibration.setSummary(R.string.failed);
|
echoCancellerCalibration.setSummary(R.string.failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initOpenH264AlertDialog(final OpenH264DownloadHelper mCodecDownloader, final CheckBoxPreference codec) {
|
||||||
|
mCodecDownloader.setOpenH264HelperListener(LinphoneManager.getInstance().getOpenH264HelperListener());
|
||||||
|
mCodecDownloader.setUserData(0, LinphoneManager.getInstance().getContext());
|
||||||
|
mCodecDownloader.setUserData(1, codec);
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(LinphoneManager.getInstance().getContext());
|
||||||
|
builder.setCancelable(false);
|
||||||
|
builder.setMessage("Do you agree to download " + mCodecDownloader.getLicenseMessage()).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (which == DialogInterface.BUTTON_POSITIVE)
|
||||||
|
mCodecDownloader.downloadCodec();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if (which == DialogInterface.BUTTON_NEGATIVE) {
|
||||||
|
// Disable H264
|
||||||
|
codec.setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
|
||||||
private void initVideoSettings() {
|
private void initVideoSettings() {
|
||||||
initializePreferredVideoSizePreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key)));
|
initializePreferredVideoSizePreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key)));
|
||||||
initializePreferredVideoFpsPreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_fps_key)));
|
initializePreferredVideoFpsPreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_fps_key)));
|
||||||
|
@ -697,7 +722,7 @@ public class SettingsFragment extends PreferencesListFragment {
|
||||||
final LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
final LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
|
||||||
final OpenH264DownloadHelper mCodecDownloader = LinphoneManager.getInstance().getOpenH264DownloadHelper();
|
final OpenH264DownloadHelper mCodecDownloader = LinphoneManager.getInstance().getOpenH264DownloadHelper();
|
||||||
|
boolean h264IsHere = false;
|
||||||
for (final PayloadType pt : lc.getVideoCodecs()) {
|
for (final PayloadType pt : lc.getVideoCodecs()) {
|
||||||
final CheckBoxPreference codec = new CheckBoxPreference(getActivity());
|
final CheckBoxPreference codec = new CheckBoxPreference(getActivity());
|
||||||
codec.setTitle(pt.getMime());
|
codec.setTitle(pt.getMime());
|
||||||
|
@ -706,8 +731,7 @@ public class SettingsFragment extends PreferencesListFragment {
|
||||||
if (getResources().getBoolean(R.bool.disable_all_patented_codecs_for_markets)) {
|
if (getResources().getBoolean(R.bool.disable_all_patented_codecs_for_markets)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (!Version.hasFastCpuWithAsmOptim() && pt.getMime().equals("H264"))
|
if (!Version.hasFastCpuWithAsmOptim() && pt.getMime().equals("H264")) {
|
||||||
{
|
|
||||||
// Android without neon doesn't support H264
|
// Android without neon doesn't support H264
|
||||||
Log.w("CPU does not have asm optimisations available, disabling H264");
|
Log.w("CPU does not have asm optimisations available, disabling H264");
|
||||||
continue;
|
continue;
|
||||||
|
@ -715,9 +739,12 @@ public class SettingsFragment extends PreferencesListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lc.downloadOpenH264Enabled()) {
|
if (lc.downloadOpenH264Enabled()) {
|
||||||
if (pt.getMime().equals("H264") && mCodecDownloader.isCodecFound()) {
|
if (pt.getMime().equals("H264")) {
|
||||||
codec.setSummary(mCodecDownloader.getLicenseMessage());
|
h264IsHere = true;
|
||||||
codec.setTitle("OpenH264");
|
if (mCodecDownloader.isCodecFound()) {
|
||||||
|
codec.setSummary(mCodecDownloader.getLicenseMessage());
|
||||||
|
codec.setTitle("OpenH264");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codec.setChecked(lc.isPayloadTypeEnabled(pt));
|
codec.setChecked(lc.isPayloadTypeEnabled(pt));
|
||||||
|
@ -730,27 +757,7 @@ public class SettingsFragment extends PreferencesListFragment {
|
||||||
if (lc.downloadOpenH264Enabled()) {
|
if (lc.downloadOpenH264Enabled()) {
|
||||||
if (enable && Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86")
|
if (enable && Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86")
|
||||||
&& pt.getMime().equals("H264") && !mCodecDownloader.isCodecFound()) {
|
&& pt.getMime().equals("H264") && !mCodecDownloader.isCodecFound()) {
|
||||||
mCodecDownloader.setOpenH264HelperListener(LinphoneManager.getInstance().getOpenH264HelperListener());
|
initOpenH264AlertDialog(mCodecDownloader, codec);
|
||||||
mCodecDownloader.setUserData(0, LinphoneManager.getInstance().getContext());
|
|
||||||
mCodecDownloader.setUserData(1, codec);
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(LinphoneManager.getInstance().getContext());
|
|
||||||
builder.setCancelable(false);
|
|
||||||
builder.setMessage("Do you agree to download " + mCodecDownloader.getLicenseMessage()).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE)
|
|
||||||
mCodecDownloader.downloadCodec();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if (which == DialogInterface.BUTTON_NEGATIVE) {
|
|
||||||
// Disable H264
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().enablePayloadType(pt, enable);
|
LinphoneManager.getLcIfManagerNotDestroyedOrNull().enablePayloadType(pt, enable);
|
||||||
|
@ -763,6 +770,27 @@ public class SettingsFragment extends PreferencesListFragment {
|
||||||
|
|
||||||
codecs.addPreference(codec);
|
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_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_use_front_camera_key))).setChecked(mPrefs.useFrontCam());
|
||||||
((CheckBoxPreference) findPreference(getString(R.string.pref_video_initiate_call_with_video_key))).setChecked(mPrefs.shouldInitiateVideoCall());
|
((CheckBoxPreference) findPreference(getString(R.string.pref_video_initiate_call_with_video_key))).setChecked(mPrefs.shouldInitiateVideoCall());
|
||||||
|
|
Loading…
Reference in a new issue