Force audio only layout in conference waiting room if low bandwidth is detected

This commit is contained in:
Sylvain Berfini 2022-04-01 10:45:36 +02:00
parent 1b9d15c087
commit f83eb5e6b1
6 changed files with 34 additions and 8 deletions

View file

@ -28,6 +28,7 @@ import androidx.lifecycle.ViewModelProvider
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.R
import org.linphone.activities.GenericFragment
import org.linphone.activities.main.MainActivity
import org.linphone.activities.main.conference.viewmodels.ConferenceWaitingRoomViewModel
import org.linphone.activities.navigateToDialer
import org.linphone.compatibility.Compatibility
@ -110,6 +111,14 @@ class ConferenceWaitingRoomFragment : GenericFragment<ConferenceWaitingRoomFragm
}
}
viewModel.onMessageToNotifyEvent.observe(
viewLifecycleOwner
) {
it.consume { message ->
(activity as MainActivity).showSnackBar(message)
}
}
if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
checkPermissions()
}

View file

@ -21,16 +21,18 @@ package org.linphone.activities.main.conference.viewmodels
import android.Manifest
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.R
import org.linphone.activities.main.viewmodels.MessageNotifierViewModel
import org.linphone.activities.voip.ConferenceDisplayMode
import org.linphone.core.*
import org.linphone.core.tools.Log
import org.linphone.utils.AudioRouteUtils
import org.linphone.utils.Event
import org.linphone.utils.LinphoneUtils
import org.linphone.utils.PermissionHelper
class ConferenceWaitingRoomViewModel : ViewModel() {
class ConferenceWaitingRoomViewModel : MessageNotifierViewModel() {
val subject = MutableLiveData<String>()
val isMicrophoneMuted = MutableLiveData<Boolean>()
@ -53,6 +55,8 @@ class ConferenceWaitingRoomViewModel : ViewModel() {
val isSwitchCameraAvailable = MutableLiveData<Boolean>()
val isLowBandwidth = MutableLiveData<Boolean>()
val joinInProgress = MutableLiveData<Boolean>()
val askPermissionEvent: MutableLiveData<Event<String>> by lazy {
@ -105,6 +109,18 @@ class ConferenceWaitingRoomViewModel : ViewModel() {
Log.i("[Conference Waiting Room] Video will be ${if (callParams.isVideoEnabled) "enabled" else "disabled"}")
updateVideoState()
isLowBandwidth.value = false
if (LinphoneUtils.checkIfNetworkHasLowBandwidth(coreContext.context)) {
Log.w("[Conference Waiting Room] Enabling low bandwidth mode, forcing audio only layout!")
callParams.isLowBandwidthEnabled = true
callParams.isVideoEnabled = false
callParams.videoDirection = MediaDirection.Inactive
isLowBandwidth.value = true
updateVideoState()
onMessageToNotifyEvent.value = Event(R.string.conference_low_bandwidth)
}
layoutMenuSelected.value = false
updateLayout()

View file

@ -267,7 +267,7 @@
android:layout_marginStart="5dp"
android:background="@drawable/button_background_reverse"
android:contentDescription="@{viewModel.isVideoEnabled ? @string/content_description_disable_video : @string/content_description_enable_video}"
android:enabled="@{viewModel.isVideoAvailable}"
android:enabled="@{viewModel.isVideoAvailable &amp;&amp; !viewModel.isLowBandwidth}"
android:onClick="@{() -> viewModel.toggleVideo()}"
android:padding="5dp"
android:selected="@{viewModel.isVideoEnabled}"
@ -282,6 +282,7 @@
android:layout_marginEnd="20dp"
android:background="@drawable/button_toggle_background_reverse"
android:contentDescription="@string/content_description_toggle_layout_menu"
android:enabled="@{!viewModel.isLowBandwidth}"
android:onClick="@{() -> viewModel.toggleLayoutMenu()}"
android:padding="10dp"
android:selected="@{viewModel.layoutMenuSelected}"

View file

@ -56,15 +56,12 @@
android:background="@drawable/generated_avatar_bg"
android:src="@drawable/icon_single_contact_avatar"
android:contentDescription="@string/content_description_change_own_picture"
glidePath="@{viewModel.defaultAccountAvatar}" />
glideAvatar="@{viewModel.defaultAccountAvatar}" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:layout_margin="10dp"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:src="@drawable/avatar_border"

View file

@ -717,4 +717,6 @@
<string name="conference_display_mode_audio_only">Mode audio uniquement</string>
<string name="conference_too_many_participants_for_mosaic_layout">Il y a trop de participants pour la disposition en mosaïque, passage à l\'intervenant actif</string>
<string name="conference_participant_paused">(en pause)</string>
<string name="content_description_take_screenshot">Prendre une capture de la vidéo reçue</string>
<string name="conference_low_bandwidth">Faible bande passante détectée, vidéo désactivée</string>
</resources>

View file

@ -289,6 +289,7 @@
<string name="conference_empty">You are currently alone in this conference</string>
<string name="conference_invitation_received_notification">You have been invited to a conference</string>
<string name="conference_invitation">Conference invitation</string>
<string name="conference_low_bandwidth">Low bandwidth detected, disabling video</string>
<!-- Call -->
<string name="call_incoming_title">Incoming Call</string>