Struct AVCaptureDevice

Source
#[repr(C)]
pub struct AVCaptureDevice { /* private fields */ }
Available on crate feature AVCaptureDevice only.
Expand description

An AVCaptureDevice represents a physical device that provides realtime input media data, such as video and audio.

Each instance of AVCaptureDevice corresponds to a device, such as a camera or microphone. Instances of AVCaptureDevice cannot be created directly. An array of all currently available devices can also be obtained using the AVCaptureDeviceDiscoverySession. Devices can provide one or more streams of a given media type. Applications can search for devices matching desired criteria by using AVCaptureDeviceDiscoverySession, or may obtain a reference to the default device matching desired criteria by using +[AVCaptureDevice defaultDeviceWithDeviceType:mediaType:position:].

Instances of AVCaptureDevice can be used to provide media data to an AVCaptureSession by creating an AVCaptureDeviceInput with the device and adding that to the capture session.

See also Apple’s documentation

Implementations§

Source§

impl AVCaptureDevice

Source

pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>

Source

pub unsafe fn new() -> Retained<Self>

Source

pub unsafe fn devices() -> Retained<NSArray<AVCaptureDevice>>

👎Deprecated: Use AVCaptureDeviceDiscoverySession instead.

Returns an array of devices currently available for use as media input sources.

Returns: An NSArray of AVCaptureDevice instances for each available device.

This method returns an array of AVCaptureDevice instances for input devices currently connected and available for capture. The returned array contains all devices that are available at the time the method is called. Applications should observe AVCaptureDeviceWasConnectedNotification and AVCaptureDeviceWasDisconnectedNotification to be notified when the list of available devices has changed.

Source

pub unsafe fn devicesWithMediaType( media_type: &AVMediaType, ) -> Retained<NSArray<AVCaptureDevice>>

👎Deprecated: Use AVCaptureDeviceDiscoverySession instead.
Available on crate feature AVMediaFormat only.

Returns an array of devices currently available for use as sources of media with the given media type.

Parameter mediaType: The media type, such as AVMediaTypeVideo, AVMediaTypeAudio, or AVMediaTypeMuxed, supported by each returned device.

Returns: An NSArray of AVCaptureDevice instances for each available device.

This method returns an array of AVCaptureDevice instances for input devices currently connected and available for capture that provide media of the given type. Media type constants are defined in AVMediaFormat.h. The returned array contains all devices that are available at the time the method is called. Applications should observe AVCaptureDeviceWasConnectedNotification and AVCaptureDeviceWasDisconnectedNotification to be notified when the list of available devices has changed.

Source

pub unsafe fn defaultDeviceWithMediaType( media_type: &AVMediaType, ) -> Option<Retained<AVCaptureDevice>>

Available on crate feature AVMediaFormat only.

Returns an AVCaptureDevice instance for the default device of the given media type.

Parameter mediaType: The media type, such as AVMediaTypeVideo, AVMediaTypeAudio, or AVMediaTypeMuxed, supported by the returned device.

Returns: The default device with the given media type, or nil if no device with that media type exists.

This method returns the default device of the given media type currently available on the system. For example, for AVMediaTypeVideo, this method will return the built in camera that is primarily used for capture and recording. Media type constants are defined in AVMediaFormat.h.

Source

pub unsafe fn deviceWithUniqueID( device_unique_id: &NSString, ) -> Option<Retained<AVCaptureDevice>>

Returns an AVCaptureDevice instance with the given unique ID.

Parameter deviceUniqueID: The unique ID of the device instance to be returned.

Returns: An AVCaptureDevice instance with the given unique ID, or nil if no device with that unique ID is available.

Every available capture device has a unique ID that persists on one system across device connections and disconnections, application restarts, and reboots of the system itself. This method can be used to recall or track the status of a specific device whose unique ID has previously been saved.

Source

pub unsafe fn uniqueID(&self) -> Retained<NSString>

An ID unique to the model of device corresponding to the receiver.

Every available capture device has a unique ID that persists on one system across device connections and disconnections, application restarts, and reboots of the system itself. Applications can store the value returned by this property to recall or track the status of a specific device in the future.

Source

pub unsafe fn modelID(&self) -> Retained<NSString>

The model ID of the receiver.

The value of this property is an identifier unique to all devices of the same model. The value is persistent across device connections and disconnections, and across different systems. For example, the model ID of the camera built in to two identical iPhone models will be the same even though they are different physical devices.

Source

pub unsafe fn localizedName(&self) -> Retained<NSString>

A localized human-readable name for the receiver.

This property can be used for displaying the name of a capture device in a user interface.

Source

pub unsafe fn manufacturer(&self) -> Retained<NSString>

The human-readable manufacturer name for the receiver.

This property can be used to identify capture devices from a particular manufacturer. All Apple devices return “Apple Inc.”. Devices from third party manufacturers may return an empty string.

Source

pub unsafe fn transportType(&self) -> i32

The transport type of the receiver (e.g. USB, PCI, etc).

This property can be used to discover the transport type of a capture device. Transport types are defined in <IOKit /audio/IOAudioTypes.h> as kIOAudioDeviceTransportType*.

Source

pub unsafe fn hasMediaType(&self, media_type: &AVMediaType) -> bool

Available on crate feature AVMediaFormat only.

Returns whether the receiver provides media with the given media type.

Parameter mediaType: A media type, such as AVMediaTypeVideo, AVMediaTypeAudio, or AVMediaTypeMuxed.

Returns: YES if the device outputs the given media type, NO otherwise.

Media type constants are defined in AVMediaFormat.h.

Source

pub unsafe fn lockForConfiguration(&self) -> Result<(), Retained<NSError>>

Requests exclusive access to configure device hardware properties.

Parameter outError: On return, if the device could not be locked, points to an NSError describing why the failure occurred.

Returns: A BOOL indicating whether the device was successfully locked for configuration.

In order to set hardware properties on an AVCaptureDevice, such as focusMode and exposureMode, clients must first acquire a lock on the device. Clients should only hold the device lock if they require settable device properties to remain unchanged. Holding the device lock unnecessarily may degrade capture quality in other applications sharing the device.

Source

pub unsafe fn unlockForConfiguration(&self)

Release exclusive control over device hardware properties.

This method should be called to match an invocation of lockForConfiguration: when an application no longer needs to keep device hardware properties from changing automatically.

Source

pub unsafe fn supportsAVCaptureSessionPreset( &self, preset: &AVCaptureSessionPreset, ) -> bool

Available on crate feature AVCaptureSessionPreset only.

Returns whether the receiver can be used in an AVCaptureSession configured with the given preset.

Parameter preset: An AVCaptureSession preset.

Returns: YES if the receiver can be used with the given preset, NO otherwise.

An AVCaptureSession instance can be associated with a preset that configures its inputs and outputs to fulfill common use cases. This method can be used to determine if the receiver can be used in a capture session with the given preset. Presets are defined in AVCaptureSession.h.

Source

pub unsafe fn isConnected(&self) -> bool

Indicates whether the device is connected and available to the system.

The value of this property is a BOOL indicating whether the device represented by the receiver is connected and available for use as a capture device. Clients can key value observe the value of this property to be notified when a device is no longer available. When the value of this property becomes NO for a given instance, it will not become YES again. If the same physical device again becomes available to the system, it will be represented using a new instance of AVCaptureDevice.

Source

pub unsafe fn isInUseByAnotherApplication(&self) -> bool

Indicates whether the device is in use by another application.

The value of this property is a BOOL indicating whether the device represented by the receiver is in use by another application. Clients can key value observe the value of this property to be notified when another app starts or stops using this device.

Source

pub unsafe fn isSuspended(&self) -> bool

Indicates whether the device is suspended.

The value of this property is a BOOL indicating whether the device represented by the receiver is currently suspended. Some devices disallow data capture due to a feature on the device. For example, isSuspended returns YES for the external iSight when its privacy iris is closed, or for the internal iSight on a notebook when the notebook’s display is closed. Clients can key value observe the value of this property to be notified when the device becomes suspended or unsuspended.

Source

pub unsafe fn linkedDevices(&self) -> Retained<NSArray<AVCaptureDevice>>

An array of AVCaptureDevice objects physically linked to the receiver.

The value of this property is an array of AVCaptureDevice objects that are a part of the same physical device as the receiver. For example, for the external iSight camera, linkedDevices returns an array containing an AVCaptureDevice for the external iSight microphone.

Source

pub unsafe fn formats(&self) -> Retained<NSArray<AVCaptureDeviceFormat>>

An array of AVCaptureDeviceFormat objects supported by the receiver.

This property can be used to enumerate the formats natively supported by the receiver. The capture device’s activeFormat property may be set to one of the formats in this array. Clients can observe automatic changes to the receiver’s formats by key value observing this property.

Source

pub unsafe fn activeFormat(&self) -> Retained<AVCaptureDeviceFormat>

The currently active format of the receiver.

This property can be used to get or set the currently active device format.

-setActiveFormat: throws an NSInvalidArgumentException if set to a format not present in the formats array.

-setActiveFormat: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:.

Clients can observe automatic changes to the receiver’s activeFormat by key value observing this property.

On iOS, use of AVCaptureDevice’s setActiveFormat: and AVCaptureSession’s setSessionPreset: are mutually exclusive. If you set a capture device’s active format, the session to which it is attached changes its preset to AVCaptureSessionPresetInputPriority. Likewise if you set the AVCaptureSession’s sessionPreset property, the session assumes control of its input devices, and configures their activeFormat appropriately. Note that audio devices do not expose any user-configurable formats on iOS. To configure audio input on iOS, you should use the AVAudioSession APIs instead (see AVAudioSession.h).

The activeFormat, activeVideoMinFrameDuration, and activeVideoMaxFrameDuration properties may be set simultaneously by using AVCaptureSession’s begin/commitConfiguration methods:

[session beginConfiguration]; // the session to which the receiver’s AVCaptureDeviceInput is added. if ( [device lockForConfiguration: &error ] ) { [device setActiveFormat:newFormat]; [device setActiveVideoMinFrameDuration:newMinDuration]; [device setActiveVideoMaxFrameDuration:newMaxDuration]; [device unlockForConfiguration]; } [session commitConfiguration]; // The new format and frame rates are applied together in commitConfiguration

Note that when configuring a session to use an active format intended for high resolution still photography and applying one or more of the following operations to an AVCaptureVideoDataOutput, the system may not meet the target framerate: zoom, orientation changes, format conversion.

Source

pub unsafe fn setActiveFormat(&self, active_format: &AVCaptureDeviceFormat)

Setter for activeFormat.

Source

pub unsafe fn activeVideoMinFrameDuration(&self) -> CMTime

Available on crate feature objc2-core-media only.

A property indicating the receiver’s current active minimum frame duration (the reciprocal of its max frame rate).

An AVCaptureDevice’s activeVideoMinFrameDuration property is the reciprocal of its active maximum frame rate. To limit the max frame rate of the capture device, clients may set this property to a value supported by the receiver’s activeFormat (see AVCaptureDeviceFormat’s videoSupportedFrameRateRanges property). Clients may set this property’s value to kCMTimeInvalid to return activeVideoMinFrameDuration to its default value for the given activeFormat.

-setActiveVideoMinFrameDuration: throws an NSInvalidArgumentException if set to an unsupported value.

-setActiveVideoMinFrameDuration: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:.

Clients can observe automatic changes to the receiver’s activeVideoMinFrameDuration by key value observing this property.

On iOS, the receiver’s activeVideoMinFrameDuration resets to its default value under the following conditions:

  • The receiver’s activeFormat changes
  • The receiver’s AVCaptureDeviceInput’s session’s sessionPreset changes
  • The receiver’s AVCaptureDeviceInput is added to a session

When exposureMode is AVCaptureExposureModeCustom, setting the activeVideoMinFrameDuration affects max frame rate, but not exposureDuration. You may use setExposureModeCustomWithDuration:ISO:completionHandler: to set a shorter exposureDuration than your activeVideoMinFrameDuration, if desired.

When autoVideoFrameRateEnabled is true, setting activeVideoMinFrameDuration throws an NSInvalidArgumentException.

Source

pub unsafe fn setActiveVideoMinFrameDuration( &self, active_video_min_frame_duration: CMTime, )

Available on crate feature objc2-core-media only.
Source

pub unsafe fn activeVideoMaxFrameDuration(&self) -> CMTime

Available on crate feature objc2-core-media only.

A property indicating the receiver’s current active maximum frame duration (the reciprocal of its min frame rate).

An AVCaptureDevice’s activeVideoMaxFrameDuration property is the reciprocal of its active minimum frame rate. To limit the min frame rate of the capture device, clients may set this property to a value supported by the receiver’s activeFormat (see AVCaptureDeviceFormat’s videoSupportedFrameRateRanges property). Clients may set this property’s value to kCMTimeInvalid to return activeVideoMaxFrameDuration to its default value for the given activeFormat.

-setActiveVideoMaxFrameDuration: throws an NSInvalidArgumentException if set to an unsupported value.

-setActiveVideoMaxFrameDuration: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:.

Clients can observe automatic changes to the receiver’s activeVideoMaxFrameDuration by key value observing this property.

