mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-23 16:50:11 +00:00
Merge branch 'master' of https://github.com/peter-iakovlev/TelegramCore
This commit is contained in:
commit
18beabff2e
@ -577,7 +577,7 @@ public struct Api {
|
|||||||
return parser(reader)
|
return parser(reader)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print("Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
|
Logger.shared.log("TL", "Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,7 +79,7 @@ public struct MacosLegacy {
|
|||||||
return parser(reader)
|
return parser(reader)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print("Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
|
Logger.log("TL", "Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -408,7 +408,7 @@ private func decryptedAttributes46(_ attributes: [TelegramMediaFileAttribute]) -
|
|||||||
result.append(.documentAttributeSticker(alt: displayText, stickerset: stickerSet))
|
result.append(.documentAttributeSticker(alt: displayText, stickerset: stickerSet))
|
||||||
case let .ImageSize(size):
|
case let .ImageSize(size):
|
||||||
result.append(.documentAttributeImageSize(w: Int32(size.width), h: Int32(size.height)))
|
result.append(.documentAttributeImageSize(w: Int32(size.width), h: Int32(size.height)))
|
||||||
case let .Video(duration, size):
|
case let .Video(duration, size, videoFlags):
|
||||||
result.append(.documentAttributeVideo(duration: Int32(duration), w: Int32(size.width), h: Int32(size.height)))
|
result.append(.documentAttributeVideo(duration: Int32(duration), w: Int32(size.width), h: Int32(size.height)))
|
||||||
case let .Audio(isVoice, duration, title, performer, waveform):
|
case let .Audio(isVoice, duration, title, performer, waveform):
|
||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
|
|||||||
@ -114,8 +114,12 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF
|
|||||||
attributes.append(.documentAttributeSticker(flags: flags, alt: displayText, stickerset: stickerSet, maskCoords: nil))
|
attributes.append(.documentAttributeSticker(flags: flags, alt: displayText, stickerset: stickerSet, maskCoords: nil))
|
||||||
case .HasLinkedStickers:
|
case .HasLinkedStickers:
|
||||||
attributes.append(.documentAttributeHasStickers)
|
attributes.append(.documentAttributeHasStickers)
|
||||||
case let .Video(duration, size):
|
case let .Video(duration, size, videoFlags):
|
||||||
attributes.append(.documentAttributeVideo(flags: 0, duration: Int32(duration), w: Int32(size.width), h: Int32(size.height)))
|
var flags: Int32 = 0
|
||||||
|
if videoFlags.contains(.instantRoundVideo) {
|
||||||
|
flags |= (1 << 0)
|
||||||
|
}
|
||||||
|
attributes.append(.documentAttributeVideo(flags: flags, duration: Int32(duration), w: Int32(size.width), h: Int32(size.height)))
|
||||||
case let .Audio(isVoice, duration, title, performer, waveform):
|
case let .Audio(isVoice, duration, title, performer, waveform):
|
||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
if isVoice {
|
if isVoice {
|
||||||
|
|||||||
@ -430,7 +430,7 @@ extension TelegramMediaFileAttribute {
|
|||||||
}
|
}
|
||||||
self = .Sticker(displayText: alt, packReference: packReference)
|
self = .Sticker(displayText: alt, packReference: packReference)
|
||||||
case let .documentAttributeVideo(duration, w, h):
|
case let .documentAttributeVideo(duration, w, h):
|
||||||
self = .Video(duration: Int(duration), size: CGSize(width: CGFloat(w), height: CGFloat(h)))
|
self = .Video(duration: Int(duration), size: CGSize(width: CGFloat(w), height: CGFloat(h)), flags: [])
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -497,7 +497,7 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32
|
|||||||
text = caption
|
text = caption
|
||||||
}
|
}
|
||||||
if let file = file {
|
if let file = file {
|
||||||
var parsedAttributes: [TelegramMediaFileAttribute] = [.Video(duration: Int(duration), size: CGSize(width: CGFloat(w), height: CGFloat(h))), .FileName(fileName: "video.mov")]
|
var parsedAttributes: [TelegramMediaFileAttribute] = [.Video(duration: Int(duration), size: CGSize(width: CGFloat(w), height: CGFloat(h)), flags: []), .FileName(fileName: "video.mov")]
|
||||||
var previewRepresentations: [TelegramMediaImageRepresentation] = []
|
var previewRepresentations: [TelegramMediaImageRepresentation] = []
|
||||||
if thumb.size != 0 {
|
if thumb.size != 0 {
|
||||||
let resource = LocalFileMediaResource(fileId: arc4random64())
|
let resource = LocalFileMediaResource(fileId: arc4random64())
|
||||||
|
|||||||
@ -82,7 +82,7 @@ public struct SecretApi46 {
|
|||||||
return parser(reader)
|
return parser(reader)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print("Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
|
Logger.shared.log("TL", "Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ public struct SecretApi8 {
|
|||||||
return parser(reader)
|
return parser(reader)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print("Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
|
Logger.shared.log("TL", "Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,12 +42,26 @@ public enum StickerPackReference: Coding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct TelegramMediaVideoFlags: OptionSet {
|
||||||
|
public var rawValue: Int32
|
||||||
|
|
||||||
|
public init() {
|
||||||
|
self.rawValue = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(rawValue: Int32) {
|
||||||
|
self.rawValue = rawValue
|
||||||
|
}
|
||||||
|
|
||||||
|
public static let instantRoundVideo = TelegramMediaVideoFlags(rawValue: 1 << 0)
|
||||||
|
}
|
||||||
|
|
||||||
public enum TelegramMediaFileAttribute: Coding {
|
public enum TelegramMediaFileAttribute: Coding {
|
||||||
case FileName(fileName: String)
|
case FileName(fileName: String)
|
||||||
case Sticker(displayText: String, packReference: StickerPackReference?)
|
case Sticker(displayText: String, packReference: StickerPackReference?)
|
||||||
case ImageSize(size: CGSize)
|
case ImageSize(size: CGSize)
|
||||||
case Animated
|
case Animated
|
||||||
case Video(duration: Int, size: CGSize)
|
case Video(duration: Int, size: CGSize, flags: TelegramMediaVideoFlags)
|
||||||
case Audio(isVoice: Bool, duration: Int, title: String?, performer: String?, waveform: MemoryBuffer?)
|
case Audio(isVoice: Bool, duration: Int, title: String?, performer: String?, waveform: MemoryBuffer?)
|
||||||
case HasLinkedStickers
|
case HasLinkedStickers
|
||||||
|
|
||||||
@ -63,7 +77,7 @@ public enum TelegramMediaFileAttribute: Coding {
|
|||||||
case typeAnimated:
|
case typeAnimated:
|
||||||
self = .Animated
|
self = .Animated
|
||||||
case typeVideo:
|
case typeVideo:
|
||||||
self = .Video(duration: Int(decoder.decodeInt32ForKey("du")), size: CGSize(width: CGFloat(decoder.decodeInt32ForKey("w")), height: CGFloat(decoder.decodeInt32ForKey("h"))))
|
self = .Video(duration: Int(decoder.decodeInt32ForKey("du")), size: CGSize(width: CGFloat(decoder.decodeInt32ForKey("w")), height: CGFloat(decoder.decodeInt32ForKey("h"))), flags: TelegramMediaVideoFlags(rawValue: decoder.decodeInt32ForKey("f")))
|
||||||
case typeAudio:
|
case typeAudio:
|
||||||
let waveformBuffer = decoder.decodeBytesForKeyNoCopy("wf")
|
let waveformBuffer = decoder.decodeBytesForKeyNoCopy("wf")
|
||||||
var waveform: MemoryBuffer?
|
var waveform: MemoryBuffer?
|
||||||
@ -97,11 +111,12 @@ public enum TelegramMediaFileAttribute: Coding {
|
|||||||
encoder.encodeInt32(Int32(size.height), forKey: "h")
|
encoder.encodeInt32(Int32(size.height), forKey: "h")
|
||||||
case .Animated:
|
case .Animated:
|
||||||
encoder.encodeInt32(typeAnimated, forKey: "t")
|
encoder.encodeInt32(typeAnimated, forKey: "t")
|
||||||
case let .Video(duration, size):
|
case let .Video(duration, size, flags):
|
||||||
encoder.encodeInt32(typeVideo, forKey: "t")
|
encoder.encodeInt32(typeVideo, forKey: "t")
|
||||||
encoder.encodeInt32(Int32(duration), forKey: "du")
|
encoder.encodeInt32(Int32(duration), forKey: "du")
|
||||||
encoder.encodeInt32(Int32(size.width), forKey: "w")
|
encoder.encodeInt32(Int32(size.width), forKey: "w")
|
||||||
encoder.encodeInt32(Int32(size.height), forKey: "h")
|
encoder.encodeInt32(Int32(size.height), forKey: "h")
|
||||||
|
encoder.encodeInt32(flags.rawValue, forKey: "f")
|
||||||
case let .Audio(isVoice, duration, title, performer, waveform):
|
case let .Audio(isVoice, duration, title, performer, waveform):
|
||||||
encoder.encodeInt32(typeAudio, forKey: "t")
|
encoder.encodeInt32(typeAudio, forKey: "t")
|
||||||
encoder.encodeInt32(isVoice ? 1 : 0, forKey: "iv")
|
encoder.encodeInt32(isVoice ? 1 : 0, forKey: "iv")
|
||||||
@ -233,7 +248,7 @@ public final class TelegramMediaFile: Media, Equatable {
|
|||||||
public var dimensions: CGSize? {
|
public var dimensions: CGSize? {
|
||||||
for attribute in self.attributes {
|
for attribute in self.attributes {
|
||||||
switch attribute {
|
switch attribute {
|
||||||
case let .Video(_, size):
|
case let .Video(_, size, _):
|
||||||
return size
|
return size
|
||||||
case let .ImageSize(size):
|
case let .ImageSize(size):
|
||||||
return size
|
return size
|
||||||
@ -313,7 +328,11 @@ public func telegramMediaFileAttributesFromApiAttributes(_ attributes: [Api.Docu
|
|||||||
case .documentAttributeAnimated:
|
case .documentAttributeAnimated:
|
||||||
result.append(.Animated)
|
result.append(.Animated)
|
||||||
case let .documentAttributeVideo(flags, duration, w, h):
|
case let .documentAttributeVideo(flags, duration, w, h):
|
||||||
result.append(.Video(duration: Int(duration), size: CGSize(width: CGFloat(w), height: CGFloat(h))))
|
var videoFlags = TelegramMediaVideoFlags()
|
||||||
|
if (flags & (1 << 0)) != 0 {
|
||||||
|
videoFlags.insert(.instantRoundVideo)
|
||||||
|
}
|
||||||
|
result.append(.Video(duration: Int(duration), size: CGSize(width: CGFloat(w), height: CGFloat(h)), flags: videoFlags))
|
||||||
case let .documentAttributeAudio(flags, duration, title, performer, waveform):
|
case let .documentAttributeAudio(flags, duration, title, performer, waveform):
|
||||||
let isVoice = (flags & (1 << 10)) != 0
|
let isVoice = (flags & (1 << 10)) != 0
|
||||||
var waveformBuffer: MemoryBuffer?
|
var waveformBuffer: MemoryBuffer?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user