Load mixminus module on-demand and add calls to conference dynamically

This commit is contained in:
Juha Heinanen
2026-01-14 03:36:11 +02:00
parent ef29fd1855
commit b3cb2ff413
3 changed files with 15 additions and 3 deletions
@@ -1104,6 +1104,8 @@ class BaresipService: Service() {
call.onHoldCall = null call.onHoldCall = null
} }
call.remove() call.remove()
if (call.conferenceCall && ua.calls().isEmpty())
Api.module_unload("mixminus")
val reason = ev[1] val reason = ev[1]
val tone = ev[2] val tone = ev[2]
if (tone == "busy") { if (tone == "busy") {
@@ -11,6 +11,7 @@ class Call(val callp: Long, val ua: UserAgent, val peerUri: String, val dir: Str
var onhold = false var onhold = false
var held = false var held = false
var terminated = false
var conferenceCall = false var conferenceCall = false
var onHoldCall: Call? = null var onHoldCall: Call? = null
var newCall: Call? = null var newCall: Call? = null
@@ -1478,10 +1478,13 @@ private fun CallRow(
IconButton( IconButton(
modifier = Modifier.size(48.dp), modifier = Modifier.size(48.dp),
onClick = { onClick = {
if (!call.terminated) {
call.terminated = true
abandonAudioFocus(ctx) abandonAudioFocus(ctx)
Log.d(TAG, "AoR ${call.ua.account.aor} hanging up call ${call.callp} with ${call.callUri.value}") Log.d(TAG, "AoR ${call.ua.account.aor} hanging up call ${call.callp} with ${call.callUri.value}")
Api.ua_hangup(call.ua.uap, call.callp, 487, "Request Terminated") Api.ua_hangup(call.ua.uap, call.callp, 487, "Request Terminated")
} }
}
) { ) {
Icon( Icon(
imageVector = Icons.Filled.CallEnd, imageVector = Icons.Filled.CallEnd,
@@ -2067,6 +2070,8 @@ private fun call(
onHoldCall: Call? = null onHoldCall: Call? = null
): Call? { ): Call? {
spinToAor(viewModel, ua.account.aor) spinToAor(viewModel, ua.account.aor)
if (conferenceCall && ua.calls().isEmpty())
Api.module_load("mixminus")
val callp = ua.callAlloc(0L, Api.VIDMODE_OFF) val callp = ua.callAlloc(0L, Api.VIDMODE_OFF)
return if (callp != 0L) { return if (callp != 0L) {
Log.d(TAG, "Adding outgoing call ${ua.uap}/$callp/$uri") Log.d(TAG, "Adding outgoing call ${ua.uap}/$callp/$uri")
@@ -2090,6 +2095,8 @@ private fun call(
} }
} else { } else {
Log.w(TAG, "callAlloc for ${ua.uap} to $uri failed") Log.w(TAG, "callAlloc for ${ua.uap} to $uri failed")
if (conferenceCall && ua.calls().isEmpty())
Api.module_unload("mixminus")
null null
} }
} }
@@ -2318,6 +2325,8 @@ fun handleServiceEvent(ctx: Context, viewModel: ViewModel, event: String, params
val call = Call.ofCallp(callp) val call = Call.ofCallp(callp)
if (call != null) { if (call != null) {
call.dtmfText.value = "" call.dtmfText.value = ""
if (call.conferenceCall)
Api.cmd_exec("conference")
} }
showCall(ctx, viewModel, ua, call) showCall(ctx, viewModel, ua, call)
} }