Don't download Openh264 if not enabled on the project
This commit is contained in:
parent
186656c10d
commit
4ff7acf40c
8 changed files with 61 additions and 50 deletions
|
@ -61,7 +61,7 @@
|
|||
android:paddingLeft="30dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:text="@string/password"
|
||||
|
|
|
@ -58,12 +58,9 @@
|
|||
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"/>
|
||||
android:layout_toStartOf="@+id/imageView" />
|
||||
|
||||
<Button
|
||||
style="@style/font7"
|
||||
|
@ -85,8 +82,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:id="@+id/answerOk"
|
||||
android:layout_alignTop="@+id/answerYes"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignTop="@+id/answerYes" />
|
||||
|
||||
<TextView
|
||||
style="@style/font7"
|
||||
|
|
|
@ -179,6 +179,7 @@
|
|||
<string name="warning_wrong_destination_address">Cannot build destination address from %s</string>
|
||||
<string name="error_unknown">Unknown error</string>
|
||||
<string name="error_call_declined">Call declined</string>
|
||||
<string name="error_user_busy">User busy</string>
|
||||
<string name="error_user_not_found">User not found</string>
|
||||
<string name="error_incompatible_media">Incompatible media parameters</string>
|
||||
<string name="error_low_bandwidth">Your correspondent has low bandwidth, video cannot be started</string>
|
||||
|
|
|
@ -111,6 +111,8 @@ public class CallOutgoingActivity extends Activity implements OnClickListener{
|
|||
displayCustomToast(getString(R.string.error_user_not_found), Toast.LENGTH_SHORT);
|
||||
} else if (message != null && call.getErrorInfo().getReason() == Reason.Media) {
|
||||
displayCustomToast(getString(R.string.error_incompatible_media), Toast.LENGTH_SHORT);
|
||||
} else if (message != null && call.getErrorInfo().getReason() == Reason.Busy) {
|
||||
displayCustomToast(getString(R.string.error_user_busy), Toast.LENGTH_SHORT);
|
||||
} else if (message != null) {
|
||||
displayCustomToast(getString(R.string.error_unknown) + " - " + message, Toast.LENGTH_SHORT);
|
||||
}
|
||||
|
|
|
@ -215,11 +215,11 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
@Override
|
||||
public void OnProgress(final int current, final int max) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@Override
|
||||
public void run() {
|
||||
OpenH264DownloadHelper ohcodec = LinphoneManager.getInstance().getOpenH264DownloadHelper();
|
||||
if (progress == null) {
|
||||
progress = new ProgressDialog((Context)ohcodec.getUserData(ctxt));
|
||||
progress = new ProgressDialog((Context) ohcodec.getUserData(ctxt));
|
||||
progress.setCanceledOnTouchOutside(false);
|
||||
progress.setCancelable(false);
|
||||
progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
@ -238,22 +238,22 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OnError (final String error){
|
||||
public void OnError(final String error) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (progress != null) progress.dismiss();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder((Context)LinphoneManager.getInstance().getOpenH264DownloadHelper().getUserData(ctxt));
|
||||
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);
|
||||
|
|
|
@ -685,7 +685,7 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
PreferenceCategory codecs = (PreferenceCategory) findPreference(getString(R.string.pref_video_codecs_key));
|
||||
codecs.removeAll();
|
||||
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
final LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
||||
final OpenH264DownloadHelper mCodecDownloader = LinphoneManager.getInstance().getOpenH264DownloadHelper();
|
||||
|
||||
|
@ -705,9 +705,11 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (pt.getMime().equals("H264") && mCodecDownloader.isCodecFound()) {
|
||||
codec.setSummary(mCodecDownloader.getLicenseMessage());
|
||||
codec.setTitle("OpenH264");
|
||||
if (lc.openH264Enabled()) {
|
||||
if (pt.getMime().equals("H264") && mCodecDownloader.isCodecFound()) {
|
||||
codec.setSummary(mCodecDownloader.getLicenseMessage());
|
||||
codec.setTitle("OpenH264");
|
||||
}
|
||||
}
|
||||
codec.setChecked(lc.isPayloadTypeEnabled(pt));
|
||||
|
||||
|
@ -716,29 +718,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()) {
|
||||
mCodecDownloader.setOpenH264HelperListener(LinphoneManager.getInstance().getOpenH264HelperListener());
|
||||
mCodecDownloader.setUserData(0,LinphoneManager.getInstance().getContext());
|
||||
mCodecDownloader.setUserData(1,codec);
|
||||
if (lc.openH264Enabled()) {
|
||||
if (enable && Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86")
|
||||
&& pt.getMime().equals("H264") && !mCodecDownloader.isCodecFound()) {
|
||||
mCodecDownloader.setOpenH264HelperListener(LinphoneManager.getInstance().getOpenH264HelperListener());
|
||||
mCodecDownloader.setUserData(0, LinphoneManager.getInstance().getContext());
|
||||
mCodecDownloader.setUserData(1, codec);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(LinphoneManager.getInstance().getContext());
|
||||
builder.setCancelable(false);
|
||||
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
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(LinphoneManager.getInstance().getContext());
|
||||
builder.setCancelable(false);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}).show();
|
||||
});
|
||||
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) {
|
||||
|
|
|
@ -479,8 +479,11 @@ public class StatusFragment extends Fragment {
|
|||
PayloadType payloadVideo = params.getUsedVideoCodec();
|
||||
if (payloadVideo != null && payloadAudio != null) {
|
||||
String videoMime = payloadVideo.getMime();
|
||||
if (payloadVideo.getMime().equals("H264") && LinphoneManager.getInstance().getOpenH264DownloadHelper().isCodecFound())
|
||||
if (LinphoneManager.getLc().openH264Enabled() &&
|
||||
payloadVideo.getMime().equals("H264") &&
|
||||
LinphoneManager.getInstance().getOpenH264DownloadHelper().isCodecFound()) {
|
||||
videoMime = "OpenH264";
|
||||
}
|
||||
codec.setText(videoMime + " / " + payloadAudio.getMime() + (payloadAudio.getRate() / 1000));
|
||||
}
|
||||
dl.setText(String.valueOf((int) videoStats.getDownloadBandwidth()) + " / " + (int) audioStats.getDownloadBandwidth() + " kbits/s");
|
||||
|
|
|
@ -377,15 +377,19 @@ private static AssistantActivity instance;
|
|||
}
|
||||
|
||||
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
|
||||
if (LinphoneManager.getLc().openH264Enabled()) {
|
||||
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();
|
||||
} else {
|
||||
goToLinphoneActivity();
|
||||
}
|
||||
}
|
||||
|
||||
public void endDownloadCodec() {
|
||||
|
|
Loading…
Reference in a new issue