Update cap_ios_abstract_camera.mm
authorMarijan Vukcevich <marijan@eastsideinteractive.com>
Tue, 4 Feb 2014 18:10:50 +0000 (10:10 -0800)
committerAlexander Shishkov <alexander.shishkov@itseez.com>
Mon, 17 Feb 2014 09:23:25 +0000 (13:23 +0400)
AVCaptureVideoPreviewLayer setOrientation is depricated. This fixes the warning and provides backward compatibility.

modules/highgui/src/cap_ios_abstract_camera.mm

index a77e200..6675a9d 100644 (file)
 {
     self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
 
-    if ([self.captureVideoPreviewLayer isOrientationSupported]) {
-        [self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation];
-    }
+    if ([self.captureVideoPreviewLayer respondsToSelector:@selector(connection)])
+       {
+               if ([self.captureVideoPreviewLayer.connection isVideoOrientationSupported])
+               {
+                       [self.captureVideoPreviewLayer.connection setVideoOrientation:self.defaultAVCaptureVideoOrientation];
+               }
+       }
+       else
+       {
+               // Deprecated in 6.0; here for backward compatibility
+               if ([self.captureVideoPreviewLayer isOrientationSupported])
+               {
+                       [self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation];
+               }                
+       }
 
     if (parentView != nil) {
         self.captureVideoPreviewLayer.frame = self.parentView.bounds;