react-native-camera/RCTCameraManager.m

51 lines
1.3 KiB
Mathematica
Raw Normal View History

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];
}
RCT_EXPORT_VIEW_PROPERTY(aspect, NSString);
RCT_EXPORT_VIEW_PROPERTY(camera, NSInteger);
2015-04-01 01:02:57 +00:00
RCT_EXPORT_VIEW_PROPERTY(orientation, NSInteger);
- (NSDictionary *)constantsToExport
{
return @{
@"aspects": @{
@"Stretch": AVLayerVideoGravityResize,
@"Fit": AVLayerVideoGravityResizeAspect,
@"Fill": AVLayerVideoGravityResizeAspectFill
},
@"cameras": @{
@"Front": @(AVCaptureDevicePositionFront),
@"Back": @(AVCaptureDevicePositionBack)
},
@"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 01:02:57 +00:00
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
callback(@[[NSNull null], @(granted)]);
}];
}
@end