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)..