Commit 67fe8822 authored by Erwan Croze's avatar Erwan Croze 👋🏻
Browse files

Add log for OpenH264 downloading

parent f6381d91
......@@ -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);
......
......@@ -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) {
......
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