Here is my code:
if( [self.captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080] == YES ) { [self.captureSession setSessionPreset:AVCaptureSessionPreset1920x1080]; self.currentPreset = GMCVideoCaptureRecordingPresetFullHD; }
On iOS4 execution stops on the first line with 'Bad access' error. On iOS5 it works fine.
How to correctly check for compatibility here?
AVCaptureSessionPreset1920x1080
is an NSString *const
. You can just check that its address is not NULL
. So like so:
if( &AVCaptureSessionPreset1920x1080 != NULL && [self.captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080] == YES )
{
[self.captureSession setSessionPreset:AVCaptureSessionPreset1920x1080];
self.currentPreset = GMCVideoCaptureRecordingPresetFullHD;
}
That should do what you want. Note that you won't be setting the preset on < iOS 5 though so you will presumably want an else
in there to handle the case of it being < iOS 5 or the 1920x1080 preset can't be set.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.