Use edge optimization if needed
This commit is contained in:
parent
66af2ebdca
commit
aaab2ddc86
5 changed files with 71 additions and 6 deletions
|
@ -49,7 +49,7 @@ public class CallManager {
|
|||
|
||||
|
||||
|
||||
void inviteAddress(LinphoneAddress lAddress, boolean videoEnabled) throws LinphoneCoreException {
|
||||
void inviteAddress(LinphoneAddress lAddress, boolean videoEnabled, boolean lowBandwidth) throws LinphoneCoreException {
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
|
||||
LinphoneCallParams params = lc.createDefaultCallParameters();
|
||||
|
@ -60,6 +60,11 @@ public class CallManager {
|
|||
} else {
|
||||
params.setVideoEnabled(false);
|
||||
}
|
||||
|
||||
if (lowBandwidth) {
|
||||
params.enableLowBandwidth(true);
|
||||
Log.d("Low bandwidth enabled in call params");
|
||||
}
|
||||
|
||||
lc.inviteAddressWithParams(lAddress, params);
|
||||
}
|
||||
|
|
|
@ -162,6 +162,12 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
|||
params.setVideoEnabled(false);
|
||||
}
|
||||
|
||||
boolean isLowBandwidthConnection = !LinphoneUtils.isHightBandwidthConnection(this);
|
||||
if (isLowBandwidthConnection) {
|
||||
params.enableLowBandwidth(true);
|
||||
Log.d("Low bandwidth enabled in call params");
|
||||
}
|
||||
|
||||
if (!LinphoneManager.getInstance().acceptCallWithParams(mCall, params)) {
|
||||
// the above method takes care of Samsung Galaxy S
|
||||
Toast.makeText(this, R.string.couldnt_accept_call, Toast.LENGTH_LONG).show();
|
||||
|
@ -170,8 +176,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
|||
return;
|
||||
}
|
||||
final LinphoneCallParams remoteParams = mCall.getRemoteParams();
|
||||
if (remoteParams != null && remoteParams.getVideoEnabled()
|
||||
&& LinphoneManager.getInstance().isAutoAcceptCamera()) {
|
||||
if (remoteParams != null && remoteParams.getVideoEnabled() && LinphoneManager.getInstance().isAutoAcceptCamera()) {
|
||||
LinphoneActivity.instance().startVideoActivity(mCall);
|
||||
} else {
|
||||
LinphoneActivity.instance().startIncallActivity(mCall);
|
||||
|
|
|
@ -274,14 +274,16 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
}
|
||||
lAddress.setDisplayName(address.getDisplayedName());
|
||||
|
||||
boolean isLowBandwidthConnection = !LinphoneUtils.isHightBandwidthConnection(LinphoneService.instance().getApplicationContext());
|
||||
|
||||
try {
|
||||
if (Version.isVideoCapable()) {
|
||||
boolean prefVideoEnable = isVideoEnabled();
|
||||
int key = R.string.pref_video_initiate_call_with_video_key;
|
||||
boolean prefInitiateWithVideo = getPrefBoolean(key, false);
|
||||
CallManager.getInstance().inviteAddress(lAddress, prefVideoEnable && prefInitiateWithVideo);
|
||||
CallManager.getInstance().inviteAddress(lAddress, prefVideoEnable && prefInitiateWithVideo, isLowBandwidthConnection);
|
||||
} else {
|
||||
CallManager.getInstance().inviteAddress(lAddress, false);
|
||||
CallManager.getInstance().inviteAddress(lAddress, false, isLowBandwidthConnection);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,8 +47,11 @@ import android.content.Intent;
|
|||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.TypedValue;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
|
@ -277,5 +280,55 @@ public final class LinphoneUtils {
|
|||
state == LinphoneCall.State.PausedByRemote ||
|
||||
state == LinphoneCall.State.Pausing;
|
||||
}
|
||||
|
||||
public static boolean isHightBandwidthConnection(Context context){
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo info = cm.getActiveNetworkInfo();
|
||||
return (info != null && info.isConnected() && isConnectionFast(info.getType(),info.getSubtype()));
|
||||
}
|
||||
|
||||
private static boolean isConnectionFast(int type, int subType){
|
||||
if (type == ConnectivityManager.TYPE_WIFI) {
|
||||
return true;
|
||||
} else if (type == ConnectivityManager.TYPE_MOBILE) {
|
||||
switch (subType) {
|
||||
case TelephonyManager.NETWORK_TYPE_1xRTT:
|
||||
return false; // ~ 50-100 kbps
|
||||
case TelephonyManager.NETWORK_TYPE_CDMA:
|
||||
return false; // ~ 14-64 kbps
|
||||
case TelephonyManager.NETWORK_TYPE_EDGE:
|
||||
return false; // ~ 50-100 kbps
|
||||
case TelephonyManager.NETWORK_TYPE_GPRS:
|
||||
return false; // ~ 100 kbps
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_0:
|
||||
return false; // ~25 kbps
|
||||
case TelephonyManager.NETWORK_TYPE_LTE:
|
||||
return true; // ~ 400-1000 kbps
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_A:
|
||||
return true; // ~ 600-1400 kbps
|
||||
case TelephonyManager.NETWORK_TYPE_HSDPA:
|
||||
return true; // ~ 2-14 Mbps
|
||||
case TelephonyManager.NETWORK_TYPE_HSPA:
|
||||
return true; // ~ 700-1700 kbps
|
||||
case TelephonyManager.NETWORK_TYPE_HSUPA:
|
||||
return true; // ~ 1-23 Mbps
|
||||
case TelephonyManager.NETWORK_TYPE_UMTS:
|
||||
return true; // ~ 400-7000 kbps
|
||||
case TelephonyManager.NETWORK_TYPE_EHRPD:
|
||||
return true; // ~ 1-2 Mbps
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_B:
|
||||
return true; // ~ 5 Mbps
|
||||
case TelephonyManager.NETWORK_TYPE_HSPAP:
|
||||
return true; // ~ 10-20 Mbps
|
||||
case TelephonyManager.NETWORK_TYPE_IDEN:
|
||||
return true; // ~ 10+ Mbps
|
||||
case TelephonyManager.NETWORK_TYPE_UNKNOWN:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7d07ca75e745d5fc29e3f5687b5eed17a2e54135
|
||||
Subproject commit 1e75dc40229e1f8e6e5c6c121957722f11c03a3e
|
Loading…
Reference in a new issue