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