 import Foundation
 import AVFoundation
 
-public enum ApertureError: Error {
-	case invalidScreen
-	case invalidAudioDevice
-	case couldNotAddScreen
-	case couldNotAddMic
-	case couldNotAddOutput
-}
-
 public final class Aperture: NSObject {
+	public enum Error: Swift.Error {
+		case invalidScreen
+		case invalidAudioDevice
+		case couldNotAddScreen
+		case couldNotAddMic
+		case couldNotAddOutput
+	}
+
 	private let destination: URL
 	private let session: AVCaptureSession
 	private let output: AVCaptureMovieFileOutput

		audioDevice: AVCaptureDevice? = .default(for: .audio),
		videoCodec: String? = nil
	) throws {
		let input = try AVCaptureScreenInput(displayID: screenId).unwrapOrThrow(ApertureError.invalidScreen)

		input.minFrameDuration = CMTime(videoFramesPerSecond: framesPerSecond)


			if session.canAddInput(audioInput) {
				session.addInput(audioInput)
			} else {
				throw Error.couldNotAddMic
			}
		}

		if session.canAddInput(input) {
			session.addInput(input)
		} else {
			throw Error.couldNotAddScreen
		}

		if session.canAddOutput(output) {
			session.addOutput(output)
		} else {
			throw Error.couldNotAddOutput
		}

		// TODO: Default to HEVC when on 10.13 or newer and encoding is hardware supported. Without hardware encoding I got 3 FPS full screen recording.
