mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
@@ -223,7 +223,7 @@ public enum TelegramMediaFileAttribute: PostboxCoding, Equatable {
|
||||
case Sticker(displayText: String, packReference: StickerPackReference?, maskData: StickerMaskCoords?)
|
||||
case ImageSize(size: PixelDimensions)
|
||||
case Animated
|
||||
case Video(duration: Int, size: PixelDimensions, flags: TelegramMediaVideoFlags)
|
||||
case Video(duration: Int, size: PixelDimensions, flags: TelegramMediaVideoFlags, preloadSize: Int32?)
|
||||
case Audio(isVoice: Bool, duration: Int, title: String?, performer: String?, waveform: Data?)
|
||||
case HasLinkedStickers
|
||||
case hintFileIsLarge
|
||||
@@ -243,7 +243,7 @@ public enum TelegramMediaFileAttribute: PostboxCoding, Equatable {
|
||||
case typeAnimated:
|
||||
self = .Animated
|
||||
case typeVideo:
|
||||
self = .Video(duration: Int(decoder.decodeInt32ForKey("du", orElse: 0)), size: PixelDimensions(width: decoder.decodeInt32ForKey("w", orElse: 0), height: decoder.decodeInt32ForKey("h", orElse: 0)), flags: TelegramMediaVideoFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0)))
|
||||
self = .Video(duration: Int(decoder.decodeInt32ForKey("du", orElse: 0)), size: PixelDimensions(width: decoder.decodeInt32ForKey("w", orElse: 0), height: decoder.decodeInt32ForKey("h", orElse: 0)), flags: TelegramMediaVideoFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0)), preloadSize: decoder.decodeOptionalInt32ForKey("prs"))
|
||||
case typeAudio:
|
||||
let waveformBuffer = decoder.decodeBytesForKeyNoCopy("wf")
|
||||
var waveform: Data?
|
||||
@@ -290,12 +290,17 @@ public enum TelegramMediaFileAttribute: PostboxCoding, Equatable {
|
||||
encoder.encodeInt32(Int32(size.height), forKey: "h")
|
||||
case .Animated:
|
||||
encoder.encodeInt32(typeAnimated, forKey: "t")
|
||||
case let .Video(duration, size, flags):
|
||||
case let .Video(duration, size, flags, preloadSize):
|
||||
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")
|
||||
if let preloadSize = preloadSize {
|
||||
encoder.encodeInt32(preloadSize, forKey: "prs")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "prs")
|
||||
}
|
||||
case let .Audio(isVoice, duration, title, performer, waveform):
|
||||
encoder.encodeInt32(typeAudio, forKey: "t")
|
||||
encoder.encodeInt32(isVoice ? 1 : 0, forKey: "iv")
|
||||
@@ -568,13 +573,22 @@ public final class TelegramMediaFile: Media, Equatable, Codable {
|
||||
|
||||
public var isInstantVideo: Bool {
|
||||
for attribute in self.attributes {
|
||||
if case .Video(_, _, let flags) = attribute {
|
||||
if case .Video(_, _, let flags, _) = attribute {
|
||||
return flags.contains(.instantRoundVideo)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
public var preloadSize: Int32? {
|
||||
for attribute in self.attributes {
|
||||
if case .Video(_, _, _, let preloadSize) = attribute {
|
||||
return preloadSize
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
public var isAnimated: Bool {
|
||||
for attribute in self.attributes {
|
||||
if case .Animated = attribute {
|
||||
|
||||
Reference in New Issue
Block a user