Display conference speakers only

This commit is contained in:
Benoit Martins 2023-08-25 16:50:57 +02:00 committed by QuentinArguillere
parent be8062ff9b
commit 6f88231cdd
6 changed files with 53 additions and 34 deletions

View file

@ -305,7 +305,7 @@
return;
}
ConferenceWaitingRoomView *view = VIEW(ConferenceWaitingRoomView);
[view setDetailsWithSubject:[NSString stringWithUTF8String:linphone_conference_info_get_subject(confInfo)] url:[NSString stringWithUTF8String:linphone_address_as_string(linphone_conference_info_get_uri(confInfo))]];
[view setDetailsWithSubject:[NSString stringWithUTF8String:linphone_conference_info_get_subject(confInfo)] url:[NSString stringWithUTF8String:linphone_address_as_string(linphone_conference_info_get_uri(confInfo))] conferenceInfo:(confInfo)];
[PhoneMainView.instance changeCurrentView:ConferenceWaitingRoomView.compositeViewDescription];
} else {
const LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog);

View file

@ -48,6 +48,7 @@ import linphonesw
var conferenceUrl : String? = nil
let conferenceSubject = MutableLiveData<String>()
var conferenceSpeaker : Bool? = false
let controlsView = ControlsView(showVideo: true, controlsViewModel: ConferenceWaitingRoomViewModel.sharedModel)
var layoutPicker : CallControlButton? = nil
@ -250,9 +251,19 @@ import linphonesw
super.viewWillDisappear(animated)
}
@objc func setDetails(subject:String, url:String) {
@objc func setDetails(subject:String, url:String, conferenceInfo:OpaquePointer) {
self.conferenceSubject.value = subject
self.conferenceUrl = url
let confInfo = ConferenceInfo.getSwiftObject(cObject: conferenceInfo)
var imSpeaker = false
confInfo.participantInfos.forEach { participant in
if participant.address != nil && participant.address!.isMe() && participant.role == .Speaker {
imSpeaker = true
}
}
self.conferenceSpeaker = imSpeaker
}
}

View file

