mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Voice chat updates
This commit is contained in:
parent
bc12ca8a9a
commit
8b748e0045
@ -272,7 +272,7 @@ public protocol PresentationGroupCall: class {
|
|||||||
var state: Signal<PresentationGroupCallState, NoError> { get }
|
var state: Signal<PresentationGroupCallState, NoError> { get }
|
||||||
var summaryState: Signal<PresentationGroupCallSummaryState?, NoError> { get }
|
var summaryState: Signal<PresentationGroupCallSummaryState?, NoError> { get }
|
||||||
var members: Signal<PresentationGroupCallMembers?, NoError> { get }
|
var members: Signal<PresentationGroupCallMembers?, NoError> { get }
|
||||||
var audioLevels: Signal<[(PeerId, Float)], NoError> { get }
|
var audioLevels: Signal<[(PeerId, Float, Bool)], NoError> { get }
|
||||||
var myAudioLevel: Signal<Float, NoError> { get }
|
var myAudioLevel: Signal<Float, NoError> { get }
|
||||||
var isMuted: Signal<Bool, NoError> { get }
|
var isMuted: Signal<Bool, NoError> { get }
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ public protocol PresentationGroupCall: class {
|
|||||||
|
|
||||||
func updateMuteState(peerId: PeerId, isMuted: Bool)
|
func updateMuteState(peerId: PeerId, isMuted: Bool)
|
||||||
|
|
||||||
func invitePeer(_ peerId: PeerId)
|
func invitePeer(_ peerId: PeerId) -> Bool
|
||||||
func removedPeer(_ peerId: PeerId)
|
func removedPeer(_ peerId: PeerId)
|
||||||
var invitedPeers: Signal<[PeerId], NoError> { get }
|
var invitedPeers: Signal<[PeerId], NoError> { get }
|
||||||
}
|
}
|
||||||
|
@ -1010,9 +1010,9 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
|
|||||||
if updateFlags == nil {
|
if updateFlags == nil {
|
||||||
if member.adminInfo?.rights == nil {
|
if member.adminInfo?.rights == nil {
|
||||||
if channel.flags.contains(.isCreator) {
|
if channel.flags.contains(.isCreator) {
|
||||||
updateFlags = maskRightsFlags.subtracting(.canAddAdmins)
|
updateFlags = maskRightsFlags.subtracting([.canAddAdmins, .canBeAnonymous])
|
||||||
} else if let adminRights = channel.adminRights {
|
} else if let adminRights = channel.adminRights {
|
||||||
updateFlags = maskRightsFlags.intersection(adminRights.flags).subtracting(.canAddAdmins)
|
updateFlags = maskRightsFlags.intersection(adminRights.flags).subtracting([.canAddAdmins, .canBeAnonymous])
|
||||||
} else {
|
} else {
|
||||||
updateFlags = []
|
updateFlags = []
|
||||||
}
|
}
|
||||||
|
@ -239,20 +239,20 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private let audioLevelsPromise = Promise<[(PeerId, Float)]>()
|
private let audioLevelsPromise = Promise<[(PeerId, Float, Bool)]>()
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func update(levels: [(PeerId, Float)]) {
|
func update(levels: [(PeerId, Float, Bool)]) {
|
||||||
let timestamp = Int32(CFAbsoluteTimeGetCurrent())
|
let timestamp = Int32(CFAbsoluteTimeGetCurrent())
|
||||||
let currentParticipants: [PeerId: Participant] = self.participants
|
let currentParticipants: [PeerId: Participant] = self.participants
|
||||||
|
|
||||||
var validSpeakers: [PeerId: Participant] = [:]
|
var validSpeakers: [PeerId: Participant] = [:]
|
||||||
var silentParticipants = Set<PeerId>()
|
var silentParticipants = Set<PeerId>()
|
||||||
var speakingParticipants = Set<PeerId>()
|
var speakingParticipants = Set<PeerId>()
|
||||||
for (peerId, level) in levels {
|
for (peerId, level, hasVoice) in levels {
|
||||||
if level > speakingLevelThreshold {
|
if level > speakingLevelThreshold && hasVoice {
|
||||||
validSpeakers[peerId] = Participant(timestamp: timestamp, level: level)
|
validSpeakers[peerId] = Participant(timestamp: timestamp, level: level)
|
||||||
speakingParticipants.insert(peerId)
|
speakingParticipants.insert(peerId)
|
||||||
} else {
|
} else {
|
||||||
@ -276,9 +276,11 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var audioLevels: [(PeerId, Float)] = []
|
var audioLevels: [(PeerId, Float, Bool)] = []
|
||||||
for (peerId, speaker) in validSpeakers {
|
for (peerId, level, hasVoice) in levels {
|
||||||
audioLevels.append((peerId, speaker.level))
|
if level > 0.1 {
|
||||||
|
audioLevels.append((peerId, level, hasVoice))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.participants = validSpeakers
|
self.participants = validSpeakers
|
||||||
@ -290,7 +292,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
return self.speakingParticipantsPromise.get() |> distinctUntilChanged
|
return self.speakingParticipantsPromise.get() |> distinctUntilChanged
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAudioLevels() -> Signal<[(PeerId, Float)], NoError> {
|
func getAudioLevels() -> Signal<[(PeerId, Float, Bool)], NoError> {
|
||||||
return self.audioLevelsPromise.get()
|
return self.audioLevelsPromise.get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,6 +312,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
public let peerId: PeerId
|
public let peerId: PeerId
|
||||||
public let peer: Peer?
|
public let peer: Peer?
|
||||||
|
|
||||||
|
private let temporaryJoinTimestamp: Int32
|
||||||
|
|
||||||
private var internalState: InternalState = .requesting
|
private var internalState: InternalState = .requesting
|
||||||
|
|
||||||
private var callContext: OngoingGroupCallContext?
|
private var callContext: OngoingGroupCallContext?
|
||||||
@ -357,7 +361,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
|
|
||||||
private let speakingParticipantsContext = SpeakingParticipantsContext()
|
private let speakingParticipantsContext = SpeakingParticipantsContext()
|
||||||
private var speakingParticipantsReportTimestamp: [PeerId: Double] = [:]
|
private var speakingParticipantsReportTimestamp: [PeerId: Double] = [:]
|
||||||
public var audioLevels: Signal<[(PeerId, Float)], NoError> {
|
public var audioLevels: Signal<[(PeerId, Float, Bool)], NoError> {
|
||||||
return self.speakingParticipantsContext.getAudioLevels()
|
return self.speakingParticipantsContext.getAudioLevels()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,6 +463,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
self.peerId = peerId
|
self.peerId = peerId
|
||||||
self.peer = peer
|
self.peer = peer
|
||||||
|
|
||||||
|
self.temporaryJoinTimestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970)
|
||||||
|
|
||||||
var didReceiveAudioOutputs = false
|
var didReceiveAudioOutputs = false
|
||||||
|
|
||||||
if !audioSession.getIsHeadsetPluggedIn() {
|
if !audioSession.getIsHeadsetPluggedIn() {
|
||||||
@ -611,10 +617,15 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
impl.get(account: accountContext.account, peerId: peerId, call: CachedChannelData.ActiveCall(id: initialCall.id, accessHash: initialCall.accessHash))
|
impl.get(account: accountContext.account, peerId: peerId, call: CachedChannelData.ActiveCall(id: initialCall.id, accessHash: initialCall.accessHash))
|
||||||
}) {
|
}) {
|
||||||
if let participantsContext = temporaryParticipantsContext.context.participantsContext {
|
if let participantsContext = temporaryParticipantsContext.context.participantsContext {
|
||||||
|
let accountPeerId = self.accountContext.account.peerId
|
||||||
|
let accountPeer = self.accountContext.account.postbox.transaction { transaction -> Peer? in
|
||||||
|
return transaction.getPeer(accountPeerId)
|
||||||
|
}
|
||||||
self.participantsContextStateDisposable.set(combineLatest(queue: .mainQueue(),
|
self.participantsContextStateDisposable.set(combineLatest(queue: .mainQueue(),
|
||||||
|
accountPeer,
|
||||||
participantsContext.state,
|
participantsContext.state,
|
||||||
participantsContext.activeSpeakers
|
participantsContext.activeSpeakers
|
||||||
).start(next: { [weak self] state, activeSpeakers in
|
).start(next: { [weak self] accountPeer, state, activeSpeakers in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -631,7 +642,22 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
var updatedInvitedPeers = strongSelf.invitedPeersValue
|
var updatedInvitedPeers = strongSelf.invitedPeersValue
|
||||||
var didUpdateInvitedPeers = false
|
var didUpdateInvitedPeers = false
|
||||||
|
|
||||||
for participant in state.participants {
|
var participants = state.participants
|
||||||
|
|
||||||
|
if !participants.contains(where: { $0.peer.id == accountPeerId }) {
|
||||||
|
if let accountPeer = accountPeer {
|
||||||
|
participants.append(GroupCallParticipantsContext.Participant(
|
||||||
|
peer: accountPeer,
|
||||||
|
ssrc: 0,
|
||||||
|
joinTimestamp: strongSelf.temporaryJoinTimestamp,
|
||||||
|
activityTimestamp: nil,
|
||||||
|
muteState: GroupCallParticipantsContext.Participant.MuteState(canUnmute: true)
|
||||||
|
))
|
||||||
|
participants.sort()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for participant in participants {
|
||||||
members.participants.append(participant)
|
members.participants.append(participant)
|
||||||
|
|
||||||
if topParticipants.count < 3 {
|
if topParticipants.count < 3 {
|
||||||
@ -816,9 +842,10 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var result: [(PeerId, Float)] = []
|
var result: [(PeerId, Float, Bool)] = []
|
||||||
var myLevel: Float = 0.0
|
var myLevel: Float = 0.0
|
||||||
for (ssrcKey, level) in levels {
|
var myLevelHasVoice: Bool = false
|
||||||
|
for (ssrcKey, level, hasVoice) in levels {
|
||||||
var peerId: PeerId?
|
var peerId: PeerId?
|
||||||
switch ssrcKey {
|
switch ssrcKey {
|
||||||
case .local:
|
case .local:
|
||||||
@ -828,20 +855,20 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
}
|
}
|
||||||
if let peerId = peerId {
|
if let peerId = peerId {
|
||||||
if case .local = ssrcKey {
|
if case .local = ssrcKey {
|
||||||
myLevel = level
|
if !strongSelf.isMutedValue.isEffectivelyMuted {
|
||||||
|
myLevel = level
|
||||||
|
myLevelHasVoice = hasVoice
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result.append((peerId, level))
|
result.append((peerId, level, hasVoice))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strongSelf.speakingParticipantsContext.update(levels: result)
|
strongSelf.speakingParticipantsContext.update(levels: result)
|
||||||
|
|
||||||
let mappedLevel = myLevel * 1.5
|
let mappedLevel = myLevel * 1.5
|
||||||
|
|
||||||
strongSelf.myAudioLevelPipe.putNext(mappedLevel)
|
strongSelf.myAudioLevelPipe.putNext(mappedLevel)
|
||||||
strongSelf.processMyAudioLevel(level: mappedLevel)
|
strongSelf.processMyAudioLevel(level: mappedLevel, hasVoice: myLevelHasVoice)
|
||||||
if !strongSelf.isMutedValue.isEffectivelyMuted {
|
|
||||||
strongSelf.speakingParticipantsContext.update(levels: [(strongSelf.account.peerId, mappedLevel)])
|
|
||||||
}
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1273,9 +1300,9 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func invitePeer(_ peerId: PeerId) {
|
public func invitePeer(_ peerId: PeerId) -> Bool {
|
||||||
guard case let .estabilished(callInfo, _, _, _) = self.internalState, !self.invitedPeersValue.contains(peerId) else {
|
guard case let .estabilished(callInfo, _, _, _) = self.internalState, !self.invitedPeersValue.contains(peerId) else {
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var updatedInvitedPeers = self.invitedPeersValue
|
var updatedInvitedPeers = self.invitedPeersValue
|
||||||
@ -1283,6 +1310,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
self.invitedPeersValue = updatedInvitedPeers
|
self.invitedPeersValue = updatedInvitedPeers
|
||||||
|
|
||||||
let _ = inviteToGroupCall(account: self.account, callId: callInfo.id, accessHash: callInfo.accessHash, peerId: peerId).start()
|
let _ = inviteToGroupCall(account: self.account, callId: callInfo.id, accessHash: callInfo.accessHash, peerId: peerId).start()
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
public func removedPeer(_ peerId: PeerId) {
|
public func removedPeer(_ peerId: PeerId) {
|
||||||
@ -1329,10 +1358,10 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
myAudioLevelTimer.start()
|
myAudioLevelTimer.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func processMyAudioLevel(level: Float) {
|
private func processMyAudioLevel(level: Float, hasVoice: Bool) {
|
||||||
self.currentMyAudioLevel = level
|
self.currentMyAudioLevel = level
|
||||||
|
|
||||||
if level > 0.01 {
|
if level > 0.01 && hasVoice {
|
||||||
self.currentMyAudioLevelTimestamp = CACurrentMediaTime()
|
self.currentMyAudioLevelTimestamp = CACurrentMediaTime()
|
||||||
|
|
||||||
if self.myAudioLevelTimer == nil {
|
if self.myAudioLevelTimer == nil {
|
||||||
|
@ -172,9 +172,9 @@ public final class VoiceChatController: ViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateAudioLevels(_ levels: [(PeerId, Float)], reset: Bool = false) {
|
func updateAudioLevels(_ levels: [(PeerId, Float, Bool)], reset: Bool = false) {
|
||||||
var updated = Set<PeerId>()
|
var updated = Set<PeerId>()
|
||||||
for (peerId, level) in levels {
|
for (peerId, level, _) in levels {
|
||||||
if let pipe = self.audioLevels[peerId] {
|
if let pipe = self.audioLevels[peerId] {
|
||||||
if reset {
|
if reset {
|
||||||
pipe.putNext(level)
|
pipe.putNext(level)
|
||||||
@ -578,10 +578,11 @@ public final class VoiceChatController: ViewController {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if let participant = participant {
|
if let participant = participant {
|
||||||
strongSelf.call.invitePeer(participant.peer.id)
|
|
||||||
dismissController?()
|
dismissController?()
|
||||||
|
|
||||||
strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .invitedToVoiceChat(context: strongSelf.context, peer: participant.peer, text: strongSelf.presentationData.strings.VoiceChat_InvitedPeerText(peer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)).0), elevatedLayout: false, action: { _ in return false }), in: .current)
|
if strongSelf.call.invitePeer(participant.peer.id) {
|
||||||
|
strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .invitedToVoiceChat(context: strongSelf.context, peer: participant.peer, text: strongSelf.presentationData.strings.VoiceChat_InvitedPeerText(peer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)).0), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
strongSelf.controller?.present(textAlertController(context: strongSelf.context, forceTheme: strongSelf.darkTheme, title: nil, text: strongSelf.presentationData.strings.VoiceChat_InviteMemberToGroupFirstText(peer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder), groupPeer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)).0, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: presentationData.strings.VoiceChat_InviteMemberToGroupFirstAdd, action: {
|
strongSelf.controller?.present(textAlertController(context: strongSelf.context, forceTheme: strongSelf.darkTheme, title: nil, text: strongSelf.presentationData.strings.VoiceChat_InviteMemberToGroupFirstText(peer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder), groupPeer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)).0, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: presentationData.strings.VoiceChat_InviteMemberToGroupFirstAdd, action: {
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
@ -649,10 +650,11 @@ public final class VoiceChatController: ViewController {
|
|||||||
dismissController?()
|
dismissController?()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.call.invitePeer(peer.id)
|
|
||||||
dismissController?()
|
dismissController?()
|
||||||
|
|
||||||
strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .invitedToVoiceChat(context: strongSelf.context, peer: peer, text: strongSelf.presentationData.strings.VoiceChat_InvitedPeerText(peer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)).0), elevatedLayout: false, action: { _ in return false }), in: .current)
|
if strongSelf.call.invitePeer(peer.id) {
|
||||||
|
strongSelf.controller?.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .invitedToVoiceChat(context: strongSelf.context, peer: peer, text: strongSelf.presentationData.strings.VoiceChat_InvitedPeerText(peer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder)).0), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
})]), in: .window(.root))
|
})]), in: .window(.root))
|
||||||
}
|
}
|
||||||
@ -846,7 +848,6 @@ public final class VoiceChatController: ViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if strongSelf.callState != state {
|
if strongSelf.callState != state {
|
||||||
let wasMuted = strongSelf.callState?.muteState != nil
|
|
||||||
strongSelf.callState = state
|
strongSelf.callState = state
|
||||||
|
|
||||||
if let muteState = state.muteState, !muteState.canUnmute {
|
if let muteState = state.muteState, !muteState.canUnmute {
|
||||||
@ -1214,7 +1215,7 @@ public final class VoiceChatController: ViewController {
|
|||||||
self.call.setIsMuted(action: .muted(isPushToTalkActive: false))
|
self.call.setIsMuted(action: .muted(isPushToTalkActive: false))
|
||||||
}
|
}
|
||||||
|
|
||||||
self.itemInteraction?.updateAudioLevels([(self.context.account.peerId, 0.0)], reset: true)
|
self.itemInteraction?.updateAudioLevels([(self.context.account.peerId, 0.0, false)], reset: true)
|
||||||
|
|
||||||
if let (layout, navigationHeight) = self.validLayout {
|
if let (layout, navigationHeight) = self.validLayout {
|
||||||
self.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: .animated(duration: 0.3, curve: .spring))
|
self.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: .animated(duration: 0.3, curve: .spring))
|
||||||
@ -1744,17 +1745,6 @@ public final class VoiceChatController: ViewController {
|
|||||||
index += 1
|
index += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if let accountPeer = self.accountPeer, !processedPeerIds.contains(accountPeer.id) {
|
|
||||||
entries.insert(.peer(PeerEntry(
|
|
||||||
peer: accountPeer,
|
|
||||||
presence: nil,
|
|
||||||
activityTimestamp: Int32.max - 1 - index,
|
|
||||||
state: .listening,
|
|
||||||
muteState: GroupCallParticipantsContext.Participant.MuteState(canUnmute: true),
|
|
||||||
canManageCall: callState?.canManageCall ?? false
|
|
||||||
)), at: 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
for peer in invitedPeers {
|
for peer in invitedPeers {
|
||||||
if processedPeerIds.contains(peer.id) {
|
if processedPeerIds.contains(peer.id) {
|
||||||
continue
|
continue
|
||||||
|
@ -103,6 +103,7 @@ public func getCurrentGroupCall(account: Account, callId: Int64, accessHash: Int
|
|||||||
peer: peer,
|
peer: peer,
|
||||||
ssrc: ssrc,
|
ssrc: ssrc,
|
||||||
joinTimestamp: date,
|
joinTimestamp: date,
|
||||||
|
activityTimestamp: activeDate.flatMap(Double.init),
|
||||||
muteState: muteState
|
muteState: muteState
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -512,6 +513,20 @@ public final class GroupCallParticipantsContext {
|
|||||||
public var activityTimestamp: Double?
|
public var activityTimestamp: Double?
|
||||||
public var muteState: MuteState?
|
public var muteState: MuteState?
|
||||||
|
|
||||||
|
public init(
|
||||||
|
peer: Peer,
|
||||||
|
ssrc: UInt32,
|
||||||
|
joinTimestamp: Int32,
|
||||||
|
activityTimestamp: Double?,
|
||||||
|
muteState: MuteState?
|
||||||
|
) {
|
||||||
|
self.peer = peer
|
||||||
|
self.ssrc = ssrc
|
||||||
|
self.joinTimestamp = joinTimestamp
|
||||||
|
self.activityTimestamp = activityTimestamp
|
||||||
|
self.muteState = muteState
|
||||||
|
}
|
||||||
|
|
||||||
public static func ==(lhs: Participant, rhs: Participant) -> Bool {
|
public static func ==(lhs: Participant, rhs: Participant) -> Bool {
|
||||||
if !lhs.peer.isEqual(rhs.peer) {
|
if !lhs.peer.isEqual(rhs.peer) {
|
||||||
return false
|
return false
|
||||||
|
@ -235,7 +235,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
private let unblockingPeer = ValuePromise<Bool>(false, ignoreRepeated: true)
|
private let unblockingPeer = ValuePromise<Bool>(false, ignoreRepeated: true)
|
||||||
private let searching = ValuePromise<Bool>(false, ignoreRepeated: true)
|
private let searching = ValuePromise<Bool>(false, ignoreRepeated: true)
|
||||||
private let searchResult = Promise<(SearchMessagesResult, SearchMessagesState, SearchMessagesLocation)?>()
|
private let searchResult = Promise<(SearchMessagesResult, SearchMessagesState, SearchMessagesLocation)?>()
|
||||||
private let loadingMessage = ValuePromise<ChatLoadingMessageSubject?>(nil, ignoreRepeated: true)
|
private let loadingMessage = Promise<ChatLoadingMessageSubject?>(nil)
|
||||||
private let performingInlineSearch = ValuePromise<Bool>(false, ignoreRepeated: true)
|
private let performingInlineSearch = ValuePromise<Bool>(false, ignoreRepeated: true)
|
||||||
|
|
||||||
private var preloadHistoryPeerId: PeerId?
|
private var preloadHistoryPeerId: PeerId?
|
||||||
@ -4828,7 +4828,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.loadingMessage.set(.generic)
|
strongSelf.loadingMessage.set(.single(.generic))
|
||||||
|
|
||||||
let peerId: PeerId
|
let peerId: PeerId
|
||||||
let threadId: Int64?
|
let threadId: Int64?
|
||||||
@ -4843,7 +4843,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
strongSelf.messageIndexDisposable.set((searchMessageIdByTimestamp(account: strongSelf.context.account, peerId: peerId, threadId: threadId, timestamp: timestamp) |> deliverOnMainQueue).start(next: { messageId in
|
strongSelf.messageIndexDisposable.set((searchMessageIdByTimestamp(account: strongSelf.context.account, peerId: peerId, threadId: threadId, timestamp: timestamp) |> deliverOnMainQueue).start(next: { messageId in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.loadingMessage.set(nil)
|
strongSelf.loadingMessage.set(.single(nil))
|
||||||
if let messageId = messageId {
|
if let messageId = messageId {
|
||||||
strongSelf.navigateToMessage(from: nil, to: .id(messageId), forceInCurrentChat: true)
|
strongSelf.navigateToMessage(from: nil, to: .id(messageId), forceInCurrentChat: true)
|
||||||
}
|
}
|
||||||
@ -9243,13 +9243,13 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}, completed: { [weak self] in
|
}, completed: { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.loadingMessage.set(nil)
|
strongSelf.loadingMessage.set(.single(nil))
|
||||||
strongSelf.chatDisplayNode.historyNode.scrollToEndOfHistory()
|
strongSelf.chatDisplayNode.historyNode.scrollToEndOfHistory()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
cancelImpl = { [weak self] in
|
cancelImpl = { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.loadingMessage.set(nil)
|
strongSelf.loadingMessage.set(.single(nil))
|
||||||
strongSelf.messageIndexDisposable.set(nil)
|
strongSelf.messageIndexDisposable.set(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9307,13 +9307,13 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}, completed: { [weak self] in
|
}, completed: { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.loadingMessage.set(nil)
|
strongSelf.loadingMessage.set(.single(nil))
|
||||||
strongSelf.chatDisplayNode.historyNode.scrollToStartOfHistory()
|
strongSelf.chatDisplayNode.historyNode.scrollToStartOfHistory()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
cancelImpl = { [weak self] in
|
cancelImpl = { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.loadingMessage.set(nil)
|
strongSelf.loadingMessage.set(.single(nil))
|
||||||
strongSelf.messageIndexDisposable.set(nil)
|
strongSelf.messageIndexDisposable.set(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9491,14 +9491,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
if let scrollFromIndex = scrollFromIndex {
|
if let scrollFromIndex = scrollFromIndex {
|
||||||
if let messageId = messageLocation.messageId, let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) {
|
if let messageId = messageLocation.messageId, let message = self.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) {
|
||||||
self.loadingMessage.set(nil)
|
self.loadingMessage.set(.single(nil))
|
||||||
self.messageIndexDisposable.set(nil)
|
self.messageIndexDisposable.set(nil)
|
||||||
self.chatDisplayNode.historyNode.scrollToMessage(from: scrollFromIndex, to: message.index, animated: animated, scrollPosition: scrollPosition)
|
self.chatDisplayNode.historyNode.scrollToMessage(from: scrollFromIndex, to: message.index, animated: animated, scrollPosition: scrollPosition)
|
||||||
completion?()
|
completion?()
|
||||||
} else if case let .index(index) = messageLocation, index.id.id == 0, index.timestamp > 0, case .scheduledMessages = self.presentationInterfaceState.subject {
|
} else if case let .index(index) = messageLocation, index.id.id == 0, index.timestamp > 0, case .scheduledMessages = self.presentationInterfaceState.subject {
|
||||||
self.chatDisplayNode.historyNode.scrollToMessage(from: scrollFromIndex, to: index, animated: animated, scrollPosition: scrollPosition)
|
self.chatDisplayNode.historyNode.scrollToMessage(from: scrollFromIndex, to: index, animated: animated, scrollPosition: scrollPosition)
|
||||||
} else {
|
} else {
|
||||||
self.loadingMessage.set(statusSubject)
|
self.loadingMessage.set(.single(statusSubject) |> delay(0.1, queue: .mainQueue()))
|
||||||
let searchLocation: ChatHistoryInitialSearchLocation
|
let searchLocation: ChatHistoryInitialSearchLocation
|
||||||
switch messageLocation {
|
switch messageLocation {
|
||||||
case let .id(id):
|
case let .id(id):
|
||||||
@ -9580,12 +9580,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}, completed: { [weak self] in
|
}, completed: { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.loadingMessage.set(nil)
|
strongSelf.loadingMessage.set(.single(nil))
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
cancelImpl = { [weak self] in
|
cancelImpl = { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.loadingMessage.set(nil)
|
strongSelf.loadingMessage.set(.single(nil))
|
||||||
strongSelf.messageIndexDisposable.set(nil)
|
strongSelf.messageIndexDisposable.set(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9607,7 +9607,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
if let _ = fromId, rememberInStack {
|
if let _ = fromId, rememberInStack {
|
||||||
self.historyNavigationStack.add(fromIndex)
|
self.historyNavigationStack.add(fromIndex)
|
||||||
}
|
}
|
||||||
self.loadingMessage.set(statusSubject)
|
self.loadingMessage.set(.single(statusSubject) |> delay(0.1, queue: .mainQueue()))
|
||||||
let historyView = preloadedChatHistoryViewForLocation(ChatHistoryLocationInput(content: .InitialSearch(location: searchLocation, count: 50, highlight: true), id: 0), context: self.context, chatLocation: self.chatLocation, subject: self.subject, chatLocationContextHolder: self.chatLocationContextHolder, fixedCombinedReadStates: nil, tagMask: nil, additionalData: [])
|
let historyView = preloadedChatHistoryViewForLocation(ChatHistoryLocationInput(content: .InitialSearch(location: searchLocation, count: 50, highlight: true), id: 0), context: self.context, chatLocation: self.chatLocation, subject: self.subject, chatLocationContextHolder: self.chatLocationContextHolder, fixedCombinedReadStates: nil, tagMask: nil, additionalData: [])
|
||||||
let signal = historyView
|
let signal = historyView
|
||||||
|> mapToSignal { historyView -> Signal<MessageIndex?, NoError> in
|
|> mapToSignal { historyView -> Signal<MessageIndex?, NoError> in
|
||||||
@ -9638,7 +9638,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}, completed: { [weak self] in
|
}, completed: { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.loadingMessage.set(nil)
|
strongSelf.loadingMessage.set(.single(nil))
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,7 +46,7 @@ public final class OngoingGroupCallContext {
|
|||||||
let joinPayload = Promise<(String, UInt32)>()
|
let joinPayload = Promise<(String, UInt32)>()
|
||||||
let networkState = ValuePromise<NetworkState>(.connecting, ignoreRepeated: true)
|
let networkState = ValuePromise<NetworkState>(.connecting, ignoreRepeated: true)
|
||||||
let isMuted = ValuePromise<Bool>(true, ignoreRepeated: true)
|
let isMuted = ValuePromise<Bool>(true, ignoreRepeated: true)
|
||||||
let audioLevels = ValuePipe<[(AudioLevelKey, Float)]>()
|
let audioLevels = ValuePipe<[(AudioLevelKey, Float, Bool)]>()
|
||||||
|
|
||||||
init(queue: Queue, inputDeviceId: String, outputDeviceId: String) {
|
init(queue: Queue, inputDeviceId: String, outputDeviceId: String) {
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
@ -88,7 +88,7 @@ public final class OngoingGroupCallContext {
|
|||||||
|
|
||||||
let audioLevels = self.audioLevels
|
let audioLevels = self.audioLevels
|
||||||
audioLevelsUpdatedImpl = { levels in
|
audioLevelsUpdatedImpl = { levels in
|
||||||
var mappedLevels: [(AudioLevelKey, Float)] = []
|
var mappedLevels: [(AudioLevelKey, Float, Bool)] = []
|
||||||
var i = 0
|
var i = 0
|
||||||
while i < levels.count {
|
while i < levels.count {
|
||||||
let uintValue = levels[i].uint32Value
|
let uintValue = levels[i].uint32Value
|
||||||
@ -98,8 +98,8 @@ public final class OngoingGroupCallContext {
|
|||||||
} else {
|
} else {
|
||||||
key = .source(uintValue)
|
key = .source(uintValue)
|
||||||
}
|
}
|
||||||
mappedLevels.append((key, levels[i + 1].floatValue))
|
mappedLevels.append((key, levels[i + 1].floatValue, levels[i + 2].boolValue))
|
||||||
i += 2
|
i += 3
|
||||||
}
|
}
|
||||||
queue.async {
|
queue.async {
|
||||||
audioLevels.putNext(mappedLevels)
|
audioLevels.putNext(mappedLevels)
|
||||||
@ -177,7 +177,7 @@ public final class OngoingGroupCallContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public var audioLevels: Signal<[(AudioLevelKey, Float)], NoError> {
|
public var audioLevels: Signal<[(AudioLevelKey, Float, Bool)], NoError> {
|
||||||
return Signal { subscriber in
|
return Signal { subscriber in
|
||||||
let disposable = MetaDisposable()
|
let disposable = MetaDisposable()
|
||||||
self.impl.with { impl in
|
self.impl.with { impl in
|
||||||
|
@ -825,11 +825,12 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
|
|||||||
networkStateUpdated(isConnected ? GroupCallNetworkStateConnected : GroupCallNetworkStateConnecting);
|
networkStateUpdated(isConnected ? GroupCallNetworkStateConnected : GroupCallNetworkStateConnecting);
|
||||||
}];
|
}];
|
||||||
},
|
},
|
||||||
.audioLevelsUpdated = [audioLevelsUpdated](std::vector<std::pair<uint32_t, float>> const &levels) {
|
.audioLevelsUpdated = [audioLevelsUpdated](std::vector<std::pair<uint32_t, std::pair<float, bool>>> const &levels) {
|
||||||
NSMutableArray *result = [[NSMutableArray alloc] init];
|
NSMutableArray *result = [[NSMutableArray alloc] init];
|
||||||
for (auto &it : levels) {
|
for (auto &it : levels) {
|
||||||
[result addObject:@(it.first)];
|
[result addObject:@(it.first)];
|
||||||
[result addObject:@(it.second)];
|
[result addObject:@(it.second.first)];
|
||||||
|
[result addObject:@(it.second.second)];
|
||||||
}
|
}
|
||||||
audioLevelsUpdated(result);
|
audioLevelsUpdated(result);
|
||||||
},
|
},
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 503f8ad1e8f0a744b1fb3eddb66e33176e427074
|
Subproject commit 91102cef8ef03b7223b04e28c8794c87bc78614d
|
Loading…
x
Reference in New Issue
Block a user