diff --git a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift index f990bdf289..f857776cc3 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift @@ -2111,7 +2111,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { var topParticipants: [GroupCallParticipantsContext.Participant] = [] var reportSpeakingParticipants: [PeerId: UInt32] = [:] - let timestamp = CACurrentMediaTime() + let timestamp = CFAbsoluteTimeGetCurrent() for (peerId, ssrc) in speakingParticipants { let shouldReport: Bool if let previousTimestamp = strongSelf.speakingParticipantsReportTimestamp[peerId] { diff --git a/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift b/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift index 2bc963014d..fa1b22cd3e 100644 --- a/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift +++ b/submodules/TelegramCallsUI/Sources/VideoChatScreen.swift @@ -110,6 +110,7 @@ final class VideoChatScreenComponent: Component { var applicationStateDisposable: Disposable? var expandedParticipantsVideoState: VideoChatParticipantsComponent.ExpandedVideoState? + var focusedSpeakerAutoSwitchDeadline: Double = 0.0 var isTwoColumnSidebarHidden: Bool = false let inviteDisposable = MetaDisposable() @@ -762,7 +763,7 @@ final class VideoChatScreenComponent: Component { if self.members != members { var members = members - #if DEBUG && true + #if DEBUG && false if let membersValue = members { var participants = membersValue.participants for i in 1 ... 20 { @@ -841,12 +842,13 @@ final class VideoChatScreenComponent: Component { if videoCount == 1, let participantsView = self.participants.view as? VideoChatParticipantsComponent.View, let participantsComponent = participantsView.component { if participantsComponent.layout.videoColumn != nil { self.expandedParticipantsVideoState = nil + self.focusedSpeakerAutoSwitchDeadline = 0.0 } } } if let expandedParticipantsVideoState = self.expandedParticipantsVideoState, let members { - if !expandedParticipantsVideoState.isMainParticipantPinned, let participant = members.participants.first(where: { participant in + if CFAbsoluteTimeGetCurrent() > self.focusedSpeakerAutoSwitchDeadline, !expandedParticipantsVideoState.isMainParticipantPinned, let participant = members.participants.first(where: { participant in if let callState = self.callState, participant.peer.id == callState.myPeerId { return false } @@ -863,6 +865,7 @@ final class VideoChatScreenComponent: Component { } else { self.expandedParticipantsVideoState = VideoChatParticipantsComponent.ExpandedVideoState(mainParticipant: VideoChatParticipantsComponent.VideoParticipantKey(id: participant.peer.id, isPresentation: false), isMainParticipantPinned: false, isUIHidden: expandedParticipantsVideoState.isUIHidden) } + self.focusedSpeakerAutoSwitchDeadline = CFAbsoluteTimeGetCurrent() + 1.0 } } @@ -895,11 +898,14 @@ final class VideoChatScreenComponent: Component { } else { self.expandedParticipantsVideoState = VideoChatParticipantsComponent.ExpandedVideoState(mainParticipant: VideoChatParticipantsComponent.VideoParticipantKey(id: participant.peer.id, isPresentation: false), isMainParticipantPinned: false, isUIHidden: expandedParticipantsVideoState.isUIHidden) } + self.focusedSpeakerAutoSwitchDeadline = CFAbsoluteTimeGetCurrent() + 1.0 } else { self.expandedParticipantsVideoState = nil + self.focusedSpeakerAutoSwitchDeadline = 0.0 } } else { self.expandedParticipantsVideoState = nil + self.focusedSpeakerAutoSwitchDeadline = 0.0 } if !self.isUpdating { @@ -1509,6 +1515,7 @@ final class VideoChatScreenComponent: Component { } self.expandedParticipantsVideoState = VideoChatParticipantsComponent.ExpandedVideoState(mainParticipant: key, isMainParticipantPinned: false, isUIHidden: isUIHidden) + self.focusedSpeakerAutoSwitchDeadline = CFAbsoluteTimeGetCurrent() + 3.0 self.state?.updated(transition: .spring(duration: 0.4)) } else if self.expandedParticipantsVideoState != nil { self.expandedParticipantsVideoState = nil