Allow use of software echo canceller even when hardware one would be available
This commit is contained in:
@@ -148,13 +148,9 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
oldOpusPacketLoss = Config.variable("opus_packet_loss")
|
oldOpusPacketLoss = Config.variable("opus_packet_loss")
|
||||||
opusPacketLoss.setText(oldOpusPacketLoss)
|
opusPacketLoss.setText(oldOpusPacketLoss)
|
||||||
|
|
||||||
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
|
||||||
} else {
|
|
||||||
binding.AecLayout.visibility = View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
audioDelay = binding.AudioDelay
|
audioDelay = binding.AudioDelay
|
||||||
audioDelay.setText("${BaresipService.audioDelay}")
|
audioDelay.setText("${BaresipService.audioDelay}")
|
||||||
@@ -301,7 +297,6 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
save = true
|
save = true
|
||||||
}
|
}
|
||||||
|
|
||||||
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")
|
||||||
@@ -317,13 +312,14 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BaresipService.webrtcAec = true
|
||||||
} else {
|
} else {
|
||||||
Api.module_unload("webrtc_aecm.so")
|
Api.module_unload("webrtc_aecm.so")
|
||||||
Config.removeVariableValue("module", "webrtc_aecm.so")
|
Config.removeVariableValue("module", "webrtc_aecm.so")
|
||||||
|
BaresipService.webrtcAec = false
|
||||||
}
|
}
|
||||||
save = true
|
save = true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val audioDelay = audioDelay.text.toString().trim()
|
val audioDelay = audioDelay.text.toString().trim()
|
||||||
if (audioDelay != BaresipService.audioDelay.toString()) {
|
if (audioDelay != BaresipService.audioDelay.toString()) {
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ class BaresipService: Service() {
|
|||||||
private lateinit var bluetoothReceiver: BroadcastReceiver
|
private lateinit var bluetoothReceiver: BroadcastReceiver
|
||||||
private lateinit var hotSpotReceiver: BroadcastReceiver
|
private lateinit var hotSpotReceiver: BroadcastReceiver
|
||||||
private lateinit var androidContactsObserver: ContentObserver
|
private lateinit var androidContactsObserver: ContentObserver
|
||||||
|
|
||||||
private lateinit var stopState: String
|
private lateinit var stopState: String
|
||||||
private lateinit var quitTimer: CountDownTimer
|
private lateinit var quitTimer: CountDownTimer
|
||||||
|
|
||||||
@@ -835,31 +834,14 @@ 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 (playerSessionId != 0) {
|
|
||||||
if (aecAvailable) {
|
|
||||||
val aec = AcousticEchoCanceler.create(playerSessionId)
|
|
||||||
if (aec != null) {
|
|
||||||
if (!aec.getEnabled()) {
|
|
||||||
aec.setEnabled(true)
|
|
||||||
if (aec.getEnabled())
|
|
||||||
Log.d(TAG, "aec is enabled")
|
|
||||||
else
|
|
||||||
Log.w(TAG, "Failed to enable AEC")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Log.w(TAG, "Failed to create AEC")
|
|
||||||
}
|
|
||||||
playerSessionId = 0
|
|
||||||
}
|
|
||||||
if (recorderSessionId != 0) {
|
if (recorderSessionId != 0) {
|
||||||
if (aecAvailable) {
|
if (aecAvailable && !webrtcAec) {
|
||||||
val aec = AcousticEchoCanceler.create(recorderSessionId)
|
aec = AcousticEchoCanceler.create(recorderSessionId)
|
||||||
if (aec != null) {
|
if (aec != null) {
|
||||||
if (!aec.getEnabled()) {
|
if (!aec!!.getEnabled()) {
|
||||||
aec.setEnabled(true)
|
aec!!.setEnabled(true)
|
||||||
if (aec.getEnabled())
|
if (aec!!.getEnabled())
|
||||||
Log.d(TAG, "aec is enabled")
|
Log.d(TAG, "AEC is enabled")
|
||||||
else
|
else
|
||||||
Log.w(TAG, "Failed to enable AEC")
|
Log.w(TAG, "Failed to enable AEC")
|
||||||
}
|
}
|
||||||
@@ -868,23 +850,28 @@ class BaresipService: Service() {
|
|||||||
Log.w(TAG, "Failed to create AEC")
|
Log.w(TAG, "Failed to create AEC")
|
||||||
}
|
}
|
||||||
if (agcAvailable) {
|
if (agcAvailable) {
|
||||||
val agc = AutomaticGainControl.create(recorderSessionId)
|
agc = AutomaticGainControl.create(recorderSessionId)
|
||||||
if (agc != null)
|
if (agc != null) {
|
||||||
if (!agc.getEnabled()) {
|
if (!agc!!.getEnabled()) {
|
||||||
agc.setEnabled(true)
|
agc!!.setEnabled(true)
|
||||||
if (agc.getEnabled())
|
if (agc!!.getEnabled())
|
||||||
Log.d(TAG, "agc is enabled")
|
Log.d(TAG, "AGC is enabled")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Log.w(TAG, "Failed to create AGC")
|
||||||
|
}
|
||||||
if (nsAvailable) {
|
if (nsAvailable) {
|
||||||
val ns = NoiseSuppressor.create(recorderSessionId)
|
ns = NoiseSuppressor.create(recorderSessionId)
|
||||||
if (ns != null) {
|
if (ns != null) {
|
||||||
if (!ns.getEnabled()) {
|
if (!ns!!.getEnabled()) {
|
||||||
ns.setEnabled(true)
|
ns!!.setEnabled(true)
|
||||||
if (ns.getEnabled())
|
if (ns!!.getEnabled())
|
||||||
Log.d(TAG, "ns is enabled")
|
Log.d(TAG, "ns is enabled")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Log.w(TAG, "Failed to create NS")
|
||||||
}
|
}
|
||||||
recorderSessionId = 0
|
recorderSessionId = 0
|
||||||
}
|
}
|
||||||
@@ -970,6 +957,9 @@ class BaresipService: Service() {
|
|||||||
nm.cancel(CALL_NOTIFICATION_ID)
|
nm.cancel(CALL_NOTIFICATION_ID)
|
||||||
stopRinging()
|
stopRinging()
|
||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
|
aec?.release()
|
||||||
|
agc?.release()
|
||||||
|
ns?.release()
|
||||||
val newCall = call.newCall
|
val newCall = call.newCall
|
||||||
if (newCall != null) {
|
if (newCall != null) {
|
||||||
newCall.onHoldCall = null
|
newCall.onHoldCall = null
|
||||||
@@ -1631,6 +1621,10 @@ class BaresipService: Service() {
|
|||||||
var aecAvailable = AcousticEchoCanceler.isAvailable()
|
var aecAvailable = AcousticEchoCanceler.isAvailable()
|
||||||
var agcAvailable = AutomaticGainControl.isAvailable()
|
var agcAvailable = AutomaticGainControl.isAvailable()
|
||||||
private val nsAvailable = NoiseSuppressor.isAvailable()
|
private val nsAvailable = NoiseSuppressor.isAvailable()
|
||||||
|
private var aec: AcousticEchoCanceler? = null
|
||||||
|
private var ns: NoiseSuppressor? = null
|
||||||
|
private var agc: AutomaticGainControl? = null
|
||||||
|
var webrtcAec = false
|
||||||
private var btAdapter: BluetoothAdapter? = null
|
private var btAdapter: BluetoothAdapter? = null
|
||||||
private var playerSessionId = 0
|
private var playerSessionId = 0
|
||||||
private var recorderSessionId = 0
|
private var recorderSessionId = 0
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ 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.aecAvailable)
|
|
||||||
config = "${config}module webrtc_aecm.so\n"
|
|
||||||
previousConfig = config
|
previousConfig = config
|
||||||
} else {
|
} else {
|
||||||
previousConfig = String(Utils.getFileContents(configPath)!!, StandardCharsets.ISO_8859_1)
|
previousConfig = String(Utils.getFileContents(configPath)!!, StandardCharsets.ISO_8859_1)
|
||||||
@@ -155,8 +153,10 @@ 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.aecAvailable && "webrtc_aecm.so" in previousModules)
|
if ("webrtc_aecm.so" in previousModules || !File(configPath).exists()) {
|
||||||
config = "${config}module webrtc_aecm.so\n"
|
config = "${config}module webrtc_aecm.so\n"
|
||||||
|
BaresipService.webrtcAec = true
|
||||||
|
}
|
||||||
|
|
||||||
val micGain = previousVariable("augain")
|
val micGain = previousVariable("augain")
|
||||||
config = if (BaresipService.agcAvailable || micGain == "" || micGain == "1.0")
|
config = if (BaresipService.agcAvailable || micGain == "" || micGain == "1.0")
|
||||||
|
|||||||
@@ -365,11 +365,9 @@
|
|||||||
</string>
|
</string>
|
||||||
<string name="failed_to_load_module">Modulin lataaminen epäonnistui.</string>
|
<string name="failed_to_load_module">Modulin lataaminen epäonnistui.</string>
|
||||||
<string name="aec">Akustinen kaiun poisto (AKP)</string>
|
<string name="aec">Akustinen kaiun poisto (AKP)</string>
|
||||||
<string name="aec_help">Jos merkitty, kaikua yritetään poistaa puheluiden aikana.</string>
|
<string name="aec_help">Jos merkitty, kaikua yritetään poistaa ohjelmiston avulla
|
||||||
|
puheluiden aikana.</string>
|
||||||
<string name="aec_extended_filter">AKP laajennettu suodatin</string>
|
<string name="aec_extended_filter">AKP laajennettu suodatin</string>
|
||||||
<string name="aec_extended_filter_help">Jos merkitty, kaiun poistossa käytetään laajennettua
|
|
||||||
suodatinta.
|
|
||||||
</string>
|
|
||||||
<string name="microphone_gain">Mikrofonin äänikerroin</string>
|
<string name="microphone_gain">Mikrofonin äänikerroin</string>
|
||||||
<string name="microphone_gain_help">Kertoo mikrofonin äänen voimakkuuden tällä desimaaliluvulla.
|
<string name="microphone_gain_help">Kertoo mikrofonin äänen voimakkuuden tällä desimaaliluvulla.
|
||||||
Minimikerroin on 1.0 (tehdasasetus), mikä ei muuta mikrofonin äänen voimakkuutta. Suuremmat
|
Minimikerroin on 1.0 (tehdasasetus), mikä ei muuta mikrofonin äänen voimakkuutta. Suuremmat
|
||||||
|
|||||||
@@ -340,7 +340,7 @@
|
|||||||
available for use by the accounts.</string>
|
available for use by the accounts.</string>
|
||||||
<string name="failed_to_load_module">Failed to load module.</string>
|
<string name="failed_to_load_module">Failed to load module.</string>
|
||||||
<string name="aec">Acoustic Echo Cancellation</string>
|
<string name="aec">Acoustic Echo Cancellation</string>
|
||||||
<string name="aec_help">If checked, echo cancellation is attempted on call audio.</string>
|
<string name="aec_help">If checked, software echo cancellation is attempted on call audio.</string>
|
||||||
<string name="aec_extended_filter">AEC Extended Filter</string>
|
<string name="aec_extended_filter">AEC Extended Filter</string>
|
||||||
<string name="aec_extended_filter_help">If checked, echo cancellation is using extended filter.</string>
|
<string name="aec_extended_filter_help">If checked, echo cancellation is using extended filter.</string>
|
||||||
<string name="microphone_gain">Microphone Gain</string>
|
<string name="microphone_gain">Microphone Gain</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user