Contents

setDynamicAspectRatio(_:completionHandler:)

Updates the dynamic aspect ratio of the device.

Declaration

func setDynamicAspectRatio(_ dynamicAspectRatio: AVCaptureDevice.AspectRatio, completionHandler handler: (@Sendable (CMTime, (any Error)?) -> Void)? = nil)
func setDynamicAspectRatio(_ dynamicAspectRatio: AVCaptureDevice.AspectRatio) async throws -> CMTime

Parameters

  • dynamicAspectRatio:

    The new Aspectratio the device should output.

  • handler:

    A block called by the device when dynamicAspectRatio is set to the value specified. If you call Setdynamicaspectratio(_:completionhandler:) multiple times, the completion handlers are 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 Synchronizationclock prior to comparison with the timestamps of buffers delivered via an Avcapturevideodataoutput. You may pass nil for the handler parameter if you do not need to know when the operation completes.

Discussion

This is the only way of setting dynamicAspectRatio. This method throws an NSInvalidArgumentException if dynamicAspectRatio is not a supported aspect ratio found in the device’s activeFormat’s supportedDynamicAspectRatios. This method throws an NSGenericException if you call it without first obtaining exclusive access to the device using lockForConfiguration().

See Also

Configuring dynamic aspect ratio