From 67fe882265316ef0a57300d31eebf1e0bad7a756 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Wed, 27 Jul 2016 14:42:58 +0200 Subject: [PATCH] Add log for OpenH264 downloading --- .../core/LinphoneCoreFactoryImpl.java | 19 +++++++++++++------ .../tools/OpenH264DownloadHelper.java | 10 +++++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java index b0e1efdba..cc84f4e90 100644 --- a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java @@ -19,11 +19,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. package org.linphone.core; import android.content.Context; +import android.content.ContextWrapper; +import android.os.Environment; import java.io.File; import java.io.IOException; import java.util.List; +import org.linphone.LinphoneManager; import org.linphone.mediastream.MediastreamerAndroidContext; import org.linphone.mediastream.Version; import org.linphone.tools.OpenH264DownloadHelper; @@ -98,10 +101,12 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { } private void loadOpenH264(Context context) { - fcontext = context; - OpenH264DownloadHelper downloadHelper = new OpenH264DownloadHelper(fcontext); - if(downloadHelper != null && downloadHelper.isCodecFound()) { + OpenH264DownloadHelper downloadHelper = new OpenH264DownloadHelper(context); + if (downloadHelper.isCodecFound()) { + org.linphone.mediastream.Log.i("LinphoneCoreFactoryImpl"," Loading OpenH264 plugin:" + downloadHelper.getFullPathLib()); System.load(downloadHelper.getFullPathLib()); + } else { + org.linphone.mediastream.Log.i("LinphoneCoreFactoryImpl"," Cannot load OpenH264 plugin"); } } @@ -110,7 +115,8 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { String userConfig, String factoryConfig, Object userdata, Object context) throws LinphoneCoreException { try { - loadOpenH264((Context) context); + fcontext = (Context)context; + loadOpenH264(fcontext); MediastreamerAndroidContext.setContext(context); File user = userConfig == null ? null : new File(userConfig); File factory = factoryConfig == null ? null : new File(factoryConfig); @@ -125,7 +131,8 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { @Override public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, Object context) throws LinphoneCoreException { try { - loadOpenH264((Context) context); + fcontext = (Context)context; + loadOpenH264(fcontext); MediastreamerAndroidContext.setContext(context); LinphoneCore lc = new LinphoneCoreImpl(listener); if(context!=null) lc.setContext(context); @@ -148,7 +155,7 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { @Override public OpenH264DownloadHelper createOpenH264DownloadHelper() { if (fcontext == null) { - new LinphoneCoreException("Cannot create LinphoneCore"); + new LinphoneCoreException("Cannot create OpenH264DownloadHelper"); return null;//exception } return new OpenH264DownloadHelper(fcontext); diff --git a/java/impl/org/linphone/tools/OpenH264DownloadHelper.java b/java/impl/org/linphone/tools/OpenH264DownloadHelper.java index b7dc619df..aebd401c8 100644 --- a/java/impl/org/linphone/tools/OpenH264DownloadHelper.java +++ b/java/impl/org/linphone/tools/OpenH264DownloadHelper.java @@ -32,6 +32,7 @@ import java.util.ArrayList; import org.apache.commons.compress.compressors.bzip2.*; import org.linphone.core.OpenH264DownloadHelperListener; +import org.linphone.mediastream.Log; /** * @author Erwan Croze @@ -186,12 +187,14 @@ public class OpenH264DownloadHelper { URL url = new URL(urlDownload); HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); urlConnection.connect(); - + Log.i("OpenH264Downloader"," "); InputStream inputStream = urlConnection.getInputStream(); FileOutputStream fileOutputStream = new FileOutputStream(fileDirection+"/"+nameFileDownload); int totalSize = urlConnection.getContentLength(); openH264DownloadHelperListener.OnProgress(0,totalSize); + Log.i("OpenH264Downloader"," Download file:" + nameFileDownload); + byte[] buffer = new byte[4096]; int bufferLength; int total = 0; @@ -204,6 +207,8 @@ public class OpenH264DownloadHelper { fileOutputStream.close(); inputStream.close(); + Log.i("OpenH264Downloader"," Uncompress file:" + nameFileDownload); + FileInputStream in = new FileInputStream(fileDirection+"/"+nameFileDownload); FileOutputStream out = new FileOutputStream(path); BZip2CompressorInputStream bzIn = new BZip2CompressorInputStream(in); @@ -215,7 +220,10 @@ public class OpenH264DownloadHelper { out.close(); bzIn.close(); + Log.i("OpenH264Downloader"," Remove file:" + nameFileDownload); new File(fileDirection+"/"+nameFileDownload).delete(); + + Log.i("OpenH264Downloader"," Loading plugin:" + path); System.load(path); openH264DownloadHelperListener.OnProgress(2,1); } catch (FileNotFoundException e) {