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:
@@ -210,7 +210,7 @@ static void event_handler(enum bevent_ev ev, struct bevent *event, void *arg)
|
|||||||
break;
|
break;
|
||||||
case BEVENT_CALL_REMOTE_SDP:
|
case BEVENT_CALL_REMOTE_SDP:
|
||||||
ardir = sdp_media_rdir(stream_sdpmedia(audio_strm(call_audio(call))));
|
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;
|
break;
|
||||||
case BEVENT_CALL_MENC:
|
case BEVENT_CALL_MENC:
|
||||||
if (prm[0] == '0')
|
if (prm[0] == '0')
|
||||||
|
|||||||
@@ -802,7 +802,6 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
"incoming call" -> {
|
"incoming call" -> {
|
||||||
val peerUri = ev[1]
|
val peerUri = ev[1]
|
||||||
val bevent = ev[2].toLong()
|
|
||||||
val toastMsg = if (Call.isAnyCallActive(applicationContext))
|
val toastMsg = if (Call.isAnyCallActive(applicationContext))
|
||||||
String.format(getString(R.string.call_auto_rejected),
|
String.format(getString(R.string.call_auto_rejected),
|
||||||
Utils.friendlyUri(this, peerUri, ua.account))
|
Utils.friendlyUri(this, peerUri, ua.account))
|
||||||
@@ -816,7 +815,7 @@ class BaresipService: Service() {
|
|||||||
if (toastMsg != "") {
|
if (toastMsg != "") {
|
||||||
Log.d(TAG, "Auto-rejecting incoming call to $uap from $peerUri")
|
Log.d(TAG, "Auto-rejecting incoming call to $uap from $peerUri")
|
||||||
Api.sip_treply(callp, 486, "Busy Here")
|
Api.sip_treply(callp, 486, "Busy Here")
|
||||||
Api.bevent_stop(bevent)
|
Api.bevent_stop(ev[2].toLong())
|
||||||
toast(toastMsg)
|
toast(toastMsg)
|
||||||
if (toastMsg.contains(getString(R.string.call_blocked))) {
|
if (toastMsg.contains(getString(R.string.call_blocked))) {
|
||||||
if (ua.account.callHistory)
|
if (ua.account.callHistory)
|
||||||
@@ -892,6 +891,7 @@ class BaresipService: Service() {
|
|||||||
"call update" -> {
|
"call update" -> {
|
||||||
if (call!!.conferenceCall) {
|
if (call!!.conferenceCall) {
|
||||||
Log.d(TAG, "Refusing to update conference call ${call.callp}")
|
Log.d(TAG, "Refusing to update conference call ${call.callp}")
|
||||||
|
Api.bevent_stop(ev[2].toLong())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val newHeldState = when (ev[1].toInt()) {Api.SDP_INACTIVE, Api.SDP_RECVONLY -> true
|
val newHeldState = when (ev[1].toInt()) {Api.SDP_INACTIVE, Api.SDP_RECVONLY -> true
|
||||||
@@ -1002,6 +1002,7 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
"call closed" -> {
|
"call closed" -> {
|
||||||
Log.d(TAG, "AoR $aor call $callp is closed prm: ${ev[1]}")
|
Log.d(TAG, "AoR $aor call $callp is closed prm: ${ev[1]}")
|
||||||
|
ConnectionService.lastDisconnectTime = System.currentTimeMillis()
|
||||||
val connection = ConnectionService.connections[callp]
|
val connection = ConnectionService.connections[callp]
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
val cause = when {
|
val cause = when {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class ConnectionService : ConnectionService() {
|
|||||||
companion object {
|
companion object {
|
||||||
val connections = ConcurrentHashMap<Long, BaresipConnection>()
|
val connections = ConcurrentHashMap<Long, BaresipConnection>()
|
||||||
var pendingOutgoingConnection: BaresipConnection? = null
|
var pendingOutgoingConnection: BaresipConnection? = null
|
||||||
|
var lastDisconnectTime = 0L
|
||||||
|
|
||||||
fun promoteOutgoingConnection(callp: Long) {
|
fun promoteOutgoingConnection(callp: Long) {
|
||||||
pendingOutgoingConnection?.let {
|
pendingOutgoingConnection?.let {
|
||||||
@@ -159,8 +160,16 @@ class ConnectionService : ConnectionService() {
|
|||||||
|
|
||||||
override fun onDisconnect() {
|
override fun onDisconnect() {
|
||||||
if (isDisconnecting) return
|
if (isDisconnecting) return
|
||||||
|
|
||||||
|
if (System.currentTimeMillis() - lastDisconnectTime < 500) {
|
||||||
|
Log.d(TAG, "Ignoring cascaded onDisconnect for $callp")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
Log.d(TAG, "Telecom Connection onDisconnect $callp")
|
Log.d(TAG, "Telecom Connection onDisconnect $callp")
|
||||||
isDisconnecting = true
|
isDisconnecting = true
|
||||||
|
lastDisconnectTime = System.currentTimeMillis()
|
||||||
|
|
||||||
if (callp == 0L) {
|
if (callp == 0L) {
|
||||||
pendingOutgoingConnection = null
|
pendingOutgoingConnection = null
|
||||||
setDisconnected(DisconnectCause(DisconnectCause.CANCELED))
|
setDisconnected(DisconnectCause(DisconnectCause.CANCELED))
|
||||||
|
|||||||
Reference in New Issue
Block a user