Accessing iOS 6 new APIs for camera exposure and shutter speed

It’s true that there is an -exposureMode property on AVCaptureDevice, but that’s only for setting the mode (off/auto/continuous) and not the actual f-stop, SS, or ISO. Camera apps that provide “exposure” control all seem to do it through post-processing.

However, it seems there are undocumented APIs in the framework to do this. Check out the full headers for AVCaptureDevice.h (via a class-dump) and note the following methods:

- (void)setManualExposureSupportEnabled:(BOOL)arg1;
- (BOOL)isManualExposureSupportEnabled;

- (void)setExposureGain:(float)arg1;
- (float)exposureGain;

- (void)setExposureDuration:(struct { long long x1; int x2; unsigned int x3; long long x4; })arg1;
- (struct { long long x1; int x2; unsigned int x3; long long x4; })exposureDuration;

- (void)setExposureMode:(int)arg1;
- (int)exposureMode;

- (BOOL)isExposureModeSupported:(int)arg1;

My guess is gain is equivalent f-stop (fixed aperture), and duration is shutter speed. I wonder if these are used for the iPhone 5’s low-light boost mode.

You can also use otool to poke around and try to piece together the symbols. There’s likely a new constant in exposureMode for enabling manual control, and exposureDuration seems like it has flags too. When calling these, make sure to use the new -isExposureModeSupported: and also call -respondsToSelector: to check compatibility.

As always, using private APIs is frowned upon by Apple and is cause for rejection from the App Store. There might be ways around this, such as hiding the calls using -performSelector: or obc_msgsend with rot13 strings or something, as I’m pretty sure they only do static analysis on the app binary.

Leave a Comment