diff --git a/app/src/main/cpp/baresip.c b/app/src/main/cpp/baresip.c index a51cfbec..bf59b5b3 100644 --- a/app/src/main/cpp/baresip.c +++ b/app/src/main/cpp/baresip.c @@ -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; } diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index eaf78b5e..81e4dd68 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -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 {