@ -150,7 +150,7 @@ import EventKitUI
join.onClick {
let view : ConferenceWaitingRoomView = self.VIEW(ConferenceWaitingRoomView.compositeViewDescription())
PhoneMainView.instance().changeCurrentView(view.compositeViewDescription())
view.setDetails(subject: (self.conferenceData?.subject.value)!, url: (self.conferenceData?.address.value)!)
view.setDetails(subject: (self.conferenceData?.subject.value)!, url: (self.conferenceData?.address.value)!, conferenceInfo: (self.conferenceData?.conferenceInfo.getCobject)!)
}
share.onClick {

View file

@ -230,7 +230,7 @@ class ScheduledConferencesCell: UITableViewCell {
joinConf.onClick {
let view : ConferenceWaitingRoomView = self.VIEW(ConferenceWaitingRoomView.compositeViewDescription())
PhoneMainView.instance().changeCurrentView(view.compositeViewDescription())
view.setDetails(subject: (self.conferenceData?.subject.value)!, url: (self.conferenceData?.address.value)!)
view.setDetails(subject: (self.conferenceData?.subject.value)!, url: (self.conferenceData?.address.value)!, conferenceInfo: (self.conferenceData?.conferenceInfo.getCobject)!)
}
joinEditDelete.addArrangedSubview(editConf)

View file

@ -315,7 +315,7 @@ class ConferenceViewModel {
self.conferenceParticipantDevices.value?.forEach{ $0.destroy()}
var devices :[ConferenceParticipantDeviceData] = []
let participantsList = conference.participantList
let participantsList = conference.participantList.filter({$0.role == .Speaker})
Log.i("[Conference] \(conference) Conference has \(participantsList.count) participants")
participantsList.forEach { (participant) in
@ -334,14 +334,15 @@ class ConferenceViewModel {
speakingParticipant.value = devices.first
}
conference.me?.devices.forEach { (device) in
Log.i("[Conference] \(conference) Participant device for myself found: \(device.name) (\(device.address!.asStringUriOnly()))")
let deviceData = ConferenceParticipantDeviceData(participantDevice: device, isMe: true)
devices.append(deviceData)
meParticipant.value = deviceData
if conference.me?.role == .Speaker{
conference.me?.devices.forEach { (device) in
Log.i("[Conference] \(conference) Participant device for myself found: \(device.name) (\(device.address!.asStringUriOnly()))")
let deviceData = ConferenceParticipantDeviceData(participantDevice: device, isMe: true)
devices.append(deviceData)
meParticipant.value = deviceData
}
}
conferenceParticipantDevices.value = devices
}
@ -355,33 +356,37 @@ class ConferenceViewModel {
}
Log.i("[Conference] New participant device found: \(device.name) (\((device.address?.asStringUriOnly()).orNil)")
let deviceData = ConferenceParticipantDeviceData(participantDevice: device, isMe: false)
devices.append(deviceData)
let sortedDevices = sortDevicesDataList(devices: devices)
if (speakingParticipant.value == nil) {
speakingParticipant.value = deviceData
if (device.address != nil && conference.value?.findParticipant(uri: device.address!)?.role == .Speaker){
let deviceData = ConferenceParticipantDeviceData(participantDevice: device, isMe: false)
devices.append(deviceData)
let sortedDevices = sortDevicesDataList(devices: devices)
if (speakingParticipant.value == nil) {
speakingParticipant.value = deviceData
}
conferenceParticipantDevices.value = sortedDevices
}
conferenceParticipantDevices.value = sortedDevices
}
private func removeParticipantDevice(device: ParticipantDevice) {
let devices = conferenceParticipantDevices.value?.filter {
$0.participantDevice.address?.asStringUriOnly() != device.address?.asStringUriOnly()
}
conferenceParticipantDevices.value?.filter {
$0.participantDevice.address?.asStringUriOnly() == device.address?.asStringUriOnly()
}.first?.destroy()
if (devices?.count == conferenceParticipantDevices.value?.count) {
Log.e("[Conference] Failed to remove participant device: \(device.name) (\((device.address?.asStringUriOnly()).orNil)")
} else {
Log.i("[Conference] Participant device removed: \(device.name) (\((device.address?.asStringUriOnly()).orNil)")
if (device.address != nil && conference.value?.findParticipant(uri: device.address!)?.role == .Speaker){
conferenceParticipantDevices.value?.filter {
$0.participantDevice.address?.asStringUriOnly() == device.address?.asStringUriOnly()
}.first?.destroy()
if (devices?.count == conferenceParticipantDevices.value?.count) {
Log.e("[Conference] Failed to remove participant device: \(device.name) (\((device.address?.asStringUriOnly()).orNil)")
} else {
Log.i("[Conference] Participant device removed: \(device.name) (\((device.address?.asStringUriOnly()).orNil)")
}
conferenceParticipantDevices.value = devices
}
conferenceParticipantDevices.value = devices
}
@ -418,7 +423,7 @@ class ConferenceViewModel {
// Adding new participants first, because if we remove all of them (or all of them except one)
// It will terminate the conference first and we won't be able to add new participants after
try addresses.forEach { address in
let participant = conference.participantList.filter { $0.address?.asStringUriOnly() == address.asStringUriOnly() }.first
let participant = conference.participantList.filter {$0.address?.asStringUriOnly() == address.asStringUriOnly() }.first
if (participant == nil) {
Log.i("[Conference Participants] Participant \(address.asStringUriOnly()) will be added to group")
try conference.addParticipant(uri: address)

View file

@ -58,9 +58,11 @@ class VoipConferenceActiveSpeakerView: UIView, UICollectionViewDataSource, UICol
var fullScreenOpaqueMasqForNotchedDevices = UIView()
let conferenceJoinSpinner = RotatingSpinner(color:VoipTheme.dark_grey_color)
var imSpeaker = true
var conferenceViewModel: ConferenceViewModel? = nil {
didSet {
imSpeaker = conferenceViewModel?.conference.value?.me?.role == .Speaker
if let model = conferenceViewModel {
self.activeSpeakerVideoView.isHidden = true
self.activeSpeakerVideoViewAlone.isHidden = true
@ -80,7 +82,7 @@ class VoipConferenceActiveSpeakerView: UIView, UICollectionViewDataSource, UICol
}
model.activeSpeakerConferenceParticipantDevices.readCurrentAndObserve { (_) in
self.reloadData()
let otherSpeakersCount = model.conferenceParticipantDevices.value!.count - 1
let otherSpeakersCount = model.conferenceParticipantDevices.value!.count - (self.imSpeaker ? 1 : 0)
self.switchCamera.isHidden = true
if (otherSpeakersCount == 0) {
self.layoutRotatableElements()
@ -142,7 +144,7 @@ class VoipConferenceActiveSpeakerView: UIView, UICollectionViewDataSource, UICol
}
}
model.speakingParticipant.readCurrentAndObserve { speakingParticipant in
if (model.conferenceParticipantDevices.value!.count - 1 > 1) {
if (model.conferenceParticipantDevices.value!.count - (self.imSpeaker ? 1 : 0) > 1) {
speakingParticipant?.videoEnabled.readCurrentAndObserve { video in
self.fillActiveSpeakerSpace(data: speakingParticipant,video: video == true)
self.muted.isHidden = true
@ -200,6 +202,7 @@ class VoipConferenceActiveSpeakerView: UIView, UICollectionViewDataSource, UICol
}
init() {
imSpeaker = conferenceViewModel?.conference.value?.me?.role == .Speaker
layout.minimumInteritemSpacing = 0
layout.minimumLineSpacing = 0
@ -398,7 +401,7 @@ class VoipConferenceActiveSpeakerView: UIView, UICollectionViewDataSource, UICol
meGrid.removeConstraints().done()
activeSpeakerView.removeConstraints().done()
activeSpeakerAvatar.removeConstraints().done()
var otherParticipantsCount = (conferenceViewModel?.conferenceParticipantDevices.value!.count ?? 0) > 0 ? conferenceViewModel!.conferenceParticipantDevices.value!.count - 1 : 0
var otherParticipantsCount = (conferenceViewModel?.conferenceParticipantDevices.value!.count ?? 0) > 0 ? conferenceViewModel!.conferenceParticipantDevices.value!.count - (imSpeaker ? 1 : 0) : 0
if ([.landscapeLeft, .landscapeRight].contains( UIDevice.current.orientation)) {
if (otherParticipantsCount == 0) {
activeSpeakerView.matchParentDimmensions().done()