I have a third party app for controlling Sony mirrorless cameras over WiFi. I’m really excited to integrate the new camera controls on the iPhone 16 Pro with the app. I’ve found the documentation around this, and seems I need an AVCaptureSession setup in order to utilise them.
func configureControls(_ controls: [AVCaptureControl]) {
// Verify the host system supports controls; otherwise, return early.
guard captureSession.supportsControls else { return }
// Begin configuring the capture session.
captureSession.beginConfiguration()
// Remove previously configured controls, if any.
for control in captureSession.controls {
captureSession.removeControl(control)
}
// Iterate over the passed in controls.
for control in controls {
// Add the control to the capture session if possible.
if captureSession.canAddControl(control) {
captureSession.addControl(control)
} else {
print("Unable to add control \(control).")
}
}
// Commit the capture session configuration.
captureSession.commitConfiguration()
}
can I just use a freshly initialised capture session for this? Or does it need to be configured in any other ways? Are there any down sides to creating a session (CPU usage etc) that I may experience from this?
Also, the scope of the controls is quite narrow. For something like shutter speed or aperture that has quite a number of possible values but requires custom labels, and a non-linear scale (so the AVCaptureIndexPicker
seems to be the way to go). Will that picker support enough values to represent something like shutter speed or aperture? Is there any chance we may get non-linear float based controls in the future, which may feel more natural from a UX perspective than index-based?
Apologies, lots of edits going on here as I think about this more.
Is there any way, or would any way be considered of putting these controls in a disabled state like with other UI elements in iOS? There are times (during capture for example) that a lot of these settings can be unavailable (as communicated by the Sony camera) to be changed by the user, and managing a queue of changes when the function is unavailable to be set is going to be a challenge. If there won’t be, how will they behave if controls are removed whilst being interacted with? Presumably they will disappear entirely from the UI?
Thanks!
Hi Simon,
Replying to a few of your points here:
For something like shutter speed or aperture that has quite a number of possible values but requires custom labels, and a non-linear scale (so the AVCaptureIndexPicker seems to be the way to go).
You'll want to check out AVCaptureSlider's localizedValueFormat property that can be used to specify a custom label for a slider so that you could display "ƒ1.2" for the slider's value. See its documentation on how to craft the value format string: https://docs.devpubs.apple.com/releases/geode-hw-draft/documentation/avfoundation/avcaptureslider/4479606-localizedvalueformat.
Is there any chance we may get non-linear float based controls in the future, which may feel more natural from a UX perspective than index-based?
Could you submit an enhancement request for this? I see you've filed FB15100641 but it doesn't include these details.
And regarding using the AVCaptureControl
API with external cameras over WiFi, the AVCaptureControl
classes are designed to be used with cameras added to an AVCaptureSession
. On iPhone this means AVCaptureControl
is restricted to built-in cameras. And while on iPadOS external USB cameras are supported with AVCaptureSession
, it sounds like you are connecting to the external camera over WiFi outside of an AVCaptureSession
. So given this the AVCaptureControl
API could not be used with your use case to control an external WiFi camera on iPhone as it requires use of a built-in camera on iPhone.