diff --git a/TelegramCore/Api.swift b/TelegramCore/Api.swift index 1151e1f25f..5f601aa955 100644 --- a/TelegramCore/Api.swift +++ b/TelegramCore/Api.swift @@ -577,7 +577,7 @@ public struct Api { return parser(reader) } 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 } } diff --git a/TelegramCore/MacosLegacy.swift b/TelegramCore/MacosLegacy.swift index 45443a02f4..c3384c9250 100644 --- a/TelegramCore/MacosLegacy.swift +++ b/TelegramCore/MacosLegacy.swift @@ -79,7 +79,7 @@ public struct MacosLegacy { return parser(reader) } 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 } } diff --git a/TelegramCore/ManagedSecretChatOutgoingOperations.swift b/TelegramCore/ManagedSecretChatOutgoingOperations.swift index 2c85f95bab..f0bace05b5 100644 --- a/TelegramCore/ManagedSecretChatOutgoingOperations.swift +++ b/TelegramCore/ManagedSecretChatOutgoingOperations.swift @@ -408,7 +408,7 @@ private func decryptedAttributes46(_ attributes: [TelegramMediaFileAttribute]) - result.append(.documentAttributeSticker(alt: displayText, stickerset: stickerSet)) case let .ImageSize(size): 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))) case let .Audio(isVoice, duration, title, performer, waveform): var flags: Int32 = 0 diff --git a/TelegramCore/PendingMessageUploadedContent.swift b/TelegramCore/PendingMessageUploadedContent.swift index e026622782..9b7aa2c1a2 100644 --- a/TelegramCore/PendingMessageUploadedContent.swift +++ b/TelegramCore/PendingMessageUploadedContent.swift @@ -114,8 +114,12 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF attributes.append(.documentAttributeSticker(flags: flags, alt: displayText, stickerset: stickerSet, maskCoords: nil)) case .HasLinkedStickers: attributes.append(.documentAttributeHasStickers) - case let .Video(duration, size): - attributes.append(.documentAttributeVideo(flags: 0, duration: Int32(duration), w: Int32(size.width), h: Int32(size.height))) + case let .Video(duration, size, videoFlags): + 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): var flags: Int32 = 0 if isVoice { diff --git a/TelegramCore/ProcessSecretChatIncomingDecryptedOperations.swift b/TelegramCore/ProcessSecretChatIncomingDecryptedOperations.swift index fb2c569ac3..a0ca3c14c9 100644 --- a/TelegramCore/ProcessSecretChatIncomingDecryptedOperations.swift +++ b/TelegramCore/ProcessSecretChatIncomingDecryptedOperations.swift @@ -430,7 +430,7 @@ extension TelegramMediaFileAttribute { } self = .Sticker(displayText: alt, packReference: packReference) 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: return nil } @@ -497,7 +497,7 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 text = caption } 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] = [] if thumb.size != 0 { let resource = LocalFileMediaResource(fileId: arc4random64()) diff --git a/TelegramCore/SecretApiLayer46.swift b/TelegramCore/SecretApiLayer46.swift index 846e8526a8..e65a287291 100644 --- a/TelegramCore/SecretApiLayer46.swift +++ b/TelegramCore/SecretApiLayer46.swift @@ -82,7 +82,7 @@ public struct SecretApi46 { return parser(reader) } 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 } } diff --git a/TelegramCore/SecretApiLayer8.swift b/TelegramCore/SecretApiLayer8.swift index d01469d08d..6d40db2e40 100644 --- a/TelegramCore/SecretApiLayer8.swift +++ b/TelegramCore/SecretApiLayer8.swift @@ -48,7 +48,7 @@ public struct SecretApi8 { return parser(reader) } 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 } } diff --git a/TelegramCore/TelegramMediaFile.swift b/TelegramCore/TelegramMediaFile.swift index 4947c84f8e..1424ddee4c 100644 --- a/TelegramCore/TelegramMediaFile.swift +++ b/TelegramCore/TelegramMediaFile.swift @@ -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 { case FileName(fileName: String) case Sticker(displayText: String, packReference: StickerPackReference?) case ImageSize(size: CGSize) 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 HasLinkedStickers @@ -63,7 +77,7 @@ public enum TelegramMediaFileAttribute: Coding { case typeAnimated: self = .Animated 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: let waveformBuffer = decoder.decodeBytesForKeyNoCopy("wf") var waveform: MemoryBuffer? @@ -97,11 +111,12 @@ public enum TelegramMediaFileAttribute: Coding { encoder.encodeInt32(Int32(size.height), forKey: "h") case .Animated: encoder.encodeInt32(typeAnimated, forKey: "t") - case let .Video(duration, size): + case let .Video(duration, size, flags): encoder.encodeInt32(typeVideo, forKey: "t") encoder.encodeInt32(Int32(duration), forKey: "du") encoder.encodeInt32(Int32(size.width), forKey: "w") encoder.encodeInt32(Int32(size.height), forKey: "h") + encoder.encodeInt32(flags.rawValue, forKey: "f") case let .Audio(isVoice, duration, title, performer, waveform): encoder.encodeInt32(typeAudio, forKey: "t") encoder.encodeInt32(isVoice ? 1 : 0, forKey: "iv") @@ -233,7 +248,7 @@ public final class TelegramMediaFile: Media, Equatable { public var dimensions: CGSize? { for attribute in self.attributes { switch attribute { - case let .Video(_, size): + case let .Video(_, size, _): return size case let .ImageSize(size): return size @@ -313,7 +328,11 @@ public func telegramMediaFileAttributesFromApiAttributes(_ attributes: [Api.Docu case .documentAttributeAnimated: result.append(.Animated) 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): let isVoice = (flags & (1 << 10)) != 0 var waveformBuffer: MemoryBuffer?