Hide actively speaking participant miniature

This commit is contained in:
Sylvain Berfini 2023-01-09 12:10:27 +01:00
parent 6a5b014789
commit 1d0c34b30b
4 changed files with 20 additions and 3 deletions

View file

@ -47,6 +47,8 @@ class ConferenceParticipantDeviceData(
val isJoining = MutableLiveData<Boolean>()
val isActiveSpeaker = MutableLiveData<Boolean>()
private var textureView: TextureView? = null
private val listener = object : ParticipantDeviceListenerStub() {
@ -113,6 +115,7 @@ class ConferenceParticipantDeviceData(
participantDevice.addListener(listener)
isSpeaking.value = false
isActiveSpeaker.value = false
isMuted.value = participantDevice.isMuted
videoAvailable.value = participantDevice.getStreamAvailability(StreamType.Video)

View file

@ -185,8 +185,11 @@ class ConferenceViewModel : ViewModel() {
val device = conferenceParticipantDevices.value.orEmpty().find {
it.participantDevice.address.weakEqual(participantDevice.address)
}
if (device != null && device != speakingParticipant.value) {
Log.i("[Conference] Found actively speaking participant device")
speakingParticipant.value?.isActiveSpeaker?.value = false
device.isActiveSpeaker.value = true
speakingParticipant.value = device!!
} else if (device == null) {
Log.w("[Conference] Participant device [${participantDevice.address.asStringUriOnly()}] is the active speaker but couldn't find it in devices list")
@ -488,6 +491,7 @@ class ConferenceViewModel : ViewModel() {
if (activelySpeakingParticipantDevice == device) {
Log.i("[Conference] Actively speaking participant device found: ${device.name} (${device.address.asStringUriOnly()})")
speakingParticipant.value = deviceData
deviceData.isActiveSpeaker.value = true
foundActivelySpeakingParticipantDevice = true
}
}
@ -495,7 +499,9 @@ class ConferenceViewModel : ViewModel() {
if (!foundActivelySpeakingParticipantDevice && devices.isNotEmpty()) {
Log.w("[Conference] Actively speaking participant device not found, using first participant device available")
speakingParticipant.value = devices.first()
val deviceData = devices.first()
speakingParticipant.value = deviceData
deviceData.isActiveSpeaker.value = true
}
for (device in conference.me.devices) {
@ -530,6 +536,7 @@ class ConferenceViewModel : ViewModel() {
if (speakingParticipant.value == null) {
speakingParticipant.value = deviceData
deviceData.isActiveSpeaker.value = true
}
conferenceParticipantDevices.value = sortedDevices
@ -561,7 +568,9 @@ class ConferenceViewModel : ViewModel() {
if (removedDeviceWasActiveSpeaker && devicesCount > 1) {
Log.w("[Conference] Updating actively speaking participant device using first one available")
// Using second device as first is ourselves
speakingParticipant.value = devices[1]
val deviceData = devices[1]
speakingParticipant.value = deviceData
deviceData.isActiveSpeaker.value = true
}
conferenceParticipantDevices.value = devices

View file

@ -29,7 +29,11 @@ import org.linphone.core.tools.Log
class GridBoxLayout : GridLayout {
companion object {
private val placementMatrix = arrayOf(intArrayOf(1, 2, 3, 4, 5, 6), intArrayOf(1, 1, 2, 2, 3, 3), intArrayOf(1, 1, 1, 2, 2, 2), intArrayOf(1, 1, 1, 1, 2, 2), intArrayOf(1, 1, 1, 1, 1, 2), intArrayOf(1, 1, 1, 1, 1, 1))
private val placementMatrix = arrayOf(
intArrayOf(1, 2, 3, 4, 5, 6), intArrayOf(1, 1, 2, 2, 3, 3),
intArrayOf(1, 1, 1, 2, 2, 2), intArrayOf(1, 1, 1, 1, 2, 2),
intArrayOf(1, 1, 1, 1, 1, 2), intArrayOf(1, 1, 1, 1, 1, 1)
)
}
constructor(context: Context) : this(context, null)

View file

@ -16,6 +16,7 @@
android:layout_height="@dimen/voip_active_speaker_miniature_size"
android:layout_margin="5dp"
android:background="@{!data.isInConference &amp;&amp; !data.isJoining ? @drawable/shape_remote_paused_background : @drawable/shape_remote_background, default=@drawable/shape_remote_background}"
android:visibility="@{data.isActiveSpeaker ? View.GONE : View.VISIBLE}"
app:layout_alignSelf="flex_end"
app:layout_flexShrink="0">