On iOS, the receiver’s activeVideoMaxFrameDuration resets to its default value under the following conditions:

  • The receiver’s activeFormat changes
  • The receiver’s AVCaptureDeviceInput’s session’s sessionPreset changes
  • The receiver’s AVCaptureDeviceInput is added to a session

When exposureMode is AVCaptureExposureModeCustom, frame rate and exposure duration are interrelated. If you call setExposureModeCustomWithDuration:ISO:completionHandler: with an exposureDuration longer than the current activeVideoMaxFrameDuration, the activeVideoMaxFrameDuration will be lengthened to accommodate the longer exposure time. Setting a shorter exposure duration does not automatically change the activeVideoMinFrameDuration or activeVideoMaxFrameDuration. To explicitly increase the frame rate in custom exposure mode, you must set the activeVideoMaxFrameDuration to a shorter value. If your new max frame duration is shorter than the current exposureDuration, the exposureDuration will shorten as well to accommodate the new frame rate.

When autoVideoFrameRateEnabled is true, setting activeVideoMaxFrameDuration throws an NSInvalidArgumentException.

Source

pub unsafe fn setActiveVideoMaxFrameDuration( &self, active_video_max_frame_duration: CMTime, )

Available on crate feature objc2-core-media only.
Source

pub unsafe fn isAutoVideoFrameRateEnabled(&self) -> bool

Indicates whether the receiver should enable auto video frame rate.

When enabled the receiver automatically adjusts the active frame rate, depending on light level. Under low light conditions, frame rate is decreased to properly expose the scene. For formats with a maximum frame rate of 30 fps, the frame rate switches between 30 - 24. For formats with a maximum frame rate of 60 fps, the frame rate switches between 60 - 30 - 24.

Setting this property throws an NSInvalidArgumentException if the active format’s -isAutoVideoFrameRateSupported returns NO. Changing the device’s active format resets isAutoVideoFrameRateEnabled to its default value of NO.

When autoVideoFrameRateEnabled is true, setting activeVideoMinFrameDuration or activeVideoMaxFrameDuration throws an NSInvalidArgumentException.

Source

pub unsafe fn setAutoVideoFrameRateEnabled( &self, auto_video_frame_rate_enabled: bool, )

Source

pub unsafe fn inputSources( &self, ) -> Retained<NSArray<AVCaptureDeviceInputSource>>

An array of AVCaptureDeviceInputSource objects supported by the receiver.

Some devices can capture data from one of multiple data sources (different input jacks on the same audio device, for example). For devices with multiple possible data sources, inputSources can be used to enumerate the possible choices. Clients can observe automatic changes to the receiver’s inputSources by key value observing this property.

Source

pub unsafe fn activeInputSource( &self, ) -> Option<Retained<AVCaptureDeviceInputSource>>

The currently active input source of the receiver.

This property can be used to get or set the currently active device input source. -setActiveInputSource: throws an NSInvalidArgumentException if set to a value not present in the inputSources array. -setActiveInputSource: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. Clients can observe automatic changes to the receiver’s activeInputSource by key value observing this property.

Source

pub unsafe fn setActiveInputSource( &self, active_input_source: Option<&AVCaptureDeviceInputSource>, )

Setter for activeInputSource.

Source§

impl AVCaptureDevice

AVCaptureDevicePosition.

Source

pub unsafe fn position(&self) -> AVCaptureDevicePosition

Indicates the physical position of an AVCaptureDevice’s hardware on the system.

The value of this property is an AVCaptureDevicePosition indicating where the receiver’s device is physically located on the system hardware.

Source§

impl AVCaptureDevice

AVCaptureDeviceType.

Source

pub unsafe fn deviceType(&self) -> Retained<AVCaptureDeviceType>

The type of the capture device.

A capture device’s type never changes.

Source§

impl AVCaptureDevice

AVCaptureDefaultDevice.

Source

pub unsafe fn defaultDeviceWithDeviceType_mediaType_position( device_type: &AVCaptureDeviceType, media_type: Option<&AVMediaType>, position: AVCaptureDevicePosition, ) -> Option<Retained<AVCaptureDevice>>

Available on crate feature AVMediaFormat only.

Returns an AVCaptureDevice instance for the default device of the given device type, media type, and position.

Parameter deviceType: The device type supported by the returned device. It must be a valid AVCaptureDeviceType.

Parameter mediaType: The media type, such as AVMediaTypeVideo, AVMediaTypeAudio, or AVMediaTypeMuxed, supported by the returned device. Pass nil to consider devices with any media type.

Parameter position: The position supported by the returned device. Pass AVCaptureDevicePositionUnspecified to consider devices with any position.

Returns: The default device with the given device type, media type and position or nil if no device with that media type exists and nil otherwise.

This method returns the default device of the given combination of device type, media type, and position currently available on the system.

Source§

impl AVCaptureDevice

AVCaptureDevicePreferredCamera.

Source

pub unsafe fn userPreferredCamera() -> Option<Retained<AVCaptureDevice>>

Settable property that specifies a user preferred camera.

Setting this property allows an application to persist its user’s preferred camera across app launches and reboots. The property internally maintains a short history, so if your user’s most recent preferred camera is not currently connected, it still reports the next best choice. This property always returns a device that is present. If no camera is available nil is returned. Setting the property to nil has no effect.

Source

pub unsafe fn setUserPreferredCamera( user_preferred_camera: Option<&AVCaptureDevice>, )

Setter for userPreferredCamera.

Source

pub unsafe fn systemPreferredCamera() -> Option<Retained<AVCaptureDevice>>

Specifies the best camera to use as determined by the system.

Apple chooses the default value. This property incorporates userPreferredCamera as well as other factors, such as camera suspension and Apple cameras appearing that should be automatically chosen. The property may change spontaneously, such as when the preferred camera goes away. This property always returns a device that is present. If no camera is available nil is returned.

Applications that adopt this API should always key-value observe this property and update their AVCaptureSession’s input device to reflect changes to the systemPreferredCamera. The application can still offer users the ability to pick a camera by setting userPreferredCamera, which will cause the systemPreferredCamera API to put the user’s choice first until either another Apple-preferred device becomes available or the machine is rebooted (after which it reverts to its original behavior of returning the internally determined best camera to use).

If the application wishes to offer users a fully manual camera selection mode in addition to automatic camera selection, it is recommended to call setUserPreferredCamera: each time the user makes a camera selection, but ignore key-value observer updates to systemPreferredCamera while in manual selection mode.

Source§

impl AVCaptureDevice

AVCaptureDeviceSystemPressure.

Source

pub unsafe fn systemPressureState( &self, ) -> Retained<AVCaptureSystemPressureState>

Available on crate feature AVCaptureSystemPressure only.

A key-value observable property indicating the capture device’s current system pressure state.

This property indicates whether the capture device is currently subject to an elevated system pressure condition. When system pressure reaches AVCaptureSystemPressureLevelShutdown, the capture device cannot continue to provide input, so the AVCaptureSession becomes interrupted until the pressured state abates. System pressure can be effectively mitigated by lowering the device’s activeVideoMinFrameDuration in response to changes in the systemPressureState. Clients are encouraged to implement frame rate throttling to bring system pressure down if their capture use case can tolerate a reduced frame rate.

Source§

impl AVCaptureDevice

AVCaptureDeviceVirtual.

Source

pub unsafe fn isVirtualDevice(&self) -> bool

A property indicating whether the receiver is a virtual device consisting of constituent physical devices.

Two examples of virtual devices are: The Dual Camera, which supports seamlessly switching between a wide and telephoto camera while zooming and generating depth data from the disparities between the different points of view of the physical cameras. The TrueDepth Camera, which generates depth data from disparities between a YUV camera and an Infrared camera pointed in the same direction.

Source

pub unsafe fn constituentDevices(&self) -> Retained<NSArray<AVCaptureDevice>>

An array of constituent physical devices comprising a virtual device.

When called on a device for which virtualDevice == NO, an empty array is returned.

Source

pub unsafe fn virtualDeviceSwitchOverVideoZoomFactors( &self, ) -> Retained<NSArray<NSNumber>>

An array of video zoom factors at or above which a virtual device (such as the Dual Camera) may switch to its next constituent device.

This array contains zoom factors at which one of the constituent device’s field of view matches the next constituent device’s full field of view. The number of switch over video zoom factors is always one less than the count of the constituentDevices property, and the factors progress in the same order as the devices listed in that property. On non-virtual devices this property returns an empty array.

Source

pub unsafe fn setPrimaryConstituentDeviceSwitchingBehavior_restrictedSwitchingBehaviorConditions( &self, switching_behavior: AVCapturePrimaryConstituentDeviceSwitchingBehavior, restricted_switching_behavior_conditions: AVCapturePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditions, )

The switching behavior and conditions, unless overwritten via -[AVCaptureMovieFileOutput setPrimaryConstituentDeviceSwitchingBehavior:restrictedSwitchingBehaviorConditions].

Parameter switchingBehavior: The desired switching behavior.

Parameter restrictedSwitchingBehaviorConditions: The desired conditions for restricting camera switching. This must be set to AVCapturePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditionNone whenever switchingBehavior is not equal to AVCapturePrimaryConstituentDeviceSwitchingBehaviorRestricted.

The switching behavior may be overridden on the AVCaptureMovieFileOutput while recording (see -[AVCaptureMovieFileOutput setPrimaryConstituentDeviceSwitchingBehavior:restrictedSwitchingBehaviorConditions]). This method throws an NSInvalidArgumentException if constituent device switching is not supported by the receiver or if restrictedSwitchingBehaviorConditions is not equal to AVCapturePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditionNone and switchingBehavior is not equal to AVCapturePrimaryConstituentDeviceSwitchingBehaviorRestricted.

Source

pub unsafe fn primaryConstituentDeviceSwitchingBehavior( &self, ) -> AVCapturePrimaryConstituentDeviceSwitchingBehavior

The primaryConstituentDeviceSwitchingBehavior as set by -[AVCaptureDevice setPrimaryConstituentDeviceSwitchingBehavior:restrictedSwitchingBehaviorConditions:].

By default, this property is set to AVCapturePrimaryConstituentDeviceSwitchingBehaviorAuto for AVCaptureDevices that support it. This property is key-value observable.

Source

pub unsafe fn primaryConstituentDeviceRestrictedSwitchingBehaviorConditions( &self, ) -> AVCapturePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditions

The primaryConstituentDeviceRestrictedSwitchingBehaviorConditions as set by -[AVCaptureDevice setPrimaryConstituentDeviceSwitchingBehavior:restrictedSwitchingBehaviorConditions:].

By default, this propety is set to AVCapturePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditionNone. This property is key-value observable.

Source

pub unsafe fn activePrimaryConstituentDeviceSwitchingBehavior( &self, ) -> AVCapturePrimaryConstituentDeviceSwitchingBehavior

The active constituent device switching behavior.

For virtual devices with multiple constituent devices, this property returns the active switching behavior. This is equal to primaryConstituentDeviceSwitchingBehavior except while recording using an AVCaptureMovieFileOutput configured with a different switching behavior (see -[AVCaptureMovieFileOutput setPrimaryConstituentDeviceSwitchingBehavior:restrictedSwitchingBehaviorConditions]). Devices that do not support constituent device switching return AVCapturePrimaryConstituentDeviceSwitchingBehaviorUnsupported. This property is key-value observable.

Source

pub unsafe fn activePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditions( &self, ) -> AVCapturePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditions

The active constituent device restricted switching behavior.

For virtual devices with multiple constituent devices, this property returns the active restricted switching behavior conditions. This is equal to primaryConstituentDeviceRestrictedSwitchingBehaviorConditions except while recording using an AVCaptureMovieFileOutput configured with different retricted switching behavior conditions (see -[AVCaptureMovieFileOutput setPrimaryConstituentDeviceSwitchingBehaviorForRecording:restrictedSwitchingBehaviorConditions]). Devices that do not support constituent device switching return AVCapturePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditionNone. This property is key-value observable.

Source

pub unsafe fn activePrimaryConstituentDevice( &self, ) -> Option<Retained<AVCaptureDevice>>

For virtual devices, this property indicates which constituent device is currently the primary constituent device. The primary constituent device may change when zoom, exposure, or focus changes.

This property returns nil for non-virtual devices. On virtual devices this property returns nil until the device is used in a running AVCaptureSession. This property is key-value observable.

Source

pub unsafe fn supportedFallbackPrimaryConstituentDevices( &self, ) -> Retained<NSArray<AVCaptureDevice>>

The constituent devices that may be selected as a fallback for a longer focal length primary constituent device.

This property returns an empty array for non-virtual devices. This property never changes for a given virtual device.

Source

pub unsafe fn fallbackPrimaryConstituentDevices( &self, ) -> Retained<NSArray<AVCaptureDevice>>

The constituent devices that may be used as a fallback device when a constituent device with a longer focal length becomes limited by its light sensitivity or minimum focus distance.

This may only be set to the supportedFallbackPrimaryConstituentDevices or a subset thereof. By default this is set to all supportedFallbackPrimaryConstituentDevices. This property will throw an NSInvalidArgumentException if the array includes any device not reported in supportedFallbackPrimaryConstituentDevices. This property is key-value observable.

