Zum Inhalt

apple/PhysarumApp/Sources/Capture/CaptureConfig.swift

import Foundation

enum PhotoFormat: String, CaseIterable, Identifiable, Equatable {
    case png, heic, livePhoto
    var id: String { rawValue }
    var label: String { self == .png ? "PNG" : self == .heic ? "HEIC" : "Live Photo" }
    var fileExtension: String { self == .heic ? "heic" : self == .livePhoto ? "heic" : "png" }
}

enum VideoCodec: String, CaseIterable, Identifiable, Equatable {
    case hevc, h264
    var id: String { rawValue }
    var label: String { self == .hevc ? "HEVC (.mov)" : "H.264 (.mp4)" }
    var fileExtension: String { self == .hevc ? "mov" : "mp4" }
}

enum CaptureKind: Equatable { case still; case video(durationSeconds: Int) }

struct CaptureConfig: Equatable {
    var kind: CaptureKind
    var longEdge: Int
    var fps: Int = 60
    var codec: VideoCodec = .hevc
    var photoFormat: PhotoFormat = .png

    static let stillSizes = [1080, 2048, 4096]
    static let videoSizes = [1280, 1920, 2560]
    static let videoDurations = [5, 10, 15, 30]
    static let defaultStill = CaptureConfig(kind: .still, longEdge: 2048)
    static let defaultVideo = CaptureConfig(kind: .video(durationSeconds: 10), longEdge: 1920)

    // iPad (fanless) drops the heaviest combos; macOS (cooling/RAM) and iPhone
    // (validated on device) keep the full ceilings. Capture is offline, but the
    // single heavy render still spikes thermals on a tablet.
    static func offeredStillSizes(idiom: DeviceIdiom) -> [Int] {
        idiom == .pad ? [1080, 2048] : stillSizes
    }
    static func offeredVideoSizes(idiom: DeviceIdiom) -> [Int] {
        idiom == .pad ? [1280, 1920] : videoSizes
    }
    static func offeredVideoDurations(idiom: DeviceIdiom) -> [Int] {
        idiom == .pad ? [5, 10, 15] : videoDurations
    }
}