PlanetKitCameraManager

public class PlanetKitCameraManager : NSObject
extension PlanetKitCameraManager: PlanetKitVideoOutputDelegate

A class that manages the camera device.

  • The shared instance of the PlanetKitCameraManager.

    Declaration

    Swift

    @objc
    public static let shared: PlanetKitCameraManager
  • The delegate object that will receive camera events.

    Declaration

    Swift

    @objc
    public weak var delegate: PlanetKitCameraDelegate? { get set }

Preview management

  • Starts the camera preview.

    This method initiates the camera preview by adding the provided delegate to the preview stream. If the camera is not already started, it will start the camera with the default device.

    Declaration

    Swift

    @objc
    public func startPreview(delegate: PlanetKitVideoOutputDelegate)

    Parameters

    delegate

    An object conforming to PlanetKitVideoOutputDelegate that will receive the preview stream.

  • Stops the camera preview.

    This method removes the given delegate from the preview stream’s receivers. If there are no more receivers left, it stops the camera if it is currently running.

    Declaration

    Swift

    @objc
    public func stopPreview(delegate: PlanetKitVideoOutputDelegate)

    Parameters

    delegate

    The delegate that should stop receiving the preview stream.

  • Gets or sets the preview modifier.

    This property is used to modify the video stream for preview purposes. The delegate conforms to the PlanetKitVideoModifierDelegate protocol and provides the necessary methods to apply custom modifications to the video stream.

    Declaration

    Swift

    @objc
    public var previewModifier: PlanetKitVideoModifierDelegate? { get set }

Custom camera management

  • Sets a custom camera to the camera manager.

    Declaration

    Swift

    @objc
    public func setCustomCamera(_ customCamera: PlanetKitCustomCamera)

    Parameters

    camera

    An optional PlanetKitCameraControllable object representing the new custom camera to be set. If nil, the current camera will be removed without setting a new one.

  • Resets the camera to the default camera.

    Declaration

    Swift

    @objc
    public func resetToDefaultCamera()
  • Declaration

    Swift

    public func videoOutput(_ videoBuffer: PlanetKitVideoBuffer)

Camera functions

Virtual background

  • Gets or sets the virtual background.

    Remark

    The virtualBackground property is available on iOS 15.0 and macOS 12.0 or newer versions. Set virtualBackground with desired PlanetKitVirtualBackground settings to apply a virtual background. Set virtualBackground to nil to remove the virtual background. The default value is nil. For iOS: Due to the segmentation performance requirements, we recommend using this feature for iPhone 12 or newer models.

    Declaration

    Swift

    @available(iOS 15.0, macOS 12.0, *)
    @objc
    public var virtualBackground: PlanetKitVirtualBackground? { get set }

Camera devices

  • Returns an array of available video capture devices

    Declaration

    Swift

    @objc
    public var deviceInfos: [PlanetKitVideoCaptureDeviceInfo] { get }
  • A property that indicates whether the camera is available on the current platform.

    Declaration

    Swift

    @objc
    public static var isCameraAvailable: Bool { get }

    Return Value

    true if the camera is available, false otherwise.

Camera device change events