Source

pub unsafe fn setFallbackPrimaryConstituentDevices( &self, fallback_primary_constituent_devices: &NSArray<AVCaptureDevice>, )

Source§

impl AVCaptureDevice

AVCaptureDeviceFlash.

Source

pub unsafe fn hasFlash(&self) -> bool

Indicates whether the receiver has a flash.

The value of this property is a BOOL indicating whether the receiver has a flash. The receiver’s flashMode property can only be set when this property returns YES.

Source

pub unsafe fn isFlashAvailable(&self) -> bool

Indicates whether the receiver’s flash is currently available for use.

The value of this property is a BOOL indicating whether the receiver’s flash is currently available. The flash may become unavailable if, for example, the device overheats and needs to cool off. This property is key-value observable.

Source

pub unsafe fn isFlashActive(&self) -> bool

👎Deprecated: Use AVCapturePhotoOutput’s -isFlashScene instead.

Indicates whether the receiver’s flash is currently active.

The value of this property is a BOOL indicating whether the receiver’s flash is currently active. When the flash is active, it will flash if a still image is captured. When a still image is captured with the flash active, exposure and white balance settings are overridden for the still. This is true even when using AVCaptureExposureModeCustom and/or AVCaptureWhiteBalanceModeLocked. This property is key-value observable.

Source

pub unsafe fn isFlashModeSupported( &self, flash_mode: AVCaptureFlashMode, ) -> bool

👎Deprecated: Use AVCapturePhotoOutput’s -supportedFlashModes instead.

Returns whether the receiver supports the given flash mode.

Parameter flashMode: An AVCaptureFlashMode to be checked.

Returns: YES if the receiver supports the given flash mode, NO otherwise.

The receiver’s flashMode property can only be set to a certain mode if this method returns YES for that mode.

Source

pub unsafe fn flashMode(&self) -> AVCaptureFlashMode

👎Deprecated: Use AVCapturePhotoSettings.flashMode instead.

Indicates current mode of the receiver’s flash, if it has one.

The value of this property is an AVCaptureFlashMode that determines the mode of the receiver’s flash, if it has one. -setFlashMode: throws an NSInvalidArgumentException if set to an unsupported value (see -isFlashModeSupported:). -setFlashMode: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. Clients can observe automatic changes to the receiver’s flashMode by key value observing this property.

When using AVCapturePhotoOutput, AVCaptureDevice’s flashMode property is ignored. You specify flashMode on a per photo basis by setting the AVCapturePhotoSettings.flashMode property.

Source

pub unsafe fn setFlashMode(&self, flash_mode: AVCaptureFlashMode)

👎Deprecated: Use AVCapturePhotoSettings.flashMode instead.

Setter for flashMode.

Source§

impl AVCaptureDevice

AVCaptureDeviceTorch.

Source

pub unsafe fn hasTorch(&self) -> bool

Indicates whether the receiver has a torch.

The value of this property is a BOOL indicating whether the receiver has a torch. The receiver’s torchMode property can only be set when this property returns YES.

Source

pub unsafe fn isTorchAvailable(&self) -> bool

Indicates whether the receiver’s torch is currently available for use.

The value of this property is a BOOL indicating whether the receiver’s torch is currently available. The torch may become unavailable if, for example, the device overheats and needs to cool off. This property is key-value observable.

Source

pub unsafe fn isTorchActive(&self) -> bool

Indicates whether the receiver’s torch is currently active.

The value of this property is a BOOL indicating whether the receiver’s torch is currently active. If the current torchMode is AVCaptureTorchModeAuto and isTorchActive is YES, the torch will illuminate once a recording starts (see AVCaptureOutput.h -startRecordingToOutputFileURL:recordingDelegate:). This property is key-value observable.

Source

pub unsafe fn torchLevel(&self) -> c_float

Indicates the receiver’s current torch brightness level as a floating point value.

The value of this property is a float indicating the receiver’s torch level from 0.0 (off) -> 1.0 (full). This property is key-value observable.

Source

pub unsafe fn isTorchModeSupported( &self, torch_mode: AVCaptureTorchMode, ) -> bool

Returns whether the receiver supports the given torch mode.

Parameter torchMode: An AVCaptureTorchMode to be checked.

Returns: YES if the receiver supports the given torch mode, NO otherwise.

The receiver’s torchMode property can only be set to a certain mode if this method returns YES for that mode.

Source

pub unsafe fn torchMode(&self) -> AVCaptureTorchMode

Indicates current mode of the receiver’s torch, if it has one.

The value of this property is an AVCaptureTorchMode that determines the mode of the receiver’s torch, if it has one. -setTorchMode: throws an NSInvalidArgumentException if set to an unsupported value (see -isTorchModeSupported:). -setTorchMode: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. Clients can observe automatic changes to the receiver’s torchMode by key value observing this property.

Source

pub unsafe fn setTorchMode(&self, torch_mode: AVCaptureTorchMode)

Setter for torchMode.

Source

pub unsafe fn setTorchModeOnWithLevel_error( &self, torch_level: c_float, ) -> Result<(), Retained<NSError>>

Sets the current mode of the receiver’s torch to AVCaptureTorchModeOn at the specified level.

This method sets the torch mode to AVCaptureTorchModeOn at a specified level. torchLevel must be a value between 0 and 1, or the special value AVCaptureMaxAvailableTorchLevel. The specified value may not be available if the iOS device is too hot. This method throws an NSInvalidArgumentException if set to an unsupported level. If the specified level is valid, but unavailable, the method returns NO with AVErrorTorchLevelUnavailable. -setTorchModeOnWithLevel:error: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. Clients can observe automatic changes to the receiver’s torchMode by key value observing the torchMode property.

Source§

impl AVCaptureDevice

AVCaptureDeviceFocus.

Source

pub unsafe fn isFocusModeSupported( &self, focus_mode: AVCaptureFocusMode, ) -> bool

Returns whether the receiver supports the given focus mode.

Parameter focusMode: An AVCaptureFocusMode to be checked.

Returns: YES if the receiver supports the given focus mode, NO otherwise.

The receiver’s focusMode property can only be set to a certain mode if this method returns YES for that mode.

Source

pub unsafe fn isLockingFocusWithCustomLensPositionSupported(&self) -> bool

Indicates whether the receiver supports a lens position other than AVCaptureLensPositionCurrent.

If lockingFocusWithCustomLensPositionSupported returns NO, setFocusModeLockedWithLensPosition: may only be called with AVCaptureLensPositionCurrent. Passing any other lens position will result in an exception.

Source

pub unsafe fn focusMode(&self) -> AVCaptureFocusMode

Indicates current focus mode of the receiver, if it has one.

The value of this property is an AVCaptureFocusMode that determines the receiver’s focus mode, if it has one. -setFocusMode: throws an NSInvalidArgumentException if set to an unsupported value (see -isFocusModeSupported:). -setFocusMode: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. Clients can observe automatic changes to the receiver’s focusMode by key value observing this property.

Source

pub unsafe fn setFocusMode(&self, focus_mode: AVCaptureFocusMode)

Setter for focusMode.

Source

pub unsafe fn isFocusPointOfInterestSupported(&self) -> bool

Indicates whether the receiver supports focus points of interest.

The receiver’s focusPointOfInterest property can only be set if this property returns YES.

Source

pub unsafe fn focusPointOfInterest(&self) -> CGPoint

Available on crate feature objc2-core-foundation only.

Indicates current focus point of interest of the receiver, if it has one.

The value of this property is a CGPoint that determines the receiver’s focus point of interest, if it has one. A value of (0,0) indicates that the camera should focus on the top left corner of the image, while a value of (1,1) indicates that it should focus on the bottom right. The default value is (0.5,0.5). -setFocusPointOfInterest: throws an NSInvalidArgumentException if isFocusPointOfInterestSupported returns NO. -setFocusPointOfInterest: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. Clients can observe automatic changes to the receiver’s focusPointOfInterest by key value observing this property. Note that setting focusPointOfInterest alone does not initiate a focus operation. After setting focusPointOfInterest, call -setFocusMode: to apply the new point of interest.

Source

pub unsafe fn setFocusPointOfInterest(&self, focus_point_of_interest: CGPoint)

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn isAdjustingFocus(&self) -> bool

Indicates whether the receiver is currently performing a focus scan to adjust focus.

The value of this property is a BOOL indicating whether the receiver’s camera focus is being automatically adjusted by means of a focus scan, because its focus mode is AVCaptureFocusModeAutoFocus or AVCaptureFocusModeContinuousAutoFocus. Clients can observe the value of this property to determine whether the camera’s focus is stable.

See also: lensPosition

See also: AVCaptureAutoFocusSystem

Source

pub unsafe fn isAutoFocusRangeRestrictionSupported(&self) -> bool

Indicates whether the receiver supports autofocus range restrictions.

The receiver’s autoFocusRangeRestriction property can only be set if this property returns YES.

Source

pub unsafe fn autoFocusRangeRestriction( &self, ) -> AVCaptureAutoFocusRangeRestriction

Indicates current restriction of the receiver’s autofocus system to a particular range of focus scan, if it supports range restrictions.

The value of this property is an AVCaptureAutoFocusRangeRestriction indicating how the autofocus system should limit its focus scan. The default value is AVCaptureAutoFocusRangeRestrictionNone. -setAutoFocusRangeRestriction: throws an NSInvalidArgumentException if isAutoFocusRangeRestrictionSupported returns NO. -setAutoFocusRangeRestriction: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. This property only has an effect when the focusMode property is set to AVCaptureFocusModeAutoFocus or AVCaptureFocusModeContinuousAutoFocus. Note that setting autoFocusRangeRestriction alone does not initiate a focus operation. After setting autoFocusRangeRestriction, call -setFocusMode: to apply the new restriction.

Source

pub unsafe fn setAutoFocusRangeRestriction( &self, auto_focus_range_restriction: AVCaptureAutoFocusRangeRestriction, )

Source

pub unsafe fn isSmoothAutoFocusSupported(&self) -> bool

Indicates whether the receiver supports smooth autofocus.

The receiver’s smoothAutoFocusEnabled property can only be set if this property returns YES.

Source

pub unsafe fn isSmoothAutoFocusEnabled(&self) -> bool

Indicates whether the receiver should use smooth autofocus.

On a receiver where -isSmoothAutoFocusSupported returns YES and smoothAutoFocusEnabled is set to YES, a smooth autofocus will be engaged when the focus mode is set to AVCaptureFocusModeAutoFocus or AVCaptureFocusModeContinuousAutoFocus. Enabling smooth autofocus is appropriate for movie recording. Smooth autofocus is slower and less visually invasive. Disabling smooth autofocus is more appropriate for video processing where a fast autofocus is necessary. The default value is NO. Setting this property throws an NSInvalidArgumentException if -isSmoothAutoFocusSupported returns NO. The receiver must be locked for configuration using lockForConfiguration: before clients can set this method, otherwise an NSGenericException is thrown. Note that setting smoothAutoFocusEnabled alone does not initiate a focus operation. After setting smoothAutoFocusEnabled, call -setFocusMode: to apply the new smooth autofocus mode.

Source

pub unsafe fn setSmoothAutoFocusEnabled(&self, smooth_auto_focus_enabled: bool)

Source

pub unsafe fn automaticallyAdjustsFaceDrivenAutoFocusEnabled(&self) -> bool

Indicates whether the receiver should automatically adjust face-driven autofocus.

The value of this property is a BOOL that determines the receiver’s automatic adjustment of face-driven autofocus. Default is YES on all platforms, if the receiver supports autofocus. This property must be set to NO before manually setting faceDrivenAutoFocusEnabled to YES/NO. -setAutomaticallyAdjustsFaceDrivenAutoFocusEnabled: throws an NSInvalidArgumentException if the receiver doesn’t support autofocus. -setAutomaticallyAdjustsFaceDrivenAutoFocusEnabled: throws an NSGenericException if called without first obtaining exclusive access to the receiver using -lockForConfiguration:. After setting automaticallyAdjustsFaceDrivenAutoFocusEnabled, call -setFocusMode: to apply the change.

Source

pub unsafe fn setAutomaticallyAdjustsFaceDrivenAutoFocusEnabled( &self, automatically_adjusts_face_driven_auto_focus_enabled: bool, )

Source

pub unsafe fn isFaceDrivenAutoFocusEnabled(&self) -> bool

Indicates whether face-driven autofocus is enabled on the receiver.

Default is YES for all apps linked on or after iOS 15.4 when the receiver supports autofocus. -setFaceDrivenAutoFocusEnabled: throws an NSInvalidArgumentException if automaticallyAdjustsFaceDrivenAutoFocusEnabled returns YES. -setFaceDrivenAutoFocusEnabled: throws an NSInvalidArgumentException if the receiver doesn’t support autofocus. -setFaceDrivenAutoFocusEnabled: throws an NSGenericException if called without first obtaining exclusive access to the receiver using -lockForConfiguration:. Note that setting faceDrivenAutoFocusEnabled alone does not initiate this focus change operation. After setting faceDrivenAutoFocusEnabled, call -setFocusMode: to apply the change.

Source

