Automatically switch to active speaker layout when more participant devices than authorized by grid layout are present

This commit is contained in:
Sylvain Berfini 2024-02-21 16:54:01 +01:00
parent 146b9d0cdf
commit 913d126203
2 changed files with 19 additions and 0 deletions

View file

@ -32,6 +32,7 @@ import org.linphone.core.Participant
import org.linphone.core.ParticipantDevice
import org.linphone.core.StreamType
import org.linphone.core.tools.Log
import org.linphone.ui.call.view.GridBoxLayout
import org.linphone.utils.AppUtils
import org.linphone.utils.Event
@ -371,6 +372,8 @@ class ConferenceModel {
activeSpeaker.postValue(first)
}
checkIfTooManyParticipantDevicesForGridLayout(devicesList)
participantDevices.postValue(sortParticipantDevicesList(devicesList))
participants.postValue(participantsList)
participantsLabel.postValue(
@ -441,6 +444,7 @@ class ConferenceModel {
val newModel = ConferenceParticipantDeviceModel(participantDevice)
list.add(newModel)
checkIfTooManyParticipantDevicesForGridLayout(list)
participantDevices.postValue(sortParticipantDevicesList(list))
}
@ -497,4 +501,17 @@ class ConferenceModel {
}
}
}
@WorkerThread
private fun checkIfTooManyParticipantDevicesForGridLayout(
list: ArrayList<ConferenceParticipantDeviceModel>
) {
if (list.size > GridBoxLayout.MAX_CHILD && conferenceLayout.value == GRID_LAYOUT) {
Log.w(
"$TAG Too many participant devices for grid layout, switching to active speaker layout"
)
setNewLayout(ACTIVE_SPEAKER_LAYOUT)
// TODO FIXME: notify user
}
}
}

View file

@ -32,6 +32,8 @@ class GridBoxLayout : GridLayout {
companion object {
private const val TAG = "[Grid Box Layout]"
const val MAX_CHILD = 6
private val placementMatrix = arrayOf(
intArrayOf(1, 2, 3, 4, 5, 6),
intArrayOf(1, 1, 2, 2, 3, 3),