From 8dd53e5eb673b6984ce9ed3fec4ffede6775dd03 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 3 Jan 2017 16:34:05 +0100 Subject: [PATCH] Refactoring loading of downloaded OpenH264 --- .../org/linphone/core/LinphoneCore.java | 8 +++---- .../core/LinphoneCoreFactoryImpl.java | 24 +++++++++---------- .../org/linphone/core/LinphoneCoreImpl.java | 10 ++++---- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 6a6fc589a..d6c89dc11 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -2504,16 +2504,16 @@ public interface LinphoneCore { public void setVerifyServerCN(boolean enable); /** - * Enable or not openh264 + * Enable or not openh264 download * @param enable */ - public void enableOpenH264(boolean enable); + public void enableDownloadOpenH264(boolean enable); /** - * Return if we enable openh264 + * Return if we enable openh264 download * @return */ - public boolean openH264Enabled(); + public boolean downloadOpenH264Enabled(); /** * @return a new LinphoneFriend link with this LinphoneCore diff --git a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java index eaac0e085..5eaf469dd 100644 --- a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java @@ -100,23 +100,21 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { return LpConfigImpl.fromBuffer(buffer); } - private boolean loadOpenH264(Context context) { + private boolean loadingDownloadedOpenH264(Context context) { File file = new File(context.getFilesDir()+"/../lib/libmsopenh264.so"); - // Only enable for android <= 5.0 - if (!file.exists() || Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { - Log.i("LinphoneCoreFactoryImpl"," Openh264 disabled on the project"); + if (!file.exists()) { + Log.i("LinphoneCoreFactoryImpl"," libmsopenh264 not found, we disable the download of Openh264"); return false; } OpenH264DownloadHelper downloadHelper = new OpenH264DownloadHelper(context); if (downloadHelper.isCodecFound()) { - Log.i("LinphoneCoreFactoryImpl"," Loading OpenH264 plugin:" + downloadHelper.getFullPathLib()); + Log.i("LinphoneCoreFactoryImpl"," Loading OpenH264 downloaded plugin:" + downloadHelper.getFullPathLib()); System.load(downloadHelper.getFullPathLib()); } else { - Log.i("LinphoneCoreFactoryImpl"," Cannot load OpenH264 plugin"); + Log.i("LinphoneCoreFactoryImpl"," Cannot load OpenH264 downloaded plugin"); } - return true; } @@ -126,13 +124,13 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { throws LinphoneCoreException { try { fcontext = (Context)context; - boolean openh264Enabled = false; - if (context != null) openh264Enabled = loadOpenH264(fcontext); + boolean openh264DownloadEnabled = false; + if (context != null) openh264DownloadEnabled = loadingDownloadedOpenH264(fcontext); MediastreamerAndroidContext.setContext(context); File user = userConfig == null ? null : new File(userConfig); File factory = factoryConfig == null ? null : new File(factoryConfig); LinphoneCore lc = new LinphoneCoreImpl(listener, user, factory, userdata); - lc.enableOpenH264(openh264Enabled); + lc.enableDownloadOpenH264(openh264DownloadEnabled); if (context != null) lc.setContext(context); return lc; } catch (IOException e) { @@ -144,11 +142,11 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, Object context) throws LinphoneCoreException { try { fcontext = (Context)context; - boolean openh264Enabled = false; - if (context != null) openh264Enabled = loadOpenH264(fcontext); + boolean openh264DownloadEnabled = false; + if (context != null) openh264DownloadEnabled = loadingDownloadedOpenH264(fcontext); MediastreamerAndroidContext.setContext(context); LinphoneCore lc = new LinphoneCoreImpl(listener); - lc.enableOpenH264(openh264Enabled); + lc.enableDownloadOpenH264(openh264DownloadEnabled); if (context != null) lc.setContext(context); return lc; } catch (IOException e) { diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 6d96b6848..e71cb4119 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -45,7 +45,7 @@ class LinphoneCoreImpl implements LinphoneCore { protected long nativePtr = 0; private Context mContext = null; private AudioManager mAudioManager = null; - private boolean openh264Enabled = false; + private boolean openh264DownloadEnabled = false; private boolean mSpeakerEnabled = false; private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata); private native void iterate(long nativePtr); @@ -1797,12 +1797,12 @@ class LinphoneCoreImpl implements LinphoneCore { setVerifyServerCN(nativePtr, enable); } - public void enableOpenH264(boolean enable) { - openh264Enabled = enable; + public void enableDownloadOpenH264(boolean enable) { + openh264DownloadEnabled = enable; } - public boolean openH264Enabled() { - return openh264Enabled; + public boolean downloadOpenH264Enabled() { + return openh264DownloadEnabled; } public LinphoneFriend createFriend() {