pub unsafe fn setFaceDrivenAutoFocusEnabled( &self, face_driven_auto_focus_enabled: bool, )

Source

pub unsafe fn lensPosition(&self) -> c_float

Indicates the focus position of the lens.

The range of possible positions is 0.0 to 1.0, with 0.0 being the shortest distance at which the lens can focus and 1.0 the furthest. Note that 1.0 does not represent focus at infinity. The default value is 1.0. Note that a given lens position value does not correspond to an exact physical distance, nor does it represent a consistent focus distance from device to device. This property is key-value observable. It can be read at any time, regardless of focus mode, but can only be set via setFocusModeLockedWithLensPosition:completionHandler:.

Source

pub unsafe fn setFocusModeLockedWithLensPosition_completionHandler( &self, lens_position: c_float, handler: Option<&DynBlock<dyn Fn(CMTime)>>, )

Available on crate features block2 and objc2-core-media only.

Sets focusMode to AVCaptureFocusModeLocked and locks lensPosition at an explicit value.

Parameter lensPosition: The lens position, as described in the documentation for the lensPosition property. A value of AVCaptureLensPositionCurrent can be used to indicate that the caller does not wish to specify a value for lensPosition.

Parameter handler: A block to be called when lensPosition has been set to the value specified and focusMode is set to AVCaptureFocusModeLocked. If setFocusModeLockedWithLensPosition:completionHandler: is called multiple times, the completion handlers will be called in FIFO order. The block receives a timestamp which matches that of the first buffer to which all settings have been applied. Note that the timestamp is synchronized to the device clock, and thus must be converted to the master clock prior to comparison with the timestamps of buffers delivered via an AVCaptureVideoDataOutput. The client may pass nil for the handler parameter if knowledge of the operation’s completion is not required.

This is the only way of setting lensPosition. This method throws an NSRangeException if lensPosition is set to an unsupported level. This method throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:.

Source

pub unsafe fn minimumFocusDistance(&self) -> NSInteger

A property indicating the minimum focus distance.

The minimum focus distance is given in millimeters, -1 if unknown. For virtual cameras (AVCaptureDeviceTypeBuiltInDualCamera, AVCaptureDeviceTypeBuiltInTripleCamera, etc.), the value reported is the smallest minimum focus distance of the auto-focus-capable cameras that it sources.

Source§

impl AVCaptureDevice

AVCaptureDeviceExposure.

Source

pub unsafe fn isExposureModeSupported( &self, exposure_mode: AVCaptureExposureMode, ) -> bool

Returns whether the receiver supports the given exposure mode.

Parameter exposureMode: An AVCaptureExposureMode to be checked.

Returns: YES if the receiver supports the given exposure mode, NO otherwise.

The receiver’s exposureMode property can only be set to a certain mode if this method returns YES for that mode.

Source

pub unsafe fn exposureMode(&self) -> AVCaptureExposureMode

Indicates current exposure mode of the receiver, if it has adjustable exposure.

The value of this property is an AVCaptureExposureMode that determines the receiver’s exposure mode, if it has adjustable exposure. -setExposureMode: throws an NSInvalidArgumentException if set to an unsupported value (see -isExposureModeSupported:). -setExposureMode: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. When using AVCapturePhotoOutput and capturing photos with AVCapturePhotoSettings’ photoQualityPrioritization property set to AVCapturePhotoQualityPrioritizationBalanced or higher, the receiver’s ISO and exposureDuration values may be overridden when exposing the photo if the scene is dark enough to warrant some form of multi-image fusion to improve quality. To ensure that the receiver’s ISO and exposureDuration values are honored while in AVCaptureExposureModeCustom or AVCaptureExposureModeLocked, you must set your AVCapturePhotoSettings.photoQualityPrioritization property to AVCapturePhotoQualityPrioritizationSpeed. The same rule applies if you are using the deprecated AVCapturePhotoSettings.autoStillImageStabilizationEnabled property; you must set it to NO to preserve your custom exposure values in the photo capture. Likewise if you’re using AVCaptureStillImageOutput, automaticallyEnablesStillImageStabilizationWhenAvailable must be set to NO to preserve your custom exposure values in a still image capture. Clients can observe automatic changes to the receiver’s exposureMode by key value observing this property.

Source

pub unsafe fn setExposureMode(&self, exposure_mode: AVCaptureExposureMode)

Setter for exposureMode.

Source

pub unsafe fn isExposurePointOfInterestSupported(&self) -> bool

Indicates whether the receiver supports exposure points of interest.

The receiver’s exposurePointOfInterest property can only be set if this property returns YES.

Source

pub unsafe fn exposurePointOfInterest(&self) -> CGPoint

Available on crate feature objc2-core-foundation only.

Indicates current exposure point of interest of the receiver, if it has one.

The value of this property is a CGPoint that determines the receiver’s exposure point of interest, if it has adjustable exposure. A value of (0,0) indicates that the camera should adjust exposure based on the top left corner of the image, while a value of (1,1) indicates that it should adjust exposure based on the bottom right corner. The default value is (0.5,0.5). -setExposurePointOfInterest: throws an NSInvalidArgumentException if isExposurePointOfInterestSupported returns NO. -setExposurePointOfInterest: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. Note that setting exposurePointOfInterest alone does not initiate an exposure operation. After setting exposurePointOfInterest, call -setExposureMode: to apply the new point of interest.

Source

pub unsafe fn setExposurePointOfInterest( &self, exposure_point_of_interest: CGPoint, )

Available on crate feature objc2-core-foundation only.
Source

pub unsafe fn automaticallyAdjustsFaceDrivenAutoExposureEnabled(&self) -> bool

Indicates whether the receiver should automatically adjust face-driven auto exposure.

The value of this property is a BOOL that determines the receiver’s automatic adjustment of face-driven auto exposure. Default is YES on all platforms, if the receiver supports auto exposure. This property must be set to NO before manually setting faceDrivenAutoExposureEnabled to YES/NO. -setAutomaticallyAdjustsFaceDrivenAutoExposureEnabled: throws an NSInvalidArgumentException if the receiver doesn’t support auto exposure. -setAutomaticallyAdjustsFaceDrivenAutoExposureEnabled: throws an NSGenericException if called without first obtaining exclusive access to the receiver using -lockForConfiguration:. After setting automaticallyAdjustsFaceDrivenAutoExposureEnabled, call -setExposureMode: to apply the change.

Source

pub unsafe fn setAutomaticallyAdjustsFaceDrivenAutoExposureEnabled( &self, automatically_adjusts_face_driven_auto_exposure_enabled: bool, )

Source

pub unsafe fn isFaceDrivenAutoExposureEnabled(&self) -> bool

Indicates whether face-driven auto exposure is enabled on the receiver.

Default is YES for all apps linked on or after iOS 15.4 when the receiver supports auto exposure. -setFaceDrivenAutoExposureEnabled: throws an NSInvalidArgumentException if automaticallyAdjustsFaceDrivenAutoExposureEnabled returns YES. -setFaceDrivenAutoExposureEnabled: throws an NSInvalidArgumentException if the receiver doesn’t support auto exposure. -setFaceDrivenAutoExposureEnabled: throws an NSGenericException if called without first obtaining exclusive access to the receiver using -lockForConfiguration:. Note that setting faceDrivenAutoExposureEnabled alone does not initiate this exposure change operation. After setting faceDrivenAutoExposureEnabled, call -setExposureMode: to apply the change.

Source

pub unsafe fn setFaceDrivenAutoExposureEnabled( &self, face_driven_auto_exposure_enabled: bool, )

Source

pub unsafe fn activeMaxExposureDuration(&self) -> CMTime

Available on crate feature objc2-core-media only.

The maximum exposure (integration) time that may be used by the auto exposure algorithm.

When an AVCaptureDevice’s exposureMode is set to AVCaptureExposureModeAutoExpose or AVCaptureExposureModeContinuousAutoExposure, the auto exposure algorithm picks a default max exposure duration that is tuned for the current configuration, balancing low light image quality with motion preservation. By querying or key-value observing this property, you may find out the current max exposure duration in use. You may also override the default value by setting this property to a value between activeFormat.maxExposureDuration and activeFormat.minExposureDuration. An NSRangeException is thrown if you pass an out-of-bounds exposure duration. Setting the property to the special value of kCMTimeInvalid resets the auto exposure max duration to the device’s default for your current configuration. When the device’s activeFormat or the AVCaptureSession’s sessionPreset changes, this property resets to the default max exposure duration for the new format or session preset.

On some devices, the auto exposure algorithm picks a different max exposure duration for a given format depending whether you used the -[AVCaptureSession setSessionPreset:] API or the -[AVCaptureDevice setActiveFormat:] API to set the format. To ensure uniform default handling of max exposure duration, you can set your AVCaptureDeviceInput’s unifiedAutoExposureDefaultsEnabled property to YES.

Source

pub unsafe fn setActiveMaxExposureDuration( &self, active_max_exposure_duration: CMTime, )

Available on crate feature objc2-core-media only.
Source

pub unsafe fn isAdjustingExposure(&self) -> bool

Indicates whether the receiver is currently adjusting camera exposure.

The value of this property is a BOOL indicating whether the receiver’s camera exposure is being automatically adjusted because its exposure mode is AVCaptureExposureModeAutoExpose or AVCaptureExposureModeContinuousAutoExposure. Clients can observe the value of this property to determine whether the camera exposure is stable or is being automatically adjusted.

Source

pub unsafe fn lensAperture(&self) -> c_float

The size of the lens diaphragm.

The value of this property is a float indicating the size (f number) of the lens diaphragm. This property does not change.

Source

pub unsafe fn exposureDuration(&self) -> CMTime

Available on crate feature objc2-core-media only.

The length of time over which exposure takes place.

Only exposure duration values between activeFormat.minExposureDuration and activeFormat.maxExposureDuration are supported. This property is key-value observable. It can be read at any time, regardless of exposure mode, but can only be set via setExposureModeCustomWithDuration:ISO:completionHandler:.

Source

pub unsafe fn ISO(&self) -> c_float

The current exposure ISO value.

This property controls the sensor’s sensitivity to light by means of a gain value applied to the signal. Only ISO values between activeFormat.minISO and activeFormat.maxISO are supported. Higher values will result in noisier images. This property is key-value observable. It can be read at any time, regardless of exposure mode, but can only be set via setExposureModeCustomWithDuration:ISO:completionHandler:.

Source

pub unsafe fn setExposureModeCustomWithDuration_ISO_completionHandler( &self, duration: CMTime, iso: c_float, handler: Option<&DynBlock<dyn Fn(CMTime)>>, )

Available on crate features block2 and objc2-core-media only.

Sets exposureMode to AVCaptureExposureModeCustom and locks exposureDuration and ISO at explicit values.

Parameter duration: The exposure duration, as described in the documentation for the exposureDuration property. A value of AVCaptureExposureDurationCurrent can be used to indicate that the caller does not wish to specify a value for exposureDuration. Note that changes to this property may result in changes to activeVideoMinFrameDuration and/or activeVideoMaxFrameDuration.

Parameter ISO: The exposure ISO value, as described in the documentation for the ISO property. A value of AVCaptureISOCurrent can be used to indicate that the caller does not wish to specify a value for ISO.

Parameter handler: A block to be called when both exposureDuration and ISO have been set to the values specified and exposureMode is set to AVCaptureExposureModeCustom. If setExposureModeCustomWithDuration:ISO:completionHandler: is called multiple times, the completion handlers will be called in FIFO order. The block receives a timestamp which matches that of the first buffer to which all settings have been applied. Note that the timestamp is synchronized to the device clock, and thus must be converted to the master clock prior to comparison with the timestamps of buffers delivered via an AVCaptureVideoDataOutput. The client may pass nil for the handler parameter if knowledge of the operation’s completion is not required.

This is the only way of setting exposureDuration and ISO. This method throws an NSRangeException if either exposureDuration or ISO is set to an unsupported level. This method throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. When using AVCapturePhotoOutput to capture photos, note that the photoQualityPrioritization property of AVCapturePhotoSettings defaults to AVCapturePhotoQualityPrioritizationBalanced, which allows photo capture to temporarily override the capture device’s ISO and exposureDuration values if the scene is dark enough to warrant some form of multi-image fusion to improve quality. To ensure that the receiver’s ISO and exposureDuration values are honored while in AVCaptureExposureModeCustom or AVCaptureExposureModeLocked, you must set your AVCapturePhotoSettings.photoQualityPrioritization property to AVCapturePhotoQualityPrioritizationSpeed. The same rule applies if you use the deprecated AVCapturePhotoSettings.autoStillImageStabilizationEnabled property or AVCaptureStillImageOutput.automaticallyEnablesStillImageStabilizationWhenAvailable property. You must set them to NO to preserve your custom or locked exposure settings.

Source

pub unsafe fn exposureTargetOffset(&self) -> c_float

Indicates the metered exposure level’s offset from the target exposure value, in EV units.

The value of this read-only property indicates the difference between the metered exposure level of the current scene and the target exposure value. This property is key-value observable.

Source

pub unsafe fn exposureTargetBias(&self) -> c_float

Bias applied to the target exposure value, in EV units.

