Fixed sending of player session id and reinstalled player aec

This commit is contained in:
Juha Heinanen
2025-01-26 22:14:53 +02:00
parent 4570bb614c
commit c668b8cfa8
2 changed files with 33 additions and 4 deletions

View File

@ -246,7 +246,7 @@ static void event_handler(enum ua_event ev, struct bevent *event, void *arg)
len = re_snprintf(event_buf, sizeof event_buf, "sndfile dump,%r", &data);
break;
}
if (!pl_strcmp(&module_event, "player sessionid")) {
if (!pl_strcmp(&module_event, "player: sessionid")) {
len = re_snprintf(event_buf, sizeof event_buf, "player sessionid,%r", &data);
break;
}

View File

@ -628,6 +628,12 @@ class BaresipService: Service() {
return
}
if (ev[0] == "player sessionid") {
playerSessionId = ev[1].toInt()
Log.d(TAG, "got player sessionid $playerSessionId")
return
}
if (ev[0] == "recorder sessionid") {
recorderSessionId = ev[1].toInt()
Log.d(TAG, "got recorder sessionid $recorderSessionId")
@ -829,15 +835,37 @@ class BaresipService: Service() {
if (am.mode != MODE_IN_COMMUNICATION)
am.mode = MODE_IN_COMMUNICATION
call!!.status = "connected"
if (recorderSessionId != 0) {
if (playerSessionId != 0) {
if (aecAvailable) {
val aec = AcousticEchoCanceler.create(recorderSessionId)
if (aec != null)
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 (aecAvailable) {
val aec = AcousticEchoCanceler.create(recorderSessionId)
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")
}
if (agcAvailable) {
val agc = AutomaticGainControl.create(recorderSessionId)
@ -1604,6 +1632,7 @@ class BaresipService: Service() {
var agcAvailable = AutomaticGainControl.isAvailable()
private val nsAvailable = NoiseSuppressor.isAvailable()
private var btAdapter: BluetoothAdapter? = null
private var playerSessionId = 0
private var recorderSessionId = 0
fun requestAudioFocus(ctx: Context): Boolean {