From a350d5ac0a550f06638c206e0f7ce2caf9c6fa40 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Tue, 5 May 2020 09:08:37 +0300 Subject: [PATCH] - Simplified proximity sensing control with help of two new call events. --- app/src/main/cpp/baresip.c | 6 ++++++ .../main/kotlin/com/tutpro/baresip/BaresipService.kt | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/baresip.c b/app/src/main/cpp/baresip.c index ee97691a..1e980179 100644 --- a/app/src/main/cpp/baresip.c +++ b/app/src/main/cpp/baresip.c @@ -186,6 +186,12 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev, } len = re_snprintf(event_buf, sizeof event_buf, "%s", "call incoming"); break; + case UA_EVENT_CALL_LOCAL_SDP: + if (strcmp(prm, "offer")) + len = re_snprintf(event_buf, sizeof event_buf, "%s", "call offered"); + else + len = re_snprintf(event_buf, sizeof event_buf, "%s", "call answered"); + break; case UA_EVENT_CALL_RINGING: play = mem_deref(play); (void)play_file(&play, player, "ringback.wav", -1, NULL, NULL); diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 24881b0c..8f372ed8 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -419,8 +419,6 @@ class BaresipService: Service() { "SetSpeaker" -> { Log.d(LOG_TAG, "Set speakerphone $speakerPhone") am.isSpeakerphoneOn = speakerPhone - if (Call.call("established") != null) - proximitySensing(!speakerPhone) } "Stop", "Stop Force" -> { @@ -547,6 +545,10 @@ class BaresipService: Service() { if (!Utils.isVisible()) return } + "call offered" -> { + proximitySensing(true) + return + } "call progress", "call ringing" -> { requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION) setCallVolume() @@ -629,6 +631,10 @@ class BaresipService: Service() { return } } + "call answered" -> { + proximitySensing(true) + return + } "call established" -> { nm.cancel(CALL_NOTIFICATION_ID) val call = Call.find(callp) @@ -649,7 +655,6 @@ class BaresipService: Service() { am.mode = AudioManager.MODE_IN_COMMUNICATION requestAudioFocus(AudioAttributes.USAGE_VOICE_COMMUNICATION) setCallVolume() - proximitySensing(!speakerPhone) if (!Utils.isVisible()) return }