Switch from audio only to active speaker using toggle video button (instead of disabling it)

This commit is contained in:
Christophe Deschamps 2022-11-17 17:59:14 +01:00
parent 669851065a
commit 65573ba1be
2 changed files with 8 additions and 4 deletions

View file

@ -243,11 +243,14 @@ class ConferenceViewModel {
}
func changeLayout(layout: ConferenceDisplayMode) {
func changeLayout(layout: ConferenceDisplayMode, sendVideo:Bool = false) {
Log.i("[Conference] Trying to change conference layout to $layout")
if let conference = conference.value, let call = conference.call, let params = try?call.core?.createCallParams(call: call) {
params.videoEnabled = layout != .AudioOnly
params.conferenceVideoLayout = layout == ConferenceDisplayMode.Grid ? .Grid : .ActiveSpeaker
if (sendVideo) {
params.videoDirection = .SendRecv
}
try?call.update(params: params)
conferenceDisplayMode.value = layout

View file

@ -141,7 +141,9 @@ class ControlsViewModel {
func toggleVideo() {
if let currentCall = core.currentCall {
if (currentCall.conference != nil) {
if let params = try?core.createCallParams(call: currentCall) {
if (ConferenceViewModel.shared.conferenceDisplayMode.value == .AudioOnly) {
ConferenceViewModel.shared.changeLayout(layout: .ActiveSpeaker, sendVideo:true)
} else if let params = try?core.createCallParams(call: currentCall) {
isVideoUpdateInProgress.value = true
params.videoDirection = params.videoDirection == MediaDirection.RecvOnly ? MediaDirection.SendRecv : MediaDirection.RecvOnly
try?currentCall.update(params: params)
@ -197,8 +199,7 @@ class ControlsViewModel {
(core.videoCaptureEnabled || core.videoPreviewEnabled) &&
currentCall?.state != .Paused &&
currentCall?.state != .PausedByRemote &&
((currentCall != nil && currentCall?.mediaInProgress() != true) || (core.conference?.isIn == true)) &&
(ConferenceViewModel.shared.conferenceExists.value != true || ConferenceViewModel.shared.conferenceDisplayMode.value != .AudioOnly)
((currentCall != nil && currentCall?.mediaInProgress() != true) || (core.conference?.isIn == true))
}
private func updateVideoEnabled() {