You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.7 KiB
58 lines
1.7 KiB
import Foundation
|
|
|
|
/// An NDI source as seen on the network.
|
|
public struct Source: Codable, Hashable, Sendable {
|
|
public var ndiName: String
|
|
public var label: String
|
|
|
|
public init(ndiName: String, label: String? = nil) {
|
|
self.ndiName = ndiName
|
|
self.label = label ?? Source.defaultLabel(for: ndiName)
|
|
}
|
|
|
|
/// NDI names look like "MACHINE (Stream)". The stream part is the friendlier label.
|
|
public static func defaultLabel(for ndiName: String) -> String {
|
|
guard let open = ndiName.firstIndex(of: "("),
|
|
let close = ndiName.lastIndex(of: ")"),
|
|
open < close
|
|
else { return ndiName }
|
|
let inner = ndiName[ndiName.index(after: open)..<close].trimmingCharacters(in: .whitespaces)
|
|
return inner.isEmpty ? ndiName : inner
|
|
}
|
|
}
|
|
|
|
public enum Output: Codable, Hashable, Sendable {
|
|
case screen(displayID: UInt32)
|
|
case audioChannel(deviceUID: String, channel: Int)
|
|
}
|
|
|
|
public struct Route: Codable, Hashable, Sendable {
|
|
public enum Mode: String, Codable, Sendable { case videoAndAudio, videoOnly, audioOnly }
|
|
|
|
public var source: Source
|
|
public var output: Output
|
|
public var mode: Mode
|
|
|
|
public init(source: Source, output: Output, mode: Mode) {
|
|
self.source = source
|
|
self.output = output
|
|
self.mode = mode
|
|
}
|
|
}
|
|
|
|
public enum Role: String, Codable, Sendable { case control, node }
|
|
|
|
public struct Scene: Codable, Identifiable, Hashable, Sendable {
|
|
public var id: UUID
|
|
public var name: String
|
|
public var role: Role
|
|
public var routes: [Route]
|
|
|
|
public init(id: UUID = UUID(), name: String, role: Role, routes: [Route] = []) {
|
|
self.id = id
|
|
self.name = name
|
|
self.role = role
|
|
self.routes = routes
|
|
}
|
|
}
|