When exposureMode is AVCaptureExposureModeContinuousAutoExposure or AVCaptureExposureModeLocked, the bias will affect both metering (exposureTargetOffset), and the actual exposure level (exposureDuration and ISO). When the exposure mode is AVCaptureExposureModeCustom, it will only affect metering. This property is key-value observable. It can be read at any time, but can only be set via setExposureTargetBias:completionHandler:.

Source

pub unsafe fn minExposureTargetBias(&self) -> c_float

A float indicating the minimum supported exposure bias, in EV units.

This read-only property indicates the minimum supported exposure bias.

Source

pub unsafe fn maxExposureTargetBias(&self) -> c_float

A float indicating the maximum supported exposure bias, in EV units.

This read-only property indicates the maximum supported exposure bias.

Source

pub unsafe fn setExposureTargetBias_completionHandler( &self, bias: c_float, handler: Option<&DynBlock<dyn Fn(CMTime)>>, )

Available on crate features block2 and objc2-core-media only.

Sets the bias to be applied to the target exposure value.

Parameter bias: The bias to be applied to the exposure target value, as described in the documentation for the exposureTargetBias property.

Parameter handler: A block to be called when exposureTargetBias has been set to the value specified. If setExposureTargetBias:completionHandler: is called multiple times, the completion handlers will be called in FIFO order. The block receives a timestamp which matches that of the first buffer to which the setting has been applied. Note that the timestamp is synchronized to the device clock, and thus must be converted to the master clock prior to comparison with the timestamps of buffers delivered via an AVCaptureVideoDataOutput. The client may pass nil for the handler parameter if knowledge of the operation’s completion is not required.

This is the only way of setting exposureTargetBias. This method throws an NSRangeException if exposureTargetBias is set to an unsupported level. This method throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:.

Source§

impl AVCaptureDevice

AVCaptureDeviceToneMapping.

Source

pub unsafe fn isGlobalToneMappingEnabled(&self) -> bool

Indicates whether the receiver should use global tone mapping.

Tone mapping is a technique used by the device to map the pixel levels in high dynamic range images to a more limited dynamic range (such as 16 bit to 8 bit), while still retaining as close an appearance as possible. Normally the device employs adaptive, local tone curves to preserve highest image quality and adapt quickly to changing lighting conditions.

This property indicates to the receiver to use a global tone map. If set to YES, the tone map is adjusted dynamically depending on the current scene and the same tone map is applied to all pixels in an image. If set to its default value of NO, different tone maps may be applied to different pixels in an image.

globalToneMappingEnabled may only be set to YES if the receiver’s activeFormat.isGlobalToneMappingSupported property returns YES, otherwise an NSGenericException is thrown. Setting globalToneMappingEnabled throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:.

When global tone mapping is enabled, an AVCapturePhotoOutput connected to the AVCaptureDeviceInput’s session disables all forms of still image fusion, resulting in still images with no automatic stabilization applied.

The receiver’s globalToneMappingEnabled resets to its default value of NO under the following conditions:

  • The receiver’s activeFormat changes
  • The receiver’s AVCaptureDeviceInput’s session’s sessionPreset changes
  • The receiver’s AVCaptureDeviceInput is added to a session

Clients can observe automatic changes to the receiver’s globalToneMappingEnabled by key value observing this property.

Source

pub unsafe fn setGlobalToneMappingEnabled( &self, global_tone_mapping_enabled: bool, )

Source§

impl AVCaptureDevice

AVCaptureDeviceWhiteBalance.

Source

pub unsafe fn isWhiteBalanceModeSupported( &self, white_balance_mode: AVCaptureWhiteBalanceMode, ) -> bool

Returns whether the receiver supports the given white balance mode.

Parameter whiteBalanceMode: An AVCaptureWhiteBalanceMode to be checked.

Returns: YES if the receiver supports the given white balance mode, NO otherwise.

The receiver’s whiteBalanceMode property can only be set to a certain mode if this method returns YES for that mode.

Source

pub unsafe fn isLockingWhiteBalanceWithCustomDeviceGainsSupported(&self) -> bool

Indicates whether the receiver supports white balance gains other than AVCaptureWhiteBalanceGainsCurrent.

If lockingWhiteBalanceWithCustomDeviceGainsSupported returns NO, setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains: may only be called with AVCaptureWhiteBalanceGainsCurrent. Passing any other white balance gains will result in an exception.

Source

pub unsafe fn whiteBalanceMode(&self) -> AVCaptureWhiteBalanceMode

Indicates current white balance mode of the receiver, if it has adjustable white balance.

The value of this property is an AVCaptureWhiteBalanceMode that determines the receiver’s white balance mode, if it has adjustable white balance. -setWhiteBalanceMode: throws an NSInvalidArgumentException if set to an unsupported value (see -isWhiteBalanceModeSupported:). -setWhiteBalanceMode: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. Clients can observe automatic changes to the receiver’s whiteBalanceMode by key value observing this property.

Source

pub unsafe fn setWhiteBalanceMode( &self, white_balance_mode: AVCaptureWhiteBalanceMode, )

Setter for whiteBalanceMode.

Source

pub unsafe fn isAdjustingWhiteBalance(&self) -> bool

Indicates whether the receiver is currently adjusting camera white balance.

The value of this property is a BOOL indicating whether the receiver’s camera white balance is being automatically adjusted because its white balance mode is AVCaptureWhiteBalanceModeAutoWhiteBalance or AVCaptureWhiteBalanceModeContinuousAutoWhiteBalance. Clients can observe the value of this property to determine whether the camera white balance is stable or is being automatically adjusted.

Source

pub unsafe fn deviceWhiteBalanceGains(&self) -> AVCaptureWhiteBalanceGains

Indicates the current device-specific RGB white balance gain values in use.

This property specifies the current red, green, and blue gain values used for white balance. The values can be used to adjust color casts for a given scene. For each channel, only values between 1.0 and -maxWhiteBalanceGain are supported. This property is key-value observable. It can be read at any time, regardless of white balance mode, but can only be set via setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains:completionHandler:.

Source

pub unsafe fn grayWorldDeviceWhiteBalanceGains( &self, ) -> AVCaptureWhiteBalanceGains

Indicates the current device-specific Gray World RGB white balance gain values in use.

This property specifies the current red, green, and blue gain values derived from the current scene to deliver a neutral (or “Gray World”) white point for white balance. Gray World values assume a neutral subject (e.g. a gray card) has been placed in the middle of the subject area and fills the center 50% of the frame. Clients can read these values and apply them to the device using setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains:completionHandler:. For each channel, only values between 1.0 and -maxWhiteBalanceGain are supported. This property is key-value observable. It can be read at any time, regardless of white balance mode.

Source

pub unsafe fn maxWhiteBalanceGain(&self) -> c_float

Indicates the maximum supported value to which a channel in the AVCaptureWhiteBalanceGains may be set.

This property does not change for the life of the receiver.

Source

pub unsafe fn setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains_completionHandler( &self, white_balance_gains: AVCaptureWhiteBalanceGains, handler: Option<&DynBlock<dyn Fn(CMTime)>>, )

Available on crate features block2 and objc2-core-media only.

Sets white balance to locked mode with explicit deviceWhiteBalanceGains values.

Parameter whiteBalanceGains: The white balance gain values, as described in the documentation for the deviceWhiteBalanceGains property. A value of AVCaptureWhiteBalanceGainsCurrent can be used to indicate that the caller does not wish to specify a value for deviceWhiteBalanceGains.

Parameter handler: A block to be called when white balance gains have been set to the values specified and whiteBalanceMode is set to AVCaptureWhiteBalanceModeLocked. If setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains:completionHandler: is called multiple times, the completion handlers will be called in FIFO order. The block receives a timestamp which matches that of the first buffer to which all settings have been applied. Note that the timestamp is synchronized to the device clock, and thus must be converted to the master clock prior to comparison with the timestamps of buffers delivered via an AVCaptureVideoDataOutput. This parameter may be nil if synchronization is not required.

For each channel in the whiteBalanceGains struct, only values between 1.0 and -maxWhiteBalanceGain are supported. Gain values are normalized to the minimum channel value to avoid brightness changes (e.g. R:2 G:2 B:4 will be normalized to R:1 G:1 B:2). This method throws an NSRangeException if any of the whiteBalanceGains are set to an unsupported level. This method throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:.

Source

pub unsafe fn chromaticityValuesForDeviceWhiteBalanceGains( &self, white_balance_gains: AVCaptureWhiteBalanceGains, ) -> AVCaptureWhiteBalanceChromaticityValues

Converts device-specific white balance RGB gain values to device-independent chromaticity values.

Parameter whiteBalanceGains: White balance gain values, as described in the documentation for the deviceWhiteBalanceGains property. A value of AVCaptureWhiteBalanceGainsCurrent may not be used in this function.

Returns: A fully populated AVCaptureWhiteBalanceChromaticityValues structure containing device-independent values.

This method may be called on the receiver to convert device-specific white balance RGB gain values to device-independent chromaticity (little x, little y) values. For each channel in the whiteBalanceGains struct, only values between 1.0 and -maxWhiteBalanceGain are supported. This method throws an NSRangeException if any of the whiteBalanceGains are set to unsupported values.

Source

pub unsafe fn deviceWhiteBalanceGainsForChromaticityValues( &self, chromaticity_values: AVCaptureWhiteBalanceChromaticityValues, ) -> AVCaptureWhiteBalanceGains

Converts device-independent chromaticity values to device-specific white balance RGB gain values.

Parameter chromaticityValues: Little x, little y chromaticity values as described in the documentation for AVCaptureWhiteBalanceChromaticityValues.

Returns: A fully populated AVCaptureWhiteBalanceGains structure containing device-specific RGB gain values.

This method may be called on the receiver to convert device-independent chromaticity values to device-specific RGB white balance gain values. This method throws an NSRangeException if any of the chromaticityValues are set outside the range [0,1]. Note that some x,y combinations yield out-of-range device RGB values that will cause an exception to be thrown if passed directly to -setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains:completionHandler:. Be sure to check that red, green, and blue gain values are within the range of [1.0 - maxWhiteBalanceGain].

Source

pub unsafe fn temperatureAndTintValuesForDeviceWhiteBalanceGains( &self, white_balance_gains: AVCaptureWhiteBalanceGains, ) -> AVCaptureWhiteBalanceTemperatureAndTintValues

Converts device-specific white balance RGB gain values to device-independent temperature and tint values.

Parameter whiteBalanceGains: White balance gain values, as described in the documentation for the deviceWhiteBalanceGains property. A value of AVCaptureWhiteBalanceGainsCurrent may not be used in this function.

Returns: A fully populated AVCaptureWhiteBalanceTemperatureAndTintValues structure containing device-independent values.

This method may be called on the receiver to convert device-specific white balance RGB gain values to device-independent temperature (in kelvin) and tint values. For each channel in the whiteBalanceGains struct, only values between 1.0 and -maxWhiteBalanceGain are supported. This method throws an NSRangeException if any of the whiteBalanceGains are set to unsupported values.

Source

pub unsafe fn deviceWhiteBalanceGainsForTemperatureAndTintValues( &self, temp_and_tint_values: AVCaptureWhiteBalanceTemperatureAndTintValues, ) -> AVCaptureWhiteBalanceGains

Converts device-independent temperature and tint values to device-specific white balance RGB gain values.

Parameter tempAndTintValues: Temperature and tint values as described in the documentation for AVCaptureWhiteBalanceTemperatureAndTintValues.

Returns: A fully populated AVCaptureWhiteBalanceGains structure containing device-specific RGB gain values.

This method may be called on the receiver to convert device-independent temperature and tint values to device-specific RGB white balance gain values. You may pass any temperature and tint values and corresponding white balance gains will be produced. Note though that some temperature and tint combinations yield out-of-range device RGB values that will cause an exception to be thrown if passed directly to -setWhiteBalanceModeLockedWithDeviceWhiteBalanceGains:completionHandler:. Be sure to check that red, green, and blue gain values are within the range of [1.0 - maxWhiteBalanceGain].

Source§

impl AVCaptureDevice

AVCaptureDeviceSubjectAreaChangeMonitoring.

Source

pub unsafe fn isSubjectAreaChangeMonitoringEnabled(&self) -> bool

Indicates whether the receiver should monitor the subject area for changes.

The value of this property is a BOOL indicating whether the receiver should monitor the video subject area for changes, such as lighting changes, substantial movement, etc. If subject area change monitoring is enabled, the receiver sends an AVCaptureDeviceSubjectAreaDidChangeNotification whenever it detects a change to the subject area, at which time an interested client may wish to re-focus, adjust exposure, white balance, etc. The receiver must be locked for configuration using lockForConfiguration: before clients can set the value of this property.

Source

pub unsafe fn setSubjectAreaChangeMonitoringEnabled( &self, subject_area_change_monitoring_enabled: bool, )

Source§

impl AVCaptureDevice

AVCaptureDeviceLowLightBoost.

Source

pub unsafe fn isLowLightBoostSupported(&self) -> bool

Indicates whether the receiver supports boosting images in low light conditions.

The receiver’s automaticallyEnablesLowLightBoostWhenAvailable property can only be set if this property returns YES.

Source

