Fixed active speaker video hidden when alone in a conference and then someone else joins

This commit is contained in:
Sylvain Berfini 2024-03-08 17:34:07 +01:00
parent e6eea07da9
commit dbd626f2cd
5 changed files with 32 additions and 12 deletions

View file

@ -163,16 +163,12 @@ class ScheduledConferenceData(val conferenceInfo: ConferenceInfo, private val is
val address = participant.asStringUriOnly()
participantsListShort += "$name, "
when (info.role) {
Participant.Role.Speaker -> {
speakersListExpanded += "$name ($address)\n"
}
Participant.Role.Listener -> {
participantsListExpanded += "$name ($address)\n"
allSpeaker = false
}
else -> { // For meetings created before 5.3 SDK
participantsListExpanded += "$name ($address)\n"
allSpeaker = false
else -> { // For meetings created before 5.3 SDK, a speaker might be Unknown
speakersListExpanded += "$name ($address)\n"
}
}
}

View file

@ -58,6 +58,7 @@ class ConferenceViewModel : ViewModel() {
val speakingParticipantFound = MutableLiveData<Boolean>()
val speakingParticipant = MutableLiveData<ConferenceParticipantDeviceData>()
val speakingParticipantVideoEnabled = MutableLiveData<Boolean>()
val meParticipant = MutableLiveData<ConferenceParticipantDeviceData>()
val isBroadcast = MutableLiveData<Boolean>()
@ -128,6 +129,7 @@ class ConferenceViewModel : ViewModel() {
when (conferenceParticipantDevices.value.orEmpty().size) {
1 -> {
speakingParticipant.value?.videoEnabled?.value = false
speakingParticipantVideoEnabled.value = false
allParticipantsLeftEvent.value = Event(true)
}
2 -> {
@ -192,6 +194,8 @@ class ConferenceViewModel : ViewModel() {
}
else -> {}
}
} else {
speakingParticipantVideoEnabled.value = speakingParticipant.value?.isInConference?.value == true && speakingParticipant.value?.isSendingVideo?.value == true
}
}
@ -212,6 +216,7 @@ class ConferenceViewModel : ViewModel() {
device.isActiveSpeaker.value = true
speakingParticipant.value = device!!
speakingParticipantFound.value = true
speakingParticipantVideoEnabled.value = speakingParticipant.value?.isInConference?.value == true && speakingParticipant.value?.isSendingVideo?.value == true
} else if (device == null) {
Log.w(
"[Conference] Participant device [${participantDevice.address.asStringUriOnly()}] is the active speaker but couldn't find it in devices list"
@ -219,6 +224,20 @@ class ConferenceViewModel : ViewModel() {
}
}
override fun onParticipantDeviceMediaAvailabilityChanged(
conference: Conference,
device: ParticipantDevice
) {
speakingParticipantVideoEnabled.value = speakingParticipant.value?.isInConference?.value == true && speakingParticipant.value?.isSendingVideo?.value == true
}
override fun onParticipantDeviceMediaCapabilityChanged(
conference: Conference,
device: ParticipantDevice
) {
speakingParticipantVideoEnabled.value = speakingParticipant.value?.isInConference?.value == true && speakingParticipant.value?.isSendingVideo?.value == true
}
override fun onStateChanged(conference: Conference, state: Conference.State) {
Log.i("[Conference] State changed: $state")
isVideoConference.value = conference.currentParams.isVideoEnabled && !corePreferences.disableVideo
@ -537,6 +556,7 @@ class ConferenceViewModel : ViewModel() {
val activelySpeakingParticipantDevice = conference.activeSpeakerParticipantDevice
var foundActivelySpeakingParticipantDevice = false
speakingParticipantFound.value = false
speakingParticipantVideoEnabled.value = false
val conferenceInfo = conference.core.findConferenceInformationFromUri(
conference.conferenceAddress
@ -587,6 +607,7 @@ class ConferenceViewModel : ViewModel() {
deviceData.isActiveSpeaker.value = true
foundActivelySpeakingParticipantDevice = true
speakingParticipantFound.value = true
speakingParticipantVideoEnabled.value = speakingParticipant.value?.isInConference?.value == true && speakingParticipant.value?.isSendingVideo?.value == true
}
}
}
@ -599,6 +620,7 @@ class ConferenceViewModel : ViewModel() {
speakingParticipant.value = deviceData
deviceData.isActiveSpeaker.value = true
speakingParticipantFound.value = true
speakingParticipantVideoEnabled.value = speakingParticipant.value?.isInConference?.value == true && speakingParticipant.value?.isSendingVideo?.value == true
}
for (device in conference.me.devices) {
@ -666,10 +688,11 @@ class ConferenceViewModel : ViewModel() {
val sortedDevices = sortDevicesDataList(devices)
if (speakingParticipant.value == null) {
if (speakingParticipant.value == null || speakingParticipantFound.value == false) {
speakingParticipant.value = deviceData
deviceData.isActiveSpeaker.value = true
speakingParticipantFound.value = false
speakingParticipantFound.value = true
speakingParticipantVideoEnabled.value = speakingParticipant.value?.isInConference?.value == true && speakingParticipant.value?.isSendingVideo?.value == true
}
conferenceParticipantDevices.value = sortedDevices
@ -710,7 +733,8 @@ class ConferenceViewModel : ViewModel() {
val deviceData = devices[1]
speakingParticipant.value = deviceData
deviceData.isActiveSpeaker.value = true
speakingParticipantFound.value = false
speakingParticipantFound.value = true
speakingParticipantVideoEnabled.value = speakingParticipant.value?.isInConference?.value == true && speakingParticipant.value?.isSendingVideo?.value == true
}
conferenceParticipantDevices.value = devices

View file

@ -82,7 +82,7 @@ class CoreService : CoreService() {
// Done elsewhere
}
override fun showForegroundServiceNotification() {
override fun showForegroundServiceNotification(isVideoCall: Boolean) {
Log.i("[Service] Starting service as foreground")
coreContext.notificationsManager.startCallForeground(this)
}

View file

@ -221,7 +221,7 @@
android:id="@+id/conference_active_speaker_remote_video"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="@{!conferenceViewModel.isConferenceLocallyPaused &amp;&amp; conferenceViewModel.speakingParticipant.videoEnabled &amp;&amp; conferenceViewModel.speakingParticipant.isInConference ? View.VISIBLE : View.GONE}"
android:visibility="@{!conferenceViewModel.isConferenceLocallyPaused &amp;&amp; conferenceViewModel.speakingParticipantVideoEnabled ? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toBottomOf="@id/active_speaker_background"
app:layout_constraintEnd_toEndOf="@id/active_speaker_background"
app:layout_constraintStart_toStartOf="@id/active_speaker_background"

View file

@ -180,7 +180,7 @@
android:id="@+id/conference_active_speaker_remote_video"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="@{!conferenceViewModel.isConferenceLocallyPaused &amp;&amp; conferenceViewModel.speakingParticipant.videoEnabled &amp;&amp; conferenceViewModel.speakingParticipant.isInConference ? View.VISIBLE : View.GONE}"
android:visibility="@{!conferenceViewModel.isConferenceLocallyPaused &amp;&amp; conferenceViewModel.speakingParticipantVideoEnabled ? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toBottomOf="@id/active_speaker_background"
app:layout_constraintTop_toTopOf="@id/active_speaker_background" />