From b98e85186c1600658f9028676dbd34d736935e1a Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Wed, 21 Sep 2016 11:10:34 +0200 Subject: [PATCH] Don't load openh264 if not enabled on the project --- .../common/org/linphone/core/LinphoneCore.java | 14 +++++++++++++- .../linphone/core/LinphoneCoreFactoryImpl.java | 18 +++++++++++++++--- .../org/linphone/core/LinphoneCoreImpl.java | 9 +++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 0b34fc532..d4b75b2fc 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -79,7 +79,7 @@ public interface LinphoneCore { public String toString() { return mStringValue; } - } + } /** * linphone remote provisioning states */ @@ -2503,4 +2503,16 @@ public interface LinphoneCore { * @param path the path of the key */ public void setTlsKeyPath(String path); + + /** + * Enable or not openh264 + * @param enable + */ + public void enableOpenH264(boolean enable); + + /** + * Return if we enable openh264 + * @return + */ + public boolean openH264Enabled(); } diff --git a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java index a67ccea71..76f921fb3 100644 --- a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.IOException; import java.util.List; +import org.linphone.mediastream.Log; import org.linphone.mediastream.MediastreamerAndroidContext; import org.linphone.mediastream.Version; import org.linphone.tools.OpenH264DownloadHelper; @@ -97,7 +98,14 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { return LpConfigImpl.fromBuffer(buffer); } - private void loadOpenH264(Context context) { + private boolean loadOpenH264(Context context) { + File file = new File(context.getFilesDir()+"/../lib/libmsopenh264.so"); + + if (!file.exists()) { + Log.i("LinphoneCoreFactoryImpl"," Openh264 disabled on the project"); + return false; + } + OpenH264DownloadHelper downloadHelper = new OpenH264DownloadHelper(context); if (downloadHelper.isCodecFound()) { org.linphone.mediastream.Log.i("LinphoneCoreFactoryImpl"," Loading OpenH264 plugin:" + downloadHelper.getFullPathLib()); @@ -105,6 +113,8 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { } else { org.linphone.mediastream.Log.i("LinphoneCoreFactoryImpl"," Cannot load OpenH264 plugin"); } + + return true; } @Override @@ -113,11 +123,12 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { throws LinphoneCoreException { try { fcontext = (Context)context; - loadOpenH264(fcontext); + boolean openh264Enabled = loadOpenH264(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); if(context!=null) lc.setContext(context); return lc; } catch (IOException e) { @@ -129,9 +140,10 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, Object context) throws LinphoneCoreException { try { fcontext = (Context)context; - loadOpenH264(fcontext); + boolean openh264Enabled = loadOpenH264(fcontext); MediastreamerAndroidContext.setContext(context); LinphoneCore lc = new LinphoneCoreImpl(listener); + lc.enableOpenH264(openh264Enabled); 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 affa42d20..40cbf5416 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -45,6 +45,7 @@ class LinphoneCoreImpl implements LinphoneCore { protected long nativePtr = 0; private Context mContext = null; private AudioManager mAudioManager = null; + private boolean openh264Enabled = false; private boolean mSpeakerEnabled = false; private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata); private native void iterate(long nativePtr); @@ -1779,4 +1780,12 @@ class LinphoneCoreImpl implements LinphoneCore { public void setTlsKeyPath(String path) { setTlsKeyPath(nativePtr, path); } + + public void enableOpenH264(boolean enable) { + openh264Enabled = enable; + } + + public boolean openH264Enabled() { + return openh264Enabled; + } }