use default ringtone in incoming calls

This commit is contained in:
Juha Heinanen
2018-06-24 14:35:26 +03:00
parent 95b4e22491
commit fc5cdde885
2 changed files with 10 additions and 4 deletions

View File

@ -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)); re_snprintf(event_buf, sizeof event_buf, "%s", ua_event_reg_str(ev));
break; break;
case UA_EVENT_CALL_INCOMING: case UA_EVENT_CALL_INCOMING:
play = mem_deref(play);
if (list_count(ua_calls(ua)) > 1) { if (list_count(ua_calls(ua)) > 1) {
play = mem_deref(play);
(void)play_file(&play, player, "callwaiting.wav", 3); (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"); re_snprintf(event_buf, sizeof event_buf, "%s", "call incoming");
break; break;
case UA_EVENT_CALL_RINGING: case UA_EVENT_CALL_RINGING:

View File

@ -22,6 +22,8 @@ import java.io.File
import java.io.FileInputStream import java.io.FileInputStream
import java.io.ObjectInputStream import java.io.ObjectInputStream
import android.support.v4.content.LocalBroadcastManager import android.support.v4.content.LocalBroadcastManager
import android.media.RingtoneManager
import android.media.Ringtone
class BaresipService: Service() { class BaresipService: Service() {
@ -34,6 +36,7 @@ class BaresipService: Service() {
internal lateinit var nr: BroadcastReceiver internal lateinit var nr: BroadcastReceiver
internal lateinit var wl: PowerManager.WakeLock internal lateinit var wl: PowerManager.WakeLock
internal lateinit var fl: WifiManager.WifiLock internal lateinit var fl: WifiManager.WifiLock
internal lateinit var rt: Ringtone
override fun onCreate() { 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() super.onCreate()
} }
@ -227,6 +234,7 @@ class BaresipService: Service() {
nb.setContent(view) nb.setContent(view)
nm.notify(STATUS_NOTIFICATION_ID, nb.build()) nm.notify(STATUS_NOTIFICATION_ID, nb.build())
} }
rt.play()
} }
"call established", "call closed" -> { "call established", "call closed" -> {
nm.cancel(STATUS_NOTIFICATION_ID) nm.cancel(STATUS_NOTIFICATION_ID)
@ -235,6 +243,7 @@ class BaresipService: Service() {
nb.setContent(view) nb.setContent(view)
nb.setVibrate(null) nb.setVibrate(null)
nm.notify(STATUS_NOTIFICATION_ID, nb.build()) nm.notify(STATUS_NOTIFICATION_ID, nb.build())
rt.stop()
} }
} }
} }