Merge remote-tracking branch 'origin/dev_codec_downloader'

This commit is contained in:
Erwan Croze 2016-07-27 09:34:16 +02:00
commit 3d26997367
12 changed files with 909 additions and 8 deletions

View file

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp"
android:orientation="vertical" >
<TextView
android:text="@string/assistant_codec_down_question"
style="@style/font7"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/question"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_above="@+id/answerNo"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/downloadingInfo"
android:layout_alignEnd="@+id/downloadingInfo"/>
<TextView
style="@style/font7"
android:text="@string/assistant_codec_downloading"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloading"
android:layout_above="@+id/imageView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<Button
style="@style/font7"
android:text="No"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerNo"
android:layout_marginBottom="35dp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/imageView"
android:layout_toStartOf="@+id/imageView"
android:layout_marginRight="26dp"
android:layout_marginEnd="26dp"/>
<Button
style="@style/font7"
android:text="Yes"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerYes"
android:layout_below="@+id/progressBar"
android:layout_alignRight="@+id/progressBar"
android:layout_alignEnd="@+id/progressBar"/>
<Button
style="@style/font7"
android:text="Ok"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerOk"
android:layout_alignTop="@+id/answerYes"
android:layout_centerHorizontal="true"/>
<TextView
style="@style/font7"
android:text="@string/assistant_codec_downloaded"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloaded"
android:layout_above="@+id/imageView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
style="@style/font7"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloadingInfo"
android:layout_above="@+id/progressBar"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>

View file

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp"
android:orientation="vertical" >
<TextView
android:text="@string/assistant_codec_down_question"
style="@style/font7"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/question"
android:layout_alignTop="@+id/downloading"
android:layout_centerHorizontal="true"/>
<ImageView
android:src="@drawable/linphone_logo_orange"
android:layout_width="150dp"
android:layout_height="150dp"
android:id="@+id/imageView"
android:layout_marginTop="38dp"
android:layout_below="@+id/question"
android:layout_centerHorizontal="true"/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_alignBottom="@+id/answerNo"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
style="@style/font7"
android:text="@string/assistant_codec_downloading"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloading"
android:layout_alignTop="@+id/downloaded"
android:layout_alignLeft="@+id/question"
android:layout_alignStart="@+id/question"/>
<Button
style="@style/font7"
android:text="No"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerNo"
android:layout_marginBottom="40dp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/imageView"
android:layout_toStartOf="@+id/imageView"/>
<Button
style="@style/font7"
android:text="Yes"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerYes"
android:layout_alignTop="@+id/answerOk"
android:layout_toRightOf="@+id/imageView"
android:layout_toEndOf="@+id/imageView"/>
<Button
style="@style/font7"
android:text="Ok"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerOk"
android:layout_alignTop="@+id/answerNo"
android:layout_centerHorizontal="true"/>
<TextView
style="@style/font7"
android:text="@string/assistant_codec_downloaded"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloaded"
android:layout_marginTop="36dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>
<TextView
style="@style/font7"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloadingInfo"
android:layout_above="@+id/answerOk"
android:layout_centerHorizontal="true"/>
</RelativeLayout>

View file

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp"
android:orientation="vertical" >
<TextView
android:text="@string/assistant_codec_down_question"
style="@style/font7"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/question"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="145dp"/>
<ImageView
android:src="@drawable/linphone_logo_orange"
android:layout_width="150dp"
android:layout_height="150dp"
android:id="@+id/imageView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_below="@+id/imageView"
android:layout_marginTop="107dp"
android:layout_alignRight="@+id/question"
android:layout_alignEnd="@+id/question"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
style="@style/font7"
android:text="@string/assistant_codec_downloading"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloading"
android:layout_alignTop="@+id/downloaded"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<Button
style="@style/font7"
android:text="No"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerNo"
android:layout_marginBottom="40dp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/imageView"
android:layout_toStartOf="@+id/imageView"/>
<Button
style="@style/font7"
android:text="Yes"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerYes"
android:layout_alignTop="@+id/answerOk"
android:layout_toRightOf="@+id/imageView"
android:layout_toEndOf="@+id/imageView"/>
<Button
style="@style/font7"
android:text="Ok"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerOk"
android:layout_alignTop="@+id/answerNo"
android:layout_centerHorizontal="true"/>
<TextView
style="@style/font7"
android:text="@string/assistant_codec_downloaded"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloaded"
android:layout_alignBaseline="@+id/question"
android:layout_alignBottom="@+id/question"
android:layout_centerHorizontal="true"/>
<TextView
style="@style/font7"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloadingInfo"
android:layout_marginBottom="29dp"
android:layout_alignBottom="@+id/progressBar"
android:layout_centerHorizontal="true"/>
</RelativeLayout>

