AVCaptureDevice
An object that represents a hardware or virtual capture device like a camera or microphone.
Declaration
class AVCaptureDeviceMentioned in
Overview
Capture devices provide media data to capture session inputs that you connect to an AVCaptureSession. An individual device can provide one or more streams of media of a particular type.
You don’t create capture device instances directly. Instead, retrieve them using an instance of AVCaptureDevice.DiscoverySession, or by calling the default(_:for:position:) method.
A capture device provides several configuration options. Before attempting to configure device properties, such as its focus mode, exposure mode, and so on, you must first acquire a lock on the device by calling the lockForConfiguration() method. You should also query the device’s capabilities to ensure that the new modes you intend to set are valid for the device. You can then set the properties and release the lock using the unlockForConfiguration() method. You may hold the lock if you want all settable device properties to remain unchanged. However, holding the device lock unnecessarily may degrade capture quality in other apps sharing the device and isn’t recommended.
Topics
Finding and monitoring devices
AVCaptureDevice.DiscoverySessiondefault(_:for:position:)default(for:)init(uniqueID:)wasConnectedNotificationwasDisconnectedNotificationdevices(for:)devices()
Authorizing device access
Identifying a device
uniqueIDmodelIDlocalizedNamemanufacturerdeviceTypeAVCaptureDevice.DeviceTypepositionAVCaptureDevice.Position
Accessing device state
Inspecting device characteristics
Monitoring device rotation
Configuring camera hardware
lockForConfiguration()unlockForConfiguration()isSubjectAreaChangeMonitoringEnabledsubjectAreaDidChangeNotificationFormatsFocusExposureWhite balanceLightingColorZoom
Configuring Cinematic video
setCinematicVideoFixedFocus(at:focusMode:)setCinematicVideoTrackingFocus(at:focusMode:)setCinematicVideoTrackingFocus(detectedObjectID:focusMode:)AVCaptureDevice.CinematicVideoFocusModeAVCaptureSceneMonitoringStatusnotEnoughLightcinematicVideoCaptureSceneMonitoringStatuses
Configuring smart framing
Configuring dynamic aspect ratio
setDynamicAspectRatio(_:completionHandler:)AVCaptureDevice.AspectRatiodynamicAspectRatiodynamicDimensions
Enabling automatic frame rate
Supporting spatial capture
Supporting Continuity Camera
Supporting system features
Monitoring system pressure
systemPressureStateAVCaptureDevice.SystemPressureStateAVCaptureSessionInterruptionSystemPressureStateKey
Restricting camera switching
setPrimaryConstituentDeviceSwitchingBehavior(_:restrictedSwitchingBehaviorConditions:)primaryConstituentDeviceSwitchingBehaviorprimaryConstituentDeviceRestrictedSwitchingBehaviorConditionsactivePrimaryConstituentDeviceSwitchingBehavioractivePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditionsactivePrimaryConstituentAVCaptureDevice.PrimaryConstituentDeviceSwitchingBehaviorAVCaptureDevice.PrimaryConstituentDeviceRestrictedSwitchingBehaviorConditionssupportedFallbackPrimaryConstituentDevicesfallbackPrimaryConstituentDevices
Configuring macOS features
Accessing camera extrinsics
Accessing the focal length
Determining lens stabilization
Configuring lens smudge detection
isCameraLensSmudgeDetectionEnabledsetCameraLensSmudgeDetectionEnabled(_:detectionInterval:)cameraLensSmudgeDetectionIntervalcameraLensSmudgeDetectionStatusAVCaptureCameraLensSmudgeDetectionStatus
Synchronizing with external devices
isFollowingExternalSyncDeviceminSupportedExternalSyncFrameDurationisVideoFrameDurationLockedminSupportedLockedVideoFrameDuration