//
//  LMCameraCaptureManager.h
//  FaceEngineMobile
//
//  Created on 24.10.16.
//  Copyright © 2016 Vision Labs. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import "LMCameraCaptureProtocol.h"

NS_ASSUME_NONNULL_BEGIN

/// Delegate of camera capture manager
@protocol LMCameraCaptureManagerDelegate <NSObject>

/// Calls when device is jailbroken
- (void)deviceIsJailbroken;

/// Flag for check if we must delete resulting video (e.g. in cases of sessions without any face in frame)
- (BOOL)shouldDeleteResultingVideo;
/// Calls when starts to proccessing recorded video
- (void)videoSaveProcessBegan;
/// Calls on error during video flushing
/// - Parameter error: error
- (void)videoSavedWithError: (NSError *_Nullable) error;
/// Calls in any cases of problems while recording video
/// - Parameter error: error
- (void)videoStopWithError: (NSError * _Nonnull) error;

@end


/// Video stream capture manager.
@interface LMCameraCaptureManager : NSObject<LMCameraCaptureProtocol>


/// Determines whether orientation change will be processed. By default false.
/// @note If the property is true, the video stream frame will be expanded  according to the device orientation.
@property (nonatomic) BOOL orientationEnabled;

/// Specifies whether the capture manager should record the video stream
@property (nonatomic, assign) BOOL canRecordVideo;
/// Defines the duration of the recorded video
@property (nonatomic, assign) CGFloat videoRecordLength;
/// Capture manager delegate
@property (nonatomic, weak) id<LMCameraCaptureManagerDelegate> delegate;

/// Holds ouput video file name
@property (nonatomic, readonly) NSString *videoFile;

/// Current camer
@property (nonatomic, readonly) AVCaptureDevicePosition cameraPosition;

/// Current status of camera authorization
+ (AVAuthorizationStatus)cameraAuthorizationStatus;

/// Updates camera about interface orientation changes.
/// @param orientation Interface  orientation.
- (void)updateCameraOrientation:(UIInterfaceOrientation) orientation;

/// Requests access to the camera to capture a video stream.
/// If authorization was passed before, request of authorization will be skipped and current status of authorization will be passed ///to callback
/// @note It is required to add to key NSCameraUsageDescription in  Info.plist of project using this framework
/// @param completion  Callback will be called after authorization passing. Passed parameter with status type of authorization
+ (void)requestAccessForVideoWithCompletion: (void(^)(AVAuthorizationStatus status))completion;

@end
NS_ASSUME_NONNULL_END
