use default ringtone in incoming calls
This commit is contained in:
@ -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:
|
||||||
|
|||||||
@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user