View file

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp"
android:orientation="vertical" >
<TextView
android:text="@string/assistant_codec_down_question"
style="@style/font7"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/question"
android:layout_alignTop="@+id/downloading"
android:layout_centerHorizontal="true"/>
<ImageView
android:src="@drawable/linphone_logo_orange"
android:layout_width="150dp"
android:layout_height="150dp"
android:id="@+id/imageView"
android:layout_marginTop="96dp"
android:layout_below="@+id/question"
android:layout_centerHorizontal="true"/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_below="@+id/imageView"
android:layout_marginTop="120dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
style="@style/font7"
android:text="@string/assistant_codec_downloading"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloading"
android:layout_alignTop="@+id/downloaded"
android:layout_alignLeft="@+id/question"
android:layout_alignStart="@+id/question"/>
<Button
style="@style/font7"
android:text="No"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerNo"
android:layout_marginBottom="40dp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/imageView"
android:layout_toStartOf="@+id/imageView"/>
<Button
style="@style/font7"
android:text="Yes"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerYes"
android:layout_alignTop="@+id/answerOk"
android:layout_toRightOf="@+id/imageView"
android:layout_toEndOf="@+id/imageView"/>
<Button
style="@style/font7"
android:text="Ok"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerOk"
android:layout_alignTop="@+id/answerNo"
android:layout_centerHorizontal="true"/>
<TextView
style="@style/font7"
android:text="@string/assistant_codec_downloaded"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloaded"
android:layout_marginTop="37dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>
<TextView
style="@style/font7"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloadingInfo"
android:layout_alignBottom="@+id/progressBar"
android:layout_centerHorizontal="true"
android:layout_marginBottom="54dp"/>
</RelativeLayout>

View file

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp"
android:orientation="vertical" >
<TextView
android:text="@string/assistant_codec_down_question"
style="@style/font7"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/question"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<ImageView
android:src="@drawable/linphone_logo_orange"
android:layout_width="150dp"
android:layout_height="150dp"
android:id="@+id/imageView"
android:layout_below="@+id/question"
android:layout_centerHorizontal="true"
android:layout_marginTop="36dp"/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_marginBottom="50dp"
android:layout_above="@+id/answerNo"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<TextView
style="@style/font7"
android:text="@string/assistant_codec_downloading"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloading"
android:layout_above="@+id/imageView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<Button
style="@style/font7"
android:text="No"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerNo"
android:layout_marginBottom="35dp"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/imageView"
android:layout_toStartOf="@+id/imageView"
android:layout_marginRight="26dp"
android:layout_marginEnd="26dp"/>
<Button
style="@style/font7"
android:text="Yes"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerYes"
android:layout_below="@+id/progressBar"
android:layout_toRightOf="@+id/imageView"
android:layout_toEndOf="@+id/imageView"/>
<Button
style="@style/font7"
android:text="Ok"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/answerOk"
android:layout_alignTop="@+id/answerYes"
android:layout_centerHorizontal="true"/>
<TextView
style="@style/font7"
android:text="@string/assistant_codec_downloaded"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloaded"
android:layout_above="@+id/imageView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
style="@style/font7"
android:textAllCaps="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/downloadingInfo"
android:layout_above="@+id/progressBar"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>

