diff --git a/submodules/AccountContext/Sources/PresentationCallManager.swift b/submodules/AccountContext/Sources/PresentationCallManager.swift index 7c12ee423b..75e5db62f4 100644 --- a/submodules/AccountContext/Sources/PresentationCallManager.swift +++ b/submodules/AccountContext/Sources/PresentationCallManager.swift @@ -265,6 +265,7 @@ public protocol PresentationGroupCall: class { var members: Signal { get } var audioLevels: Signal<[(PeerId, Float)], NoError> { get } var myAudioLevel: Signal { get } + var speakingAudioLevels: Signal<[(PeerId, Float)], NoError> { get } var isMuted: Signal { get } func leave(terminateIfPossible: Bool) -> Signal diff --git a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift index e37b25b02e..6047e8e915 100644 --- a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift +++ b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift @@ -403,6 +403,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { if previousTheme !== presentationData.theme || previousStrings !== presentationData.strings { strongSelf.mediaAccessoryPanel?.0.containerNode.updatePresentationData(presentationData) strongSelf.locationBroadcastAccessoryPanel?.updatePresentationData(presentationData) + strongSelf.groupCallAccessoryPanel?.updatePresentationData(presentationData) } } }) diff --git a/submodules/TelegramCallsUI/Sources/GroupCallNavigationAccessoryPanel.swift b/submodules/TelegramCallsUI/Sources/GroupCallNavigationAccessoryPanel.swift index 17cb61c52f..487ce94388 100644 --- a/submodules/TelegramCallsUI/Sources/GroupCallNavigationAccessoryPanel.swift +++ b/submodules/TelegramCallsUI/Sources/GroupCallNavigationAccessoryPanel.swift @@ -217,7 +217,7 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode { } } - func updatePresentationData(_ presentationData: PresentationData) { + public func updatePresentationData(_ presentationData: PresentationData) { self.theme = presentationData.theme self.strings = presentationData.strings diff --git a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift index 356b1b4f04..80214a93eb 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift @@ -89,6 +89,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { } } + private let audioLevelsPromise = Promise<[(PeerId, Float)]>() + init() { } @@ -124,13 +126,23 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { } } + var audioLevels: [(PeerId, Float)] = [] + for (peerId, speaker) in validSpeakers { + audioLevels.append((peerId, speaker.level)) + } + self.participants = validSpeakers self.speakingParticipants = speakingParticipants + self.audioLevelsPromise.set(.single(audioLevels)) } func get() -> Signal, NoError> { return self.speakingParticipantsPromise.get() |> distinctUntilChanged } + + func getAudioLevels() -> Signal<[(PeerId, Float)], NoError> { + return self.audioLevelsPromise.get() + } } public let account: Account @@ -189,8 +201,10 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { } private var audioLevelsDisposable = MetaDisposable() - private let speakingParticipantsContext = SpeakingParticipantsContext() + public var speakingAudioLevels: Signal<[(PeerId, Float)], NoError> { + return self.speakingParticipantsContext.getAudioLevels() + } private var participantsContextStateDisposable = MetaDisposable() private var participantsContext: GroupCallParticipantsContext? diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index a22d6d30ee..e2c220ab1b 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -139,12 +139,10 @@ public final class VoiceChatController: ViewController { |> mapToSignal { value in if value > 0.0 { return .single(value) - |> then(.single(0.0) |> delay(1.0, queue: Queue.mainQueue())) + |> then(.single(0.0) |> delay(0.1, queue: Queue.mainQueue())) } else { return .single(value) } - } |> mapToThrottled { next -> Signal in - return .single(next) |> then(.complete() |> delay(0.1, queue: Queue.mainQueue())) } } @@ -582,7 +580,7 @@ public final class VoiceChatController: ViewController { } }) - self.audioLevelsDisposable = (call.audioLevels + self.audioLevelsDisposable = (call.speakingAudioLevels |> deliverOnMainQueue).start(next: { [weak self] levels in guard let strongSelf = self else { return