Major rewrite of settings implementation by separating static and dynamic
settings Changed opus expected packed loss default value from 0 to 1 in order to enable forward error correction Restored original audio jitten buffer size to 0-20 now when upstream bug is fixed
This commit is contained in:
@ -1,37 +1,25 @@
|
||||
auto_start yes
|
||||
log_level 2
|
||||
poll_method epoll
|
||||
sip_trans_bsize 128
|
||||
sip_verify_server no
|
||||
call_local_timeout 120
|
||||
call_max_calls 4
|
||||
call_hold_other_calls yes
|
||||
audio_player opensles,nil
|
||||
audio_source opensles,nil
|
||||
audio_alert opensles,nil
|
||||
audio_level no
|
||||
ausrc_format s16
|
||||
auplay_format s16
|
||||
auenc_format s16
|
||||
audec_format s16
|
||||
audio_buffer 20-300
|
||||
audio_buffer_mode adaptive
|
||||
ausrc_format s16
|
||||
auenc_format s16
|
||||
auplay_format s16
|
||||
audec_format s16
|
||||
audio_silence -35.0
|
||||
audio_telev_pt 10
|
||||
rtp_tos 184
|
||||
rtp_video_tos 136
|
||||
audio_jitter_buffer_type adaptive
|
||||
audio_jitter_buffer_delay 0-20
|
||||
video_jitter_buffer_type adaptive
|
||||
video_jitter_buffer_delay 1-50
|
||||
rtp_stats yes
|
||||
rtp_timeout 60
|
||||
dyn_dns yes
|
||||
module opus.so
|
||||
module amr.so
|
||||
module g722.so
|
||||
module g7221.so
|
||||
module g726.so
|
||||
module g729.so
|
||||
module gsm.so
|
||||
module g711.so
|
||||
module webrtc_aecm.so
|
||||
module opensles.so
|
||||
module stun.so
|
||||
module turn.so
|
||||
@ -44,11 +32,10 @@ module_app account.so
|
||||
module_app debug_cmd.so
|
||||
module_app mwi.so
|
||||
evdev_device /dev/input/event0
|
||||
opus_bitrate 28000
|
||||
opus_samplerate 16000
|
||||
opus_stereo no
|
||||
opus_sprop_stereo no
|
||||
opus_cbr no
|
||||
opus_inbandfec yes
|
||||
opus_application voip
|
||||
opus_stereo no
|
||||
opus_sprop_stereo no
|
||||
dtls_srtp_use_ec prime256v1
|
||||
@ -27,8 +27,6 @@ class AudioActivity : AppCompatActivity() {
|
||||
private var oldOpusBitrate = ""
|
||||
private var oldOpusPacketLoss = ""
|
||||
private var oldAec = false
|
||||
private var oldAudioDelay = BaresipService.audioDelay.toString()
|
||||
private val audioModules = listOf("opus", "amr", "g722", "g7221", "g726", "g729", "g711")
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
@ -74,6 +72,8 @@ class AudioActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
val modules = Config.variables("module")
|
||||
|
||||
val audioModulesList = binding.AudioModulesList
|
||||
var id = 1000
|
||||
for (module in audioModules) {
|
||||
@ -102,29 +102,26 @@ class AudioActivity : AppCompatActivity() {
|
||||
cbParams.addRule(RelativeLayout.CENTER_VERTICAL)
|
||||
cb.layoutParams = cbParams
|
||||
cb.gravity = Gravity.END
|
||||
cb.isChecked = Config.variable("module $module.so").size > 0
|
||||
cb.isChecked = modules.contains("${module}.so")
|
||||
oldAudioModules[module] = cb.isChecked
|
||||
rl.addView(cb)
|
||||
audioModulesList.addView(rl)
|
||||
}
|
||||
|
||||
opusBitRate = binding.OpusBitRate
|
||||
val obCv = Config.variable("opus_bitrate")
|
||||
oldOpusBitrate = if (obCv.size == 0) "28000" else obCv[0]
|
||||
oldOpusBitrate = Config.variable("opus_bitrate")
|
||||
opusBitRate.setText(oldOpusBitrate)
|
||||
|
||||
opusPacketLoss = binding.OpusPacketLoss
|
||||
val oplCv = Config.variable("opus_packet_loss")
|
||||
oldOpusPacketLoss = if (oplCv.size == 0) "0" else oplCv[0]
|
||||
oldOpusPacketLoss = Config.variable("opus_packet_loss")
|
||||
opusPacketLoss.setText(oldOpusPacketLoss)
|
||||
|
||||
aec = binding.Aec
|
||||
val aecCv = Config.variable("module")
|
||||
oldAec = aecCv.contains("webrtc_aecm.so")
|
||||
oldAec = modules.contains("webrtc_aecm.so")
|
||||
aec.isChecked = oldAec
|
||||
|
||||
audioDelay = binding.AudioDelay
|
||||
audioDelay.setText(oldAudioDelay)
|
||||
audioDelay.setText(BaresipService.audioDelay.toString())
|
||||
|
||||
bindTitles()
|
||||
|
||||
@ -160,18 +157,19 @@ class AudioActivity : AppCompatActivity() {
|
||||
for (module in audioModules) {
|
||||
val box = findViewById<CheckBox>(id++)
|
||||
if (box.isChecked && !oldAudioModules[module]!!) {
|
||||
if (Api.module_load("$module.so") != 0) {
|
||||
if (Api.module_load("${module}.so") != 0) {
|
||||
Utils.alertView(this, getString(R.string.error),
|
||||
"${getString(R.string.failed_to_load_module)}: $module.so")
|
||||
"${getString(R.string.failed_to_load_module)}: ${module}.so")
|
||||
return false
|
||||
}
|
||||
Config.addModuleLine("module $module.so")
|
||||
Config.addVariable("module", "${module}.so")
|
||||
save = true
|
||||
}
|
||||
if (!box.isChecked && oldAudioModules[module]!!) {
|
||||
Api.module_unload("$module.so")
|
||||
Config.removeLine("module $module.so")
|
||||
for (ua in BaresipService.uas) ua.account.removeAudioCodecs(module)
|
||||
Api.module_unload("${module}.so")
|
||||
Config.removeVariableValue("module", "${module}.so")
|
||||
for (ua in BaresipService.uas)
|
||||
ua.account.removeAudioCodecs(module)
|
||||
AccountsActivity.saveAccounts()
|
||||
save = true
|
||||
}
|
||||
@ -185,8 +183,7 @@ class AudioActivity : AppCompatActivity() {
|
||||
"${getString(R.string.invalid_opus_bitrate)}: $opusBitRate.")
|
||||
return false
|
||||
}
|
||||
Config.removeVariable("opus_bitrate")
|
||||
Config.addLine("opus_bitrate $opusBitRate")
|
||||
Config.replaceVariable("opus_bitrate", opusBitRate)
|
||||
reload = true
|
||||
save = true
|
||||
}
|
||||
@ -198,20 +195,14 @@ class AudioActivity : AppCompatActivity() {
|
||||
"${getString(R.string.invalid_opus_packet_loss)}: $opusPacketLoss")
|
||||
return false
|
||||
}
|
||||
Config.removeVariable("opus_inbandfec")
|
||||
Config.removeVariable("opus_packet_loss")
|
||||
if (opusPacketLoss != "0") {
|
||||
Config.addLine("opus_inbandfec yes")
|
||||
Config.addLine("opus_packet_loss $opusPacketLoss")
|
||||
}
|
||||
Config.replaceVariable("opus_packet_loss", opusPacketLoss)
|
||||
reload = true
|
||||
save = true
|
||||
}
|
||||
|
||||
if (aec.isChecked != oldAec) {
|
||||
Config.removeLine("module webrtc_aecm.so")
|
||||
if (aec.isChecked) {
|
||||
Config.addModuleLine("module webrtc_aecm.so")
|
||||
Config.replaceVariable("module", "webrtc_aecm.so")
|
||||
if (Api.module_load("webrtc_aecm.so") != 0) {
|
||||
Utils.alertView(this, getString(R.string.error),
|
||||
getString(R.string.failed_to_load_module))
|
||||
@ -220,19 +211,19 @@ class AudioActivity : AppCompatActivity() {
|
||||
}
|
||||
} else {
|
||||
Api.module_unload("webrtc_aecm.so")
|
||||
Config.removeVariableValue("module", "webrtc_aecm.so")
|
||||
}
|
||||
save = true
|
||||
}
|
||||
|
||||
val audioDelay = audioDelay.text.toString().trim()
|
||||
if (audioDelay != oldAudioDelay) {
|
||||
if (audioDelay != BaresipService.audioDelay.toString()) {
|
||||
if (!checkAudioDelay(audioDelay)) {
|
||||
Utils.alertView(this, getString(R.string.notice),
|
||||
String.format(getString(R.string.invalid_audio_delay), audioDelay))
|
||||
return false
|
||||
}
|
||||
Config.removeVariable("audio_delay")
|
||||
Config.addLine("audio_delay $audioDelay")
|
||||
Config.replaceVariable("audio_delay", audioDelay)
|
||||
BaresipService.audioDelay = audioDelay.toLong()
|
||||
save = true
|
||||
}
|
||||
@ -303,4 +294,9 @@ class AudioActivity : AppCompatActivity() {
|
||||
val number = audioDelay.toIntOrNull() ?: return false
|
||||
return (number >= 100) && (number <= 3000)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val audioModules = listOf("opus", "amr", "g722", "g7221", "g726", "g729", "g711")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ class BaresipService: Service() {
|
||||
}
|
||||
for (a in assets) {
|
||||
file = File("${filesPath}/$a")
|
||||
if (!file.exists()) {
|
||||
if (!file.exists() && a != "config") {
|
||||
Log.i(TAG, "Copying asset '$a'")
|
||||
Utils.copyAssetToFile(applicationContext, a, "$filesPath/$a")
|
||||
} else {
|
||||
|
||||
@ -2,156 +2,203 @@ package com.tutpro.baresip
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import java.io.File
|
||||
import java.net.InetAddress
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
object Config {
|
||||
|
||||
private val configPath = BaresipService.filesPath + "/config"
|
||||
private var config = String(Utils.getFileContents(configPath)!!, StandardCharsets.ISO_8859_1)
|
||||
private lateinit var config: String
|
||||
private lateinit var lines: List<String>
|
||||
private lateinit var previousConfig: String
|
||||
private lateinit var previousLines: List<String>
|
||||
|
||||
fun initialize(ctx: Context) {
|
||||
|
||||
config = config.replace("module_tmp uuid.so", "module uuid.so")
|
||||
config = config.replace("module_tmp account.so", "module_app account.so")
|
||||
config = config.replace("webrtc_aec.so", "webrtc_aecm.so")
|
||||
config = config.replace("module zrtp.so", "module gzrtp.so")
|
||||
|
||||
removeLine("module_app contact.so")
|
||||
|
||||
if (!config.contains("module gsm.so")) {
|
||||
config = "${config}module gsm.so\n"
|
||||
config = ctx.assets.open("config.static").bufferedReader().use { it.readText() }
|
||||
if (!File(configPath).exists()) {
|
||||
for (module in AudioActivity.audioModules)
|
||||
config = "${config}module ${module}.so\n"
|
||||
config = "${config}module webrtc_aecm.so\n"
|
||||
previousConfig = config
|
||||
} else {
|
||||
previousConfig = String(Utils.getFileContents(configPath)!!, StandardCharsets.ISO_8859_1)
|
||||
}
|
||||
previousLines = previousConfig.split("\n")
|
||||
|
||||
if (config.contains("rtp_stats no"))
|
||||
replaceVariable("rtp_stats", "yes")
|
||||
|
||||
if (!config.contains(Regex("ausrc_format s16"))) {
|
||||
config = "${config}ausrc_format s16\nauplay_format s16\nauenc_format s16\naudec_format s16\nmodule webrtc_aecm.so\n"
|
||||
}
|
||||
|
||||
if (!config.contains("log_level")) {
|
||||
val logLevel = previousVariable("log_level")
|
||||
if (logLevel == "") {
|
||||
config = "${config}log_level 2\n"
|
||||
Log.logLevel = Log.LogLevel.WARN
|
||||
BaresipService.logLevel = 2
|
||||
} else {
|
||||
val ll = variable("log_level")[0].toInt()
|
||||
replaceVariable("log_level", "$ll")
|
||||
Log.logLevelSet(ll)
|
||||
BaresipService.logLevel = ll
|
||||
config = "${config}log_level $logLevel\n"
|
||||
BaresipService.logLevel = logLevel.toInt()
|
||||
Log.logLevelSet(BaresipService.logLevel)
|
||||
}
|
||||
|
||||
if (!config.contains("call_volume")) {
|
||||
config = "${config}call_volume 0\n"
|
||||
} else {
|
||||
BaresipService.callVolume = variable("call_volume")[0].toInt()
|
||||
val autoStart = previousVariable("auto_start")
|
||||
config = if (autoStart != "")
|
||||
"${config}auto_start $autoStart\n"
|
||||
else
|
||||
"${config}auto_start no\n"
|
||||
|
||||
val sipListen = previousVariable("sip_listen")
|
||||
if (sipListen != "")
|
||||
config = "${config}sip_listen $sipListen\n"
|
||||
|
||||
val addressFamily = previousVariable("net_af")
|
||||
if (addressFamily != "") {
|
||||
config = "${config}net_af $addressFamily\n"
|
||||
BaresipService.addressFamily = addressFamily
|
||||
}
|
||||
|
||||
if (config.contains("audio_delay")) {
|
||||
BaresipService.audioDelay = variable("audio_delay")[0].toLong()
|
||||
}
|
||||
val sipCertificate = previousVariable("sip_certificate")
|
||||
if (sipCertificate != "")
|
||||
config = "${config}sip_certificate $sipCertificate\n"
|
||||
|
||||
if (config.contains("net_af"))
|
||||
BaresipService.addressFamily = variable("net_af")[0]
|
||||
val sipVerifyServer = previousVariable("sip_verify_server")
|
||||
if (sipVerifyServer != "")
|
||||
config = "${config}sip_verify_server $sipVerifyServer\n"
|
||||
|
||||
if (!config.contains("dyn_dns")) {
|
||||
val sipCaFile = previousVariable("sip_cafile")
|
||||
if (sipCaFile != "")
|
||||
config = "${config}sip_cafile $sipCaFile\n"
|
||||
|
||||
val dynamicDns = previousVariable("dyn_dns")
|
||||
if (dynamicDns == "no") {
|
||||
config = "${config}dyn_dns no\n"
|
||||
for (server in previousVariables("dns_server"))
|
||||
config = "${config}dns_server $server\n"
|
||||
} else {
|
||||
if (config.contains(Regex("dyn_dns\\s+yes"))) {
|
||||
removeVariable("dns_server")
|
||||
for (dnsServer in BaresipService.dnsServers)
|
||||
config = if (Utils.checkIpV4(dnsServer.hostAddress!!))
|
||||
"${config}dns_server ${dnsServer.hostAddress}:53\n"
|
||||
else
|
||||
"${config}dns_server [${dnsServer.hostAddress}]:53\n"
|
||||
BaresipService.dynDns = true
|
||||
}
|
||||
config = "${config}dyn_dns yes\n"
|
||||
for (dnsServer in BaresipService.dnsServers)
|
||||
config = if (Utils.checkIpV4(dnsServer.hostAddress!!))
|
||||
"${config}dns_server ${dnsServer.hostAddress}:53\n"
|
||||
else
|
||||
"${config}dns_server [${dnsServer.hostAddress}]:53\n"
|
||||
BaresipService.dynDns = true
|
||||
}
|
||||
|
||||
if (!config.contains("audio_buffer_mode"))
|
||||
config = "${config}audio_buffer_mode adaptive\n"
|
||||
|
||||
replaceVariable("audio_buffer", "20-300")
|
||||
|
||||
removeVariable("jitter_buffer_type")
|
||||
removeVariable("jitter_buffer_delay")
|
||||
|
||||
replaceVariable("audio_jitter_buffer_type", "adaptive")
|
||||
replaceVariable("audio_jitter_buffer_delay", "0-20")
|
||||
|
||||
replaceVariable("video_jitter_buffer_type", "adaptive")
|
||||
replaceVariable("video_jitter_buffer_delay", "1-50")
|
||||
|
||||
if (!config.contains("rtp_timeout"))
|
||||
config = "${config}rtp_timeout 60\n"
|
||||
|
||||
if (config.contains("contacts_mode")) {
|
||||
BaresipService.contactsMode = variable("contacts_mode")[0].lowercase()
|
||||
if (BaresipService.contactsMode != "baresip" &&
|
||||
var contactsMode = previousVariable("contacts_mode").lowercase()
|
||||
if (contactsMode != "") {
|
||||
if (contactsMode != "baresip" &&
|
||||
!Utils.checkPermissions(ctx, arrayOf(Manifest.permission.READ_CONTACTS,
|
||||
Manifest.permission.WRITE_CONTACTS))) {
|
||||
BaresipService.contactsMode = "baresip"
|
||||
replaceVariable("contacts_mode", "baresip")
|
||||
}
|
||||
Manifest.permission.WRITE_CONTACTS)))
|
||||
contactsMode = "baresip"
|
||||
} else {
|
||||
BaresipService.contactsMode = "baresip"
|
||||
contactsMode = "baresip"
|
||||
}
|
||||
config = "${config}contacts_mode $contactsMode\n"
|
||||
BaresipService.contactsMode = contactsMode
|
||||
|
||||
config = "${config}snd_path ${BaresipService.filesPath}/recordings\n"
|
||||
|
||||
val callVolume = previousVariable("call_volume")
|
||||
if (callVolume != "") {
|
||||
config = "${config}call_volume $callVolume\n"
|
||||
BaresipService.callVolume = callVolume.toInt()
|
||||
} else {
|
||||
config = "${config}call_volume ${BaresipService.callVolume}\n"
|
||||
}
|
||||
|
||||
if (!config.contains("dtls_srtp_use_ec"))
|
||||
config = "${config}dtls_srtp_use_ec prime256v1\n"
|
||||
val previousModules = previousVariables("module")
|
||||
for (module in AudioActivity.audioModules)
|
||||
if ("${module}.so" in previousModules)
|
||||
config = "${config}module ${module}.so\n"
|
||||
|
||||
replaceVariable("snd_path", "${BaresipService.filesPath}/recordings")
|
||||
if ("webrtc_aecm.so" in previousModules)
|
||||
config = "${config}module webrtc_aecm.so\n"
|
||||
|
||||
Utils.putFileContents(configPath, config.toByteArray())
|
||||
val opusBitRate = previousVariable("opus_bitrate")
|
||||
config = if (opusBitRate == "")
|
||||
"${config}opus_bit_rate 28000\n"
|
||||
else
|
||||
"${config}opus_bit_rate $opusBitRate\n"
|
||||
|
||||
val opusPacketLoss = previousVariable("opus_packet_loss")
|
||||
config = if (opusPacketLoss == "")
|
||||
"${config}opus_packet_loss 1\n"
|
||||
else
|
||||
"${config}opus_packet_loss $opusPacketLoss\n"
|
||||
|
||||
val audioDelay = previousVariable("audio_delay")
|
||||
if (audioDelay != "") {
|
||||
config = "${config}audio_delay $audioDelay\n"
|
||||
BaresipService.audioDelay = audioDelay.toLong()
|
||||
} else {
|
||||
config = "${config}audio_delay ${BaresipService.audioDelay}\n"
|
||||
}
|
||||
|
||||
save()
|
||||
BaresipService.isConfigInitialized = true
|
||||
Log.i(TAG, "Initialized config to '$config'")
|
||||
|
||||
}
|
||||
|
||||
fun variable(name: String): ArrayList<String> {
|
||||
private fun previousVariable(name: String): String {
|
||||
for (line in previousLines) {
|
||||
val nameValue = line.split(" ")
|
||||
if (nameValue.size == 2 && nameValue[0] == name)
|
||||
return nameValue[1].trim()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
private fun previousVariables(name: String): ArrayList<String> {
|
||||
val result = ArrayList<String>()
|
||||
val lines = config.split("\n")
|
||||
for (line in lines) {
|
||||
if (line.startsWith(name))
|
||||
result.add((line.substring(name.length).trim()).split("# \t")[0])
|
||||
for (line in previousLines) {
|
||||
val nameValue = line.split(" ")
|
||||
if (nameValue.size == 2 && nameValue[0] == name)
|
||||
result.add(nameValue[1].trim())
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
fun addLine(line: String) {
|
||||
config += "$line\n"
|
||||
fun variable(name: String): String {
|
||||
for (line in lines) {
|
||||
val nameValue = line.split(" ")
|
||||
if (nameValue.size == 2 && nameValue[0] == name)
|
||||
return nameValue[1].trim()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
fun removeLine(line: String) {
|
||||
config = Utils.removeLinesStartingWithString(config, line)
|
||||
fun variables(name: String): ArrayList<String> {
|
||||
val result = ArrayList<String>()
|
||||
for (line in lines) {
|
||||
val nameValue = line.split(" ")
|
||||
if (nameValue.size == 2 && nameValue[0] == name)
|
||||
result.add(nameValue[1].trim())
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
fun addModuleLine(line: String) {
|
||||
// Make sure it goes before first 'module_tmp'
|
||||
config = config.replace("module opensles.so", "$line\nmodule opensles.so")
|
||||
fun addVariable(name: String, value: String) {
|
||||
config += "$name $value\n"
|
||||
}
|
||||
|
||||
fun removeVariable(variable: String) {
|
||||
config = Utils.removeLinesStartingWithString(config, "$variable ")
|
||||
}
|
||||
|
||||
fun replaceVariable(variable: String, value: String) {
|
||||
removeVariable(variable)
|
||||
addLine("$variable $value")
|
||||
fun removeVariableValue(variable: String, value: String) {
|
||||
config = Utils.removeLinesStartingWithString(config, "$variable $value")
|
||||
}
|
||||
|
||||
fun reset(ctx: Context) {
|
||||
Utils.copyAssetToFile(ctx, "config", configPath)
|
||||
fun replaceVariable(variable: String, value: String) {
|
||||
removeVariable(variable)
|
||||
if (value != "")
|
||||
addVariable(variable, value)
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
Utils.deleteFile(File(configPath))
|
||||
}
|
||||
|
||||
fun save() {
|
||||
var result = ""
|
||||
for (line in config.split("\n"))
|
||||
if (line.isNotEmpty())
|
||||
result = result + line + '\n'
|
||||
config = result
|
||||
Utils.putFileContents(configPath, config.toByteArray())
|
||||
Log.d(TAG, "Saved new config '$result'")
|
||||
lines = config.split("\n")
|
||||
Log.d(TAG, "Saved new config '$config'")
|
||||
// Api.reload_config()
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.transition.Visibility
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.tutpro.baresip.Utils.copyInputStreamToFile
|
||||
@ -62,7 +61,7 @@ class ConfigActivity : AppCompatActivity() {
|
||||
private var oldListenAddr = ""
|
||||
private var oldDnsServers = ""
|
||||
private var oldCertificateFile = false
|
||||
private var oldVerifyServer = ""
|
||||
private var oldVerifyServer = false
|
||||
private var oldCAFile = false
|
||||
private var oldLogLevel = ""
|
||||
private var oldDisplayTheme = -1
|
||||
@ -93,8 +92,7 @@ class ConfigActivity : AppCompatActivity() {
|
||||
baresipService = Intent(this@ConfigActivity, BaresipService::class.java)
|
||||
|
||||
autoStart = binding.AutoStart
|
||||
val asCv = Config.variable("auto_start")
|
||||
oldAutoStart = if (asCv.size == 0) "no" else asCv[0]
|
||||
oldAutoStart = Config.variable("auto_start")
|
||||
autoStart.isChecked = oldAutoStart == "yes"
|
||||
|
||||
val pm = getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||
@ -145,15 +143,13 @@ class ConfigActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
listenAddr = binding.ListenAddress
|
||||
val laCv = Config.variable("sip_listen")
|
||||
oldListenAddr = if (laCv.size == 0) "" else laCv[0]
|
||||
oldListenAddr = Config.variable("sip_listen")
|
||||
listenAddr.setText(oldListenAddr)
|
||||
|
||||
netAfSpinner = binding.NetAfSpinner
|
||||
netAfKeys = arrayListOf("", "ipv4", "ipv6")
|
||||
val netAfVals = arrayListOf("-", "IPv4", "IPv6")
|
||||
val netAfCv = Config.variable("net_af")
|
||||
oldNetAf = if (netAfCv.size == 0) "" else netAfCv[0].lowercase()
|
||||
oldNetAf = Config.variable("net_af").lowercase()
|
||||
netAf = oldNetAf
|
||||
val netAfIndex = netAfKeys.indexOf(oldNetAf)
|
||||
val netAfValue = netAfVals.elementAt(netAfIndex)
|
||||
@ -172,19 +168,20 @@ class ConfigActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
dnsServers = binding.DnsServers
|
||||
val ddCv = Config.variable("dyn_dns")
|
||||
if (ddCv[0] == "yes") {
|
||||
val dynamicDns = Config.variable("dyn_dns")
|
||||
if (dynamicDns == "yes") {
|
||||
oldDnsServers = ""
|
||||
} else {
|
||||
val dsCv = Config.variable("dns_server")
|
||||
var dsTv = ""
|
||||
for (ds in dsCv) dsTv += ", $ds"
|
||||
oldDnsServers = dsTv.trimStart(',').trimStart(' ')
|
||||
val servers = Config.variables("dns_server")
|
||||
var serverList = ""
|
||||
for (server in servers)
|
||||
serverList += ", $server"
|
||||
oldDnsServers = serverList.trimStart(',').trimStart(' ')
|
||||
}
|
||||
dnsServers.setText(oldDnsServers)
|
||||
|
||||
certificateFile = binding.CertificateFile
|
||||
oldCertificateFile = Config.variable("sip_certificate").isNotEmpty()
|
||||
oldCertificateFile = Config.variable("sip_certificate") != ""
|
||||
certificateFile.isChecked = oldCertificateFile
|
||||
|
||||
val certificateRequest =
|
||||
@ -195,11 +192,10 @@ class ConfigActivity : AppCompatActivity() {
|
||||
val inputStream =
|
||||
applicationContext.contentResolver.openInputStream(uri)
|
||||
as FileInputStream
|
||||
File(BaresipService.filesPath + "/cert.pem")
|
||||
.copyInputStreamToFile(inputStream)
|
||||
val certPath = BaresipService.filesPath + "/cert.pem"
|
||||
File(certPath).copyInputStreamToFile(inputStream)
|
||||
inputStream.close()
|
||||
Config.removeVariable("sip_certificate")
|
||||
Config.addLine("sip_certificate ${BaresipService.filesPath}/cert.pem")
|
||||
Config.replaceVariable("sip_certificate", certPath)
|
||||
save = true
|
||||
restart = true
|
||||
} catch (e: Error) {
|
||||
@ -234,10 +230,9 @@ class ConfigActivity : AppCompatActivity() {
|
||||
)
|
||||
return@setOnCheckedChangeListener
|
||||
}
|
||||
val filesPath = BaresipService.filesPath + "/cert.pem"
|
||||
Utils.putFileContents(filesPath, content)
|
||||
Config.removeVariable("sip_certificate")
|
||||
Config.addLine("sip_certificate $filesPath")
|
||||
val certPath = BaresipService.filesPath + "/cert.pem"
|
||||
Utils.putFileContents(certPath, content)
|
||||
Config.replaceVariable("sip_certificate", certPath)
|
||||
certificateFile.isChecked = true
|
||||
save = true
|
||||
restart = true
|
||||
@ -270,12 +265,11 @@ class ConfigActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
verifyServer = binding.VerifyServer
|
||||
val vsCv = Config.variable("sip_verify_server")
|
||||
oldVerifyServer = if (vsCv.size == 0) "no" else vsCv[0]
|
||||
verifyServer.isChecked = oldVerifyServer == "yes"
|
||||
oldVerifyServer = Config.variable("sip_verify_server") == "yes"
|
||||
verifyServer.isChecked = oldVerifyServer
|
||||
|
||||
caFile = binding.CAFile
|
||||
oldCAFile = Config.variable("sip_cafile").isNotEmpty()
|
||||
oldCAFile = Config.variable("sip_cafile") != ""
|
||||
caFile.isChecked = oldCAFile
|
||||
|
||||
val certificatesRequest =
|
||||
@ -286,11 +280,10 @@ class ConfigActivity : AppCompatActivity() {
|
||||
val inputStream =
|
||||
applicationContext.contentResolver.openInputStream(uri)
|
||||
as FileInputStream
|
||||
File(BaresipService.filesPath + "/ca_certs.crt")
|
||||
.copyInputStreamToFile(inputStream)
|
||||
val caCertsPath = BaresipService.filesPath + "/ca_certs.crt"
|
||||
File(caCertsPath).copyInputStreamToFile(inputStream)
|
||||
inputStream.close()
|
||||
Config.removeVariable("sip_cafile")
|
||||
Config.addLine("sip_cafile ${BaresipService.filesPath}/ca_certs.crt")
|
||||
Config.replaceVariable("sip_cafile", caCertsPath)
|
||||
save = true
|
||||
restart = true
|
||||
} catch (e: Error) {
|
||||
@ -324,10 +317,9 @@ class ConfigActivity : AppCompatActivity() {
|
||||
)
|
||||
return@setOnCheckedChangeListener
|
||||
}
|
||||
val filesPath = BaresipService.filesPath + "/ca_certs.crt"
|
||||
Utils.putFileContents(filesPath, content)
|
||||
Config.removeVariable("sip_cafile")
|
||||
Config.addLine("sip_cafile $filesPath")
|
||||
val caCertsPath = BaresipService.filesPath + "/ca_certs.crt"
|
||||
Utils.putFileContents(caCertsPath, content)
|
||||
Config.replaceVariable("sip_cafile", caCertsPath)
|
||||
caFile.isChecked = true
|
||||
save = true
|
||||
restart = true
|
||||
@ -367,8 +359,7 @@ class ConfigActivity : AppCompatActivity() {
|
||||
contactsModeKeys = arrayListOf("baresip", "android", "both")
|
||||
val contactsModeVals = arrayListOf(getString(R.string.baresip), getString(R.string.android),
|
||||
getString(R.string.both))
|
||||
val ctCv = Config.variable("contacts_mode")
|
||||
oldContactsMode = if (ctCv.size == 0) "baresip" else ctCv[0].lowercase()
|
||||
oldContactsMode = Config.variable("contacts_mode").lowercase()
|
||||
contactsMode = oldContactsMode
|
||||
val keyIndex = contactsModeKeys.indexOf(oldContactsMode)
|
||||
val keyValue = contactsModeVals.elementAt(keyIndex)
|
||||
@ -408,11 +399,7 @@ class ConfigActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
debug = binding.Debug
|
||||
val dbCv = Config.variable("log_level")
|
||||
oldLogLevel = if (dbCv.size == 0)
|
||||
"2"
|
||||
else
|
||||
dbCv[0]
|
||||
oldLogLevel = Config.variable("log_level")
|
||||
debug.isChecked = oldLogLevel == "0"
|
||||
|
||||
sipTrace = binding.SipTrace
|
||||
@ -427,7 +414,7 @@ class ConfigActivity : AppCompatActivity() {
|
||||
setTitle(R.string.confirmation)
|
||||
setMessage(getString(R.string.reset_config_alert))
|
||||
setPositiveButton(getText(R.string.reset)) { dialog, _ ->
|
||||
Config.reset(this@ConfigActivity)
|
||||
Config.reset()
|
||||
save = false
|
||||
restart = true
|
||||
done()
|
||||
@ -523,12 +510,10 @@ class ConfigActivity : AppCompatActivity() {
|
||||
|
||||
R.id.checkIcon -> {
|
||||
|
||||
var autoStartString = "no"
|
||||
if (autoStart.isChecked) autoStartString = "yes"
|
||||
val autoStartString = if (autoStart.isChecked) "yes" else "no"
|
||||
if (oldAutoStart != autoStartString) {
|
||||
Config.replaceVariable("auto_start", autoStartString)
|
||||
save = true
|
||||
restart = false
|
||||
}
|
||||
|
||||
val listenAddr = listenAddr.text.toString().trim()
|
||||
@ -538,17 +523,13 @@ class ConfigActivity : AppCompatActivity() {
|
||||
"${getString(R.string.invalid_listen_address)}: $listenAddr")
|
||||
return false
|
||||
}
|
||||
Config.removeVariable("sip_listen")
|
||||
if (listenAddr != "") Config.addLine("sip_listen $listenAddr")
|
||||
Config.replaceVariable("sip_listen", listenAddr)
|
||||
save = true
|
||||
restart = true
|
||||
}
|
||||
|
||||
if (oldNetAf != netAf) {
|
||||
if (netAf == "")
|
||||
Config.removeVariable("net_af")
|
||||
else
|
||||
Config.replaceVariable("net_af", netAf)
|
||||
Config.replaceVariable("net_af", netAf)
|
||||
save = true
|
||||
restart = true
|
||||
}
|
||||
@ -561,19 +542,18 @@ class ConfigActivity : AppCompatActivity() {
|
||||
"${getString(R.string.invalid_dns_servers)}: $dnsServers")
|
||||
return false
|
||||
}
|
||||
Config.removeVariable("dyn_dns")
|
||||
Config.removeVariable("dns_server")
|
||||
if (dnsServers.isNotEmpty()) {
|
||||
for (server in dnsServers.split(","))
|
||||
Config.addLine("dns_server $server")
|
||||
Config.addLine("dyn_dns no")
|
||||
Config.addVariable("dns_server", server)
|
||||
Config.replaceVariable("dyn_dns", "no")
|
||||
if (Api.net_use_nameserver(dnsServers) != 0) {
|
||||
Utils.alertView(this, getString(R.string.error),
|
||||
"${getString(R.string.failed_to_set_dns_servers)}: $dnsServers")
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
Config.addLine("dyn_dns yes")
|
||||
Config.replaceVariable("dyn_dns", "yes")
|
||||
Config.updateDnsServers(BaresipService.dnsServers)
|
||||
}
|
||||
// Api.net_dns_debug()
|
||||
@ -587,9 +567,9 @@ class ConfigActivity : AppCompatActivity() {
|
||||
return false
|
||||
}
|
||||
|
||||
val verifyServerString = if (verifyServer.isChecked) "yes" else "no"
|
||||
if (oldVerifyServer != verifyServerString) {
|
||||
Config.replaceVariable("sip_verify_server", verifyServerString)
|
||||
if (oldVerifyServer != verifyServer.isChecked) {
|
||||
Config.replaceVariable("sip_verify_server",
|
||||
if (verifyServer.isChecked) "yes" else "no")
|
||||
save = true
|
||||
restart = true
|
||||
}
|
||||
@ -626,8 +606,7 @@ class ConfigActivity : AppCompatActivity() {
|
||||
save = true
|
||||
}
|
||||
|
||||
var logLevelString = "2"
|
||||
if (debug.isChecked) logLevelString = "0"
|
||||
val logLevelString = if (debug.isChecked) "0" else "2"
|
||||
if (oldLogLevel != logLevelString) {
|
||||
Config.replaceVariable("log_level", logLevelString)
|
||||
Api.log_level_set(logLevelString.toInt())
|
||||
|
||||
@ -370,8 +370,8 @@
|
||||
</string>
|
||||
<string name="opus_packet_loss">Odotettu opus-pakettihäviö</string>
|
||||
<string name="opus_packet_loss_help">Odotettu opus audio virran pakettihäviö prosentteina.
|
||||
Mahdolliset arvot ovat 0-100. Oletusarvo on 0, jolloin ennakoiva virheenkorjaus
|
||||
ei ole käytössä.</string>
|
||||
Mahdolliset arvot ovat 0-100. Oletusarvo on 1. Arvo 0 poistaa käytöstä
|
||||
ennakoivan virheenkorjauksen.</string>
|
||||
<string name="invalid_opus_bitrate">Virheellinen Opus-koodekin bittinopeus</string>
|
||||
<string name="invalid_opus_packet_loss">Virheellinen Opus-koodekin odotettu pakettihäviö</string>
|
||||
<string name="audio_delay">Audioviive</string>
|
||||
|
||||
@ -345,7 +345,8 @@
|
||||
<string name="_28000" translatable="false">28000</string>
|
||||
<string name="opus_packet_loss">Expected Opus packet-loss</string>
|
||||
<string name="opus_packet_loss_help">Expected Opus audio stream packet loss percentage,
|
||||
from 0–100. By default 0, turning off Opus Forward Error Correction (FEC).</string>
|
||||
from 0–100. Factory default value is 1. Value 0 also turns off Opus Forward Error
|
||||
Correction (FEC).</string>
|
||||
<string name="_0" translatable="false">0</string>
|
||||
<string name="invalid_opus_bitrate">Invalid Opus bitrate</string>
|
||||
<string name="invalid_opus_packet_loss">Invalid Opus Packet Loss Percentage</string>
|
||||
|
||||
Reference in New Issue
Block a user