From fc5cdde885f633fa1b5525678f40cebd191fb621 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Sun, 24 Jun 2018 14:35:26 +0300 Subject: [PATCH] use default ringtone in incoming calls --- app/src/main/cpp/baresip.c | 5 +---- app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt | 9 +++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/cpp/baresip.c b/app/src/main/cpp/baresip.c index 41f3de4f..cb451b88 100644 --- a/app/src/main/cpp/baresip.c +++ b/app/src/main/cpp/baresip.c @@ -105,13 +105,10 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev, re_snprintf(event_buf, sizeof event_buf, "%s", ua_event_reg_str(ev)); break; case UA_EVENT_CALL_INCOMING: - play = mem_deref(play); if (list_count(ua_calls(ua)) > 1) { + play = mem_deref(play); (void)play_file(&play, player, "callwaiting.wav", 3); } - else { - (void)play_file(&play, player, "ring.wav", -1); - } re_snprintf(event_buf, sizeof event_buf, "%s", "call incoming"); break; case UA_EVENT_CALL_RINGING: diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 238dac8a..184a4302 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -22,6 +22,8 @@ import java.io.File import java.io.FileInputStream import java.io.ObjectInputStream import android.support.v4.content.LocalBroadcastManager +import android.media.RingtoneManager +import android.media.Ringtone class BaresipService: Service() { @@ -34,6 +36,7 @@ class BaresipService: Service() { internal lateinit var nr: BroadcastReceiver internal lateinit var wl: PowerManager.WakeLock internal lateinit var fl: WifiManager.WifiLock + internal lateinit var rt: Ringtone override fun onCreate() { @@ -66,6 +69,10 @@ class BaresipService: Service() { } } + val currentRtUri = RingtoneManager + .getActualDefaultRingtoneUri(applicationContext, RingtoneManager.TYPE_RINGTONE) + rt = RingtoneManager.getRingtone(applicationContext, currentRtUri) + super.onCreate() } @@ -227,6 +234,7 @@ class BaresipService: Service() { nb.setContent(view) nm.notify(STATUS_NOTIFICATION_ID, nb.build()) } + rt.play() } "call established", "call closed" -> { nm.cancel(STATUS_NOTIFICATION_ID) @@ -235,6 +243,7 @@ class BaresipService: Service() { nb.setContent(view) nb.setVibrate(null) nm.notify(STATUS_NOTIFICATION_ID, nb.build()) + rt.stop() } } }