diff --git a/app/build.gradle b/app/build.gradle index c9b74542..cf9c5f0c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,7 +7,7 @@ android { ndkVersion '27.2.12479018' defaultConfig { applicationId = 'com.tutpro.baresip' - minSdkVersion 23 + minSdkVersion 28 targetSdkVersion 35 versionCode = 405 versionName = '61.1.0' diff --git a/app/src/main/assets/config.static b/app/src/main/assets/config.static index fdb3f400..bd0a85d9 100644 --- a/app/src/main/assets/config.static +++ b/app/src/main/assets/config.static @@ -2,9 +2,9 @@ poll_method epoll call_local_timeout 120 call_max_calls 4 call_hold_other_calls yes -audio_player opensles,nil -audio_source opensles,nil -audio_alert opensles,nil +audio_player aaudio,nil +audio_source aaudio,nil +audio_alert aaudio,nil audio_level no ausrc_format s16 auplay_format s16 @@ -19,7 +19,7 @@ audio_jitter_buffer_delay 0-20 rtp_stats yes rtp_timeout 60 rtp_rxmode thread -module opensles.so +module aaudio.so module stun.so module turn.so module ice.so diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index b6c90be0..f56903b4 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -75,7 +75,7 @@ add_definitions(-DHAVE_PTHREAD) target_link_libraries(baresip android - OpenSLES + aaudio lib_baresip lib_re lib_ssl diff --git a/app/src/main/cpp/baresip.c b/app/src/main/cpp/baresip.c index 63a599c0..a51cfbec 100644 --- a/app/src/main/cpp/baresip.c +++ b/app/src/main/cpp/baresip.c @@ -246,6 +246,14 @@ 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")) { + len = re_snprintf(event_buf, sizeof event_buf, "player sessionid,%r", &data); + break; + } + if (!pl_strcmp(&module_event, "recorder sessionid")) { + len = re_snprintf(event_buf, sizeof event_buf, "recorder sessionid,%r", &data); + break; + } default: return; } diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index b8720b08..5a58d84d 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -18,6 +18,9 @@ import android.media.* import android.media.AudioManager.MODE_IN_COMMUNICATION import android.media.AudioManager.MODE_NORMAL import android.media.AudioManager.RINGER_MODE_SILENT +import android.media.audiofx.AcousticEchoCanceler +import android.media.audiofx.AutomaticGainControl +import android.media.audiofx.NoiseSuppressor import android.net.* import android.net.wifi.WifiManager import android.os.* @@ -70,6 +73,7 @@ class BaresipService: Service() { private lateinit var bluetoothReceiver: BroadcastReceiver private lateinit var hotSpotReceiver: BroadcastReceiver private lateinit var androidContactsObserver: ContentObserver + private lateinit var stopState: String private lateinit var quitTimer: CountDownTimer @@ -625,6 +629,36 @@ class BaresipService: Service() { return } + if (ev[0] == "player sessionid") { + val sessionId = ev[1].toInt() + Log.d(TAG, "got player sessionid $sessionId") + return + } + + if (ev[0] == "recorder sessionid") { + val sessionId = ev[1].toInt() + Log.d(TAG, "got recorder sessionid $sessionId") + if (AcousticEchoCanceler.isAvailable()) { + Log.i(TAG, "AcousticEchoCanceler IS available") + AcousticEchoCanceler.create(sessionId) + } else { + Log.i(TAG, "AcousticEchoCanceler IS NOT available") + } + if (AutomaticGainControl.isAvailable()) { + Log.i(TAG, "AutomaticGainControl IS available") + AutomaticGainControl.create(sessionId) + } else { + Log.i(TAG, "AutomaticGainControl IS NOT available") + } + if (NoiseSuppressor.isAvailable()) { + Log.i(TAG, "NoiseSuppressor IS available") + NoiseSuppressor.create(sessionId) + } else { + Log.i(TAG, "NoiseSuppressor IS NOT available") + } + return + } + val ua = UserAgent.ofUap(uap) if (ua == null) { Log.w(TAG, "uaEvent $event did not find ua $uap")