From d0d3f2e403d5512795765589a77aa6869b34528e Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Wed, 11 May 2022 14:48:14 +0200 Subject: [PATCH] Update video window of conference participants upon stream availabililty --- .../ConferenceParticipantDeviceData.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Classes/Swift/Voip/ViewModels/ConferenceParticipantDeviceData.swift b/Classes/Swift/Voip/ViewModels/ConferenceParticipantDeviceData.swift index 0affb76b7..700394c60 100644 --- a/Classes/Swift/Voip/ViewModels/ConferenceParticipantDeviceData.swift +++ b/Classes/Swift/Voip/ViewModels/ConferenceParticipantDeviceData.swift @@ -28,6 +28,8 @@ class ConferenceParticipantDeviceData { let videoEnabled = MutableLiveData() let activeSpeaker = MutableLiveData() let isInConference = MutableLiveData() + private var videoView: UIView? = nil + var core : Core { get { Core.get() } } private var participantDeviceDelegate : ParticipantDeviceDelegate? @@ -42,6 +44,7 @@ class ConferenceParticipantDeviceData { }, onConferenceJoined: { (participantDevice) in Log.i("[Conference Participant Device] Participant \(participantDevice) has joined the conference") self.isInConference.value = true + self.setVideoView(view: self.videoView) }, onConferenceLeft: { (participantDevice) in Log.i("[Conference Participant Device] Participant \(participantDevice) has left the conference") self.isInConference.value = false @@ -55,6 +58,9 @@ class ConferenceParticipantDeviceData { if (streamType == StreamType.Video) { Log.i("[Conference Participant Device] Participant [\(participantDevice.address?.asStringUriOnly())] video availability changed to \(available)") self.videoEnabled.value = available + if (available) { + self.setVideoView(view: self.videoView) + } } } @@ -90,14 +96,15 @@ class ConferenceParticipantDeviceData { return isMe && Core.get().showSwitchCameraButton() } - func setVideoView(view:UIView) { + func setVideoView(view:UIView?) { + self.videoView = view Log.i("[Conference Participant Device] Setting textureView \(view) for participant \(participantDevice)") - view.contentMode = .scaleAspectFill + view?.contentMode = .scaleAspectFill if (isMe) { core.usePreviewWindow(yesno: false) core.nativePreviewWindow = view } else { - participantDevice.nativeVideoWindowId = UnsafeMutableRawPointer(Unmanaged.passUnretained(view).toOpaque()) + participantDevice.nativeVideoWindowId = view != nil ? UnsafeMutableRawPointer(Unmanaged.passUnretained(view!).toOpaque()) : nil } } }