pub unsafe fn isLowLightBoostEnabled(&self) -> bool

Indicates whether the receiver’s low light boost feature is enabled.

The value of this property is a BOOL indicating whether the receiver is currently enhancing images to improve quality due to low light conditions. When -isLowLightBoostEnabled returns YES, the receiver has switched into a special mode in which more light can be perceived in images. This property is key-value observable.

Source

pub unsafe fn automaticallyEnablesLowLightBoostWhenAvailable(&self) -> bool

Indicates whether the receiver should automatically switch to low light boost mode when necessary.

On a receiver where -isLowLightBoostSupported returns YES, a special low light boost mode may be engaged to improve image quality. When the automaticallyEnablesLowLightBoostWhenAvailable property is set to YES, the receiver switches at its discretion to a special boost mode under low light, and back to normal operation when the scene becomes sufficiently lit. An AVCaptureDevice that supports this feature may only engage boost mode for certain source formats or resolutions. Clients may observe changes to the lowLightBoostEnabled property to know when the mode has engaged. The switch between normal operation and low light boost mode may drop one or more video frames. The default value is NO. Setting this property throws an NSInvalidArgumentException if -isLowLightBoostSupported returns NO. The receiver must be locked for configuration using lockForConfiguration: before clients can set this method, otherwise an NSGenericException is thrown.

Source

pub unsafe fn setAutomaticallyEnablesLowLightBoostWhenAvailable( &self, automatically_enables_low_light_boost_when_available: bool, )

Source§

impl AVCaptureDevice

AVCaptureDeviceVideoZoom.

Source