View file

@ -77,6 +77,9 @@
<string name="assistant_account_not_validated">Your account has not been validated yet.</string>
<string name="assistant_account_validated">Your account has been validated.</string>
<string name="assistant_error_bad_credentials">Incorrect username or password</string>
<string name="assistant_codec_down_question">Do you agree to download OpenH264 Video Codec provided by Cisco Systems, Inc.?</string>
<string name="assistant_codec_downloading">Downloading OpenH264 Video Codec provided by Cisco Systems, Inc.</string>
<string name="assistant_codec_downloaded">OpenH264 Video Codec provided by Cisco Systems, Inc. downloaded.</string>
<string name="wizard_failed">An error occurred, try again later.</string>
<string name="wizard_server_unavailable">Server unreachable, verify your network connection.</string>
<string name="wizard_username_unavailable">This username is already in use.</string>

View file

@ -38,6 +38,8 @@ import java.util.TimerTask;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.CallDirection;
import org.linphone.core.OpenH264DownloadHelperAction;
import org.linphone.core.OpenH264DownloadHelperListener;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneBuffer;
import org.linphone.core.LinphoneCall;
@ -55,6 +57,7 @@ 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.LinphoneCoreFactoryImpl;
import org.linphone.core.LinphoneCoreListener;
import org.linphone.core.LinphoneEvent;
import org.linphone.core.LinphoneFriend;
@ -72,13 +75,17 @@ import org.linphone.mediastream.Version;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera;
import org.linphone.mediastream.video.capture.hwconf.Hacks;
import org.linphone.tools.OpenH264DownloadHelper;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager.NameNotFoundException;
@ -97,6 +104,9 @@ import android.os.Handler;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.Vibrator;
import android.preference.CheckBoxPreference;
import android.provider.MediaStore;
import android.provider.MediaStore.Images;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.telephony.TelephonyManager;
@ -130,6 +140,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
private Resources mR;
private LinphonePreferences mPrefs;
private LinphoneCore mLc;
private OpenH264DownloadHelper mCodecDownloader;
private OpenH264DownloadHelperListener mCodecListener;
private String lastLcStatusMessage;
private String basePath;
private static boolean sExited;
@ -207,6 +219,66 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
mLc.enableSpeaker(speakerOn);
}
public void initOpenH264Helper() {
mCodecDownloader = LinphoneCoreFactory.instance().createOpenH264DownloadHelper();
mCodecListener = new OpenH264DownloadHelperListener() {
ProgressDialog progress;
int box = 1;
int ctxt = 0;
@Override
public void OnProgress(final int current, final int max) {
mHandler.post(new Runnable() {
@Override
public void run() {
OpenH264DownloadHelper ohcodec = LinphoneManager.getInstance().getOpenH264DownloadHelper();
if (progress == null) {
progress = new ProgressDialog((Context)ohcodec.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;
LinphoneManager.getLc().reloadMsPlugins(null);
if (ohcodec.getUserDataSize() > box && ohcodec.getUserData(box) != null)
((CheckBoxPreference)ohcodec.getUserData(box)).setSummary(mCodecDownloader.getLicenseMessage());
}
}
});
}
@Override
public void OnError (final String error){
mHandler.post(new Runnable() {
@Override
public void run() {
if (progress != null) progress.dismiss();
AlertDialog.Builder builder = new AlertDialog.Builder((Context)LinphoneManager.getInstance().getOpenH264DownloadHelper().getUserData(ctxt));
builder.setMessage("Sorry an error has occurred.");
builder.setCancelable(false);
builder.setNeutralButton("Ok", null);
builder.show();
}
});
}
};
mCodecDownloader.setOpenH264HelperListener(mCodecListener);
}
public OpenH264DownloadHelperListener getOpenH264HelperListener() {
return mCodecListener;
}
public OpenH264DownloadHelper getOpenH264DownloadHelper(){
return mCodecDownloader;
}
public void routeAudioToSpeaker() {
routeAudioToSpeakerHelper(true);
}
@ -891,6 +963,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
if (state == GlobalState.GlobalOn){
try {
initLiblinphone(lc);
initOpenH264Helper();
} catch (LinphoneCoreException e) {
Log.e(e);
}

View file

@ -35,10 +35,13 @@ import org.linphone.core.PayloadType;
import org.linphone.mediastream.Log;
import org.linphone.mediastream.Version;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import org.linphone.tools.OpenH264DownloadHelper;
import org.linphone.purchase.InAppPurchaseActivity;
import org.linphone.ui.LedPreference;
import org.linphone.ui.PreferencesListFragment;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.Manifest;
import android.content.Context;
import android.content.Intent;
@ -639,8 +642,9 @@ public class SettingsFragment extends PreferencesListFragment {
codecs.removeAll();
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
final OpenH264DownloadHelper mCodecDownloader = LinphoneManager.getInstance().getOpenH264DownloadHelper();
for (final PayloadType pt : lc.getVideoCodecs()) {
CheckBoxPreference codec = new CheckBoxPreference(getActivity());
final CheckBoxPreference codec = new CheckBoxPreference(getActivity());
codec.setTitle(pt.getMime());
if (!pt.getMime().equals("VP8")) {
@ -655,6 +659,8 @@ public class SettingsFragment extends PreferencesListFragment {
}
}
}
if (pt.getMime().equals("H264") && mCodecDownloader.isCodecFound())
codec.setSummary(mCodecDownloader.getLicenseMessage());
codec.setChecked(lc.isPayloadTypeEnabled(pt));
codec.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@ -662,6 +668,31 @@ public class SettingsFragment extends PreferencesListFragment {
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean enable = (Boolean) newValue;
try {
if (enable && Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86")
&& pt.getMime().equals("H264") && !mCodecDownloader.isCodecFound()) {
LinphoneManager.getInstance().getOpenH264DownloadHelper().setOpenH264HelperListener(LinphoneManager.getInstance().getOpenH264HelperListener());
LinphoneManager.getInstance().getOpenH264DownloadHelper().setUserData(0,LinphoneManager.getInstance().getContext());
LinphoneManager.getInstance().getOpenH264DownloadHelper().setUserData(1,codec);
AlertDialog.Builder builder = new AlertDialog.Builder(LinphoneManager.getInstance().getContext());
builder.setCancelable(false);
AlertDialog.Builder show = builder.setMessage("Do you agree to download "
+ mCodecDownloader.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
}
}
}).show();
}
LinphoneManager.getLcIfManagerNotDestroyedOrNull().enablePayloadType(pt, enable);
} catch (LinphoneCoreException e) {
Log.e(e);

View file

@ -33,6 +33,8 @@ 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.OpenH264DownloadHelper;
import android.Manifest;
import android.app.Activity;
@ -75,6 +77,7 @@ private static AssistantActivity instance;
private ProgressDialog progress;
private Dialog dialog;
private boolean remoteProvisioningInProgress;
private boolean echoCancellerAlreadyDone;
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 201;
protected void onCreate(Bundle savedInstanceState) {
@ -95,6 +98,11 @@ private static AssistantActivity instance;
currentFragment = (AssistantFragmentsEnum) savedInstanceState.getSerializable("CurrentFragment");
}
}
if (savedInstanceState != null && savedInstanceState.containsKey("echoCanceller")) {
echoCancellerAlreadyDone = savedInstanceState.getBoolean("echoCanceller");
} else {
echoCancellerAlreadyDone = false;
}
mPrefs = LinphonePreferences.instance();
//if(mPrefs.isFirstLaunch()) {
status.enableSideMenu(false);
@ -155,6 +163,7 @@ private static AssistantActivity instance;
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putSerializable("CurrentFragment", currentFragment);
outState.putBoolean("echoCanceller", echoCancellerAlreadyDone);
super.onSaveInstanceState(outState);
}
@ -180,6 +189,10 @@ private static AssistantActivity instance;
transaction.commitAllowingStateLoss();
}
public AssistantFragmentsEnum getCurrentFragment() {
return currentFragment;
}
@Override
public void onClick(View v) {
int id = v.getId();
@ -254,10 +267,10 @@ private static AssistantActivity instance;
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
launchEchoCancellerCalibration(true);
} else {
goToLinphoneActivity();
isEchoCalibrationFinished();
}
} else {
goToLinphoneActivity();
isEchoCalibrationFinished();
}
}
@ -363,6 +376,22 @@ private static AssistantActivity instance;
//LinphoneManager.getInstance().restartLinphoneCore();
}
private void launchDownloadCodec() {
OpenH264DownloadHelper downloadHelper = LinphoneCoreFactory.instance().createOpenH264DownloadHelper();
if (Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86") && !downloadHelper.isCodecFound()) {
CodecDownloaderFragment codecFragment = new CodecDownloaderFragment();
changeFragment(codecFragment);
currentFragment = AssistantFragmentsEnum.DOWNLOAD_CODEC;
back.setVisibility(View.VISIBLE);
cancel.setEnabled(false);
} else
goToLinphoneActivity();
}
public void endDownloadCodec() {
goToLinphoneActivity();
}
public void saveCreatedAccount(String username, String password, String displayName, String domain, TransportType transport) {
if (accountCreated)
return;
@ -486,7 +515,7 @@ private static AssistantActivity instance;
}
public void isEchoCalibrationFinished() {
goToLinphoneActivity();
launchDownloadCodec();
}
public Dialog createErrorDialog(LinphoneProxyConfig proxy, String message){
@ -517,7 +546,7 @@ private static AssistantActivity instance;
if (needsEchoCalibration && mPrefs.isFirstLaunch()) {
launchEchoCancellerCalibration(true);
} else {
goToLinphoneActivity();
launchDownloadCodec();
}
}

