Conference listener onActiveSpeakerParticipantDevice signature has changed

This commit is contained in:
Sylvain Berfini 2025-01-30 10:55:08 +01:00
parent 5e6186d115
commit 0625239477

View file

@ -134,22 +134,36 @@ class ConferenceViewModel
@WorkerThread
override fun onActiveSpeakerParticipantDevice(
conference: Conference,
participantDevice: ParticipantDevice
participantDevice: ParticipantDevice?
) {
activeSpeaker.value?.isActiveSpeaker?.postValue(false)
val found = participantDevices.value.orEmpty().find {
it.device.address.equal(participantDevice.address)
}
if (found != null) {
Log.i("$TAG Newly active speaker participant is [${found.name}]")
found.isActiveSpeaker.postValue(true)
activeSpeaker.postValue(found!!)
if (participantDevice != null) {
val found = participantDevices.value.orEmpty().find {
it.device.address.equal(participantDevice.address)
}
if (found != null) {
Log.i("$TAG Newly active speaker participant is [${found.name}]")
found.isActiveSpeaker.postValue(true)
activeSpeaker.postValue(found!!)
} else {
Log.i("$TAG Failed to find actively speaking participant...")
val model = ConferenceParticipantDeviceModel(participantDevice)
model.isActiveSpeaker.postValue(true)
activeSpeaker.postValue(model)
}
} else {
Log.i("$TAG Failed to find actively speaking participant...")
val model = ConferenceParticipantDeviceModel(participantDevice)
model.isActiveSpeaker.postValue(true)
activeSpeaker.postValue(model)
Log.w("$TAG Notified active speaker participant device is null, using first one that's not us")
val firstNotUs = participantDevices.value.orEmpty().find {
it.isMe == false
}
if (firstNotUs != null) {
Log.i("$TAG Newly active speaker participant is [${firstNotUs.name}]")
firstNotUs.isActiveSpeaker.postValue(true)
activeSpeaker.postValue(firstNotUs!!)
} else {
Log.i("$TAG No participant device that's not us found, expected if we're alone")
}
}
}