Swiftgram/submodules/Postbox/Sources/MediaResource.swift
2021-09-24 11:59:21 +03:00

57 lines
1.3 KiB
Swift

import Foundation
public struct MediaResourceId: Equatable, Hashable {
public var stringRepresentation: String
public init(_ stringRepresentation: String) {
self.stringRepresentation = stringRepresentation
}
}
public protocol MediaResource {
var id: MediaResourceId { get }
var size: Int? { get }
var streamable: Bool { get }
var headerSize: Int32 { get }
func isEqual(to: MediaResource) -> Bool
}
public extension MediaResource {
var size: Int? {
return nil
}
var streamable: Bool {
return false
}
var headerSize: Int32 {
return 0
}
}
public protocol CachedMediaResourceRepresentation {
var uniqueId: String { get }
var keepDuration: CachedMediaRepresentationKeepDuration { get }
func isEqual(to: CachedMediaResourceRepresentation) -> Bool
}
public protocol MediaResourceFetchTag {
}
public protocol MediaResourceFetchInfo {
}
public struct MediaResourceFetchParameters {
public let tag: MediaResourceFetchTag?
public let info: MediaResourceFetchInfo?
public let isRandomAccessAllowed: Bool
public init(tag: MediaResourceFetchTag?, info: MediaResourceFetchInfo?, isRandomAccessAllowed: Bool) {
self.tag = tag
self.info = info
self.isRandomAccessAllowed = isRandomAccessAllowed
}
}