pub unsafe fn videoZoomFactor(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Controls zoom level of image outputs

Applies a centered crop for all image outputs, scaling as necessary to maintain output dimensions. Minimum value of 1.0 yields full field of view, increasing values will increase magnification, up to a maximum value specified in the activeFormat’s videoMaxZoomFactor property. Modifying the zoom factor will cancel any active rampToVideoZoomFactor:withRate:, and snap directly to the assigned value. Assigning values outside the acceptable range will generate an NSRangeException. Clients can key value observe the value of this property. When depth data delivery is enabled, changing the zoom factor sets the videoZoomFactor to the nearest supportedVideoZoomFactor from -[AVCaptureDeviceFormat supportedVideoZoomFactorsForDepthDataDelivery] with a disruptive reconfiguration of the capture render pipeline.

-setVideoZoomFactor: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:.

See also: -[AVCaptureDeviceFormat videoMaxZoomFactor], -[AVCaptureDeviceFormat videoZoomFactorUpscaleThreshold], -[AVCaptureDevice minAvailableVideoZoomFactor], -[AVCaptureDevice maxAvailableVideoZoomFactor], -[AVCaptureDeviceFormat supportedVideoZoomFactorsForDepthDataDelivery], -[AVCaptureDeviceFormat videoMinZoomFactorForCenterStage] and -[AVCaptureDeviceFormat videoMaxZoomFactorForCenterStage]

Source

pub unsafe fn setVideoZoomFactor(&self, video_zoom_factor: CGFloat)

Available on crate feature objc2-core-foundation only.

Setter for videoZoomFactor.

Source

pub unsafe fn rampToVideoZoomFactor_withRate( &self, factor: CGFloat, rate: c_float, )

Available on crate feature objc2-core-foundation only.

Provides smooth changes in zoom factor.

This method provides a change in zoom by compounding magnification at the specified rate over time. Although the zoom factor will grow exponentially, this yields a visually linear zoom in the image over time.

The zoom transition will stop at the specified factor, which must be in the valid range for videoZoomFactor. Assignments to videoZoomFactor while a ramp is in progress will cancel the ramp and snap to the assigned value.

The zoom factor is continuously scaled by pow(2,rate * time). A rate of 0 causes no change in zoom factor, equivalent to calling cancelVideoZoomRamp. A rate of 1 will cause the magnification to double every second (or halve every second if zooming out), and similarly larger or smaller values will zoom faster or slower respectively. Only the absolute value of the rate is significant–sign is corrected for the direction of the target. Changes in rate will be smoothed by an internal acceleration limit.

When depth data delivery is enabled, -rampToVideoZoomFactor:withRate: sets the videoZoomFactor to the nearest supportedVideoZoomFactor from -[AVCaptureDeviceFormat supportedVideoZoomFactorsForDepthDataDelivery] with a disruptive reconfiguration of the capture render pipeline.

-rampToVideoZoomFactor:withRate: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:.

Source

pub unsafe fn isRampingVideoZoom(&self) -> bool

Indicates if the zoom factor is transitioning to a value set by rampToVideoZoomFactor:withRate:

Clients can observe this value to determine when a ramp begins or completes.

Source

pub unsafe fn cancelVideoZoomRamp(&self)

Eases out of any video zoom transitions initiated by rampToVideoZoomFactor:withRate:

This method is equivalent to calling rampToVideoZoomFactor:withRate: using the current zoom factor target and a rate of 0. This allows a smooth stop to any changes in zoom which were in progress.

-cancelVideoZoomRamp: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:.

Source

pub unsafe fn dualCameraSwitchOverVideoZoomFactor(&self) -> CGFloat

👎Deprecated
Available on crate feature objc2-core-foundation only.

The video zoom factor at or above which a DualCamera can select between its wide angle camera and its telephoto camera.

This is the zoom factor at which the wide angle camera’s field of view matches telephoto camera’s full field of view. On non-DualCamera devices this will return 1.0. As of iOS 13.0, this API has been deprecated in favor of virtualDeviceSwitchOverVideoZoomFactors.

Source

pub unsafe fn displayVideoZoomFactorMultiplier(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

A multiplier that can be used with the receiver’s videoZoomFactor property for displaying a video zoom factor in a user interface.

In some system user interfaces, like the macOS Video Effects Menu, the video zoom factor value is displayed in a way most appropriate for visual representation and might differ from the videoZoomFactor property value on the receiver by a fixed ratio. For example, if the videoZoomFactor property value is 1.0 and the displayVideoZoomFactorMultiplier property value is 0.5, then multiplying 1.0 and 0.5 produces 0.5 which can be displayed in the UI. Client applications can key value observe this property to update the display video zoom factor values in their UI to stay consistent with Apple’s system UIs.

Source§

impl AVCaptureDevice

AVCaptureDeviceAuthorization.

Source

pub unsafe fn authorizationStatusForMediaType( media_type: &AVMediaType, ) -> AVAuthorizationStatus

Available on crate feature AVMediaFormat only.

Returns the client’s authorization status for accessing the underlying hardware that supports a given media type.

Parameter mediaType: The media type, either AVMediaTypeVideo or AVMediaTypeAudio

Returns: The authorization status of the client

This method returns the AVAuthorizationStatus of the client for accessing the underlying hardware supporting the media type. Media type constants are defined in AVMediaFormat.h. If any media type other than AVMediaTypeVideo or AVMediaTypeAudio is supplied, an NSInvalidArgumentException will be thrown. If the status is AVAuthorizationStatusNotDetermined, you may use the +requestAccessForMediaType:completionHandler: method to request access by prompting the user.

Source

pub unsafe fn requestAccessForMediaType_completionHandler( media_type: &AVMediaType, handler: &DynBlock<dyn Fn(Bool)>, )

Available on crate features AVMediaFormat and block2 only.

Requests access to the underlying hardware for the media type, showing a dialog to the user if necessary.

Parameter mediaType: The media type, either AVMediaTypeVideo or AVMediaTypeAudio

Parameter handler: A block called with the result of requesting access

Use this function to request access to the hardware for a given media type. Media type constants are defined in AVMediaFormat.h. If any media type other than AVMediaTypeVideo or AVMediaTypeAudio is supplied, an NSInvalidArgumentException will be thrown.

This call will not block while the user is being asked for access, allowing the client to continue running. Until access has been granted, any AVCaptureDevices for the media type will vend silent audio samples or black video frames. The user is only asked for permission the first time the client requests access. Later calls use the permission granted by the user.

Note that the authorization dialog will automatically be shown if the status is AVAuthorizationStatusNotDetermined when creating an AVCaptureDeviceInput.

Invoking this method with AVMediaTypeAudio is equivalent to calling -[AVAudioSession requestRecordPermission:].

The completion handler is called on an arbitrary dispatch queue. It is the client’s responsibility to ensure that any UIKit-related updates are called on the main queue or main thread as a result.

Source§

impl AVCaptureDevice

AVCaptureDeviceTransportControls.

Source

pub unsafe fn transportControlsSupported(&self) -> bool

Returns whether the receiver supports transport control commands.

For devices with transport controls, such as AVC tape-based camcorders or pro capture devices with RS422 deck control, the value of this property is YES. If transport controls are not supported, none of the associated transport control methods and properties are available on the receiver.

Source

pub unsafe fn transportControlsPlaybackMode( &self, ) -> AVCaptureDeviceTransportControlsPlaybackMode

Returns the receiver’s current playback mode.

For devices that support transport control, this property may be queried to discover the current playback mode.

Source

pub unsafe fn transportControlsSpeed( &self, ) -> AVCaptureDeviceTransportControlsSpeed

Returns the receiver’s current playback speed as a floating point value.

For devices that support transport control, this property may be queried to discover the current playback speed of the deck. 0.0 -> stopped. 1.0 -> forward at normal speed. -1.0-> reverse at normal speed. 2.0 -> forward at 2x normal speed. etc.

Source

pub unsafe fn setTransportControlsPlaybackMode_speed( &self, mode: AVCaptureDeviceTransportControlsPlaybackMode, speed: AVCaptureDeviceTransportControlsSpeed, )

Sets both the transport controls playback mode and speed in a single method.

Parameter mode: A AVCaptureDeviceTransportControlsPlaybackMode indicating whether the deck should be put into play mode.

Parameter speed: A AVCaptureDeviceTransportControlsSpeed indicating the speed at which to wind or play the tape.

A method for setting the receiver’s transport controls playback mode and speed. The receiver must be locked for configuration using lockForConfiguration: before clients can set this method, otherwise an NSGenericException is thrown.

Source§

impl AVCaptureDevice

AVCaptureDeviceHighDynamicRangeSupport.

Source

pub unsafe fn automaticallyAdjustsVideoHDREnabled(&self) -> bool

Indicates whether the receiver is allowed to turn high dynamic range streaming on or off.

The value of this property is a BOOL indicating whether the receiver is free to turn high dynamic range streaming on or off. This property defaults to YES. When automaticallyAdjustsVideoHDREnabled, the AVCaptureDevice turns videoHDR on automatically if it’s a good fit for the activeFormat. -setAutomaticallyAdjustsVideoHDREnabled: throws an NSGenericException if called without first obtaining exclusive access to the receiver using -lockForConfiguration:. Clients can key-value observe videoHDREnabled to know when the receiver has automatically changed the value.

Source

pub unsafe fn setAutomaticallyAdjustsVideoHDREnabled( &self, automatically_adjusts_video_hdr_enabled: bool, )

Source

pub unsafe fn isVideoHDREnabled(&self) -> bool

Indicates whether the receiver’s streaming high dynamic range feature is enabled. See AVCaptureDeviceFormat.isVideoHDRSupported.

The value of this property is a BOOL indicating whether the receiver is currently streaming high dynamic range video buffers, also known as Extended Dynamic Range (EDR). The value of this property is ignored when device.activeColorSpace is HLG BT2020 color space since HDR is effectively always on and can’t be disabled. The property may only be set if you first set automaticallyAdjustsVideoHDREnabled to NO, otherwise an NSGenericException is thrown. videoHDREnabled may only be set to YES if the receiver’s activeFormat.isVideoHDRSupported property returns YES, otherwise an NSGenericException is thrown. This property may be key-value observed.

Note that setting this property may cause a lengthy reconfiguration of the receiver, similar to setting a new active format or AVCaptureSession sessionPreset. If you are setting either the active format or the AVCaptureSession’s sessionPreset AND this property, you should bracket these operations with [session beginConfiguration] and [session commitConfiguration] to minimize reconfiguration time.

Source

pub unsafe fn setVideoHDREnabled(&self, video_hdr_enabled: bool)

Setter for isVideoHDREnabled.

Source§

impl AVCaptureDevice

AVCaptureDeviceColorSpaceSupport.

Source

pub unsafe fn activeColorSpace(&self) -> AVCaptureColorSpace

Indicates the receiver’s current active color space.

By default, an AVCaptureDevice attached to an AVCaptureSession is automatically configured for wide color by the AVCaptureSession (see AVCaptureSession automaticallyConfiguresCaptureDeviceForWideColor). You may also set the activeColorSpace manually. To prevent the AVCaptureSession from undoing your work, remember to set AVCaptureSession’s automaticallyConfiguresCaptureDeviceForWideColor property to NO. Changing the receiver’s activeColorSpace while the session is running requires a disruptive reconfiguration of the capture render pipeline. Movie captures in progress will be ended immediately; unfulfilled photo requests will be aborted; video preview will temporarily freeze. -setActiveColorSpace: throws an NSGenericException if called without first obtaining exclusive access to the receiver using -lockForConfiguration:.

Source

pub unsafe fn setActiveColorSpace( &self, active_color_space: AVCaptureColorSpace, )

Setter for activeColorSpace.

Source§

impl AVCaptureDevice

AVCaptureDeviceDepthSupport.

Source

pub unsafe fn activeDepthDataFormat( &self, ) -> Option<Retained<AVCaptureDeviceFormat>>

The currently active depth data format of the receiver.

This property can be used to get or set the device’s currently active depth data format. -setActiveDepthDataFormat: throws an NSInvalidArgumentException if set to a format not present in the activeFormat’s -supportedDepthDataFormats array. -setActiveDepthDataFormat: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:. Clients can observe automatic changes to the receiver’s activeDepthDataFormat by key value observing this property. On devices where depth data is not supported, this property returns nil.

The frame rate of depth data may not be set directly. Depth data frame rate is synchronized to the device’s activeMin/MaxFrameDurations. It may match the device’s current frame rate, or lower, if depth data cannot be produced fast enough for the active video frame rate.

Delivery of depth data to a AVCaptureDepthDataOutput may increase the system load, resulting in a reduced video frame rate for thermal sustainability.

Source

pub unsafe fn setActiveDepthDataFormat( &self, active_depth_data_format: Option<&AVCaptureDeviceFormat>, )

Source

pub unsafe fn activeDepthDataMinFrameDuration(&self) -> CMTime

Available on crate feature objc2-core-media only.

A property indicating the receiver’s current active minimum depth data frame duration (the reciprocal of its maximum depth data frame rate).

This property may be used to set an upper limit to the frame rate at which depth data is produced. Lowering the depth data frame rate typically lowers power consumption which will increase the time the camera can run before an elevated system pressure state is reached.

Setting this property to kCMTimeInvalid resets it to the active depth data format’s default min frame duration. Setting this property to kCMTimePositiveInfinity results in a depth data frame rate of 0.

The activeDepthDataMinFrameDuration gets reset whenever either the active video format or the active depth data format changes.

-setActiveDepthDataMinFrameDuration: throws an NSRangeException if set to a value that is outside of the active depth data format’s supported frame rate range. -setActiveDepthDataMinFrameDuration: throws an NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration:.

Source

pub unsafe fn setActiveDepthDataMinFrameDuration( &self, active_depth_data_min_frame_duration: CMTime, )

Available on crate feature objc2-core-media only.
Source

pub unsafe fn minAvailableVideoZoomFactor(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Indicates the minimum zoom factor available for the AVCaptureDevice’s videoZoomFactor property.

On non-virtual devices the minAvailableVideoZoomFactor is always 1.0. If the device’s videoZoomFactor property is assigned a value smaller than 1.0, an NSRangeException is thrown. On a virtual device the minAvailableVideoZoomFactor can change when the device is delivering depth data to one or more outputs (see -[AVCaptureDeviceFormat supportedVideoZoomFactorsForDepthDataDelivery]). When depth data delivery is enabled, allowed zoom factor values are governed by -[AVCaptureDeviceFormat supportedVideoZoomFactorsForDepthDataDelivery] and this contains the absolute minimum zoom of all allowed zoom factors. Setting the videoZoomFactor to a value greater than or equal to 1.0, but lower than minAvailableVideoZoomFactor results in the value being clamped to the minAvailableVideoZoomFactor. Clients can key value observe the value of this property.

Source

pub unsafe fn maxAvailableVideoZoomFactor(&self) -> CGFloat

Available on crate feature objc2-core-foundation only.

Indicates the maximum zoom factor available for the AVCaptureDevice’s videoZoomFactor property.

On non-virtual devices the maxAvailableVideoZoomFactor is always equal to the activeFormat.videoMaxZoomFactor. If the device’s videoZoomFactor property is assigned a value greater than activeFormat.videoMaxZoomFactor, an NSRangeException is thrown. On a virtual device the maxAvailableVideoZoomFactor can change when the device is delivering depth data to one or more outputs (see -[AVCaptureDeviceFormat supportedVideoZoomFactorsForDepthDataDelivery]). When depth data delivery is enabled, allowed zoom factor values are governed by -[AVCaptureDeviceFormat supportedVideoZoomFactorsForDepthDataDelivery] and this contains the absolute maximum zoom of all allowed zoom factors. Setting the videoZoomFactor to a value less than or equal to activeFormat.videoMaxZoomFactor, but greater than maxAvailableVideoZoomFactor results in the value being clamped to the maxAvailableVideoZoomFactor. Clients can key value observe the value of this property.

Source§

impl AVCaptureDevice

AVCaptureDeviceGeometricDistortionCorrection.

Source

pub unsafe fn isGeometricDistortionCorrectionSupported(&self) -> bool

Indicates that geometric distortion correction is supported by the receiver.

Some AVCaptureDevices benefit from geometric distortion correction (GDC), such as devices with a very wide field of view. GDC lessens the fisheye effect at the outer edge of the frame at the cost of losing a small amount of vertical and horizontal field of view. When GDC is enabled on the AVCaptureDevice (see geometricDistortionEnabled), the corrected image is upscaled to the original image size when needed. With respect to the AVCaptureDevice.videoZoomFactor API, the full viewable field of view is always represented with a videoZoomFactor of 1.0. Thus, when GDC is enabled, the AVCaptureDevice.activeFormat’s field of view at videoZoomFactor = 1.0 will be different than when GDC is disabled. The smaller field of view is reported through the activeFormat’s geometricDistortionCorrectedVideoFieldOfView property. Beware though that RAW photo captures never have GDC applied, regardless of the value of AVCaptureDevice.geometricDistortionCorrectionEnabled.

Source

pub unsafe fn isGeometricDistortionCorrectionEnabled(&self) -> bool

Indicates whether geometric distortion correction is enabled by the receiver.

Where supported, the default value is YES. The receiver must be locked for configuration using lockForConfiguration: before clients can set this method, otherwise an NSGenericException is thrown.

Source

pub unsafe fn setGeometricDistortionCorrectionEnabled( &self, geometric_distortion_correction_enabled: bool, )

Source§

impl AVCaptureDevice

AVCaptureDeviceCalibration.

Source

pub unsafe fn extrinsicMatrixFromDevice_toDevice( from_device: &AVCaptureDevice, to_device: &AVCaptureDevice, ) -> Option<Retained<NSData>>

An NSData containing the relative extrinsic matrix from one AVCaptureDevice to another.

Parameter fromDevice: The AVCaptureDevice to use as the source. Must be non nil or an NSInvalidArgumentException is thrown.

Parameter toDevice: The AVCaptureDevice to use as the destination. Must be non nil or an NSInvalidArgumentException is thrown.

The extrinsic matrix consists of a unitless 3x3 rotation matrix (R) on the left and a translation (t) 3x1 column vector on the right. The translation vector’s units are millimeters. The extrinsics of the “toDevice” camera are expressed with respect to a reference camera “fromDevice”. If X_from is a 3D point in “fromCamera”’s coordinate system, then it can be projected into “toCamera”’s coordinate system with X_to = [R | t] * X_from. Note that a matrix_float4x3 matrix is column major with 3 rows and 4 columns. The extrinsicMatrix is only provided for physical cameras for which factory calibrations exist. Virtual device cameras return nil. /
/
| r1,1 r1,2 r1,3 | t1 | |R|t| = | r2,1 r2,2 r2,3 | t2 |
/ | r3,1 r3,2 r3,3 | t3 |
/

Note that if you enable video stabilization (see AVCaptureConnection.preferredVideoStabilizationMode), the pixels in stabilized video frames no longer match the relative extrinsicMatrix from one device to another due to warping. The extrinsicMatrix and camera intrinsics should only be used when video stabilization is disabled.

Source§

impl AVCaptureDevice

AVCaptureDeviceCenterStage.

Source

pub unsafe fn centerStageControlMode() -> AVCaptureCenterStageControlMode

A class property indicating the current mode of Center Stage control (user, app, or cooperative).

This class property determines how the Center Stage feature is controlled. When set to the default value of AVCaptureCenterStageControlModeUser, centerStageEnabled may not be set programmatically and throws an NSInvalidArgumentException. In User mode, the feature may only be set by the user in Control Center. If you wish to take Center Stage control away from the user and exclusively enable / disable it programmatically, set this property to AVCaptureCenterStageControlModeApp. When under exclusive app control, Center Stage user control is disallowed (for instance, the toggle is grayed out in Control Center). If you wish to take control of Center Stage, but also cooperate with the user by listening for and appropriately reacting to their changes to the centerStageEnabled property, set this property to AVCaptureCenterStageControlModeCooperative. Note that in this mode, the onus is on you, the app developer, to honor user intent and conform your AVCaptureSession configuration to make Center Stage active (see the AVCaptureDevice instance property centerStageActive). In cooperative mode, the centerStageEnabled property may change at any time (such as when the user enables / disables the feature in Control Center).

Source

pub unsafe fn setCenterStageControlMode( center_stage_control_mode: AVCaptureCenterStageControlMode, )

Source

pub unsafe fn isCenterStageEnabled() -> bool

A class property indicating whether the Center Stage feature is currently enabled or disabled (such as in Control Center or programmatically via your app).

This property may only be set if centerStageControlMode is AVCaptureCenterStageControlModeApp or AVCaptureCenterStageControlModeCooperative, and otherwise throws an NSInvalidArgumentException. When centerStageControlMode is AVCaptureCenterStageControlModeUser or AVCaptureCenterStageControlModeCooperative, this property may change according to user desire (such as enabling / disabling the feature in Control Center), so you should key-value observe it.

Source

pub unsafe fn setCenterStageEnabled(center_stage_enabled: bool)

Source

pub unsafe fn isCenterStageActive(&self) -> bool

Indicates whether Center Stage is currently active on a particular AVCaptureDevice.

This readonly property returns YES when Center Stage is currently active on the receiver. When active, the camera automatically adjusts to keep people optimally framed within the field of view. The field of view may pan, tighten or widen as needed. Certain restrictions come into play when Center Stage is active:

  • The device’s minAvailableVideoZoomFactor and maxAvailableVideoZoomFactor become restricted (see AVCaptureDeviceFormat’s videoMinZoomFactorForCenterStage and videoMaxZoomFactorForCenterStage).
  • The device’s activeVideoMinFrameDuration and activeVideoMaxFrameDuration are limited (see AVCaptureDeviceFormat’s videoFrameRateRangeForCenterStage). Center Stage may be enabled via user control or application control, depending on the current +AVCaptureDevice.centerStageControlMode. When +AVCaptureDevice.centerStageEnabled is YES, a particular AVCaptureDevice instance may return YES for this property, depending whether it supports the feature in its current configuration. Some device features are mutually exclusive to Center Stage:
  • If depth data delivery is enabled on any output, such as AVCaptureDepthDataOutput, or -AVCapturePhotoOutput.depthDataDeliveryEnabled, Center Stage is deactivated.
  • If geometricDistortionCorrectionSupported is YES, geometricDistortionCorrectionEnabled must also be YES, or Center Stage is deactivated. This property is key-value observable.
Source

pub unsafe fn isCenterStageRectOfInterestSupported(&self) -> bool

Indicates whether the device supports the Center Stage Rect of Interest feature.

This property returns YES if the device supports Center Stage Rect of Interest.

Source

pub unsafe fn centerStageRectOfInterest(&self) -> CGRect

Available on crate feature objc2-core-foundation only.

Specifies the effective region within the output pixel buffer that will be used to perform Center Stage framing.

Applications that wish to apply additional processing (such as cropping) on top of Center Stage’s output can use this property to guide Center Stage’s framing.

The rectangle’s origin is top left and is relative to the coordinate space of the output pixel buffer. The default value of this property is the value CGRectMake(0, 0, 1, 1), where {0,0} represents the top left of the picture area, and {1,1} represents the bottom right on an unrotated picture. This rectangle of interest is applied prior to rotation, mirroring or scaling.

Pixels outside of this rectangle of interest will be blackened out.

Setting this property has no impact on objects specified in the metadata output.

-setCenterStageRectOfInterest: throws an NSGenericException if called without first obtaining exclusive access to the receiver using -lockForConfiguration:. -setCenterStageRectOfInterest: throws an NSInvalidArgumentException if none of the AVCaptureDeviceFormats supported by the receiver support CenterStage. -setCenterStageRectOfInterest: throws an NSInvalidArgumentException if +centerStageEnabled is NO on the AVCaptureDevice class. -setCenterStageRectOfInterest: throws an NSInvalidArgumentException if the provided rectOfInterest goes outside the normalized (0-1) coordinate space.

Source

pub unsafe fn setCenterStageRectOfInterest( &self, center_stage_rect_of_interest: CGRect, )

Available on crate feature objc2-core-foundation only.
Source§

impl AVCaptureDevice

AVCaptureDevicePortraitEffect.

Source

pub unsafe fn isPortraitEffectEnabled() -> bool

A class property indicating whether the Portrait Effect feature is currently enabled in Control Center.

This property changes to reflect the Portrait Effect state in Control Center. It is key-value observable. On iOS, Portrait Effect only applies to video conferencing apps by default (apps that use “voip” as one of their UIBackgroundModes). Non video conferencing apps may opt in for the Portrait Effect by adding the following key to their Info.plist: <key

NSCameraPortraitEffectEnabled </key

Source

pub unsafe fn isPortraitEffectActive(&self) -> bool

Indicates whether Portrait Effect is currently active for a particular AVCaptureDevice.

This readonly property returns YES when Portrait Effect is currently active on the receiver. When active, the device blurs the background, simulating a shallow depth of field effect. Certain restrictions come into play when Portrait Effect is active:

  • The device’s activeVideoMinFrameDuration and activeVideoMaxFrameDuration are limited (see AVCaptureDeviceFormat’s videoFrameRateRangeForPortraitEffect). Note that when +AVCaptureDevice.portraitEffectEnabled is YES, a particular AVCaptureDevice instance may return YES for this property, depending whether it supports the feature in its current configuration. This property is key-value observable.
Source§

impl AVCaptureDevice

AVCaptureDeviceReactionEffects.

Source

pub unsafe fn reactionEffectsEnabled() -> bool

A class property indicating whether the application is suitable for reaction effects, either by automatic gesture detection, or by calls to -[AVCaptureDevice performEffectForReaction:]. Reactions are only rendered when the device’s activeFormat.reactionEffectsSupported is also YES, which will be reflected by canPerformReactionEffects when the feature is both enabled and supported.

On macOS, Reaction Effects are enabled by default for all applications. On iOS, Reaction Effects are enabled by default for video conferencing applications (apps that use “voip” as one of their UIBackgroundModes). Non video conferencing applications may opt in for Reaction Effects by adding the following key to their Info.plist: <key

NSCameraReactionEffectsEnabled </key

Source

pub unsafe fn reactionEffectGesturesEnabled() -> bool

A class property indicating whether gesture detection will trigger reaction effects on the video stream. Gesture detection will only run when the device’s activeFormat.reactionEffectsSupported is also YES, which will be reflected by canPerformReactionEffects.

This property changes to reflect the Gestures state in Control Center. It is key-value observable. Clients can call performEffectForReaction: independently of whether gesture detection is enabled, reaction effects from either source will be intermixed. By default, gesture detection is enabled. As of iOS 17.4 and macOS 14.4, applications can control the default value of this property by adding the following key to their Info.plist: <key

NSCameraReactionEffectGesturesEnabledDefault </key

A value of true enables gesture detection and a value of false disables it, until such time that the user makes their own selection in Control Center.

Source

pub unsafe fn canPerformReactionEffects(&self) -> bool

Indicates whether reactions can be performed on a particular AVCaptureDevice. This requires reactionEffectsEnabled to be YES, as well as using a AVCaptureDeviceFormat with reactionEffectsSupported.

This readonly property returns YES when resources for reactions are available on the device instance. When YES, calls to performEffectForReaction: will render on the video feed, otherwise those calls are ignored. It is key-value observable.

Source

pub unsafe fn availableReactionTypes( &self, ) -> Retained<NSSet<AVCaptureReactionType>>

Available on crate feature AVCaptureReactions only.

Returns a list of reaction types which can be passed to performEffectForReaction.

The list may differ between devices, or be affected by changes to active format, and can be key-value observed.

Source

pub unsafe fn performEffectForReaction( &self, reaction_type: &AVCaptureReactionType, )

Available on crate feature AVCaptureReactions only.

Triggers a specified reaction on the video stream.

Parameter reactionType: Indicates which reaction to perform.

The entries in reactionEffectsInProgress may not reflect one-to-one against calls to this method. Depending on reaction style or resource limits, triggering multiple overlapping reactions of the same type may be coalesced into extending an existing reaction rather than overlaying a new one.

The reactionType requested must be one of those listed in availableReactionTypes or an exception will be thrown. Performing a reaction when canPerformReactionEffects is NO is ignored, and VoIP applications are encouraged to transmit and display such reactions outside of the video feed.

Source

pub unsafe fn reactionEffectsInProgress( &self, ) -> Retained<NSArray<AVCaptureReactionEffectState>>

Available on crate feature AVCaptureReactions only.

Contains an array of reaction effects that are currently being performed by the device, sorted by timestamp. If observing old and new values in the KVO callback, the reaction effects which are still running in the new array will have kCMTimeInvalid as their endTime property. Reaction effects which have ended will only be in the old array, and will have their endTime property set to the presentation time of the first frame where the reaction effect was no longer present.

Reaction effects which are triggered by either a call to performEffectForReaction: or by the automatic gesture detection will be reflected in this array. It is key-value observable to be notified when reaction effects begin or end.

Source§

impl AVCaptureDevice

AVCaptureDeviceBackgroundReplacement.

Source

pub unsafe fn isBackgroundReplacementEnabled() -> bool

A class property indicating whether the user has enabled the Background Replacement feature for this application.

Source

pub unsafe fn isBackgroundReplacementActive(&self) -> bool

Indicates whether Background Replacement is currently active on a particular AVCaptureDevice.

This property is key-value observable.

Source§

impl AVCaptureDevice

AVCaptureDeviceContinuityCamera.

Source

pub unsafe fn isContinuityCamera(&self) -> bool

A property that reports YES if the receiver is a Continuity Camera.

Access this property to discover if the receiver is a Continuity Camera (external iPhone webcam).

Source§

impl AVCaptureDevice

AVCaptureDeviceDeskViewCamera.

Source

pub unsafe fn companionDeskViewCamera( &self, ) -> Option<Retained<AVCaptureDevice>>

A reference to the Desk View Camera that is associated with and derived from this camera.

The companionDeskViewCamera property allows you to discover if the receiver has a paired Desk View Camera which derives its desk framing from the receiver’s ultra wide frame. In the presence of multiple Continuity Cameras, this property allows you to pair a particular Continuity Camera with its associated Desk View Camera.

Source§

impl AVCaptureDevice

AVCaptureMicrophoneMode.

Source

pub unsafe fn preferredMicrophoneMode() -> AVCaptureMicrophoneMode

Indicates the microphone mode that has been selected by the user in Control Center.

This readonly property returns the microphone mode selected by the user in Control Center. It is key-value observable.

Source

pub unsafe fn activeMicrophoneMode() -> AVCaptureMicrophoneMode

Indicates the currently active microphone mode.

This readonly property returns the currently active microphone mode, which may differ from the preferredMicrophoneMode if the application’s active audio route does not support the preferred microphone mode. This property is key-value observable.

Source§

impl AVCaptureDevice

AVCaptureSystemUserInterface.

Source

pub unsafe fn showSystemUserInterface( system_user_interface: AVCaptureSystemUserInterface, )

Displays the system’s user interface for video effects or microphone modes.

Parameter systemUserInterface: The system UI to show.

This method allows the calling application to prompt the user to make changes to Video Effects (such as Center Stage or the Portrait Effect) or Microphone Modes. It brings up the system user interface and deep links to the appropriate module. This method is non-blocking. After presenting the desired system user interface, control returns immediately to the application.

Source§

impl AVCaptureDevice

AVCaptureDeviceSpatialCapture.

Source

pub unsafe fn spatialCaptureDiscomfortReasons( &self, ) -> Retained<NSSet<AVSpatialCaptureDiscomfortReason>>

Indicates whether or not the current environmental conditions are amenable to a spatial capture that is comfortable to view.

This property can be monitored in order to determine the presentation of U/I elements to inform the user that they should reframe their scene for a more pleasing spatial capture (“subject is too close”, “scene is too dark”).

Source§

impl AVCaptureDevice

AVCaptureDeviceStudioLight.

Source

pub unsafe fn isStudioLightEnabled() -> bool

A class property indicating whether the Studio Light feature is currently enabled in Control Center.

This property changes to reflect the Studio Light state in Control Center. It is key-value observable. On iOS, Studio Light only applies to video conferencing apps by default (apps that use “voip” as one of their UIBackgroundModes). Non video conferencing apps may opt in for Studio Light by adding the following key to their Info.plist: <key

NSCameraStudioLightEnabled </key

Source

pub unsafe fn isStudioLightActive(&self) -> bool

Indicates whether Studio Light is currently active on a particular AVCaptureDevice.

This readonly property returns YES when Studio Light is currently active on the receiver. When active, the subject’s face is artificially lit to simulate the presence of a studio light near the camera.

Methods from Deref<Target = NSObject>§

Source

pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !

Handle messages the object doesn’t recognize.

See Apple’s documentation for details.

Methods from Deref<Target = AnyObject>§

Source

pub fn class(&self) -> &'static AnyClass

Dynamically find the class of this object.

§Panics

May panic if the object is invalid (which may be the case for objects returned from unavailable init/new methods).

§Example

Check that an instance of NSObject has the precise class NSObject.

use objc2::ClassType;
use objc2::runtime::NSObject;

let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Source

pub unsafe fn get_ivar<T>(&self, name: &str) -> &T
where T: Encode,

👎Deprecated: this is difficult to use correctly, use Ivar::load instead.

Use Ivar::load instead.

§Safety

The object must have an instance variable with the given name, and it must be of type T.

See Ivar::load_ptr for details surrounding this.

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: DowncastTarget,

Attempt to downcast the object to a class of type T.

This is the reference-variant. Use Retained::downcast if you want to convert a retained object to another type.

§Mutable classes

Some classes have immutable and mutable variants, such as NSString and NSMutableString.

When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.

So using this method to convert a NSString to a NSMutableString, while not unsound, is generally frowned upon unless you created the string yourself, or the API explicitly documents the string to be mutable.

See Apple’s documentation on mutability and on isKindOfClass: for more details.

§Generic classes

Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.

You can, however, safely downcast to generic collections where all the type-parameters are AnyObject.

§Panics

This works internally by calling isKindOfClass:. That means that the object must have the instance method of that name, and an exception will be thrown (if CoreFoundation is linked) or the process will abort if that is not the case. In the vast majority of cases, you don’t need to worry about this, since both root objects NSObject and NSProxy implement this method.

§Examples

Cast an NSString back and forth from NSObject.

use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};

let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();

Try (and fail) to cast an NSObject to an NSString.

use objc2_foundation::{NSObject, NSString};

let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());

Try to cast to an array of strings.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();

This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.

Downcast when processing each element instead.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);

