Added back bandwidth check before starting/accepting call
This commit is contained in:
parent
eadb55e9c4
commit
808163cdde
2 changed files with 32 additions and 1 deletions
|
@ -315,6 +315,10 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
Log.i("[Context] Answering call $call")
|
||||
val params = core.createCallParams(call)
|
||||
params?.recordFile = LinphoneUtils.getRecordingFilePathForAddress(call.remoteAddress)
|
||||
if (LinphoneUtils.checkIfNetworkHasLowBandwidth(context)) {
|
||||
Log.w("[Context] Enabling low bandwidth mode!")
|
||||
params?.enableLowBandwidth(true)
|
||||
}
|
||||
call.acceptWithParams(params)
|
||||
}
|
||||
|
||||
|
@ -376,6 +380,10 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
if (forceZRTP) {
|
||||
params?.mediaEncryption = MediaEncryption.ZRTP
|
||||
}
|
||||
if (LinphoneUtils.checkIfNetworkHasLowBandwidth(context)) {
|
||||
Log.w("[Context] Enabling low bandwidth mode!")
|
||||
params?.enableLowBandwidth(true)
|
||||
}
|
||||
params?.recordFile = LinphoneUtils.getRecordingFilePathForAddress(address)
|
||||
|
||||
val call = if (params != null) {
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
*/
|
||||
package org.linphone.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.NetworkInfo
|
||||
import android.telephony.TelephonyManager.*
|
||||
import androidx.core.content.ContextCompat.getSystemService
|
||||
import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
@ -88,7 +93,10 @@ class LinphoneUtils {
|
|||
|
||||
fun getRecordingFilePathForAddress(address: Address): String {
|
||||
val displayName = getDisplayName(address)
|
||||
val dateFormat: DateFormat = SimpleDateFormat(RECORDING_DATE_PATTERN, Locale.getDefault())
|
||||
val dateFormat: DateFormat = SimpleDateFormat(
|
||||
RECORDING_DATE_PATTERN,
|
||||
Locale.getDefault()
|
||||
)
|
||||
val fileName = "${displayName}_${dateFormat.format(Date())}.mkv"
|
||||
return FileUtils.getFileStoragePath(fileName).absolutePath
|
||||
}
|
||||
|
@ -96,5 +104,20 @@ class LinphoneUtils {
|
|||
fun getRecordingDateFromFileName(name: String): Date {
|
||||
return SimpleDateFormat(RECORDING_DATE_PATTERN, Locale.getDefault()).parse(name)
|
||||
}
|
||||
|
||||
fun checkIfNetworkHasLowBandwidth(context: Context): Boolean {
|
||||
val connMgr = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val networkInfo: NetworkInfo? = connMgr.activeNetworkInfo
|
||||
if (networkInfo != null && networkInfo.isConnected) {
|
||||
if (networkInfo.type == ConnectivityManager.TYPE_MOBILE) {
|
||||
return when (networkInfo.subtype) {
|
||||
NETWORK_TYPE_EDGE, NETWORK_TYPE_GPRS, NETWORK_TYPE_IDEN -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
// In doubt return false
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue