AVCaptureSession canAddInput для передней камеры всегда возвращает false на iPad - PullRequest
0 голосов
/ 30 мая 2020

Следующий код отлично работает на iPhone. Переключение между задней и передней камерой. Однако при запуске на iPad метод canAddInput всегда возвращает NO при выборе передней камеры (задняя камера работает нормально). Есть идеи, почему?

- (void)addVideoInput:(BOOL)isFront{

    AVCaptureDevice *videoDevice;

    //NSLog(@"Adding Video input - front: %i", isFront);

    [self.captureSession removeInput:self.currentInput];

    if(isFront == YES){
        self.isFrontCam = YES;
        videoDevice = [self frontFacingCameraIfAvailable];
    }else{
        self.isFrontCam = NO;
        videoDevice = [self backCamera];
    }



    if (videoDevice) {

        NSError *error;
        AVCaptureDeviceInput *videoIn = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
        if (!error) {

          // Everything's fine up to here.
          // the next line always resolves to NO and thus the
          // Video input isn't added.



            if ([[self captureSession] canAddInput:videoIn]){
                [[self captureSession] addInput:videoIn];
                self.currentInput = videoIn;

                // Set the preset for the video input

                if([self.captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080]){
                    [self.captureSession setSessionPreset:AVCaptureSessionPreset1920x1080];
                }
            }
            else {
                NSLog(@"Couldn't add video input");
                NSLog(@"error: %@", error.localizedDescription);
            }
        }
        else{
            NSLog(@"Couldn't create video input");
            NSLog(@"error: %@", error.localizedDescription);
        }
    }else
        NSLog(@"Couldn't create video capture device");

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...