for elem in arr {
    if let Some(data) = elem.downcast_ref::<NSString>() {
        // handle `data`
    }
}

Trait Implementations§

Source§

impl AsRef<AVCaptureDevice> for AVCaptureDevice

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<AnyObject> for AVCaptureDevice

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<NSObject> for AVCaptureDevice

Source§

fn as_ref(&self) -> &NSObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for AVCaptureDevice

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<NSObject> for AVCaptureDevice

Source§

fn borrow(&self) -> &NSObject

Immutably borrows from an owned value. Read more
Source§

impl ClassType for AVCaptureDevice

Source§

const NAME: &'static str = "AVCaptureDevice"

The name of the Objective-C class that this type represents. Read more
Source§

type Super = NSObject

The superclass of this class. Read more
Source§

type ThreadKind = <<AVCaptureDevice as ClassType>::Super as ClassType>::ThreadKind

Whether the type can be used from any thread, or from only the main thread. Read more
Source§

fn class() -> &'static AnyClass

Get a reference to the Objective-C class that this type represents. Read more
Source§

fn as_super(&self) -> &Self::Super

Get an immutable reference to the superclass.
Source§

impl Debug for AVCaptureDevice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for AVCaptureDevice

Source§

type Target = NSObject

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for AVCaptureDevice

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for AVCaptureDevice

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl NSObjectProtocol for AVCaptureDevice

Source§

fn isEqual(&self, other: Option<&AnyObject>) -> bool
where Self: Sized + Message,

Check whether the object is equal to an arbitrary other object. Read more
Source§

fn hash(&self) -> usize
where Self: Sized + Message,

An integer that can be used as a table address in a hash table structure. Read more
Source§

fn isKindOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of the class, or one of its subclasses. Read more
Source§

fn is_kind_of<T>(&self) -> bool
where T: ClassType, Self: Sized + Message,

👎Deprecated: use isKindOfClass directly, or cast your objects with AnyObject::downcast_ref
Check if the object is an instance of the class type, or one of its subclasses. Read more
Source§

fn isMemberOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of a specific class, without checking subclasses. Read more
Source§

fn respondsToSelector(&self, aSelector: Sel) -> bool
where Self: Sized + Message,

Check whether the object implements or inherits a method with the given selector. Read more
Source§

fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
where Self: Sized + Message,

Check whether the object conforms to a given protocol. Read more
Source§

fn description(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object. Read more
Source§

fn debugDescription(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object to use when debugging. Read more
Source§

fn isProxy(&self) -> bool
where Self: Sized + Message,

Check whether the receiver is a subclass of the NSProxy root class instead of the usual NSObject. Read more
Source§

fn retainCount(&self) -> usize
where Self: Sized + Message,

The reference count of the object. Read more
Source§

impl PartialEq for AVCaptureDevice

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for AVCaptureDevice

Source§

const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl DowncastTarget for AVCaptureDevice

Source§

impl Eq for AVCaptureDevice

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T> AnyThread for T
where T: ClassType<ThreadKind = dyn AnyThread + 'a> + ?Sized,

Source§

fn alloc() -> Allocated<Self>
where Self: Sized + ClassType,

Allocate a new instance of the class. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,