Update linphone + CodecDownloader name
This commit is contained in:
parent
6bd92c40b7
commit
855e81df18
6 changed files with 87 additions and 65 deletions
|
@ -77,6 +77,17 @@
|
|||
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"
|
||||
|
|
|
@ -39,8 +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.OpenH264HelperAction;
|
||||
import org.linphone.core.OpenH264HelperListener;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneBuffer;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
|
@ -76,7 +76,7 @@ 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.CodecDownloader;
|
||||
import org.linphone.tools.OpenH264Helper;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
|
@ -143,9 +143,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
private Resources mR;
|
||||
private LinphonePreferences mPrefs;
|
||||
private LinphoneCore mLc;
|
||||
private CodecDownloader mCodecDownloader;
|
||||
private CodecDownloadListener mCodecListener;
|
||||
private CodecDownloadAction mCodecAction;
|
||||
private OpenH264Helper mCodecDownloader;
|
||||
private OpenH264HelperListener mCodecListener;
|
||||
private OpenH264HelperAction mCodecAction;
|
||||
private String lastLcStatusMessage;
|
||||
private String basePath;
|
||||
private static boolean sExited;
|
||||
|
@ -193,7 +193,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
mConnectivityManager = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
mR = c.getResources();
|
||||
mPendingChatFileMessage = new ArrayList<LinphoneChatMessage>();
|
||||
initCodecDownloader();
|
||||
initOpenH264Helper();
|
||||
}
|
||||
|
||||
private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL;
|
||||
|
@ -224,19 +224,19 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
mLc.enableSpeaker(speakerOn);
|
||||
}
|
||||
|
||||
public void initCodecDownloader() {
|
||||
mCodecListener = new CodecDownloadListener() {
|
||||
public void initOpenH264Helper() {
|
||||
mCodecListener = new OpenH264HelperListener() {
|
||||
ProgressDialog progress;
|
||||
int box = 1;
|
||||
int ctxt = 0;
|
||||
|
||||
@Override
|
||||
public void listenerUpdateProgressBar(final int current, final int max) {
|
||||
public void OnProgress(final int current, final int max) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (progress == null) {
|
||||
progress = new ProgressDialog((Context)LinphoneManager.getInstance().getCodecDownloader().getUserData(ctxt));
|
||||
progress = new ProgressDialog((Context)LinphoneManager.getInstance().getOpenH264Helper().getUserData(ctxt));
|
||||
progress.setCanceledOnTouchOutside(false);
|
||||
progress.setCancelable(false);
|
||||
progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
@ -248,25 +248,25 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
} else {
|
||||
progress.dismiss();
|
||||
progress = null;
|
||||
LinphoneCoreFactoryImpl.loadOptionalLibraryWithPath(((Context)LinphoneManager.getInstance().getCodecDownloader().getUserData(ctxt)).getFilesDir() + "/" + CodecDownloader.getNameLib());
|
||||
LinphoneCoreFactoryImpl.loadOptionalLibraryWithPath(((Context)LinphoneManager.getInstance().getOpenH264Helper().getUserData(ctxt)).getFilesDir() + "/" + OpenH264Helper.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());
|
||||
if (LinphoneManager.getInstance().getOpenH264Helper().getUserDataSize() > box
|
||||
&& LinphoneManager.getInstance().getOpenH264Helper().getUserData(box) != null)
|
||||
((CheckBoxPreference)LinphoneManager.getInstance().getOpenH264Helper().getUserData(box)).setSummary(OpenH264Helper.getLicenseMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listenerDownloadFailed (final String error){
|
||||
public void OnDownloadFailure (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((Context)LinphoneManager.getInstance().getCodecDownloader().getUserData(ctxt));
|
||||
builder.setMessage(error);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder((Context)LinphoneManager.getInstance().getOpenH264Helper().getUserData(ctxt));
|
||||
builder.setMessage("Sorry an error has occurred.");
|
||||
builder.setCancelable(false);
|
||||
builder.setNeutralButton("Ok", null);
|
||||
builder.show();
|
||||
|
@ -274,7 +274,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
});
|
||||
}
|
||||
};
|
||||
mCodecAction = new CodecDownloadAction() {
|
||||
mCodecAction = new OpenH264HelperAction() {
|
||||
@Override
|
||||
public void startDownload() {
|
||||
askPopUp();
|
||||
|
@ -284,7 +284,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
AlertDialog.Builder builder = new AlertDialog.Builder(LinphoneManager.getInstance().getContext());
|
||||
builder.setCancelable(false);
|
||||
AlertDialog.Builder show = builder.setMessage("Do you agree to download "
|
||||
+ CodecDownloader.getLicenseMessage()).setPositiveButton("Yes", new DialogInterface.OnClickListener(){
|
||||
+ OpenH264Helper.getLicenseMessage()).setPositiveButton("Yes", new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == DialogInterface.BUTTON_POSITIVE)
|
||||
|
@ -301,20 +301,20 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
}).show();
|
||||
}
|
||||
};
|
||||
mCodecDownloader = new CodecDownloader();
|
||||
mCodecDownloader.setCodecDownloadlistener(mCodecListener);
|
||||
mCodecDownloader.setCodecDownloadAction(mCodecAction);
|
||||
mCodecDownloader = new OpenH264Helper();
|
||||
mCodecDownloader.setOpenH264HelperListener(mCodecListener);
|
||||
mCodecDownloader.setOpenH264HelperAction(mCodecAction);
|
||||
}
|
||||
|
||||
public CodecDownloadListener getCodecDownloadListener() {
|
||||
public OpenH264HelperListener getOpenH264HelperListener() {
|
||||
return mCodecListener;
|
||||
}
|
||||
|
||||
public CodecDownloadAction getCodecDownloadAction() {
|
||||
public OpenH264HelperAction getOpenH264HelperAction() {
|
||||
return mCodecAction;
|
||||
}
|
||||
|
||||
public CodecDownloader getCodecDownloader(){
|
||||
public OpenH264Helper getOpenH264Helper(){
|
||||
return mCodecDownloader;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ 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.CodecDownloader;
|
||||
import org.linphone.tools.OpenH264Helper;
|
||||
import org.linphone.ui.LedPreference;
|
||||
import org.linphone.ui.PreferencesListFragment;
|
||||
|
||||
|
@ -570,8 +570,8 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (pt.getMime().equals("H264") && CodecDownloader.codecExist())
|
||||
codec.setSummary(CodecDownloader.getLicenseMessage());
|
||||
if (pt.getMime().equals("H264") && OpenH264Helper.codecExist())
|
||||
codec.setSummary(OpenH264Helper.getLicenseMessage());
|
||||
codec.setChecked(lc.isPayloadTypeEnabled(pt));
|
||||
|
||||
codec.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
|
@ -579,14 +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());
|
||||
OpenH264Helper.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().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();
|
||||
&& pt.getMime().equals("H264") && !OpenH264Helper.codecExist()) {
|
||||
LinphoneManager.getInstance().getOpenH264Helper().setOpenH264HelperListener(LinphoneManager.getInstance().getOpenH264HelperListener());
|
||||
LinphoneManager.getInstance().getOpenH264Helper().setOpenH264HelperAction(LinphoneManager.getInstance().getOpenH264Helper().getOpenH264HelperAction());
|
||||
LinphoneManager.getInstance().getOpenH264Helper().setUserData(0,LinphoneManager.getInstance().getContext());
|
||||
LinphoneManager.getInstance().getOpenH264Helper().setUserData(1,codec);
|
||||
LinphoneManager.getInstance().getOpenH264Helper().getOpenH264HelperAction().startDownload();
|
||||
}
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().enablePayloadType(pt, enable);
|
||||
} catch (LinphoneCoreException e) {
|
||||
|
|
|
@ -33,7 +33,7 @@ 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 org.linphone.tools.OpenH264Helper;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
|
@ -355,8 +355,8 @@ private static AssistantActivity instance;
|
|||
}
|
||||
|
||||
private void launchDownloadCodec() {
|
||||
CodecDownloader.setFileDirection(LinphoneManager.getInstance().getContext().getFilesDir().toString());
|
||||
if (Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86") && !CodecDownloader.codecExist()) {
|
||||
OpenH264Helper.setFileDirection(LinphoneManager.getInstance().getContext().getFilesDir().toString());
|
||||
if (Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86") && !OpenH264Helper.codecExist()) {
|
||||
CodecDownloaderFragment codecFragment = new CodecDownloaderFragment();
|
||||
changeFragment(codecFragment);
|
||||
currentFragment = AssistantFragmentsEnum.DOWNLOAD_CODEC;
|
||||
|
|
|
@ -25,16 +25,17 @@ 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.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.CodecDownloadListener;
|
||||
import org.linphone.core.OpenH264HelperListener;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactoryImpl;
|
||||
import org.linphone.core.PayloadType;
|
||||
import org.linphone.tools.CodecDownloader;
|
||||
import org.linphone.tools.OpenH264Helper;
|
||||
|
||||
/**
|
||||
* @author Erwan CROZE
|
||||
|
@ -50,18 +51,19 @@ public class CodecDownloaderFragment extends Fragment {
|
|||
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 Button yes = (Button) view.findViewById(R.id.answerYes);
|
||||
final Button no = (Button) view.findViewById(R.id.answerNo);
|
||||
final Button ok = (Button) view.findViewById(R.id.answerOk);
|
||||
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());
|
||||
OpenH264Helper.setFileDirection(LinphoneManager.getInstance().getContext().getFilesDir().toString());
|
||||
|
||||
final CodecDownloader codecDownloader = new CodecDownloader();
|
||||
final CodecDownloadListener codecListener = new CodecDownloadListener() {
|
||||
final OpenH264Helper codecDownloader = new OpenH264Helper();
|
||||
final OpenH264HelperListener codecListener = new OpenH264HelperListener() {
|
||||
|
||||
@Override
|
||||
public void listenerUpdateProgressBar(final int current, final int max) {
|
||||
public void OnProgress(final int current, final int max) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -74,10 +76,11 @@ public class CodecDownloaderFragment extends Fragment {
|
|||
} else {
|
||||
downloadingInfo.setVisibility(View.INVISIBLE);
|
||||
bar.setVisibility(View.INVISIBLE);
|
||||
LinphoneCoreFactoryImpl.loadOptionalLibraryWithPath(LinphoneManager.getInstance().getContext().getFilesDir() + "/" + CodecDownloader.getNameLib());
|
||||
LinphoneCoreFactoryImpl.loadOptionalLibraryWithPath(LinphoneManager.getInstance().getContext().getFilesDir() + "/" + OpenH264Helper.getNameLib());
|
||||
LinphoneManager.getLc().reloadMsPlugins(null);
|
||||
downloading.setVisibility(View.INVISIBLE);
|
||||
downloaded.setVisibility(View.VISIBLE);
|
||||
enabledH264(true);
|
||||
AssistantActivity.instance().endDownloadCodec();
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +88,7 @@ public class CodecDownloaderFragment extends Fragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void listenerDownloadFailed (final String error){
|
||||
public void OnDownloadFailure (final String error){
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -95,18 +98,22 @@ public class CodecDownloaderFragment extends Fragment {
|
|||
no.setVisibility(View.INVISIBLE);
|
||||
bar.setVisibility(View.INVISIBLE);
|
||||
downloadingInfo.setVisibility(View.INVISIBLE);
|
||||
downloaded.setText(error);
|
||||
downloaded.setText("Sorry an error has occurred.");
|
||||
downloaded.setVisibility(View.VISIBLE);
|
||||
ok.setVisibility(View.VISIBLE);
|
||||
enabledH264(false);
|
||||
AssistantActivity.instance().endDownloadCodec();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
codecDownloader.setCodecDownloadlistener(codecListener);
|
||||
codecDownloader.setOpenH264HelperListener(codecListener);
|
||||
downloading.setVisibility(View.INVISIBLE);
|
||||
downloaded.setVisibility(View.INVISIBLE);
|
||||
bar.setVisibility(View.INVISIBLE);
|
||||
downloadingInfo.setVisibility(View.INVISIBLE);
|
||||
ok.setVisibility(View.INVISIBLE);
|
||||
|
||||
yes.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -115,6 +122,7 @@ public class CodecDownloaderFragment extends Fragment {
|
|||
yes.setVisibility(View.INVISIBLE);
|
||||
no.setVisibility(View.INVISIBLE);
|
||||
downloading.setVisibility(View.VISIBLE);
|
||||
ok.setVisibility(View.INVISIBLE);
|
||||
bar.setVisibility(View.VISIBLE);
|
||||
downloadingInfo.setVisibility(View.INVISIBLE);
|
||||
codecDownloader.downloadCodec();
|
||||
|
@ -124,23 +132,26 @@ public class CodecDownloaderFragment extends Fragment {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
||||
enabledH264(false);
|
||||
AssistantActivity.instance().endDownloadCodec();
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b6bfc2dcb4ab2a3281cb3246f2862a06d3b43b58
|
||||
Subproject commit 9850fc31d3de4440f71872693b0c905621fb9b0d
|
Loading…
Reference in a new issue