Pass bevent to "call update" event and use to stop bevent when call update is skipped

Prevent other conference calls from closing when one participant hangs up
This commit is contained in:
Juha Heinanen
2026-04-09 18:05:34 +03:00
parent 9d3caf7a5a
commit ffe1946ab9
3 changed files with 13 additions and 3 deletions

View File

@ -210,7 +210,7 @@ static void event_handler(enum bevent_ev ev, struct bevent *event, void *arg)
break;
case BEVENT_CALL_REMOTE_SDP:
ardir = sdp_media_rdir(stream_sdpmedia(audio_strm(call_audio(call))));
len = re_snprintf(event_buf, sizeof event_buf, "call update,%d", ardir);
len = re_snprintf(event_buf, sizeof event_buf, "call update,%d,%ld", ardir, (long)event);
break;
case BEVENT_CALL_MENC:
if (prm[0] == '0')

View File

@ -802,7 +802,6 @@ class BaresipService: Service() {
}
"incoming call" -> {
val peerUri = ev[1]
val bevent = ev[2].toLong()
val toastMsg = if (Call.isAnyCallActive(applicationContext))
String.format(getString(R.string.call_auto_rejected),
Utils.friendlyUri(this, peerUri, ua.account))
@ -816,7 +815,7 @@ class BaresipService: Service() {
if (toastMsg != "") {
Log.d(TAG, "Auto-rejecting incoming call to $uap from $peerUri")
Api.sip_treply(callp, 486, "Busy Here")
Api.bevent_stop(bevent)
Api.bevent_stop(ev[2].toLong())
toast(toastMsg)
if (toastMsg.contains(getString(R.string.call_blocked))) {
if (ua.account.callHistory)
@ -892,6 +891,7 @@ class BaresipService: Service() {
"call update" -> {
if (call!!.conferenceCall) {
Log.d(TAG, "Refusing to update conference call ${call.callp}")
Api.bevent_stop(ev[2].toLong())
return
}
val newHeldState = when (ev[1].toInt()) {Api.SDP_INACTIVE, Api.SDP_RECVONLY -> true
@ -1002,6 +1002,7 @@ class BaresipService: Service() {
}
"call closed" -> {
Log.d(TAG, "AoR $aor call $callp is closed prm: ${ev[1]}")
ConnectionService.lastDisconnectTime = System.currentTimeMillis()
val connection = ConnectionService.connections[callp]
if (connection != null) {
val cause = when {

View File

@ -18,6 +18,7 @@ class ConnectionService : ConnectionService() {
companion object {
val connections = ConcurrentHashMap<Long, BaresipConnection>()
var pendingOutgoingConnection: BaresipConnection? = null
var lastDisconnectTime = 0L
fun promoteOutgoingConnection(callp: Long) {
pendingOutgoingConnection?.let {
@ -159,8 +160,16 @@ class ConnectionService : ConnectionService() {
override fun onDisconnect() {
if (isDisconnecting) return
if (System.currentTimeMillis() - lastDisconnectTime < 500) {
Log.d(TAG, "Ignoring cascaded onDisconnect for $callp")
return
}
Log.d(TAG, "Telecom Connection onDisconnect $callp")
isDisconnecting = true
lastDisconnectTime = System.currentTimeMillis()
if (callp == 0L) {
pendingOutgoingConnection = null
setDisconnected(DisconnectCause(DisconnectCause.CANCELED))