View file

@ -27,5 +27,6 @@ public enum AssistantFragmentsEnum {
LINPHONE_LOGIN,
LOGIN,
REMOTE_PROVISIONING,
ECHO_CANCELLER_CALIBRATION;
ECHO_CANCELLER_CALIBRATION,
DOWNLOAD_CODEC;
}

View file

@ -0,0 +1,209 @@
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.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager;
import org.linphone.R;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.OpenH264DownloadHelperListener;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.PayloadType;
import org.linphone.tools.OpenH264DownloadHelper;
/**
* @author Erwan CROZE
*/
public class CodecDownloaderFragment extends Fragment {
private Handler mHandler = new Handler();
private TextView question;
private TextView downloading;
private TextView downloaded;
private Button yes;
private Button no;
private Button ok;
private ProgressBar bar;
private TextView downloadingInfo;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.assistant_codec_downloader, container, false);
question = (TextView) view.findViewById(R.id.question);
downloading = (TextView) view.findViewById(R.id.downloading);
downloaded = (TextView) view.findViewById(R.id.downloaded);
yes = (Button) view.findViewById(R.id.answerYes);
no = (Button) view.findViewById(R.id.answerNo);
ok = (Button) view.findViewById(R.id.answerOk);
bar = (ProgressBar) view.findViewById(R.id.progressBar);
downloadingInfo = (TextView) view.findViewById(R.id.downloadingInfo);
final OpenH264DownloadHelper codecDownloader = LinphoneManager.getInstance().getOpenH264DownloadHelper();
final OpenH264DownloadHelperListener codecListener = new OpenH264DownloadHelperListener() {
@Override
public void OnProgress(final int current, final int max) {
mHandler.post(new Runnable() {
@Override
public void run() {
if (current <= max) {
hideAllItems();
downloadingInfo.setText(current + " / " + max);
downloadingInfo.setVisibility(View.VISIBLE);
downloading.setVisibility(View.VISIBLE);
bar.setMax(max);
bar.setProgress(current);
bar.setVisibility(View.VISIBLE);
} else {
hideAllItems();
LinphoneManager.getLc().reloadMsPlugins(null);
downloaded.setVisibility(View.VISIBLE);
enabledH264(true);
AssistantActivity.instance().endDownloadCodec();
}
}
});
}
@Override
public void OnError(final String error) {
mHandler.post(new Runnable() {
@Override
public void run() {
hideAllItems();
downloaded.setText("Sorry an error has occurred.");
downloaded.setVisibility(View.VISIBLE);
ok.setVisibility(View.VISIBLE);
enabledH264(false);
AssistantActivity.instance().endDownloadCodec();
}
});
}
};
codecDownloader.setOpenH264HelperListener(codecListener);
yes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hideAllItems();
bar.setVisibility(View.VISIBLE);
codecDownloader.downloadCodec();
}
});
no.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
enabledH264(false);
AssistantActivity.instance().endDownloadCodec();
}
});
hideAllItems();
if (savedInstanceState != null) {
if (savedInstanceState.containsKey("question"))
question.setVisibility((Integer) savedInstanceState.getSerializable("question"));
else
question.setVisibility(View.VISIBLE);
if (savedInstanceState.containsKey("yes"))
yes.setVisibility((Integer) savedInstanceState.getSerializable("yes"));
else
yes.setVisibility(View.VISIBLE);
if (savedInstanceState.containsKey("no"))
no.setVisibility((Integer) savedInstanceState.getSerializable("no"));
else
no.setVisibility(View.VISIBLE);
if (savedInstanceState.containsKey("downloading"))
downloading.setVisibility((Integer) savedInstanceState.getSerializable("downloading"));
if (savedInstanceState.containsKey("downloaded"))
downloaded.setVisibility((Integer) savedInstanceState.getSerializable("downloaded"));
if (savedInstanceState.containsKey("bar"))
bar.setVisibility((Integer) savedInstanceState.getSerializable("bar"));
if (savedInstanceState.containsKey("downloadingInfo"))
downloadingInfo.setVisibility((Integer) savedInstanceState.getSerializable("downloadingInfo"));
if (savedInstanceState.containsKey("ok"))
ok.setVisibility((Integer) savedInstanceState.getSerializable("ok"));
} else {
yes.setVisibility(View.VISIBLE);
question.setVisibility(View.VISIBLE);
no.setVisibility(View.VISIBLE);
}
return view;
}
@Override
public void onSaveInstanceState(Bundle outState) {
if (question != null) outState.putSerializable("question", question.getVisibility());
if (downloading != null) outState.putSerializable("downloading", downloading.getVisibility());
if (downloaded != null) outState.putSerializable("downloaded", downloaded.getVisibility());
if (yes != null) outState.putSerializable("yes", yes.getVisibility());
if (no != null) outState.putSerializable("no", no.getVisibility());
if (ok != null) outState.putSerializable("ok", ok.getVisibility());
if (bar != null) outState.putSerializable("bar", bar.getVisibility());
if (downloadingInfo != null) outState.putSerializable("downloadingInfo", downloadingInfo.getVisibility());
super.onSaveInstanceState(outState);
}
private void hideAllItems() {
if (question != null) question.setVisibility(View.INVISIBLE);
if (downloading != null) downloading.setVisibility(View.INVISIBLE);
if (downloaded != null) downloaded.setVisibility(View.INVISIBLE);
if (yes != null) yes.setVisibility(View.INVISIBLE);
if (no != null) no.setVisibility(View.INVISIBLE);
if (ok != null) ok.setVisibility(View.INVISIBLE);
if (bar != null) bar.setVisibility(View.INVISIBLE);
if (downloadingInfo != null) downloadingInfo.setVisibility(View.INVISIBLE);
}
private void enabledH264(boolean enable) {
PayloadType h264 = null;
for (PayloadType pt : LinphoneManager.getLc().getVideoCodecs()) {
if (pt.getMime().equals("H264")) h264 = pt;
}
if (h264 != null) {
try {
LinphoneManager.getLc().enablePayloadType(h264, enable);
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
}
}
}