diff --git a/res/layout/assistant_codec_downloader.xml b/res/layout/assistant_codec_downloader.xml
new file mode 100644
index 000000000..61aaf6981
--- /dev/null
+++ b/res/layout/assistant_codec_downloader.xml
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 04e309487..cd3ac8d34 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -78,6 +78,9 @@
Your account has not been validated yet.
Your account has been validated.
Incorrect username or password
+ Do you agree to download OpenH264 Video Codec provided by Cisco Systems, Inc.?
+ Downloading OpenH264 Video Codec provided by Cisco Systems, Inc.
+ OpenH264 Video Codec provided by Cisco Systems, Inc. downloaded.
An error occurred, try again later.
Server unreachable, verify your network connection.
This username is already in use.
diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java
index 7b4c93429..ef4e12e48 100644
--- a/src/org/linphone/LinphoneManager.java
+++ b/src/org/linphone/LinphoneManager.java
@@ -39,6 +39,8 @@ import java.util.TimerTask;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.CallDirection;
+import org.linphone.core.CodecDownloadAction;
+import org.linphone.core.CodecDownloadListener;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneBuffer;
import org.linphone.core.LinphoneCall;
@@ -142,6 +144,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
private LinphonePreferences mPrefs;
private LinphoneCore mLc;
private CodecDownloader mCodecDownloader;
+ private CodecDownloadListener mCodecListener;
+ private CodecDownloadAction mCodecAction;
private String lastLcStatusMessage;
private String basePath;
private static boolean sExited;
@@ -220,116 +224,94 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
mLc.enableSpeaker(speakerOn);
}
- private void initCodecDownloader() {
- mCodecDownloader = new CodecDownloader() {
- Context ctxt = mServiceContext;
+ public void initCodecDownloader() {
+ mCodecListener = new CodecDownloadListener() {
ProgressDialog progress;
- CheckBoxPreference box;
+ int box = 1;
+ int ctxt = 0;
@Override
- public void listenerDownloadStarting() {
- if (mServiceContext == null) return;
+ public void listenerUpdateProgressBar(final int current, final int max) {
mHandler.post(new Runnable() {
@Override
public void run() {
- progress = new ProgressDialog(ctxt);
- progress.setCanceledOnTouchOutside(false);
- progress.setCancelable(false);
- progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ if (progress == null) {
+ progress = new ProgressDialog((Context)LinphoneManager.getInstance().getCodecDownloader().getUserData(ctxt));
+ progress.setCanceledOnTouchOutside(false);
+ progress.setCancelable(false);
+ progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ } else if (current <= max) {
+ progress.setMessage("Downloading OpenH264");
+ progress.setMax(max);
+ progress.setProgress(current);
+ progress.show();
+ } else {
+ progress.dismiss();
+ progress = null;
+ LinphoneCoreFactoryImpl.loadOptionalLibraryWithPath(((Context)LinphoneManager.getInstance().getCodecDownloader().getUserData(ctxt)).getFilesDir() + "/" + CodecDownloader.getNameLib());
+ LinphoneManager.getLc().reloadMsPlugins(null);
+ if (LinphoneManager.getInstance().getCodecDownloader().getUserDataSize() > box
+ && LinphoneManager.getInstance().getCodecDownloader().getUserData(box) != null)
+ ((CheckBoxPreference)LinphoneManager.getInstance().getCodecDownloader().getUserData(box)).setSummary(CodecDownloader.getLicenseMessage());
+ }
}
});
}
@Override
- public void listenerUpdateMsg(final int now, final int max) {
- if (progress == null) return;
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- progress.setMessage("Downloading OpenH264");
- progress.setMax(max);
- progress.setProgress(now);
- progress.show();
- }
- });
- }
-
- @Override
- public void listenerDownloadEnding() {
- if (progress == null) return;
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- progress.dismiss();
- LinphoneCoreFactoryImpl.loadOptionalLibraryWithPath(ctxt.getFilesDir()+"/" + CodecDownloader.getNameLib());
- LinphoneManager.getLc().reloadMsPlugins(null);
- AlertDialog.Builder builder = new AlertDialog.Builder(ctxt);
- builder.setMessage(CodecDownloader.getLicenseMessage() + " downloaded");
- builder.setCancelable(false);
- builder.setNeutralButton("Ok", null);
- builder.show();
- if (box != null) box.setSummary(CodecDownloader.getLicenseMessage());
- }
- });
- }
-
- @Override
- public void listenerDownloadFailed(final String error) {
+ public void listenerDownloadFailed (final String error){
if (progress == null) return;
mHandler.post(new Runnable() {
@Override
public void run() {
if (progress != null) progress.dismiss();
- AlertDialog.Builder builder = new AlertDialog.Builder(ctxt);
+ AlertDialog.Builder builder = new AlertDialog.Builder((Context)LinphoneManager.getInstance().getCodecDownloader().getUserData(ctxt));
builder.setMessage(error);
+ builder.setCancelable(false);
+ builder.setNeutralButton("Ok", null);
builder.show();
}
});
}
-
+ };
+ mCodecAction = new CodecDownloadAction() {
@Override
- public void startDownload(Context context, Object obj) {
- box = (CheckBoxPreference)obj;
- ctxt = context;
+ public void startDownload() {
askPopUp();
}
-
public void askPopUp() {
- AlertDialog.Builder builder = new AlertDialog.Builder(ctxt);
+ AlertDialog.Builder builder = new AlertDialog.Builder(LinphoneManager.getInstance().getContext());
builder.setCancelable(false);
- AlertDialog.Builder show = builder.setMessage("Do you want to download "
+ AlertDialog.Builder show = builder.setMessage("Do you agree to download "
+ CodecDownloader.getLicenseMessage()).setPositiveButton("Yes", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE)
mCodecDownloader.downloadCodec();
- }
- });
+ }
+ });
builder.setNegativeButton("No", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_NEGATIVE){
// Disable H264
- PayloadType h264 = null;
- for (PayloadType pt : mLc.getVideoCodecs()) {
- if (pt.getMime().equals("H264")) h264 = pt;
- }
-
- if (h264 == null) return;
-
- if (LinphonePreferences.instance().isFirstLaunch()) {
- try {
- mLc.enablePayloadType(h264, false);
- } catch (LinphoneCoreException e) {
- e.printStackTrace();
- }
- }
}
}
}).show();
}
};
+ mCodecDownloader = new CodecDownloader();
+ mCodecDownloader.setCodecDownloadlistener(mCodecListener);
+ mCodecDownloader.setCodecDownloadAction(mCodecAction);
+ }
+
+ public CodecDownloadListener getCodecDownloadListener() {
+ return mCodecListener;
+ }
+
+ public CodecDownloadAction getCodecDownloadAction() {
+ return mCodecAction;
}
public CodecDownloader getCodecDownloader(){
diff --git a/src/org/linphone/SettingsFragment.java b/src/org/linphone/SettingsFragment.java
index aa05344c6..4ca099e67 100644
--- a/src/org/linphone/SettingsFragment.java
+++ b/src/org/linphone/SettingsFragment.java
@@ -37,7 +37,6 @@ import org.linphone.tools.CodecDownloader;
import org.linphone.ui.LedPreference;
import org.linphone.ui.PreferencesListFragment;
-import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.preference.CheckBoxPreference;
@@ -540,7 +539,6 @@ public class SettingsFragment extends PreferencesListFragment {
}
private void initVideoSettings() {
- final Context ctxt = LinphoneManager.getInstance().getContext();
initializePreferredVideoSizePreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key)));
initializePreferredVideoFpsPreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_fps_key)));
EditTextPreference bandwidth = (EditTextPreference) findPreference(getString(R.string.pref_bandwidth_limit_key));
@@ -581,9 +579,14 @@ public class SettingsFragment extends PreferencesListFragment {
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean enable = (Boolean) newValue;
try {
+ CodecDownloader.setFileDirection(LinphoneManager.getInstance().getContext().getFilesDir().toString());
if (enable && Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86")
&& pt.getMime().equals("H264") && !CodecDownloader.codecExist()) {
- LinphoneManager.getInstance().getCodecDownloader().startDownload(ctxt, codec);
+ LinphoneManager.getInstance().getCodecDownloader().setCodecDownloadlistener(LinphoneManager.getInstance().getCodecDownloadListener());
+ LinphoneManager.getInstance().getCodecDownloader().setCodecDownloadAction(LinphoneManager.getInstance().getCodecDownloader().getCodecDownloadAction());
+ LinphoneManager.getInstance().getCodecDownloader().setUserData(0,LinphoneManager.getInstance().getContext());
+ LinphoneManager.getInstance().getCodecDownloader().setUserData(1,codec);
+ LinphoneManager.getInstance().getCodecDownloader().getCodecDownloadAction().startDownload();
}
LinphoneManager.getLcIfManagerNotDestroyedOrNull().enablePayloadType(pt, enable);
} catch (LinphoneCoreException e) {
diff --git a/src/org/linphone/assistant/AssistantActivity.java b/src/org/linphone/assistant/AssistantActivity.java
index 9a0a99e59..a73e6e7b7 100644
--- a/src/org/linphone/assistant/AssistantActivity.java
+++ b/src/org/linphone/assistant/AssistantActivity.java
@@ -27,12 +27,13 @@ import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAddress.TransportType;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.RegistrationState;
-import org.linphone.core.LinphoneCore.RemoteProvisioningState;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListenerBase;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.mediastream.Log;
+import org.linphone.mediastream.Version;
+import org.linphone.tools.CodecDownloader;
import android.Manifest;
import android.app.Activity;
@@ -242,10 +243,10 @@ private static AssistantActivity instance;
if (getPackageManager().checkPermission(Manifest.permission.RECORD_AUDIO, getPackageName()) == PackageManager.PERMISSION_GRANTED) {
launchEchoCancellerCalibration(true);
} else {
- success();
+ launchDownloadCodec();
}
} else {
- success();
+ launchDownloadCodec();
}
}
@@ -260,7 +261,7 @@ private static AssistantActivity instance;
back.setVisibility(View.VISIBLE);
cancel.setEnabled(false);
} else {
- success();
+ launchDownloadCodec();
}
} else {
checkAndRequestAudioPermission();
@@ -353,6 +354,22 @@ private static AssistantActivity instance;
//LinphoneManager.getInstance().restartLinphoneCore();
}
+ private void launchDownloadCodec() {
+ CodecDownloader.setFileDirection(LinphoneManager.getInstance().getContext().getFilesDir().toString());
+ if (Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86") && !CodecDownloader.codecExist()) {
+ CodecDownloaderFragment codecFragment = new CodecDownloaderFragment();
+ changeFragment(codecFragment);
+ currentFragment = AssistantFragmentsEnum.DOWNLOAD_CODEC;
+ back.setVisibility(View.VISIBLE);
+ cancel.setEnabled(false);
+ } else
+ endDownloadCodec();
+ }
+
+ public void endDownloadCodec() {
+ success();
+ }
+
public void saveCreatedAccount(String username, String password, String displayName, String domain, TransportType transport) {
if (accountCreated)
return;
@@ -484,7 +501,7 @@ private static AssistantActivity instance;
}
public void isEchoCalibrationFinished() {
- success();
+ launchDownloadCodec();
}
public Dialog createErrorDialog(LinphoneProxyConfig proxy, String message){
diff --git a/src/org/linphone/assistant/AssistantFragmentsEnum.java b/src/org/linphone/assistant/AssistantFragmentsEnum.java
index 64100511b..3f6cb5735 100644
--- a/src/org/linphone/assistant/AssistantFragmentsEnum.java
+++ b/src/org/linphone/assistant/AssistantFragmentsEnum.java
@@ -27,5 +27,6 @@ public enum AssistantFragmentsEnum {
LINPHONE_LOGIN,
LOGIN,
REMOTE_PROVISIONING,
- ECHO_CANCELLER_CALIBRATION;
+ ECHO_CANCELLER_CALIBRATION,
+ DOWNLOAD_CODEC;
}
diff --git a/src/org/linphone/assistant/CodecDownloaderFragment.java b/src/org/linphone/assistant/CodecDownloaderFragment.java
new file mode 100644
index 000000000..aa740ae9f
--- /dev/null
+++ b/src/org/linphone/assistant/CodecDownloaderFragment.java
@@ -0,0 +1,146 @@
+package org.linphone.assistant;
+
+/*
+CodecDownloaderFragment.java
+Copyright (C) 2016 Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
+import org.linphone.LinphoneManager;
+import org.linphone.R;
+import org.linphone.core.CodecDownloadListener;
+import org.linphone.core.LinphoneCoreException;
+import org.linphone.core.LinphoneCoreFactoryImpl;
+import org.linphone.core.PayloadType;
+import org.linphone.tools.CodecDownloader;
+
+/**
+ * @author Erwan CROZE
+ */
+public class CodecDownloaderFragment extends Fragment {
+ private Handler mHandler = new Handler();
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ final View view = inflater.inflate(R.layout.assistant_codec_downloader, container, false);
+
+ final TextView question = (TextView) view.findViewById(R.id.question);
+ final TextView downloading = (TextView) view.findViewById(R.id.downloading);
+ final TextView downloaded = (TextView) view.findViewById(R.id.downloaded);
+ final TextView yes = (TextView) view.findViewById(R.id.answerYes);
+ final TextView no = (TextView) view.findViewById(R.id.answerNo);
+ final ProgressBar bar = (ProgressBar) view.findViewById(R.id.progressBar);
+ final TextView downloadingInfo = (TextView) view.findViewById(R.id.downloadingInfo);
+
+ CodecDownloader.setFileDirection(LinphoneManager.getInstance().getContext().getFilesDir().toString());
+
+ final CodecDownloader codecDownloader = new CodecDownloader();
+ final CodecDownloadListener codecListener = new CodecDownloadListener() {
+
+ @Override
+ public void listenerUpdateProgressBar(final int current, final int max) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (current <= max) {
+ downloadingInfo.setText(current + " / " + max);
+ downloadingInfo.setVisibility(View.VISIBLE);
+ bar.setMax(max);
+ bar.setProgress(current);
+ bar.setVisibility(View.VISIBLE);
+ } else {
+ downloadingInfo.setVisibility(View.INVISIBLE);
+ bar.setVisibility(View.INVISIBLE);
+ LinphoneCoreFactoryImpl.loadOptionalLibraryWithPath(LinphoneManager.getInstance().getContext().getFilesDir() + "/" + CodecDownloader.getNameLib());
+ LinphoneManager.getLc().reloadMsPlugins(null);
+ downloading.setVisibility(View.INVISIBLE);
+ downloaded.setVisibility(View.VISIBLE);
+ AssistantActivity.instance().endDownloadCodec();
+ }
+ }
+ });
+ }
+
+ @Override
+ public void listenerDownloadFailed (final String error){
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ question.setVisibility(View.INVISIBLE);
+ downloading.setVisibility(View.INVISIBLE);
+ yes.setVisibility(View.INVISIBLE);
+ no.setVisibility(View.INVISIBLE);
+ bar.setVisibility(View.INVISIBLE);
+ downloadingInfo.setVisibility(View.INVISIBLE);
+ downloaded.setText(error);
+ downloaded.setVisibility(View.VISIBLE);
+ }
+ });
+ }
+ };
+
+ codecDownloader.setCodecDownloadlistener(codecListener);
+ downloading.setVisibility(View.INVISIBLE);
+ downloaded.setVisibility(View.INVISIBLE);
+ bar.setVisibility(View.INVISIBLE);
+ downloadingInfo.setVisibility(View.INVISIBLE);
+
+ yes.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ question.setVisibility(View.INVISIBLE);
+ yes.setVisibility(View.INVISIBLE);
+ no.setVisibility(View.INVISIBLE);
+ downloading.setVisibility(View.VISIBLE);
+ bar.setVisibility(View.VISIBLE);
+ downloadingInfo.setVisibility(View.INVISIBLE);
+ codecDownloader.downloadCodec();
+ }
+ });
+
+ no.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ PayloadType h264 = null;
+ for (PayloadType pt : LinphoneManager.getLc().getVideoCodecs()) {
+ if (pt.getMime().equals("H264")) h264 = pt;
+ }
+
+ if (h264 != null) {
+ try {
+ LinphoneManager.getLc().enablePayloadType(h264, false);
+ } catch (LinphoneCoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ AssistantActivity.instance().endDownloadCodec();
+ }
+ });
+
+ return view;
+ }
+}
diff --git a/src/org/linphone/assistant/WelcomeFragment.java b/src/org/linphone/assistant/WelcomeFragment.java
index 680f7b424..18a3d88ec 100644
--- a/src/org/linphone/assistant/WelcomeFragment.java
+++ b/src/org/linphone/assistant/WelcomeFragment.java
@@ -17,11 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-import org.linphone.LinphoneManager;
-import org.linphone.LinphonePreferences;
import org.linphone.R;
-import org.linphone.mediastream.Version;
-import org.linphone.tools.CodecDownloader;
import android.app.Fragment;
import android.os.Bundle;
@@ -42,12 +38,6 @@ public class WelcomeFragment extends Fragment implements OnClickListener {
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_welcome, container, false);
- LinphoneManager.getInstance().getCodecDownloader().setFileDirection(getContext().getFilesDir().toString());
- if (LinphonePreferences.instance().isFirstLaunch() && Version.getCpuAbis().contains("armeabi-v7a")
- && !Version.getCpuAbis().contains("x86") && !CodecDownloader.codecExist()) {
- LinphoneManager.getInstance().getCodecDownloader().startDownload(getContext(), null);
- }
-
createAccount = (Button) view.findViewById(R.id.create_account);
createAccount.setOnClickListener(this);
diff --git a/submodules/linphone b/submodules/linphone
index c4d988bba..b6bfc2dcb 160000
--- a/submodules/linphone
+++ b/submodules/linphone
@@ -1 +1 @@
-Subproject commit c4d988bba2eeac1cb5253d3210a831cbe10120c0
+Subproject commit b6bfc2dcb4ab2a3281cb3246f2862a06d3b43b58