diff --git a/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt b/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt index 48538fda9..c578ed946 100644 --- a/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt +++ b/app/src/main/java/org/linphone/ui/call/model/ConferenceModel.kt @@ -203,50 +203,55 @@ class ConferenceModel { @UiThread fun changeLayout(newLayout: Int) { coreContext.postOnCoreThread { - val call = conference.call - if (call != null) { - val params = call.core.createCallParams(call) - if (params != null) { - val currentLayout = getCurrentLayout(call) - if (currentLayout != newLayout) { - when (newLayout) { - AUDIO_ONLY_LAYOUT -> { - Log.i("$TAG Changing conference layout to [Audio Only]") - params.isVideoEnabled = false - } - ACTIVE_SPEAKER_LAYOUT -> { - Log.i("$TAG Changing conference layout to [Active Speaker]") - params.conferenceVideoLayout = Conference.Layout.ActiveSpeaker - } - GRID_LAYOUT -> { - Log.i("$TAG Changing conference layout to [Grid]") - params.conferenceVideoLayout = Conference.Layout.Grid - } - } + setNewLayout(newLayout) + } + } - if (currentLayout == AUDIO_ONLY_LAYOUT) { - // Previous layout was audio only, make sure video isn't sent without user consent when switching layout - Log.i( - "$TAG Previous layout was [Audio Only], enabling video but in receive only direction" - ) - params.isVideoEnabled = true - params.videoDirection = MediaDirection.RecvOnly + @WorkerThread + fun setNewLayout(newLayout: Int) { + val call = conference.call + if (call != null) { + val params = call.core.createCallParams(call) + if (params != null) { + val currentLayout = getCurrentLayout(call) + if (currentLayout != newLayout) { + when (newLayout) { + AUDIO_ONLY_LAYOUT -> { + Log.i("$TAG Changing conference layout to [Audio Only]") + params.isVideoEnabled = false + } + ACTIVE_SPEAKER_LAYOUT -> { + Log.i("$TAG Changing conference layout to [Active Speaker]") + params.conferenceVideoLayout = Conference.Layout.ActiveSpeaker + } + GRID_LAYOUT -> { + Log.i("$TAG Changing conference layout to [Grid]") + params.conferenceVideoLayout = Conference.Layout.Grid } - - Log.i("$TAG Updating conference's call params") - call.update(params) - conferenceLayout.postValue(newLayout) - } else { - Log.w( - "$TAG The conference is already using selected layout, aborting layout change" - ) } + + if (currentLayout == AUDIO_ONLY_LAYOUT) { + // Previous layout was audio only, make sure video isn't sent without user consent when switching layout + Log.i( + "$TAG Previous layout was [Audio Only], enabling video but in receive only direction" + ) + params.isVideoEnabled = true + params.videoDirection = MediaDirection.RecvOnly + } + + Log.i("$TAG Updating conference's call params") + call.update(params) + conferenceLayout.postValue(newLayout) } else { - Log.e("$TAG Failed to create call params, aborting layout change") + Log.w( + "$TAG The conference is already using selected layout, aborting layout change" + ) } } else { - Log.e("$TAG Failed to get call from conference, aborting layout change") + Log.e("$TAG Failed to create call params, aborting layout change") } + } else { + Log.e("$TAG Failed to get call from conference, aborting layout change") } } diff --git a/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt b/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt index 67decdca4..afff2e53b 100644 --- a/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt +++ b/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt @@ -532,12 +532,20 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() { val params = core.createCallParams(currentCall) if (currentCall.conference != null) { if (params?.isVideoEnabled == false) { + Log.i("$TAG Conference found and video disabled in params, enabling it") params.isVideoEnabled = true params.videoDirection = MediaDirection.SendRecv + conferenceModel.setNewLayout(ConferenceModel.ACTIVE_SPEAKER_LAYOUT) } else { if (params?.videoDirection == MediaDirection.SendRecv || params?.videoDirection == MediaDirection.SendOnly) { + Log.i( + "$TAG Conference found with video already enabled, changing video media direction to receive only" + ) params.videoDirection = MediaDirection.RecvOnly } else { + Log.i( + "$TAG Conference found with video already enabled, changing video media direction to send & receive" + ) params?.videoDirection = MediaDirection.SendRecv } }