 		audioDevice: AVCaptureDevice? = .default(for: .audio),
 		videoCodec: String? = nil
 	) throws {
-		let input = try AVCaptureScreenInput(displayID: screenId).unwrapOrThrow(ApertureError.invalidScreen)
+		let input = try AVCaptureScreenInput(displayID: screenId).unwrapOrThrow(Error.invalidScreen)
 
 		input.minFrameDuration = CMTime(videoFramesPerSecond: framesPerSecond)
 

import Foundation
import AVFoundation

public enum ApertureError: Error {
	case invalidScreen
	case invalidAudioDevice
	case couldNotAddScreen
	case couldNotAddMic
	case couldNotAddOutput
}

public final class Aperture: NSObject {
	private let destination: URL
	private let session: AVCaptureSession
	private let output: AVCaptureMovieFileOutput

			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.
