Commit 8dd53e5e authored by Erwan Croze's avatar Erwan Croze 👋🏻
Browse files

Refactoring loading of downloaded OpenH264

parent e34327f5
......@@ -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
......
......@@ -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) {
......
......@@ -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() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment