CaptureManager

Undocumented

  • Set up the AVCaptureSession.

    Important

    Recreates inputs/outputs based on sessionPreset.

    Throws

    CaptureManagerError.invalidSessionPreset if sessionPreset is not valid.

    Declaration

    Swift

    public func setUp(sessionPreset: String,
                      previewLayerProvider: VideoPreviewLayerProvider?,
                      inputs: [CaptureSessionInput],
                      outputs: [CaptureSessionOutput],
                      errorHandler: @escaping ErrorCompletionHandler)

    Parameters

    sessionPreset

    The sessionPreset for the AVCaptureSession.

    inputs

    A mask of options of type CaptureSessionInputs indicating what inputs to add to the AVCaptureSession.

    outputs

    A mask of options of type CaptureSessionOutputs indicating what outputs to add to the AVCaptureSession.

    errorHandler

    A closure of type (Error) -> Void. Called on the if anything performed inside of sessionQueue thread throws an error.

  • Start running the AVCaptureSession.

    Declaration

    Swift

    public func startRunning(_ errorHandler: ErrorCompletionHandler? = nil)
  • Stop running the AVCaptureSession.

    Declaration

    Swift

    public func stopRunning()
  • Capture a still image. - parameter completion: A closure of type (UIImage?, Error?) -> Void that is called on the main thread upon successful capture of the image or the occurence of an error.

    Declaration

    Swift

    public func captureStillImage(_ completion: @escaping ImageErrorCompletionHandler)

    Parameters

    completion

    A closure of type (UIImage?, Error?) -> Void that is called on the upon successful capture of the image or the occurence of an error.

  • Start recording a video. - parameter toOutputFileURL: The URL where the video is recorded to. - parameter recordingDelegate: The AVCaptureFileOutputRecordingDelegate for movieFileOutput. - Throws: CaptureManagerError.missingMovieOutput if movieFileOutput is nil.

    Declaration

    Swift

    public func startRecordingMovie(toOutputFileURL url: URL, recordingDelegate: AVCaptureFileOutputRecordingDelegate) throws

    Parameters

    toOutputFileURL

    The URL where the video is recorded to.

    recordingDelegate

    The AVCaptureFileOutputRecordingDelegate for movieFileOutput.

  • Stop recording a video. - Throws: CaptureManagerError.missingMovieOutput if movieFileOutput is nil.

    Declaration

    Swift

    public func stopRecordingMovie() throws
  • Toggles the position of the camera if possible. - parameter errorHandler: A closure of type Error -> Void that is called on the main thread if no opposite device or input was found.

    Declaration

    Swift

    public func toggleCamera(_ errorHandler: @escaping ErrorCompletionHandler)

    Parameters

    errorHandler

    A closure of type Error -> Void that is called on the if no opposite device or input was found.

  • Sets the AVCaptureFlashMode for videoDevice. - parameter mode: The AVCaptureFlashMode to set. - parameter errorHandler: A closure of type Error -> Void that is called on the main thread if an error occurs while setting the AVCaptureFlashMode.

    Declaration

    Swift

    public func setFlash(_ mode: AVCaptureFlashMode, errorHandler: ErrorCompletionHandler? = nil) throws

    Parameters

    mode

    The AVCaptureFlashMode to set.

    errorHandler

    A closure of type Error -> Void that is called on the if an error occurs while setting the AVCaptureFlashMode.

  • Toggles the AVCaptureFlashMode for videoDevice. - Important: If the current AVCaptureFlashMode is set to .auto, this will set it to .on.

    Declaration

    Swift

    public func toggleFlash(errorHandler: ErrorCompletionHandler? = nil) throws
  • Sets the AVCaptureTorchMode for videoDevice. - parameter mode: The AVCaptureTorchMode to set. - parameter errorHandler: A closure of type Error -> Void that is called on the main thread if an error occurs while setting the AVCaptureTorchMode.

    Declaration

    Swift

    public func setTorch(_ mode: AVCaptureTorchMode, errorHandler: ErrorCompletionHandler? = nil) throws

    Parameters

    mode

    The AVCaptureTorchMode to set.

    errorHandler

    A closure of type Error -> Void that is called on the if an error occurs while setting the AVCaptureTorchMode.

  • Toggles the AVCaptureTorchMode for videoDevice. - Important: If the current AVCaptureTorchMode is set to .auto, this will set it to .on.

    Declaration

    Swift

    public func toggleTorch(errorHandler: ErrorCompletionHandler? = nil) throws
  • Focuses the camera at pointInView. - parameter pointInView: The point inside of the AVCaptureVideoPreviewLayer. - parameter errorHandler: A closure of type Error -> Void that is called on the main thread if no device or previewLayerProvider was found or if we failed to lock the device for configuration. - Important: Do not normalize! This method handles the normalization for you. Simply pass in the point relative to the preview layer’s coordinate system.

    Declaration

    Swift

    public func focusAndExposure(at pointInView: CGPoint, errorHandler: ErrorCompletionHandler? = nil) throws

    Parameters

    pointInView

    The point inside of the AVCaptureVideoPreviewLayer.

    errorHandler

    A closure of type Error -> Void that is called on the if no device or previewLayerProvider was found or if we failed to lock the device for configuration.

  • Asynchronously refreshes the videoOrientation of the AVCaptureVideoPreviewLayer.

    Declaration

    Swift

    public func refreshOrientation()