mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-24 11:56:18 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
61 lines
1.5 KiB
Swift
61 lines
1.5 KiB
Swift
import Foundation
|
|
import Postbox
|
|
import TelegramCore
|
|
|
|
private let minimalStreamableSize: Int = 384 * 1024
|
|
|
|
public func isMediaStreamable(message: Message, media: TelegramMediaFile) -> Bool {
|
|
if message.containsSecretMedia {
|
|
return false
|
|
}
|
|
if message.id.peerId.namespace == Namespaces.Peer.SecretChat {
|
|
return false
|
|
}
|
|
guard let size = media.size else {
|
|
return false
|
|
}
|
|
if size < minimalStreamableSize {
|
|
return false
|
|
}
|
|
for attribute in media.attributes {
|
|
if case let .Video(_, _, flags, _, _, _) = attribute {
|
|
if flags.contains(.supportsStreaming) || !media.alternativeRepresentations.isEmpty {
|
|
return true
|
|
}
|
|
break
|
|
}
|
|
}
|
|
#if DEBUG
|
|
if let fileName = media.fileName, fileName.hasSuffix(".mkv") {
|
|
return true
|
|
}
|
|
#endif
|
|
return false
|
|
}
|
|
|
|
public func isMediaStreamable(media: TelegramMediaFile) -> Bool {
|
|
guard let size = media.size else {
|
|
return false
|
|
}
|
|
if size < minimalStreamableSize {
|
|
return false
|
|
}
|
|
for attribute in media.attributes {
|
|
if case let .Video(_, _, flags, _, _, _) = attribute {
|
|
if flags.contains(.supportsStreaming) {
|
|
return true
|
|
}
|
|
break
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
public func isMediaStreamable(resource: MediaResource) -> Bool {
|
|
if let size = resource.size, size >= minimalStreamableSize {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|