2015-04-01 01:02:57 +00:00
|
|
|
#import "RCTCameraManager.h"
|
|
|
|
#import "RCTCamera.h"
|
|
|
|
#import "RCTBridge.h"
|
|
|
|
#import <AVFoundation/AVFoundation.h>
|
|
|
|
|
|
|
|
@implementation RCTCameraManager
|
|
|
|
|
|
|
|
@synthesize bridge = _bridge;
|
|
|
|
|
|
|
|
- (UIView *)view
|
|
|
|
{
|
|
|
|
return [[RCTCamera alloc] init];
|
|
|
|
}
|
|
|
|
|
2015-04-01 02:27:18 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(aspect, NSString);
|
2015-04-01 17:32:53 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(camera, NSInteger);
|
2015-04-01 01:02:57 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(orientation, NSInteger);
|
|
|
|
|
2015-04-01 02:27:18 +00:00
|
|
|
- (NSDictionary *)constantsToExport
|
|
|
|
{
|
|
|
|
return @{
|
|
|
|
@"aspects": @{
|
|
|
|
@"Stretch": AVLayerVideoGravityResize,
|
|
|
|
@"Fit": AVLayerVideoGravityResizeAspect,
|
|
|
|
@"Fill": AVLayerVideoGravityResizeAspectFill
|
|
|
|
},
|
2015-04-01 17:32:53 +00:00
|
|
|
@"cameras": @{
|
|
|
|
@"Front": @(AVCaptureDevicePositionFront),
|
|
|
|
@"Back": @(AVCaptureDevicePositionBack)
|
|
|
|
},
|
2015-04-01 02:27:18 +00:00
|
|
|
@"orientations": @{
|
|
|
|
@"LandscapeLeft": @(AVCaptureVideoOrientationLandscapeLeft),
|
|
|
|
@"LandscapeRight": @(AVCaptureVideoOrientationLandscapeRight),
|
|
|
|
@"Portrait": @(AVCaptureVideoOrientationPortrait),
|
|
|
|
@"PortraitUpsideDown": @(AVCaptureVideoOrientationPortraitUpsideDown)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-04-01 01:02:57 +00:00
|
|
|
- (void)checkDeviceAuthorizationStatus:(RCTResponseSenderBlock) callback
|
|
|
|
{
|
|
|
|
RCT_EXPORT();
|
|
|
|
NSString *mediaType = AVMediaTypeVideo;
|
2015-04-01 02:27:18 +00:00
|
|
|
|
2015-04-01 01:02:57 +00:00
|
|
|
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
|
|
|
|
callback(@[[NSNull null], @(granted)]);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|