parent
d8863299ff
commit
981c9123a1
@ -0,0 +1,21 @@ |
|||||||
|
import Foundation |
||||||
|
|
||||||
|
public struct AuthResponse: Codable, Equatable, Sendable { |
||||||
|
public var hostName: String |
||||||
|
public var protocolVersion: Int |
||||||
|
|
||||||
|
public init(hostName: String, protocolVersion: Int) { |
||||||
|
self.hostName = hostName |
||||||
|
self.protocolVersion = protocolVersion |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public struct DBMetadata: Codable, Equatable, Sendable { |
||||||
|
public var checksum: String |
||||||
|
public var trackCount: Int |
||||||
|
|
||||||
|
public init(checksum: String, trackCount: Int) { |
||||||
|
self.checksum = checksum |
||||||
|
self.trackCount = trackCount |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
import Foundation |
||||||
|
|
||||||
|
public enum AppRole: String, Codable, CaseIterable, Sendable { |
||||||
|
case local |
||||||
|
case remoteHost |
||||||
|
case remoteClient |
||||||
|
case streamHost |
||||||
|
case streamClient |
||||||
|
} |
||||||
|
|
||||||
|
extension AppRole { |
||||||
|
public var isHost: Bool { self == .remoteHost || self == .streamHost } |
||||||
|
public var isClient: Bool { self == .remoteClient || self == .streamClient } |
||||||
|
public var isLocal: Bool { self == .local } |
||||||
|
public var usesLocalAudio: Bool { self == .local || self == .remoteHost || self == .streamClient } |
||||||
|
public var isReadOnlyLibrary: Bool { self == .remoteClient || self == .streamClient } |
||||||
|
public var needsNetworkServer: Bool { self == .remoteHost || self == .streamHost } |
||||||
|
public var isStreaming: Bool { self == .streamHost || self == .streamClient } |
||||||
|
} |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
import Foundation |
||||||
|
|
||||||
|
public enum StreamingConstants: Sendable { |
||||||
|
public static let defaultPort: Int = 8420 |
||||||
|
public static let segmentDuration: Double = 6.0 |
||||||
|
public static let protocolVersion: Int = 1 |
||||||
|
} |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
import Foundation |
||||||
|
|
||||||
|
public enum StreamingRoutes: Sendable { |
||||||
|
public static let auth = "/auth" |
||||||
|
public static let db = "/db" |
||||||
|
public static let ws = "/ws" |
||||||
|
|
||||||
|
public static func trackManifest(trackId: Int64) -> String { |
||||||
|
"/tracks/\(trackId)/stream.m3u8" |
||||||
|
} |
||||||
|
|
||||||
|
public static func trackSegment(trackId: Int64, index: Int) -> String { |
||||||
|
"/tracks/\(trackId)/segments/\(index).mp3" |
||||||
|
} |
||||||
|
|
||||||
|
public static func trackManifestPattern() -> String { |
||||||
|
"/tracks/:trackId/stream.m3u8" |
||||||
|
} |
||||||
|
|
||||||
|
public static func trackSegmentPattern() -> String { |
||||||
|
"/tracks/:trackId/segments/:index" |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue