mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-04 10:30:42 +00:00
Merge commit '664b2bc15e1f31db9ac94b98bcefb1ae453149ba'
This commit is contained in:
commit
8c9164cbcd
@ -1,5 +1,6 @@
|
|||||||
#import "PGVideoMovie.h"
|
#import "PGVideoMovie.h"
|
||||||
#import "GPUImageFilter.h"
|
#import "GPUImageFilter.h"
|
||||||
|
#import "LegacyComponentsInternal.h"
|
||||||
|
|
||||||
GLfloat kColorConversion601Default[] = {
|
GLfloat kColorConversion601Default[] = {
|
||||||
1.164, 1.164, 1.164,
|
1.164, 1.164, 1.164,
|
||||||
@ -226,7 +227,20 @@ NSString *const kYUVVideoRangeConversionForLAFragmentShaderString = SHADER_STRIN
|
|||||||
else {
|
else {
|
||||||
[pixBuffAttributes setObject:@(kCVPixelFormatType_32BGRA) forKey:(id)kCVPixelBufferPixelFormatTypeKey];
|
[pixBuffAttributes setObject:@(kCVPixelFormatType_32BGRA) forKey:(id)kCVPixelBufferPixelFormatTypeKey];
|
||||||
}
|
}
|
||||||
playerItemOutput = [[AVPlayerItemVideoOutput alloc] initWithPixelBufferAttributes:pixBuffAttributes];
|
if (iosMajorVersion() >= 10) {
|
||||||
|
NSDictionary *hdVideoProperties = @
|
||||||
|
{
|
||||||
|
AVVideoColorPrimariesKey: AVVideoColorPrimaries_ITU_R_709_2,
|
||||||
|
AVVideoTransferFunctionKey: AVVideoTransferFunction_ITU_R_709_2,
|
||||||
|
AVVideoYCbCrMatrixKey: AVVideoYCbCrMatrix_ITU_R_709_2,
|
||||||
|
};
|
||||||
|
[pixBuffAttributes setObject:hdVideoProperties forKey:AVVideoColorPropertiesKey];
|
||||||
|
playerItemOutput = [[AVPlayerItemVideoOutput alloc] initWithOutputSettings:pixBuffAttributes];
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
playerItemOutput = [[AVPlayerItemVideoOutput alloc] initWithPixelBufferAttributes:pixBuffAttributes];
|
||||||
|
}
|
||||||
[playerItemOutput setDelegate:self queue:videoProcessingQueue];
|
[playerItemOutput setDelegate:self queue:videoProcessingQueue];
|
||||||
|
|
||||||
[_playerItem addOutput:playerItemOutput];
|
[_playerItem addOutput:playerItemOutput];
|
||||||
|
@ -816,7 +816,6 @@ public final class VoiceChatController: ViewController {
|
|||||||
|
|
||||||
private var animatingInsertion = false
|
private var animatingInsertion = false
|
||||||
private var animatingExpansion = false
|
private var animatingExpansion = false
|
||||||
private var expansionVelocity: CGFloat?
|
|
||||||
private var animatingAppearance = false
|
private var animatingAppearance = false
|
||||||
private var animatingButtonsSwap = false
|
private var animatingButtonsSwap = false
|
||||||
private var animatingMainStage = false
|
private var animatingMainStage = false
|
||||||
@ -3530,6 +3529,8 @@ public final class VoiceChatController: ViewController {
|
|||||||
} else {
|
} else {
|
||||||
topInset = max(0.0, panInitialTopInset + min(0.0, panOffset))
|
topInset = max(0.0, panInitialTopInset + min(0.0, panOffset))
|
||||||
}
|
}
|
||||||
|
} else if case .regular = layout.metrics.widthClass {
|
||||||
|
topInset = 0.0
|
||||||
} else if let currentTopInset = self.topInset {
|
} else if let currentTopInset = self.topInset {
|
||||||
topInset = self.isExpanded ? 0.0 : currentTopInset
|
topInset = self.isExpanded ? 0.0 : currentTopInset
|
||||||
} else {
|
} else {
|
||||||
@ -4057,6 +4058,8 @@ public final class VoiceChatController: ViewController {
|
|||||||
} else {
|
} else {
|
||||||
topInset = max(0.0, panInitialTopInset + min(0.0, panOffset))
|
topInset = max(0.0, panInitialTopInset + min(0.0, panOffset))
|
||||||
}
|
}
|
||||||
|
} else if case .regular = layout.metrics.widthClass {
|
||||||
|
topInset = 0.0
|
||||||
} else if let currentTopInset = self.topInset {
|
} else if let currentTopInset = self.topInset {
|
||||||
topInset = self.isExpanded ? 0.0 : currentTopInset
|
topInset = self.isExpanded ? 0.0 : currentTopInset
|
||||||
} else {
|
} else {
|
||||||
@ -5275,7 +5278,9 @@ public final class VoiceChatController: ViewController {
|
|||||||
switch recognizer.state {
|
switch recognizer.state {
|
||||||
case .began:
|
case .began:
|
||||||
let topInset: CGFloat
|
let topInset: CGFloat
|
||||||
if self.isExpanded {
|
if case .regular = layout.metrics.widthClass {
|
||||||
|
topInset = 0.0
|
||||||
|
} else if self.isExpanded {
|
||||||
topInset = 0.0
|
topInset = 0.0
|
||||||
} else if let currentTopInset = self.topInset {
|
} else if let currentTopInset = self.topInset {
|
||||||
topInset = currentTopInset
|
topInset = currentTopInset
|
||||||
@ -5448,14 +5453,20 @@ public final class VoiceChatController: ViewController {
|
|||||||
self.animatingExpansion = true
|
self.animatingExpansion = true
|
||||||
self.listNode.scroller.setContentOffset(CGPoint(), animated: false)
|
self.listNode.scroller.setContentOffset(CGPoint(), animated: false)
|
||||||
|
|
||||||
self.expansionVelocity = velocity.y
|
let distance: CGFloat
|
||||||
if let (layout, navigationHeight) = self.validLayout {
|
if let topInset = self.topInset {
|
||||||
self.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: .animated(duration: 0.3, curve: .easeInOut))
|
distance = topInset - offset
|
||||||
|
} else {
|
||||||
|
distance = 0.0
|
||||||
}
|
}
|
||||||
self.updateDecorationsLayout(transition: .animated(duration: 0.3, curve: .easeInOut), completion: {
|
let initialVelocity: CGFloat = distance.isZero ? 0.0 : abs(velocity.y / distance)
|
||||||
|
let transition = ContainedViewLayoutTransition.animated(duration: 0.45, curve: .customSpring(damping: 124.0, initialVelocity: initialVelocity))
|
||||||
|
if let (layout, navigationHeight) = self.validLayout {
|
||||||
|
self.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: transition)
|
||||||
|
}
|
||||||
|
self.updateDecorationsLayout(transition: transition, completion: {
|
||||||
self.animatingExpansion = false
|
self.animatingExpansion = false
|
||||||
})
|
})
|
||||||
self.expansionVelocity = nil
|
|
||||||
} else {
|
} else {
|
||||||
self.displayMode = .modal(isExpanded: true, isFilled: true)
|
self.displayMode = .modal(isExpanded: true, isFilled: true)
|
||||||
self.updateDecorationsColors()
|
self.updateDecorationsColors()
|
||||||
@ -5490,8 +5501,9 @@ public final class VoiceChatController: ViewController {
|
|||||||
self.listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous, .LowLatency], scrollToItem: ListViewScrollToItem(index: 0, position: .top(0.0), animated: true, curve: .Default(duration: nil), directionHint: .Up), updateSizeAndInsets: nil, stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in })
|
self.listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous, .LowLatency], scrollToItem: ListViewScrollToItem(index: 0, position: .top(0.0), animated: true, curve: .Default(duration: nil), directionHint: .Up), updateSizeAndInsets: nil, stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.expansionVelocity = velocity.y
|
let initialVelocity: CGFloat = offset.isZero ? 0.0 : abs(velocity.y / offset)
|
||||||
|
let transition = ContainedViewLayoutTransition.animated(duration: 0.45, curve: .customSpring(damping: 124.0, initialVelocity: initialVelocity))
|
||||||
if case .modal = self.displayMode {
|
if case .modal = self.displayMode {
|
||||||
self.displayMode = .modal(isExpanded: true, isFilled: true)
|
self.displayMode = .modal(isExpanded: true, isFilled: true)
|
||||||
}
|
}
|
||||||
@ -5499,12 +5511,11 @@ public final class VoiceChatController: ViewController {
|
|||||||
self.animatingExpansion = true
|
self.animatingExpansion = true
|
||||||
|
|
||||||
if let (layout, navigationHeight) = self.validLayout {
|
if let (layout, navigationHeight) = self.validLayout {
|
||||||
self.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: .animated(duration: 0.3, curve: .easeInOut))
|
self.containerLayoutUpdated(layout, navigationHeight: navigationHeight, transition: transition)
|
||||||
}
|
}
|
||||||
self.updateDecorationsLayout(transition: .animated(duration: 0.3, curve: .easeInOut), completion: {
|
self.updateDecorationsLayout(transition: transition, completion: {
|
||||||
self.animatingExpansion = false
|
self.animatingExpansion = false
|
||||||
})
|
})
|
||||||
self.expansionVelocity = nil
|
|
||||||
} else if !self.isScheduling {
|
} else if !self.isScheduling {
|
||||||
self.updateDecorationsColors()
|
self.updateDecorationsColors()
|
||||||
self.animatingExpansion = true
|
self.animatingExpansion = true
|
||||||
|
@ -122,49 +122,8 @@ public func getCurrentGroupCall(account: Account, callId: Int64, accessHash: Int
|
|||||||
})
|
})
|
||||||
updatePeerPresences(transaction: transaction, accountPeerId: account.peerId, peerPresences: peerPresences)
|
updatePeerPresences(transaction: transaction, accountPeerId: account.peerId, peerPresences: peerPresences)
|
||||||
|
|
||||||
var parsedParticipants: [GroupCallParticipantsContext.Participant] = []
|
let parsedParticipants = participants.compactMap { GroupCallParticipantsContext.Participant($0, transaction: transaction) }
|
||||||
|
|
||||||
loop: for participant in participants {
|
|
||||||
switch participant {
|
|
||||||
case let .groupCallParticipant(flags, apiPeerId, date, activeDate, source, volume, about, raiseHandRating, video, presentation):
|
|
||||||
let peerId: PeerId = apiPeerId.peerId
|
|
||||||
|
|
||||||
let ssrc = UInt32(bitPattern: source)
|
|
||||||
guard let peer = transaction.getPeer(peerId) else {
|
|
||||||
continue loop
|
|
||||||
}
|
|
||||||
let muted = (flags & (1 << 0)) != 0
|
|
||||||
let mutedByYou = (flags & (1 << 9)) != 0
|
|
||||||
var muteState: GroupCallParticipantsContext.Participant.MuteState?
|
|
||||||
if muted {
|
|
||||||
let canUnmute = (flags & (1 << 2)) != 0
|
|
||||||
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: canUnmute, mutedByYou: mutedByYou)
|
|
||||||
} else if mutedByYou {
|
|
||||||
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: false, mutedByYou: mutedByYou)
|
|
||||||
}
|
|
||||||
var videoDescription = video.flatMap(GroupCallParticipantsContext.Participant.VideoDescription.init)
|
|
||||||
var presentationDescription = presentation.flatMap(GroupCallParticipantsContext.Participant.VideoDescription.init)
|
|
||||||
if muteState?.canUnmute == false {
|
|
||||||
videoDescription = nil
|
|
||||||
presentationDescription = nil
|
|
||||||
}
|
|
||||||
parsedParticipants.append(GroupCallParticipantsContext.Participant(
|
|
||||||
peer: peer,
|
|
||||||
ssrc: ssrc,
|
|
||||||
videoDescription: videoDescription,
|
|
||||||
presentationDescription: presentationDescription,
|
|
||||||
joinTimestamp: date,
|
|
||||||
raiseHandRating: raiseHandRating,
|
|
||||||
hasRaiseHand: raiseHandRating != nil,
|
|
||||||
activityTimestamp: activeDate.flatMap(Double.init),
|
|
||||||
activityRank: nil,
|
|
||||||
muteState: muteState,
|
|
||||||
volume: volume,
|
|
||||||
about: about
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return GroupCallSummary(
|
return GroupCallSummary(
|
||||||
info: info,
|
info: info,
|
||||||
topParticipants: parsedParticipants
|
topParticipants: parsedParticipants
|
||||||
@ -442,45 +401,7 @@ public func getGroupCallParticipants(account: Account, callId: Int64, accessHash
|
|||||||
})
|
})
|
||||||
updatePeerPresences(transaction: transaction, accountPeerId: account.peerId, peerPresences: peerPresences)
|
updatePeerPresences(transaction: transaction, accountPeerId: account.peerId, peerPresences: peerPresences)
|
||||||
|
|
||||||
loop: for participant in participants {
|
parsedParticipants = participants.compactMap { GroupCallParticipantsContext.Participant($0, transaction: transaction) }
|
||||||
switch participant {
|
|
||||||
case let .groupCallParticipant(flags, apiPeerId, date, activeDate, source, volume, about, raiseHandRating, video, presentation):
|
|
||||||
let peerId: PeerId = apiPeerId.peerId
|
|
||||||
let ssrc = UInt32(bitPattern: source)
|
|
||||||
guard let peer = transaction.getPeer(peerId) else {
|
|
||||||
continue loop
|
|
||||||
}
|
|
||||||
let muted = (flags & (1 << 0)) != 0
|
|
||||||
let mutedByYou = (flags & (1 << 9)) != 0
|
|
||||||
var muteState: GroupCallParticipantsContext.Participant.MuteState?
|
|
||||||
if muted {
|
|
||||||
let canUnmute = (flags & (1 << 2)) != 0
|
|
||||||
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: canUnmute, mutedByYou: mutedByYou)
|
|
||||||
} else if mutedByYou {
|
|
||||||
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: false, mutedByYou: mutedByYou)
|
|
||||||
}
|
|
||||||
var videoDescription = video.flatMap(GroupCallParticipantsContext.Participant.VideoDescription.init)
|
|
||||||
var presentationDescription = presentation.flatMap(GroupCallParticipantsContext.Participant.VideoDescription.init)
|
|
||||||
if muteState?.canUnmute == false {
|
|
||||||
videoDescription = nil
|
|
||||||
presentationDescription = nil
|
|
||||||
}
|
|
||||||
parsedParticipants.append(GroupCallParticipantsContext.Participant(
|
|
||||||
peer: peer,
|
|
||||||
ssrc: ssrc,
|
|
||||||
videoDescription: videoDescription,
|
|
||||||
presentationDescription: presentationDescription,
|
|
||||||
joinTimestamp: date,
|
|
||||||
raiseHandRating: raiseHandRating,
|
|
||||||
hasRaiseHand: raiseHandRating != nil,
|
|
||||||
activityTimestamp: activeDate.flatMap(Double.init),
|
|
||||||
activityRank: nil,
|
|
||||||
muteState: muteState,
|
|
||||||
volume: volume,
|
|
||||||
about: about
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parsedParticipants.sort(by: { GroupCallParticipantsContext.Participant.compare(lhs: $0, rhs: $1, sortAscending: sortAscendingValue) })
|
parsedParticipants.sort(by: { GroupCallParticipantsContext.Participant.compare(lhs: $0, rhs: $1, sortAscending: sortAscendingValue) })
|
||||||
@ -2164,59 +2085,8 @@ extension GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate {
|
|||||||
|
|
||||||
extension GroupCallParticipantsContext.Update.StateUpdate {
|
extension GroupCallParticipantsContext.Update.StateUpdate {
|
||||||
init(participants: [Api.GroupCallParticipant], version: Int32, removePendingMuteStates: Set<PeerId> = Set()) {
|
init(participants: [Api.GroupCallParticipant], version: Int32, removePendingMuteStates: Set<PeerId> = Set()) {
|
||||||
var participantUpdates: [GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate] = []
|
|
||||||
for participant in participants {
|
|
||||||
switch participant {
|
|
||||||
case let .groupCallParticipant(flags, apiPeerId, date, activeDate, source, volume, about, raiseHandRating, video, presentation):
|
|
||||||
let peerId: PeerId = apiPeerId.peerId
|
|
||||||
let ssrc = UInt32(bitPattern: source)
|
|
||||||
let muted = (flags & (1 << 0)) != 0
|
|
||||||
let mutedByYou = (flags & (1 << 9)) != 0
|
|
||||||
var muteState: GroupCallParticipantsContext.Participant.MuteState?
|
|
||||||
if muted {
|
|
||||||
let canUnmute = (flags & (1 << 2)) != 0
|
|
||||||
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: canUnmute, mutedByYou: mutedByYou)
|
|
||||||
} else if mutedByYou {
|
|
||||||
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: false, mutedByYou: mutedByYou)
|
|
||||||
}
|
|
||||||
let isRemoved = (flags & (1 << 1)) != 0
|
|
||||||
let justJoined = (flags & (1 << 4)) != 0
|
|
||||||
let isMin = (flags & (1 << 8)) != 0
|
|
||||||
|
|
||||||
let participationStatusChange: GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate.ParticipationStatusChange
|
|
||||||
if isRemoved {
|
|
||||||
participationStatusChange = .left
|
|
||||||
} else if justJoined {
|
|
||||||
participationStatusChange = .joined
|
|
||||||
} else {
|
|
||||||
participationStatusChange = .none
|
|
||||||
}
|
|
||||||
|
|
||||||
var videoDescription = video.flatMap(GroupCallParticipantsContext.Participant.VideoDescription.init)
|
|
||||||
var presentationDescription = presentation.flatMap(GroupCallParticipantsContext.Participant.VideoDescription.init)
|
|
||||||
if muteState?.canUnmute == false {
|
|
||||||
videoDescription = nil
|
|
||||||
presentationDescription = nil
|
|
||||||
}
|
|
||||||
participantUpdates.append(GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate(
|
|
||||||
peerId: peerId,
|
|
||||||
ssrc: ssrc,
|
|
||||||
videoDescription: videoDescription,
|
|
||||||
presentationDescription: presentationDescription,
|
|
||||||
joinTimestamp: date,
|
|
||||||
activityTimestamp: activeDate.flatMap(Double.init),
|
|
||||||
raiseHandRating: raiseHandRating,
|
|
||||||
muteState: muteState,
|
|
||||||
participationStatusChange: participationStatusChange,
|
|
||||||
volume: volume,
|
|
||||||
about: about,
|
|
||||||
isMin: isMin
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.init(
|
self.init(
|
||||||
participantUpdates: participantUpdates,
|
participantUpdates: participants.map { GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate($0) },
|
||||||
version: version,
|
version: version,
|
||||||
removePendingMuteStates: removePendingMuteStates
|
removePendingMuteStates: removePendingMuteStates
|
||||||
)
|
)
|
||||||
@ -2551,6 +2421,48 @@ public func getAudioBroadcastPart(dataSource: AudioBroadcastDataSource, callId:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension GroupCallParticipantsContext.Participant {
|
||||||
|
init?(_ apiParticipant: Api.GroupCallParticipant, transaction: Transaction) {
|
||||||
|
switch apiParticipant {
|
||||||
|
case let .groupCallParticipant(flags, apiPeerId, date, activeDate, source, volume, about, raiseHandRating, video, presentation):
|
||||||
|
let peerId: PeerId = apiPeerId.peerId
|
||||||
|
let ssrc = UInt32(bitPattern: source)
|
||||||
|
guard let peer = transaction.getPeer(peerId) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
let muted = (flags & (1 << 0)) != 0
|
||||||
|
let mutedByYou = (flags & (1 << 9)) != 0
|
||||||
|
var muteState: GroupCallParticipantsContext.Participant.MuteState?
|
||||||
|
if muted {
|
||||||
|
let canUnmute = (flags & (1 << 2)) != 0
|
||||||
|
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: canUnmute, mutedByYou: mutedByYou)
|
||||||
|
} else if mutedByYou {
|
||||||
|
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: false, mutedByYou: mutedByYou)
|
||||||
|
}
|
||||||
|
var videoDescription = video.flatMap(GroupCallParticipantsContext.Participant.VideoDescription.init)
|
||||||
|
var presentationDescription = presentation.flatMap(GroupCallParticipantsContext.Participant.VideoDescription.init)
|
||||||
|
if muteState?.canUnmute == false {
|
||||||
|
videoDescription = nil
|
||||||
|
presentationDescription = nil
|
||||||
|
}
|
||||||
|
self.init(
|
||||||
|
peer: peer,
|
||||||
|
ssrc: ssrc,
|
||||||
|
videoDescription: videoDescription,
|
||||||
|
presentationDescription: presentationDescription,
|
||||||
|
joinTimestamp: date,
|
||||||
|
raiseHandRating: raiseHandRating,
|
||||||
|
hasRaiseHand: raiseHandRating != nil,
|
||||||
|
activityTimestamp: activeDate.flatMap(Double.init),
|
||||||
|
activityRank: nil,
|
||||||
|
muteState: muteState,
|
||||||
|
volume: volume,
|
||||||
|
about: about
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private extension GroupCallParticipantsContext.Participant.VideoDescription {
|
private extension GroupCallParticipantsContext.Participant.VideoDescription {
|
||||||
init(_ apiVideo: Api.GroupCallParticipantVideo) {
|
init(_ apiVideo: Api.GroupCallParticipantVideo) {
|
||||||
switch apiVideo {
|
switch apiVideo {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user