Improved setting of audio effects
This commit is contained in:
@@ -93,7 +93,7 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BaresipService.agc) {
|
if (!BaresipService.agcAvailable) {
|
||||||
micGain = binding.MicGain
|
micGain = binding.MicGain
|
||||||
oldMicGain = Config.variable("augain")
|
oldMicGain = Config.variable("augain")
|
||||||
micGain.setText(oldMicGain)
|
micGain.setText(oldMicGain)
|
||||||
@@ -148,7 +148,7 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
oldOpusPacketLoss = Config.variable("opus_packet_loss")
|
oldOpusPacketLoss = Config.variable("opus_packet_loss")
|
||||||
opusPacketLoss.setText(oldOpusPacketLoss)
|
opusPacketLoss.setText(oldOpusPacketLoss)
|
||||||
|
|
||||||
if (!BaresipService.aec) {
|
if (!BaresipService.aecAvailable) {
|
||||||
aec = binding.Aec
|
aec = binding.Aec
|
||||||
oldAec = modules.contains("webrtc_aecm.so")
|
oldAec = modules.contains("webrtc_aecm.so")
|
||||||
aec.isChecked = oldAec
|
aec.isChecked = oldAec
|
||||||
@@ -211,7 +211,7 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var gain = "1.0"
|
var gain = "1.0"
|
||||||
if (!BaresipService.agc) {
|
if (!BaresipService.agcAvailable) {
|
||||||
gain = micGain.text.toString().trim()
|
gain = micGain.text.toString().trim()
|
||||||
if (!gain.contains("."))
|
if (!gain.contains("."))
|
||||||
gain = "$gain.0"
|
gain = "$gain.0"
|
||||||
@@ -301,7 +301,7 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
save = true
|
save = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BaresipService.aec) {
|
if (!BaresipService.aecAvailable) {
|
||||||
if (aec.isChecked != oldAec) {
|
if (aec.isChecked != oldAec) {
|
||||||
if (aec.isChecked) {
|
if (aec.isChecked) {
|
||||||
Config.addVariable("module", "webrtc_aecm.so")
|
Config.addVariable("module", "webrtc_aecm.so")
|
||||||
|
|||||||
@@ -441,7 +441,8 @@ class BaresipService: Service() {
|
|||||||
activeNetwork = cm.activeNetwork
|
activeNetwork = cm.activeNetwork
|
||||||
Log.i(TAG, "Active network: $activeNetwork")
|
Log.i(TAG, "Active network: $activeNetwork")
|
||||||
|
|
||||||
Log.d(TAG, "AEC/AGC/NS available = $aec/$agc/$ns")
|
Log.d(TAG, "AEC/AGC/NS available = " +
|
||||||
|
"$aecAvailable/$agcAvailable/$nsAvailable")
|
||||||
|
|
||||||
val userAgent = Config.variable("user_agent")
|
val userAgent = Config.variable("user_agent")
|
||||||
Thread {
|
Thread {
|
||||||
@@ -628,14 +629,8 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ev[0] == "recorder sessionid") {
|
if (ev[0] == "recorder sessionid") {
|
||||||
val sessionId = ev[1].toInt()
|
recorderSessionId = ev[1].toInt()
|
||||||
Log.d(TAG, "got recorder sessionid $sessionId")
|
Log.d(TAG, "got recorder sessionid $recorderSessionId")
|
||||||
if (aec)
|
|
||||||
AcousticEchoCanceler.create(sessionId)
|
|
||||||
if (agc)
|
|
||||||
AutomaticGainControl.create(sessionId)
|
|
||||||
if (ns)
|
|
||||||
NoiseSuppressor.create(sessionId)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -834,6 +829,37 @@ class BaresipService: Service() {
|
|||||||
if (am.mode != MODE_IN_COMMUNICATION)
|
if (am.mode != MODE_IN_COMMUNICATION)
|
||||||
am.mode = MODE_IN_COMMUNICATION
|
am.mode = MODE_IN_COMMUNICATION
|
||||||
call!!.status = "connected"
|
call!!.status = "connected"
|
||||||
|
if (recorderSessionId != 0) {
|
||||||
|
if (aecAvailable) {
|
||||||
|
val aec = AcousticEchoCanceler.create(recorderSessionId)
|
||||||
|
if (aec != null)
|
||||||
|
if (!aec.getEnabled()) {
|
||||||
|
aec.setEnabled(true)
|
||||||
|
if (aec.getEnabled())
|
||||||
|
Log.d(TAG, "aec is enabled")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (agcAvailable) {
|
||||||
|
val agc = AutomaticGainControl.create(recorderSessionId)
|
||||||
|
if (agc != null)
|
||||||
|
if (!agc.getEnabled()) {
|
||||||
|
agc.setEnabled(true)
|
||||||
|
if (agc.getEnabled())
|
||||||
|
Log.d(TAG, "agc is enabled")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nsAvailable) {
|
||||||
|
val ns = NoiseSuppressor.create(recorderSessionId)
|
||||||
|
if (ns != null) {
|
||||||
|
if (!ns.getEnabled()) {
|
||||||
|
ns.setEnabled(true)
|
||||||
|
if (ns.getEnabled())
|
||||||
|
Log.d(TAG, "ns is enabled")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
recorderSessionId = 0
|
||||||
|
}
|
||||||
call.onhold = false
|
call.onhold = false
|
||||||
if (ua.account.callHistory)
|
if (ua.account.callHistory)
|
||||||
call.startTime = GregorianCalendar()
|
call.startTime = GregorianCalendar()
|
||||||
@@ -1574,10 +1600,11 @@ class BaresipService: Service() {
|
|||||||
// <aor, password> of those accounts that have auth username without auth password
|
// <aor, password> of those accounts that have auth username without auth password
|
||||||
val aorPasswords = mutableMapOf<String, String>()
|
val aorPasswords = mutableMapOf<String, String>()
|
||||||
var audioFocusRequest: AudioFocusRequestCompat? = null
|
var audioFocusRequest: AudioFocusRequestCompat? = null
|
||||||
var aec = AcousticEchoCanceler.isAvailable()
|
var aecAvailable = AcousticEchoCanceler.isAvailable()
|
||||||
var agc = AutomaticGainControl.isAvailable()
|
var agcAvailable = AutomaticGainControl.isAvailable()
|
||||||
private val ns = NoiseSuppressor.isAvailable()
|
private val nsAvailable = NoiseSuppressor.isAvailable()
|
||||||
private var btAdapter: BluetoothAdapter? = null
|
private var btAdapter: BluetoothAdapter? = null
|
||||||
|
private var recorderSessionId = 0
|
||||||
|
|
||||||
fun requestAudioFocus(ctx: Context): Boolean {
|
fun requestAudioFocus(ctx: Context): Boolean {
|
||||||
Log.d(TAG, "Requesting audio focus")
|
Log.d(TAG, "Requesting audio focus")
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ object Config {
|
|||||||
if (!File(configPath).exists()) {
|
if (!File(configPath).exists()) {
|
||||||
for (module in AudioActivity.audioModules)
|
for (module in AudioActivity.audioModules)
|
||||||
config = "${config}module ${module}.so\n"
|
config = "${config}module ${module}.so\n"
|
||||||
if (!BaresipService.aec)
|
if (!BaresipService.aecAvailable)
|
||||||
config = "${config}module webrtc_aecm.so\n"
|
config = "${config}module webrtc_aecm.so\n"
|
||||||
previousConfig = config
|
previousConfig = config
|
||||||
} else {
|
} else {
|
||||||
@@ -155,11 +155,11 @@ object Config {
|
|||||||
if ("${module}.so" in previousModules)
|
if ("${module}.so" in previousModules)
|
||||||
config = "${config}module ${module}.so\n"
|
config = "${config}module ${module}.so\n"
|
||||||
|
|
||||||
if (!BaresipService.aec && "webrtc_aecm.so" in previousModules)
|
if (!BaresipService.aecAvailable && "webrtc_aecm.so" in previousModules)
|
||||||
config = "${config}module webrtc_aecm.so\n"
|
config = "${config}module webrtc_aecm.so\n"
|
||||||
|
|
||||||
val micGain = previousVariable("augain")
|
val micGain = previousVariable("augain")
|
||||||
config = if (BaresipService.agc || micGain == "" || micGain == "1.0")
|
config = if (BaresipService.agcAvailable || micGain == "" || micGain == "1.0")
|
||||||
"${config}augain 1.0\n"
|
"${config}augain 1.0\n"
|
||||||
else
|
else
|
||||||
"${config}module augain.so\naugain $micGain\n"
|
"${config}module augain.so\naugain $micGain\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user